ballvicki Posted May 2, 2014 Share Posted May 2, 2014 First of all thank you for an invaluable resource - its helped me alot! I am having a bit of a problem setting up the database for the authManager. I used the setup script to set up three databases: Auth Assignment, AuthItem and AuthItemChild - but when I run the setup script it appears to stop adding to the database when it gets to the task bit! Am very much a newbie, so any help as to where my code is going wrong would be greatly appreciated! Vicki public function actionSetup() { $auth=Yii::app()->authManager; // Create Operations $auth->createOperation('createPage'); $auth->createOperation('updatePage'); $auth->createOperation('deletePage'); $auth->createOperation('createFile'); $auth->createOperation('updateFile'); $auth->createOperation('deleteFile'); $auth->createOperation('createComment'); $auth->createOperation('updateComment'); $auth->createOperation('deleteComment'); $auth->createOperation('updateUser'); $auth->createOperation('deleteUser'); // Create Tasks // Update oe delete own user only $task=$auth->createTask('updateOwnUser', 'Allows a user to update her record','return $params["id"]==Yii::app()->user->id;'); $task=addChild('updateUser'); $task=addChild('deleteUser'); // Create your own content $task=$auth->createTask('createContent', 'Allows users to create content on the site'); $task=addChild('createPage'); $task=addChild('createFile'); $task=addChild('createComment'); // Edit your own content only $task=$auth->createTask('updateOwnContent', 'Allows a user to update pages or files that she owns','return $params["ownerId"]==$params["userId"];'); $task=addChild('updatePage'); $task=addChild('deletePage'); $task=addChild('updateFile'); $task=addChild('deleteFile'); $task=addChild('updateComment'); //Create MAKESHIFTER Role $role=$auth->createRole('makeshifter'); //add a task to a role $role=addChild('updateOwnUser'); //add an operation to a role $role=addChild('createComment'); // Create TUTOR Role $role=$auth->createRole('tutor'); //add a role to a role $role=addChild('makeshifter'); //add a task to a role $role=addChild('createContent'); $role=addChild('updateOwnContent'); // Create ADMIN Role $role=$auth->createRole('admin'); //add a role to a role $role=addChild('tutor'); //add a task to a role $role=addChild('updatePage'); $role=addChild('deletePage'); $role=addChild('updateFile'); $role=addChild('deleteFile'); $role=addChild('updateComment'); $role=addChild('deleteComment'); $role=addChild('updateUser'); $role=addChild('deleteUser'); // assign roles(1) to users(2) static default yii //$auth->assign('public','demo'); //save rules $auth->save(); } } Link to comment Share on other sites More sharing options...
Larry Posted May 4, 2014 Share Posted May 4, 2014 You're quite welcome. Just to confirm, the script is adding operations but not tasks or roles? Link to comment Share on other sites More sharing options...
ballvicki Posted May 6, 2014 Author Share Posted May 6, 2014 Yes - thats it exactly - it appears to stop adding to the database directly after: $task=$auth->createTask('updateOwnUser', 'Allows a user to update her record','return $params["id"]==Yii::app()->user->id;'); I'm not getting any error messages or anything, and the tables are all InnoDB... Link to comment Share on other sites More sharing options...
Larry Posted May 8, 2014 Share Posted May 8, 2014 Okay. I don't see anything obvious. I think this will take some debugging work I'd start by making sure debug is set to true. Then I'd test what $task is after creating it. Link to comment Share on other sites More sharing options...
ballvicki Posted May 8, 2014 Author Share Posted May 8, 2014 Thank you Larry - will give that a go and see what happens! Link to comment Share on other sites More sharing options...
kakooljay Posted July 7, 2014 Share Posted July 7, 2014 You've got: $task=addChild(....); ... $role=addChild(....); Try this: $task->addChild(....); ... $role->addChild(....); Link to comment Share on other sites More sharing options...
Larry Posted July 7, 2014 Share Posted July 7, 2014 Ha! Very good catch! Link to comment Share on other sites More sharing options...
ballvicki Posted August 18, 2014 Author Share Posted August 18, 2014 Thank you - you were spot on! Apologies only just got round to sorting this out (shocking!) Link to comment Share on other sites More sharing options...
Recommended Posts