public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException('Access denied.'); } $collection = new contactsCollection('users/all'); $group = null; $memberIds = array(); if ($id = waRequest::get('id')) { $group_model = new waGroupModel(); $group = $group_model->getById($id); } if ($group) { $user_groups_model = new waUserGroupsModel(); $memberIds = $user_groups_model->getContactIds($id); } $users = $collection->getContacts('id,name'); // array(id => array(id=>...,name=>...)) $members = array(); foreach ($memberIds as $mid) { if (isset($users[$mid])) { $members[$mid] = $users[$mid]; unset($users[$mid]); } } usort($members, array($this, '_cmp')); usort($users, array($this, '_cmp')); $this->view->assign('group', $group); $this->view->assign('notIncluded', $users); $this->view->assign('members', $members); }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException('Access denied'); } if (!($group_id = (int) waRequest::get('id'))) { throw new waException('Group id not specified.'); } $gm = new waGroupModel(); $group = $gm->getById($group_id); $right_model = new waContactRightsModel(); $fullAccess = $right_model->get(-$group_id, 'webasyst', 'backend'); $apps = wa()->getApps(); if (!$fullAccess) { $appAccess = $right_model->getApps($group_id, 'backend'); } $noAccess = true; foreach ($apps as $app_id => &$app) { $app['id'] = $app_id; $app['customizable'] = isset($app['rights']) ? (bool) $app['rights'] : false; $app['access'] = $fullAccess ? 2 : 0; if (!$app['access'] && isset($appAccess[$app_id])) { $app['access'] = $appAccess[$app_id]; } $noAccess = $noAccess && !$app['access']; } unset($app); $this->view->assign('apps', $apps); $this->view->assign('group', $group); $this->view->assign('noAccess', $noAccess); $this->view->assign('fullAccess', $fullAccess); }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException('Access denied.'); } $group_model = new waGroupModel(); // Create a group or retreive by id $id = waRequest::post('id'); $name = waRequest::post('name'); if (!$id) { if (!$name && $name !== '0') { throw new waException('No group id and no name given.'); } $id = $group_model->add($name); $this->log('group_add', 1); } else { if ($name || $name === '0') { $group_model->updateById($id, array('name' => $name)); } } if (!$id) { throw new waException('Still no id here...'); // should not happen } $group = $group_model->getById($id); if (!$group) { throw new waException('No group with such id: ' . $id); } $this->response['id'] = $id; $users = waRequest::post('users', array(), 'array_int'); $type = waRequest::post('user_operation'); $user_groups_model = new waUserGroupsModel(); switch ($type) { case 'del': if ($users) { $user_groups_model->delete($users, $id); } break; case 'set': $user_groups_model->emptyGroup($id); // breakthrough // breakthrough case 'add': default: if (!$users) { break; } $data = array(); foreach ($users as $contact_id) { $data[] = array($contact_id, $id); } $user_groups_model->add($data); if ($type == 'set') { $group_model->updateCount($id, count($users)); } break; } }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException(_w('Access denied')); } $contact_id = waRequest::get('id'); $group_ids = null; if ($contact_id > 0) { $user_groups_model = new waUserGroupsModel(); $group_ids = $user_groups_model->getGroupIds($contact_id); $group_ids[] = 0; } $app_id = waRequest::get('app'); $right_model = new waContactRightsModel(); $rights = $right_model->get($contact_id, $app_id, null, false); $group_rights = null; if ($group_ids) { $group_rights = $right_model->get(array_map(wa_lambda('$a', 'return -$a;'), $group_ids), $app_id, null, false); } // Check custom rights items $app_config = SystemConfig::getAppConfig($app_id); $class_name = $app_config->getPrefix() . "RightConfig"; $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php"); if (file_exists($file_path)) { // Init app waSystem::getInstance($app_id, $app_config, true); include $file_path; /** * @var waRightConfig $right_config */ $right_config = new $class_name(); $rights += $right_config->getRights($contact_id); if ($group_ids) { $group_rights += $right_config->getRights(array_map(wa_lambda('$a', 'return -$a;'), $group_ids)); } $this->view->assign('html', $right_config->getHTML($rights, $group_rights)); waSystem::setActive('contacts'); } else { $this->view->assign('html', ''); } if ($contact_id > 0) { $this->view->assign('user', new waContact($contact_id)); } else { $gm = new waGroupModel(); $this->view->assign('group', $gm->getById(-$contact_id)); } $app = wa()->getAppInfo($app_id); $app['id'] = $app_id; $this->view->assign('app', $app); $this->view->assign('rights', $rights); $this->view->assign('group_rights', $group_rights); }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException(_w('Access denied')); } $group_model = new waGroupModel(); // Create a group or retreive by id $id = waRequest::post('id'); $name = waRequest::post('name', '', waRequest::TYPE_STRING_TRIM); $icon = waRequest::post('icon', null, waRequest::TYPE_STRING_TRIM); $data = array(); if ($name || $name === '0') { $data['name'] = $name; } if ($icon) { $data['icon'] = $icon; } if (!$id) { if (!isset($data['name'])) { throw new waException('No group id and no name given.'); } $id = $group_model->insert($data); $this->logAction('group_add', $id); } else { $group_model->updateById($id, $data); } $group = $group_model->getById($id); if (!$group) { throw new waException('No group with such id: ' . $id); } $group = $group_model->getById($id); $group['name'] = htmlspecialchars($group['name']); $this->response['id'] = $id; $this->response['group'] = $group; }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException(_w('Access denied')); } $group = null; $group_id = waRequest::get('id'); if ($group_id) { $group_model = new waGroupModel(); $group = $group_model->getById($group_id); } // only allowed to global admin $is_global_admin = wa()->getUser()->getRights('webasyst', 'backend'); $right_model = new waContactRightsModel(); $fullAccess = $right_model->get(-$group_id, 'webasyst', 'backend'); $apps = wa()->getApps(); if (!$fullAccess) { $appAccess = $right_model->getApps($group_id, 'backend'); } $noAccess = true; foreach ($apps as $app_id => &$app) { $app['id'] = $app_id; $app['customizable'] = isset($app['rights']) ? (bool) $app['rights'] : false; $app['access'] = $fullAccess ? 2 : 0; if (!$app['access'] && isset($appAccess[$app_id])) { $app['access'] = $appAccess[$app_id]; } $noAccess = $noAccess && !$app['access']; } unset($app); $user_groups = new waUserGroupsModel(); $users_count = $user_groups->countByField(array('group_id' => $group_id)); $this->view->assign('users_count', $users_count); $this->view->assign('apps', $apps); $this->view->assign('noAccess', $noAccess); $this->view->assign('fullAccess', $fullAccess); $this->view->assign('is_global_admin', $is_global_admin); $this->view->assign('group', $group); $this->view->assign('icons', waGroupModel::getIcons()); }
/** * Add joins and conditions for hash /group/$group_id * @param int $id */ protected function groupPrepare($id) { $group_model = new waGroupModel(); $group = $group_model->getById($id); if ($group) { $this->title = $group['name']; $this->update_count = array('model' => $group_model, 'id' => $id, 'count' => isset($group['cnt']) ? $group['cnt'] : 0); } $this->joins[] = array('table' => 'wa_user_groups', 'alias' => 'cg'); $this->where[] = "cg.group_id = " . (int) $id; }