Can't get the IBM tut #2 to restrict product addition to a logged-in
dealer.
Add function is below.

function add() {if (!empty($this->data)) {
//  $this->deconstruct();
  $this->Product->create();
  if ($this->Product->save($this->data)) {
  $dealer = $this->Product->Dealer->read(null,
                                   $this->data['Product']['dealer_id']);
  $parent = $this->Acl->Aco->findByAlias($dealer
                                    ['Dealer']['title']);
  $this->Acl->Aco->create(array(
       'alias' => $this->Product->id.'-'.$this->data
                                        ['Product']['title'],
       'model' => 'Product',
       'foreign_key' => $this->Product->id,
       'parent_id' => $parent['Aco']['id'])
);
  $this->Acl->Aco->save();
  $this->Acl->allow('Users',
                  $this->Product->id.'-'.$this->data['Product']['title'],
                                'read');
  $this->Acl->allow($this->Session->read('user'),
                                      
$this->Product->id.'-'.$this->data['Product']
                                         ['title'],'*');
  $this->Session->setFlash('The Product has been saved');

  $this->redirect(array('action'=>'index'), null, true);
 } else {
  $this->Session->setFlash('The Product could not be saved.
                                  Please, try again.');
}
}
$dealers = $this->Product->Dealer->find('list');
$this->set(compact('dealers'));
}

Any ideas will be appreciated.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to