Пример #1
0
 public function getGroups($with_names = false)
 {
     $user_groups_model = new waUserGroupsModel();
     if ($with_names) {
         return $user_groups_model->getGroups($this->id);
     } else {
         return $user_groups_model->getGroupIds($this->id);
     }
 }
 public function hasBackendAccess($contact_id)
 {
     $ugm = new waUserGroupsModel();
     $rm = new waContactRightsModel();
     $ownAccess = $rm->getApps(-$contact_id, 'backend', FALSE, FALSE);
     if (!isset($ownAccess['webasyst'])) {
         $ownAccess['webasyst'] = 0;
     }
     $groups = $ugm->getGroups($contact_id);
     $groupAccess = $rm->getApps(array_keys($groups), 'backend', FALSE, FALSE);
     if (!isset($groupAccess['webasyst'])) {
         $groupAccess['webasyst'] = 0;
     }
     $system = waSystem::getInstance();
     $apps = $system->getApps();
     $noAccess = true;
     $gNoAccess = true;
     foreach ($apps as $app_id => &$app) {
         $app['id'] = $app_id;
         $app['customizable'] = isset($app['rights']) ? (bool) $app['rights'] : false;
         $app['access'] = $ownAccess['webasyst'] ? 2 : 0;
         if (!$app['access'] && isset($ownAccess[$app_id])) {
             $app['access'] = $ownAccess[$app_id];
         }
         $app['gaccess'] = $groupAccess['webasyst'] ? 2 : 0;
         if (!$app['gaccess'] && isset($groupAccess[$app_id])) {
             $app['gaccess'] = $groupAccess[$app_id];
         }
         $noAccess = $noAccess && !$app['gaccess'] && !$app['access'];
         $gNoAccess = $gNoAccess && !$app['gaccess'];
     }
     unset($app);
     return $ownAccess['webasyst'] || !$noAccess;
 }
 /** Using $this->id and $this->contact, if contact is a user,
  * collect and load vars into $this->view specific to waUser. */
 protected function getUserInfo()
 {
     $system = waSystem::getInstance();
     $rm = new waContactRightsModel();
     $ugm = new waUserGroupsModel();
     $gm = new waGroupModel();
     // Personal and group access rights
     $groups = $ugm->getGroups($this->id);
     $ownAccess = $rm->getApps(-$this->id, 'backend', FALSE, FALSE);
     $groupAccess = $rm->getApps(array_keys($groups), 'backend', FALSE, FALSE);
     if (!isset($ownAccess['webasyst'])) {
         $ownAccess['webasyst'] = 0;
     }
     if (!isset($groupAccess['webasyst'])) {
         $groupAccess['webasyst'] = 0;
     }
     // Build application list with personal and group access rights for each app
     $apps = $system->getApps();
     $noAccess = true;
     $gNoAccess = true;
     foreach ($apps as $app_id => &$app) {
         $app['id'] = $app_id;
         $app['customizable'] = isset($app['rights']) ? (bool) $app['rights'] : false;
         $app['access'] = $ownAccess['webasyst'] ? 2 : 0;
         if (!$app['access'] && isset($ownAccess[$app_id])) {
             $app['access'] = $ownAccess[$app_id];
         }
         $app['gaccess'] = $groupAccess['webasyst'] ? 2 : 0;
         if (!$app['gaccess'] && isset($groupAccess[$app_id])) {
             $app['gaccess'] = $groupAccess[$app_id];
         }
         $noAccess = $noAccess && !$app['gaccess'] && !$app['access'];
         $gNoAccess = $gNoAccess && !$app['gaccess'];
     }
     unset($app);
     $this->view->assign('apps', $apps);
     $this->view->assign('groups', $groups);
     $this->view->assign('noAccess', $noAccess ? 1 : 0);
     $this->view->assign('gNoAccess', $gNoAccess ? 1 : 0);
     $this->view->assign('all_groups', $gm->getNames());
     $this->view->assign('fullAccess', $ownAccess['webasyst']);
     $this->view->assign('gFullAccess', $groupAccess['webasyst']);
     $this->view->assign('access_to_contacts', $this->getUser()->getRights('contacts', 'backend'));
 }
 public static function getAccessTabTitle(waContact $contact)
 {
     $rm = new waContactRightsModel();
     $ugm = new waUserGroupsModel();
     $gm = new waGroupModel();
     // Personal and group access rights
     $groups = $ugm->getGroups($contact['id']);
     $ownAccess = $rm->getApps(-$contact['id'], 'backend', false, false);
     $groupAccess = $rm->getApps(array_keys($groups), 'backend', false, false);
     if (!isset($ownAccess['webasyst'])) {
         $ownAccess['webasyst'] = 0;
     }
     if (!isset($groupAccess['webasyst'])) {
         $groupAccess['webasyst'] = 0;
     }
     // Build application list with personal and group access rights for each app
     $apps = wa()->getApps();
     $noAccess = true;
     $gNoAccess = true;
     foreach ($apps as $app_id => &$app) {
         $app['id'] = $app_id;
         $app['customizable'] = isset($app['rights']) ? (bool) $app['rights'] : false;
         $app['access'] = $ownAccess['webasyst'] ? 2 : 0;
         if (!$app['access'] && isset($ownAccess[$app_id])) {
             $app['access'] = $ownAccess[$app_id];
         }
         $app['gaccess'] = $groupAccess['webasyst'] ? 2 : 0;
         if (!$app['gaccess'] && isset($groupAccess[$app_id])) {
             $app['gaccess'] = $groupAccess[$app_id];
         }
         $noAccess = $noAccess && !$app['gaccess'] && !$app['access'];
         $gNoAccess = $gNoAccess && !$app['gaccess'];
     }
     unset($app);
     $html = _w('Access');
     $html .= ' <i class="icon16 c-access-icon ';
     if ($contact['is_user'] == -1) {
         $html .= 'delete';
     } else {
         if (!$groupAccess['webasyst'] && !$ownAccess['webasyst'] && $noAccess) {
             $html .= 'key-bw';
         } else {
             $html .= 'key';
         }
     }
     $html .= '"></i>';
     return $html;
 }