コード例 #1
0
ファイル: Role.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * the singleton pattern
  *
  * @return Admin_Controller_Role
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Admin_Controller_Role();
     }
     return self::$_instance;
 }
コード例 #2
0
ファイル: Json.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * get list of role rights
  *
  * @param int $roleId
  * @return array with results / totalcount
  */
 public function getRoleRights($roleId)
 {
     $result = array('results' => array(), 'totalcount' => 0);
     if (!empty($roleId)) {
         $rights = Admin_Controller_Role::getInstance()->getRoleRights($roleId);
         $result['results'] = $rights;
         $result['totalcount'] = count($rights);
     }
     return $result;
 }
コード例 #3
0
 /**
  * update to 7.3
  * 
  * @see 0006990: user with right "manage_shared_*_favorites" should be able to delete/edit default shared favorites
  * - remove manage_shared_favorites and update manage_shared_<model>_favorites accordingly
  */
 public function update_2()
 {
     $mapping = array('Timetracker' => array('Timeaccount', 'Timesheet'), 'Calendar' => array('Event'), 'Crm' => array('Lead'), 'Tasks' => array('Task'), 'Addressbook' => array('Contact'));
     $paging = new Tinebase_Model_Pagination();
     $filter = new Tinebase_Model_RoleFilter();
     foreach ($mapping as $appName => $modelNames) {
         try {
             $app = Tinebase_Application::getInstance()->getApplicationByName($appName);
         } catch (Tinebase_Exception_NotFound $e) {
             continue;
         }
         if ($app) {
             $roles = Tinebase_Acl_Roles::getInstance()->searchRoles($filter, $paging);
             if ($roles) {
                 foreach ($roles as $role) {
                     $rights = Admin_Controller_Role::getInstance()->getRoleRights($role->getId());
                     $hasRight = false;
                     $newRights = array();
                     foreach ($rights as $right) {
                         if ($right['application_id'] == $app->getId() && $right['right'] == 'manage_shared_favorites') {
                             $hasRight = true;
                         } else {
                             $newRights[] = $right;
                         }
                     }
                     if ($hasRight) {
                         foreach ($modelNames as $modelName) {
                             $newRights[] = array('role_id' => $role->getId(), 'application_id' => $app->getId(), 'right' => 'manage_shared_' . strtolower($modelName) . '_favorites');
                             Tinebase_Acl_Roles::getInstance()->setRoleRights($role->getId(), $newRights);
                         }
                     }
                 }
             }
         }
     }
     $this->setApplicationVersion('Tinebase', '7.3');
 }