Beispiel #1
0
 /**
  * get all permissions from DB
  * @return array
  */
 public function getPermissions()
 {
     $auth = new DbManager();
     $auth->init();
     $permissions = $auth->getPermissions();
     return $this->serializePermissions($permissions);
 }
Beispiel #2
0
 public function getPermissionsTree($userId = 0)
 {
     if ($userId) {
         $pms = parent::getPermissionsByUser($userId);
     } else {
         $pms = parent::getPermissions();
     }
     $menu = $this->getMenu();
     $tree = [];
     foreach ($menu as $m => $sms) {
         if (!array_key_exists($m, $pms)) {
             continue;
         }
         $_ = ['name' => $pms[$m]->description, 'subMenus' => []];
         foreach ($sms as $sm) {
             if (!array_key_exists($sm, $pms)) {
                 continue;
             }
             $_['subMenus'][$sm] = $pms[$sm]->description;
         }
         $tree[$m] = $_;
     }
     return $tree;
 }