/** * Unassigns a role-permission relation * * @param integer Id of the Role * @param integer Id of the Permission * @return boolean */ public function unassign($Role, $Permission) { $perms = new PermissionManager($this->cfg); $roleId = $this->returnId($Role); $permId = $perms->returnId($Permission); $res = $this->dmap->unassign($roleId, $permId); return $res['success']; }
function init() { if (isset($this) && $this instanceof PermissionManager) { } else { PermissionManager::instance()->init(); } // if }
/** * @param $request * @return array */ protected function mergeRequestWithPermissions($request) { return array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]); }
static function removeSource($source) { $permissions = Permissions::findAll(array('conditions' => "`source` = '" . $source . "'")); if (is_array($permissions)) { foreach ($permissions as $permission) { PermissionManager::removeUserPermissions($permission); $permission->delete(); } return true; // permission source removed } return false; // permission source does not exist }
function compute_permission_manager($rows) { $pm = new PermissionManager(); foreach ($rows as $row) { /* $permission = $row['name']; $context_type = $row[CS_ASSERTION_TABLE_FIELDNAME::CONTEXT_TYPE]; $context = $row[CS_ASSERTION_TABLE_FIELDNAME::CONTEXT]; */ $permission = $row[0]; $context_type = $row[1]; $context = $row[2]; $pm->add($permission, $context_type, $context); } // error_log("CPM = " . $pm); return $pm; }
/** * Show permission update form * * @param void * @return null */ function permissions() { if (!active_project()->canChangePermissions(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToUrl(active_project()->getOverviewUrl()); } // if $project_init = array_var($_GET, 'project_init'); tpl_assign('project_init', $project_init); tpl_assign('project_users', active_project()->getUsers(false)); tpl_assign('project_companies', active_project()->getCompanies()); tpl_assign('user_projects', logged_user()->getProjects()); $permissions = PermissionManager::getPermissionsText(); tpl_assign('permissions', $permissions); $companies = array(owner_company()); $clients = owner_company()->getClientCompanies(); if (is_array($clients)) { $companies = array_merge($companies, $clients); } // if tpl_assign('companies', $companies); if (array_var($_POST, 'process') == 'process') { try { DB::beginWork(); active_project()->clearCompanies(); active_project()->clearUsers(); $companies = array(owner_company()); $client_companies = owner_company()->getClientCompanies(); if (is_array($client_companies)) { $companies = array_merge($companies, $client_companies); } // if foreach ($companies as $company) { // Company is selected! if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') { // Owner company is automaticly included so it does not need to be in project_companies table if (!$company->isOwner()) { $project_company = new ProjectCompany(); $project_company->setProjectId(active_project()->getId()); $project_company->setCompanyId($company->getId()); $project_company->save(); } // if $users = $company->getUsers(); if (is_array($users)) { $counter = 0; foreach ($users as $user) { $user_id = $user->getId(); $counter++; if (array_var($_POST, "project_user_{$user_id}") == 'checked') { $project_user = new ProjectUser(); $project_user->setProjectId(active_project()->getId()); $project_user->setUserId($user_id); foreach ($permissions as $permission => $permission_text) { // Owner company members have all permissions $permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked'; $setter = 'set' . Inflector::camelize($permission); $project_user->{$setter}($permission_value); } // if $project_user->save(); } // if } // foreach } // if } // if } // foreach DB::commit(); flash_success(lang('success update project permissions')); if ($project_init) { $this->redirectToUrl(active_project()->getEditUrl(active_project()->getOverviewUrl())); } else { $this->redirectTo('project_settings', 'users'); } // if } catch (Exception $e) { DB::rollback(); flash_error(lang('error update project permissions')); $this->redirectTo('project_settings', 'permissions'); } // try } // if }
function loadStatsHome() { // set the pageCallBack to be without any additional parameters // (an AdminBox needs this so Language Switching on a page doesn't // pass a previous operations) $parameters = array('WEEK_ID' => $this->WEEK_ID); //[RAD_CALLBACK_PARAMS] $pageCallBack = $this->getCallBack(modulecim_stats::PAGE_STATSHOME, $this->sortBy, $parameters); $this->setPageCallBack($pageCallBack); $this->pageDisplay = new page_StatsHome($this->moduleRootPath, $this->viewer); $parameters = array(); $viewerID = $this->viewer->getViewerID(); // TODO make an object to do this work $sql = "select * from ( ( cim_hrdb_access inner join cim_hrdb_person on cim_hrdb_access.person_id=cim_hrdb_person.person_id) inner join cim_hrdb_staff on cim_hrdb_staff.person_id=cim_hrdb_person.person_id ) where cim_hrdb_access.viewer_id = " . $viewerID . " limit 1"; $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $db->runSQL($sql); // if row retrieved ... $staffID = -1; if ($row = $db->retrieveRow()) { $staffID = $row['staff_id']; } $parameters['STAFF_ID'] = $staffID; // echo print_r($parameters,true); $permManager = new PermissionManager($viewerID); $isNational = $permManager->isNational(); // echo 'isNational['.$isNational.']<br/>'; $isRegional = $permManager->isRegional(); // echo 'isRegional['.$isRegional.']<br/>'; $isCD = $permManager->isCD(); // echo 'isCD['.$isCD.']<br/>'; $isStatsCoordinator = $permManager->isStatsCoordinator(); // echo 'isStatsCoordinator['.$isStatsCoordinator.']<br/>'; $isAllStaff = $permManager->isAllStaff(); // echo 'isAllStaff['.$isAllStaff.']<br/>'; $links = array(); if ($isAllStaff) { // GROUP 1: ALL STAFF // All staff can access this link $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFWEEKLYREPORT, '', $parameters); $links['[submitWeeklyStats]'] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_STAFFADDITIONALWEEKLYSTATS, '' , $parameters); // $links[ '[submitMoreWeeklyStats]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_SELECTPRCSEMESTERCAMPUS, '', $parameters); $links['[indicatedDecisions]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFSEMESTERREPORT, '', $parameters); $links['[semesterGlance]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_CAMPUSYEARSUMMARY, '', $parameters); $links['[yearSummary]'] = $requestLink; } $coordinatorLinks = array(); if ($isStatsCoordinator || $isAllStaff) { // GROUP 2: CAMPUS STATS COORDINATORS // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_MORESTATS, '' , $parameters); // $coordinatorLinks[ '[campusWeeklyStats]' ] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_CAMPUSWEEKLYSTATSREPORT, '' , $parameters); // $coordinatorLinks[ '[campusWeeklyStatsReport]' ] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_SEMESTERREPORT, '' , $parameters); // $coordinatorLinks[ '[submitSemesterStats]' ] = $requestLink; } $cdLinks = array(); if ($isCD) { // GROUP 3: CAMPUS DIRECTORS $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFSEMESTERREPORT, '', $parameters); $cdLinks['[semesterGlance]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/stats.php" target="_blank'; $cdLinks['[monthlyReport]'] = $requestLink; } $rtLinks = array(); if ($isRegional) { // GROUP 4: REGIONAL TEAM $requestLink = $this->getCallBack(modulecim_stats::PAGE_REGIONALSEMESTERREPORT, '', $parameters); $rtLinks['[regionalPersonalMin]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/regionalstats.php" target="_blank'; $rtLinks['[regionalReport]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/weeklystats.php" target="_blank'; $rtLinks['[regionalReportWeek]'] = $requestLink; } $ntLinks = array(); if ($isNational) { // GROUP 5: NATIONAL TEAM // echo 'Is NATIONAL<br/>'; // Add these two links later in special admin section $requestLink = $this->getCallBack(modulecim_stats::PAGE_PRCMETHOD, '', $parameters); // $ntLinks[ '[prcMethod]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_EXPOSURETYPES, '', $parameters); // $ntLinks[ '[exposureTypes]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_PRC_REPORTBYCAMPUS, '', $parameters); $ntLinks['[prcReportByCampus]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/idstats.php" target="_blank'; $ntLinks['[prcIDStats]'] = $requestLink; } /*[RAD_LINK_INSERT]*/ $this->pageDisplay->setMyLinks($links, $coordinatorLinks, $cdLinks, $rtLinks, $ntLinks); $this->pageDisplay->setPerms($isNational, $isRegional, $isCD, $isStatsCoordinator, $isAllStaff); }
/** * Get all running virtual servers * @return array all running virtual servers */ public function getRunningServers() { if ($this->meta == null) { return array(); } $servers = $this->meta->getBootedServers(); $filtered = array(); foreach ($servers as $server) { if (HelperFunctions::getActiveSection() != 'admin' || PermissionManager::getInstance()->isAdminOfServer($server->id())) { // set icesecret context if set if (!empty($this->contextVars)) { $server = $server->ice_context($this->contextVars); } $filtered[] = $server; } } return $filtered; }
public function onBSGroupManagerGroupDeleted($sGroup, &$result) { global $wgGroupPermissions, $wgNamespacePermissionLockdown; unset($wgGroupPermissions[$sGroup]); foreach ($wgNamespacePermissionLockdown as $iNS => $aPermissions) { foreach ($aPermissions as $sPermission => $aGroups) { $iIndex = array_search($sGroup, $aGroups); if ($iIndex !== false) { if (count($aGroups) == 1) { unset($wgNamespacePermissionLockdown[$iNS][$sPermission]); } else { array_splice($wgNamespacePermissionLockdown[$iNS][$sPermission], $iIndex, 1); } } } } $result = PermissionManager::writeGroupSettings($wgGroupPermissions, $wgNamespacePermissionLockdown); return true; }
<?php if (!isset($_SESSION)) { session_start(); } require_once 'initClass.php'; require_once 'init.php'; if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') { $JoueurManager = new JoueurManager($db); $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant'])); $PermissionManager = new PermissionManager($db); $Privilege = new Privilege($JoueurManager->getPrivilege($Joueur->getId())); if ($Privilege->hasPermission('permission')) { if (isset($_POST['action']) && $_POST['action'] == "ajouter") { $insert = true; // Si un champ n'a pas été saisie par l'utisateur foreach ($_POST as $key => $value) { if ($value == '') { $insert = false; } } // Si champs complets, insertion en base de donnée if ($insert) { $permission = new Permission($_POST); $PermissionManager->insert($permission); } } // Liste des joueurs $listeJoueur = $JoueurManager->getAll(); // Contruction d'une variable selectJoueurs au format d'un optiongroup $selectJoueurs = array();
/** * Add user * * @access public * @param void * @return null */ function add() { $this->setTemplate('add_user'); $company = Companies::findById(get_id('company_id')); if (!$company instanceof Company) { flash_error(lang('company dnx')); $this->redirectTo('administration'); } // if if (!User::canAdd(logged_user(), $company)) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $user = new User(); $user_data = array_var($_POST, 'user'); if (!is_array($user_data)) { $user_data = array('password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $company->getTimezone()); // array } // if $projects = $company->getProjects(); $permissions = PermissionManager::getPermissionsText(); tpl_assign('user', $user); tpl_assign('company', $company); tpl_assign('projects', $projects); tpl_assign('permissions', $permissions); tpl_assign('user_data', $user_data); if (is_array(array_var($_POST, 'user'))) { $user->setFromAttributes($user_data); $user->setCompanyId($company->getId()); try { // Generate random password if (array_var($user_data, 'password_generator') == 'random') { $password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13); // Validate user input } else { $password = array_var($user_data, 'password'); if (trim($password) == '') { throw new Error(lang('password value required')); } // if if ($password != array_var($user_data, 'password_a')) { throw new Error(lang('passwords dont match')); } // if } // if $user->setPassword($password); if (config_option('check_email_unique', '1') == '1') { if (!$user->validateUniquenessOf('email')) { throw new Error(lang('email address is already used')); } } DB::beginWork(); $user->save(); ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD); if (is_array($projects)) { foreach ($projects as $project) { if (array_var($user_data, 'project_permissions_' . $project->getId()) == 'checked') { $relation = new ProjectUser(); $relation->setProjectId($project->getId()); $relation->setUserId($user->getId()); foreach ($permissions as $permission => $permission_text) { $permission_value = array_var($user_data, 'project_permission_' . $project->getId() . '_' . $permission) == 'checked'; $user->setProjectPermission($project, $permission, $permission_value); } // foreach $relation->save(); } // if } // foreach } // if DB::commit(); // Send notification... try { if (array_var($user_data, 'send_email_notification')) { Notifier::newUserAccount($user, $password); } // if } catch (Exception $e) { } // try // Add task to Welcome project... try { if (array_var($user_data, 'add welcome task')) { $task_data = array('text' => lang('welcome task text', $user->getName(), get_url('account', 'edit')), 'due date' => DateTimeValueLib::now() + 7 * 24 * 60 * 60, 'assigned_to_company_id' => $user->getCompanyId(), 'assigned_to_user_id' => $user->getId()); $task_list = ProjectTaskLists::instance()->findById(2, true); DB::beginWork(); $task = new ProjectTask(); $task->setFromAttributes($task_data); $task_list->attachTask($task); $task->save(); DB::commit(); } // if } catch (Exception $e) { DB::rollback(); } // try flash_success(lang('success add user', $user->getDisplayName())); $projects = $company->getProjects(); if (is_array($projects) || count($projects)) { $this->redirectToUrl(get_url('account', 'update_permissions', $user->getId())); // Continue to permissions page } // if $this->redirectToUrl($company->getViewUrl()); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
echo $server->id(); ?> " title="Show Server Details"><img src="<?php echo SettingsManager::getInstance()->getThemeUrl(); ?> /img/server_details.png" alt="Show Server Details" /></a> </td> </tr><?php } ?> </tbody> </table> <?php if (PermissionManager::getInstance()->isGlobalAdmin()) { ?> <a class="jqlink mpi_tooltip" id="server_create" title="Create a new Server"><img src="<?php echo SettingsManager::getInstance()->getThemeUrl(); ?> /img/server_create.png" alt="Create a new Server" /></a><br/> <a class="jqlink" onclick="jq_meta_showDefaultConfig()">Show Default Config</a> <?php } ?> <div id="jq_information"> </div> <script type="text/javascript">/*<![CDATA[*/ $('#server_create').click(
/** * Add project * * @param void * @return null */ function add() { $this->setTemplate('add_project'); $this->setLayout('administration'); if (!logged_user()->canManageProjects()) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $project = new Project(); $project_data = array_var($_POST, 'project'); tpl_assign('project', $project); tpl_assign('project_data', $project_data); // Submitted... if (is_array($project_data)) { $project->setFromAttributes($project_data); $default_folders = array(); if (plugin_active('files')) { $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', '')); if (trim($default_folders_config) == '') { $default_folders = array(); } else { $default_folders = explode("\n", $default_folders_config); } // if } // if $default_ticket_categories = array(); if (plugin_active('tickets')) { $default_ticket_categories_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('tickets_default_categories', '')); if (trim($default_ticket_categories_config) == '') { $default_ticket_categories = array(); } else { $default_ticket_categories = explode("\n", $default_ticket_categories_config); } // if } // if try { DB::beginWork(); $project->save(); $permissions = array_keys(PermissionManager::getPermissionsText()); $auto_assign_users = owner_company()->getAutoAssignUsers(); // We are getting the list of auto assign users. If current user is not in the list // add it. He's creating the project after all... if (is_array($auto_assign_users)) { $auto_assign_logged_user = false; foreach ($auto_assign_users as $user) { if ($user->getId() == logged_user()->getId()) { $auto_assign_logged_user = true; } } // if if (!$auto_assign_logged_user) { $auto_assign_users[] = logged_user(); } } else { $auto_assign_users[] = logged_user(); } // if foreach ($auto_assign_users as $auto_assign_user) { $project_user = new ProjectUser(); $project_user->setProjectId($project->getId()); $project_user->setUserId($auto_assign_user->getId()); $project_user->save(); if (is_array($permissions)) { foreach ($permissions as $permission) { $auto_assign_user->setProjectPermission($project, $permission, true); } } // if } // foreach if (count($default_folders)) { $added_folders = array(); foreach ($default_folders as $default_folder) { $folder_name = trim($default_folder); if ($folder_name == '') { continue; } // if if (in_array($folder_name, $added_folders)) { continue; } // if $folder = new ProjectFolder(); $folder->setProjectId($project->getId()); $folder->setName($folder_name); $folder->save(); $added_folders[] = $folder_name; } // foreach } // if if (count($default_ticket_categories)) { $added_categories = array(); foreach ($default_ticket_categories as $default_ticket_category) { $category_name = trim($default_ticket_category); if ($category_name == '') { continue; } // if if (in_array($category_name, $added_categories)) { continue; } // if $folder = new ProjectCategory(); $folder->setProjectId($project->getId()); $folder->setName($category_name); $folder->save(); $added_categories[] = $category_name; } // foreach } // if ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true); DB::commit(); flash_success(lang('success add project', $project->getName())); $this->redirectToUrl($project->getPermissionsUrl()); } catch (Exception $e) { tpl_assign('error', $e); DB::rollback(); } // try } // if }
/** * Add project * * @param void * @return null */ function add() { $this->setTemplate('add_project'); $this->setLayout('administration'); if (!logged_user()->canManageProjects()) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $project = new Project(); $project_data = array_var($_POST, 'project'); $page_name = 'project_overview'; $page_attachments = PageAttachments::getAttachmentsByPageNameAndProject($page_name, $project); $redirect_to = urldecode(array_var($_GET, 'redirect_to')); tpl_assign('project', $project); tpl_assign('project_data', $project_data); tpl_assign('page_attachments', $page_attachments); tpl_assign('redirect_to', $redirect_to); // Submitted... if (is_array($project_data)) { $project->setFromAttributes($project_data); $default_folders = array(); if (plugin_active('files')) { $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', '')); if (trim($default_folders_config) == '') { $default_folders = array(); } else { $default_folders = explode("\n", $default_folders_config); } // if } // if $default_ticket_categories = array(); if (plugin_active('tickets')) { $default_ticket_categories_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('tickets_default_categories', '')); if (trim($default_ticket_categories_config) == '') { $default_ticket_categories = array(); } else { $default_ticket_categories = explode("\n", $default_ticket_categories_config); } // if } // if try { DB::beginWork(); $project->save(); $permissions = array_keys(PermissionManager::getPermissionsText()); $auto_assign_users = owner_company()->getAutoAssignUsers(); // We are getting the list of auto assign users. If current user is not in the list // add it. He's creating the project after all... if (is_array($auto_assign_users)) { $auto_assign_logged_user = false; foreach ($auto_assign_users as $user) { if ($user->getId() == logged_user()->getId()) { $auto_assign_logged_user = true; } } // if if (!$auto_assign_logged_user) { $auto_assign_users[] = logged_user(); } } else { $auto_assign_users[] = logged_user(); } // if foreach ($auto_assign_users as $auto_assign_user) { $project_user = new ProjectUser(); $project_user->setProjectId($project->getId()); $project_user->setUserId($auto_assign_user->getId()); $project_user->save(); if (is_array($permissions)) { foreach ($permissions as $permission) { $auto_assign_user->setProjectPermission($project, $permission, true); } } // if } // foreach if (count($default_folders)) { $added_folders = array(); foreach ($default_folders as $default_folder) { $folder_name = trim($default_folder); if ($folder_name == '') { continue; } // if if (in_array($folder_name, $added_folders)) { continue; } // if $folder = new ProjectFolder(); $folder->setProjectId($project->getId()); $folder->setName($folder_name); $folder->save(); $added_folders[] = $folder_name; } // foreach } // if if (count($default_ticket_categories)) { $added_categories = array(); foreach ($default_ticket_categories as $default_ticket_category) { $category_name = trim($default_ticket_category); if ($category_name == '') { continue; } // if if (in_array($category_name, $added_categories)) { continue; } // if $folder = new ProjectCategory(); $folder->setProjectId($project->getId()); $folder->setName($category_name); $folder->save(); $added_categories[] = $category_name; } // foreach } // if $efqm_project = isset($project_data['efqm_project']) ? $project_data['efqm_project'] == '1' : false; if ($efqm_project) { // insert 9 milestones with task lists $efqm_template = array('efqm leadership' => array('a', 'b', 'c', 'd', 'e'), 'efqm strategy' => array('a', 'b', 'c', 'd'), 'efqm people' => array('a', 'b', 'c', 'd', 'e'), 'efqm partnership and resources' => array('a', 'b', 'c', 'd', 'e'), 'efqm processes products services' => array('a', 'b', 'c', 'd', 'e'), 'efqm customer results' => array('a', 'b'), 'efqm people results' => array('a', 'b'), 'efqm society results' => array('a', 'b'), 'efqm key results' => array('a', 'b')); foreach ($efqm_template as $criteria => $subcriteria) { $milestone = new ProjectMilestone(); $milestone->setProjectId($project->getId()); $milestone->setName(lang($criteria)); $milestone->setGoal(config_option('initial goal', 80)); $milestone->setDueDate(DateTimeValueLib::now()); $offset_in_days = config_option('due date offset', 90); $milestone->getDueDate()->advance(60 * 60 * 24 * $offset_in_days); $milestone->save(); foreach ($subcriteria as $subname) { $task_list = new ProjectTaskList(); $task_list->setMilestoneId($milestone->getId()); $task_list->setProjectId($project->getId()); $task_list->setName(lang($criteria) . ' ' . $subname); $task_list->setDueDate($milestone->getDueDate()); $task_list->setScore(config_option('initial score', 50)); $task_list->save(); } } } ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true); DB::commit(); flash_success(lang('success add project', $project->getName())); $this->redirectToUrl($project->getPermissionsUrl()); } catch (Exception $e) { tpl_assign('error', $e); DB::rollback(); } // try } // if }
); } function jq_server_getRegistrations(sid) { if (sid==null) { sid = <?php echo isset($_GET['sid']) ? $_GET['sid'] : 0; ?> ; } $.post("./?ajax=server_getRegistrations", { 'sid': sid }, function (data) { $('#jq_information').show().html(data); <?php if (PermissionManager::getInstance()->serverCanEditRegistrations($_GET['sid'])) { ?> $('#jq_information').prepend('<p style="font-size:x-small;">(Double-click entries to edit them)</p>'); $('.jq_editable').editable( { 'submit': 'save', 'cancel':'cancel', 'editBy': 'dblclick', 'onSubmit': function (content) { var domId = $(this).attr('id'); var sub = domId.substring(0, domId.lastIndexOf('_')); var id = domId.substring(domId.lastIndexOf('_')+1); if (id == 0) { alert('Changing the superuser account is not possible.'); jq_server_getRegistrations(sid); return;
<div id="menu"> <ul> <?php if (!SessionManager::getInstance()->isAdmin()) { ?> <li<?php if (HelperFunctions::getActivePage() == 'login') { echo ' class="active"'; } ?> > <a href="./?page=login">Login</a> </li> <?php } else { HelperFunctions::echoMenuEntry('meta'); HelperFunctions::echoMenuEntry('server'); if (PermissionManager::getInstance()->serverCanEditAdmins()) { HelperFunctions::echoMenuEntry('admins'); } HelperFunctions::echoMenuEntry('logout'); ?> <li style="height:10px; font-size:10px; line-height:10px; margin-top:10px; border-bottom:black;">Back to…</li> <?php } ?> <li><a href="../user/"><-- User</a></li> </ul> </div>
<?php require_once 'initClass.php'; require_once 'init.php'; if (!isset($_SESSION)) { session_start(); } if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') { $JoueurManager = new JoueurManager($db); $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant'])); $PermissionManager = new PermissionManager($db); $RoleManager = new RoleManager($db); $Privilege = new Privilege($JoueurManager->getPrivilege($Joueur->getId())); if ($Privilege->hasPermission('rolePermission')) { if (isset($_POST) && count($_POST) > 0) { // Le traitement de l'insert if ($_POST['action'] == "ajouter") { // Test si un roleid est sélectionné if ($_POST['roleId'] != '') { // Suppression des enregistrements de la table de jointure $RoleManager->delete_permission_role($_POST['roleId']); // Insertion + verification du post permission id if (isset($_POST['permissionId']) && count($_POST['permissionId']) > 0) { $permissionIdCheckbox = $_POST['permissionId']; // Parcours de toute les permissions sélectionnés foreach ($permissionIdCheckbox as $key => $permissionId) { $RoleManager->insert_permission_role($_POST['roleId'], $permissionId); } // Pour que les options soit décoché après avoir fait un insert $_SESSION['listePermissionSelected'] = ''; $_SESSION['roleIdSelected'] = '';
/** * Show update permissions page * * @param void * @return null */ function update_permissions() { $user = Users::findById(get_id()); if (!$user instanceof User) { flash_error(lang('user dnx')); $this->redirectToReferer(get_url('dashboard')); } // if if (!$user->canUpdatePermissions(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $company = $user->getCompany(); if (!$company instanceof Company) { flash_error(lang('company dnx')); $this->redirectToReferer(get_url('dashboard')); } // if $projects = $company->getProjects(); if (!is_array($projects) || !count($projects)) { flash_error(lang('no projects owned by company')); $this->redirectToReferer($company->getViewUrl()); } // if $permissions = PermissionManager::getPermissionsText(); $redirect_to = array_var($_GET, 'redirect_to'); if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) { $redirect_to = $user->getCardUrl(); } // if tpl_assign('user', $user); tpl_assign('company', $company); tpl_assign('projects', $projects); tpl_assign('permissions', $permissions); tpl_assign('redirect_to', $redirect_to); if (array_var($_POST, 'submitted') == 'submitted') { DB::beginWork(); ProjectUsers::clearByUser($user); foreach ($projects as $project) { $permission_count = 0; $permission_all = array_var($_POST, 'project_permissions_' . $project->getId() . '_all') == 'checked'; foreach ($permissions as $permission_name => $permission_text) { $permission_value = $permission_all || array_var($_POST, 'project_permission_' . $project->getId() . '_' . $permission_name) == 'checked'; if ($permission_value) { $permission_count++; } $user->setProjectPermission($project, $permission_name, $permission_value); } // foreach if ($permission_count > 0) { $relation = new ProjectUser(); $relation->setProjectId($project->getId()); $relation->setUserId($user->getId()); $relation->save(); } } // if DB::commit(); flash_success(lang('success user permissions updated')); $this->redirectToUrl($redirect_to); } // if }
/** * Create and attach a user account to the contact * * @access public * @param void * @return null */ function add_user_account() { $this->setTemplate('add_user_to_contact'); $contact = Contacts::findById(get_id()); if (!$contact instanceof Contact) { flash_error(lang('contact dnx')); $this->redirectTo('dashboard', 'contacts'); } // if if (!$contact->canAddUserAccount(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard', 'contacts'); } // if if ($contact->hasUserAccount()) { flash_error(lang('contact already has user')); $this->redirectToUrl($contact->getCardUrl()); } $user = new User(); $company = $contact->getCompany(); $user_data = array_var($_POST, 'user'); if (!is_array($user_data)) { $user_data = array('email' => $contact->getEmail(), 'password_generator' => 'random', 'timezone' => $company->getTimezone()); // array } // if $projects = $company->getProjects(); $permissions = PermissionManager::getPermissionsText(); tpl_assign('contact', $contact); tpl_assign('user', $user); tpl_assign('company', $company); tpl_assign('projects', $projects); tpl_assign('permissions', $permissions); tpl_assign('user_data', $user_data); if (is_array(array_var($_POST, 'user'))) { $user->setFromAttributes($user_data); try { // Generate random password if (array_var($user_data, 'password_generator') == 'random') { $password = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13); // Validate user input } else { $password = array_var($user_data, 'password'); if (trim($password) == '') { throw new Error(lang('password value required')); } // if if ($password != array_var($user_data, 'password_a')) { throw new Error(lang('passwords dont match')); } // if } // if $user->setPassword($password); $granted = 0; if (logged_user()->isAdministrator()) { $user->setIsAdmin(array_var($user_data, 'is_admin')); $user->setAutoAssign(array_var($user_data, 'auto_assign')); $granted = trim(array_var($user_data, 'can_manage_projects')) == '1' ? 1 : 0; } else { $user->setIsAdmin(0); $user->setAutoAssign(0); } DB::beginWork(); $user->save(); $user->setPermission(PermissionManager::CAN_MANAGE_PROJECTS, $granted); $contact->setUserId($user->getId()); $contact->save(); ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_ADD); if (is_array($projects)) { foreach ($projects as $project) { if (array_var($user_data, 'project_permissions_' . $project->getId()) == 'checked') { $relation = new ProjectUser(); $relation->setProjectId($project->getId()); $relation->setUserId($user->getId()); foreach ($permissions as $permission => $permission_text) { $permission_value = array_var($user_data, 'project_permission_' . $project->getId() . '_' . $permission) == 'checked'; $setter = 'set' . Inflector::camelize($permission); $relation->{$setter}($permission_value); } // foreach $relation->save(); } // if } // forech } // if DB::commit(); // Send notification... try { if (array_var($user_data, 'send_email_notification')) { Notifier::newUserAccount($user, $password); } // if } catch (Exception $e) { } // try flash_success(lang('success add user', $user->getDisplayName())); $this->redirectToUrl($company->getViewUrl()); // Translate to profile page } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
/** * Authorises a user against a campaign * @param <type> $campaignId * @return <type> */ public function CampaignAuth($campaignId, $fullObject = false) { $auth = new PermissionManager($this->db, $this); $SQL = ''; $SQL .= 'SELECT UserID '; $SQL .= ' FROM `campaign` '; $SQL .= ' WHERE campaign.CampaignID = %d '; if (!($ownerId = $this->db->GetSingleValue(sprintf($SQL, $campaignId), 'UserID', _INT))) { return $auth; } // If we are the owner, or a super admin then give full permissions if ($this->usertypeid == 1 || $ownerId == $this->userid) { $auth->FullAccess(); return $auth; } // Permissions for groups the user is assigned to, and Everyone $SQL = ''; $SQL .= 'SELECT UserID, MAX(IFNULL(View, 0)) AS View, MAX(IFNULL(Edit, 0)) AS Edit, MAX(IFNULL(Del, 0)) AS Del '; $SQL .= ' FROM `campaign` '; $SQL .= ' INNER JOIN lkcampaigngroup '; $SQL .= ' ON lkcampaigngroup.CampaignID = campaign.CampaignID '; $SQL .= ' INNER JOIN `group` '; $SQL .= ' ON `group`.GroupID = lkcampaigngroup.GroupID '; $SQL .= ' WHERE campaign.CampaignID = %d '; $SQL .= ' AND (`group`.IsEveryone = 1 OR `group`.GroupID IN (%s)) '; $SQL .= 'GROUP BY campaign.UserID '; $SQL = sprintf($SQL, $campaignId, implode(',', $this->GetUserGroups($this->userid, true))); //Debug::LogEntry('audit', $SQL); if (!($row = $this->db->GetSingleRow($SQL))) { return $auth; } // There are permissions to evaluate $auth->Evaluate($row['UserID'], $row['View'], $row['Edit'], $row['Del']); if ($fullObject) { return $auth; } return $auth->edit; }
function permission_manager() { return PermissionManager::instance(); }
/** * This function will check if this user has all project permissions * * @param Project $project * @param boolean $use_cache * @return boolean */ function hasAllProjectPermissions(Project $project, $use_cache = true) { $permissions = array_keys(PermissionManager::getPermissionsText()); if (is_array($permissions)) { foreach ($permissions as $permission) { if (!$this->getProjectPermission($project, $permission)) { return false; } } // foreach } // if return true; } // hasAllProjectPermissions
public static function meta_server_information_update() { $serverId = isset($_POST['serverid']) ? intval($_POST['serverid']) : null; // user has rights? if (PermissionManager::getInstance()->serverCanEditConf($serverId)) { if ($serverId != null && isset($_POST['name']) && isset($_POST['allowlogin']) && isset($_POST['allowregistration']) && isset($_POST['forcemail']) && isset($_POST['authbymail'])) { $serverId = intval($_POST['serverid']); $name = $_POST['name']; $allowLogin = $_POST['allowlogin']; $allowRegistration = $_POST['allowregistration']; $forcemail = $_POST['forcemail']; $authByMail = $_POST['authbymail']; SettingsManager::getInstance()->setServerInformation($serverId, $name, $allowLogin, $allowRegistration, $forcemail, $authByMail); } else { MessageManager::addError(TranslationManager::getInstance()->getText('error_missing_values')); } } else { MessageManager::addError('You don’t have permission to do this.'); } }