public function up()
 {
     $this->createTable('role', array('primary' => 'roleID'), array(array('roleID', 'integer'), array('roleDescription', 'string', array('limit' => 128, 'null' => true)), array('ACLstring', 'text', array('null' => true, 'limit' => '1M'))));
     $this->createTable('assignment', array('primary' => 'assignmentID'), array(array('dbUserID', 'integer'), array('roleID', 'integer'), array('assignmentID', 'integer'), array('comments', 'text', array('null' => true))));
     $this->createIndex('assignment', array('dbUserID', 'roleID'));
     // reset db metadata cache
     QFrame_Db_Table::scanDb();
     // give the admin user full global rights
     $adminRole = RoleModel::create(array('roleDescription' => 'Administrators'));
     $adminRole->grant('view');
     $adminRole->grant('edit');
     $adminRole->grant('approve');
     $adminRole->grant('administer');
     $adminRole->save();
     DbUserModel::findByUsername('admin')->addRole($adminRole)->save();
 }
예제 #2
0
 public function testSavePersistsNewRoles()
 {
     $role = RoleModel::create(array('roleDescription' => 'SAMPLE'))->save();
     $this->assertFalse(is_null($role->roleID));
     $role = RoleModel::find($role->roleID);
     $this->assertEquals($role->roleDescription, 'SAMPLE');
 }
예제 #3
0
 /**
  * Create action.  Creates a role and redirects back to the index action.
  */
 public function createAction()
 {
     RoleModel::create(array('roleDescription' => $this->_getParam('roleDescription')))->save();
     $this->flash('notice', 'Role successfully created');
     $this->_redirector->gotoRoute(array('action' => 'index'));
 }