How I can to change auth permissions on the fly

2014-02-18 Thread Uziel Barbosa
Hi guys!

It's possible to change the permissions of any logged user on the fly? I
have some roles and a need to set a different user role when accessing some
action.

Thanks!

-- 
*Uziel Barbosa*

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


3.0 update/save complex relations

2014-02-18 Thread Robert Meisner
I've started playing with new cakephp ORM functionality and i stuck with 
complex relation updates/saves.

Example relations look like this:
Customer hasMany CustomerDetails
CustomerDetails hasMany Attributes
Attributes hasMany AttributeValues

CustomerController:: view() action pases $customer entity variable 
(contains all relations) to view. 
Variable is then used in view to echo entity data but also is passed to 
Form->create($customer) to edit part of the data
I build my forms using notation below:
$this->Form->hidden("id");
$this->Form->text("customer_details.0.attributes.0.attribute_values.0.name")

After user sends data i want to populate all $customer entity variable with 
$this->request->data then try to save it and finally pass to view again 
(this way all related entities should have validation errors included):
 public function view($customer_id){

$this->Customers = TableRegistry::get ( 'Customers' );
/* @var $customer Customer */

$customer=$this->Customers->find()->where(['Customers.id'=>$customer_id])->contain(["CustomerDetails"=>["Attributes"=>["AttributeValues"]]])->first();
if($this->request->is("post")){
 
*$customer->populate($this->request->data,['associated'=>['CustomerDetails'=> 
['associated' => ['Attributes'=> ['associated' => 
['AttributesValues']]); //hydrate??*
if($this->Customers->save($customer,['associated'=>['CustomerDetails'=> 
['associated' => ['Attributes'=> ['associated' => 
['AttributesValues']])){
//Yay
}
}
$this->set(compact('customer'));
}

$this->request->data looks like this after send:

'id' => '1',
'customer_details' => array(
(int) 0 => array(
'id' => '1',
'attributes' => array(
(int) 0 => array(
'id' => '1',
'attributes_values' => array(
(int) 0 => array(
'string_value' => 'test 
test test'
)
)
),
(int) 1 => array(
'name' => 'love',
'attributes_values' => array(
(int) 0 => array(
'string_value' => 'me'
)
)
)
)
)
),

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Why does RequestHandler::beforeRedirect() "fake" AJAX redirects?

2014-02-18 Thread SacoDesign
I have a general question regarding the logic inside of 
RequestHandler::beforeRedirect() related to AJAX redirects.  Why does 
CakePHP try to "fake" a redirect- why not just do a true redirect?

This logic appears to be confusing the Security Component in my application 
(and I don't want to disable the Security Component in any way).  I'm 
curious what is the purpose of using a requestAction() call?  When I remove 
the ajax handling in the RequestHandler::beforeRedirect() my application 
works perfectly.

Thanks for any insight you can provide.


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.