public function testRoles() { $testRoles = ['ROLE_MANAGER', 'ROLE_PLAYER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN']; $this->assertEmpty($this->user->getRoles()); $this->user->setRoles($testRoles); $this->assertEquals($testRoles, $this->user->getRoles()); }
/** * @return string */ public function showRoles() { $string = ''; foreach ($this->user->getRoles() as $role) { $string .= '<li>' . $this->html($role->getName()) . '</li>'; } if (empty($string)) { $string = '<li>None</li>'; } return $string; }
public function testUpdate() { $this->entityManager->persist($this->user); $this->entityManager->flush(); $this->user->setUsername("Jorge Fernandez"); $this->user->setRoles(['ROLE_MANAGER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN']); $this->entityManager->persist($this->user); $this->entityManager->flush(); $persistedUser = $this->userRepository->findOneBy(["email" => $this->user->getEmail()]); $this->assertEquals($this->user, $persistedUser); $this->assertEquals($this->user->getRoles(), $persistedUser->getRoles()); }
/** * @test */ public function testUserProperties() { $uid = '123'; $nick = 'test'; $email = '*****@*****.**'; $user = new User($uid, $nick, $email); $this->assertEquals($nick, $user->getUsername()); $this->assertEquals(null, $user->getSalt()); $this->assertEquals(array('ROLE_USER'), $user->getRoles()); $this->assertEquals('', $user->getPassword()); }
public function checkPerm(User $user, $actionName, $params = null) { $config = Config::getInstance(); $roles = $config['actions'][$actionName]['roles']; $missingRoles = array_diff($roles, $user->getRoles()); if (isset($missingRoles[0]) && $missingRoles[0] == '' || count($missingRoles) == 0) { return true; } else { throw new MissingRolesException('Brak ról: ' . implode(' ', $missingRoles)); } }
/** * @param string $roleName * @param User $user * * @return boolean */ protected function hasUserAccess($roleName, User $user) { $roleHierarchy = new RoleHierarchy($this->container->getParameter('security.role_hierarchy.roles')); $reachableRoles = $roleHierarchy->getReachableRoles(array_map(function ($item) { return new Role($item); }, $user->getRoles())); /* @var \Symfony\Component\Security\Core\Role\RoleInterface $role */ foreach ($reachableRoles as $role) { if ($roleName === $role->getRole()) { return true; } } return false; }
/** * Render navbar * * Return a rendered twig * view that contain the * html navbar * * @param \Twig_Environment $twig - the current twig environment * * @return string - The rendered template */ public function renderNavbar(\Twig_Environment $twig) { $navbar = $this->loader->buildNavbar($this->router); $elements = $navbar->getElements(); if ($this->user !== null) { $roles = $this->user->getRoles(); } else { $roles = array(); } foreach ($elements as $key => $element) { if (!$this->checkRole($element, $roles)) { unset($elements[$key]); } } $navbar->setElements($elements); return $twig->render($this->template, array("navbar" => $navbar->getHead())); }
/** * Is granted * * @param string $slug * * @return boolean */ private function isGranted($slug) { $roles = $this->user->getRoles(); /** @var Role $role */ if (in_array('ROLE_ADMIN', $roles)) { return true; } $granted = false; $roleMenu = $this->repository->findOneBySlug($slug); if ($roleMenu instanceof RoleMenu) { if (count($roleMenu->getRoles())) { $granted = false; foreach ($roleMenu->getArrayRoles() as $role) { if (in_array($role, $roles)) { $granted = true; } } } } return $granted; }
public function testCreate() { $user = new User(); $user->setId(1); $user->setEmail('*****@*****.**'); $user->setPassword('xxxx'); $user->setFirstName('John'); $user->setLastName('Doe'); $user->addRole(new UserRole()); $user->addVehicle(new Vehicle()); $this->assertSame(null, $user->getUpdated()); $user->setUpdated(); $user->preUpdate(); $this->assertSame(1, $user->getId()); $this->assertTrue($user->getCreated() instanceof \DateTime); $this->assertTrue($user->getUpdated() instanceof \DateTime); $this->assertSame('*****@*****.**', $user->getEmail()); $this->assertSame('John', $user->getFirstName()); $this->assertSame('Doe', $user->getLastName()); $this->assertTrue($user->getRoles()[0] instanceof UserRole); $this->assertTrue($user->getVehicles()[0] instanceof Vehicle); }
} elseif (@$_POST['cat'] == 'change_status') { User::changeStatus($_POST['items'], $_POST['status']); } $project_roles = array(); $project_list = Project::getAll(); if (@$_GET['cat'] == 'edit') { $info = User::getDetails($_GET['id']); $tpl->assign('info', $info); } foreach ($project_list as $prj_id => $prj_title) { $excluded_roles = array('Customer'); if (@$info['roles'][$prj_id]['pru_role'] == User::getRoleID('Customer')) { if (count($excluded_roles) == 1) { $excluded_roles = false; } else { $excluded_roles = array('administrator'); } if (@$info['roles'][$prj_id]['pru_role'] == User::getRoleID('administrator')) { $excluded_roles = false; } } $project_roles[$prj_id] = $user_roles = array(0 => 'No Access') + User::getRoles($excluded_roles); } $show_customer = !empty($_GET['show_customers']); $show_inactive = !empty($_GET['show_inactive']); $tpl->assign('list', User::getList($show_customer, $show_inactive)); $tpl->assign('project_list', $project_list); $tpl->assign('project_roles', $project_roles); $tpl->assign('group_list', Group::getAssocListAllProjects()); $tpl->assign('partners', Partner::getAssocList()); $tpl->displayTemplate();
// sets up utils $webDBUtils = WebDBUtils::getInstance(); $roleUtils = RoleUtils::getInstance(); // sets up model $model = Utils::getInstance()->getModel($app); // renders view 'all' if ('all' == $id) { // all users $model['users'] = $webDBUtils->listUser(); $app->render('admin-user-all.php', $model); return; } // sets up a target user $targetUser = new User($id); // roles of selected user $userRoles = $targetUser->getRoles(); // all possible user roles $allRoles = $roleUtils->getRoles(); // the differnces (the not selected possible roles) $diffRoles = $roleUtils->getDiffRoles($userRoles); // fills up model $rid = $targetUser->getRadioId(); $model['radio_id'] = $rid; $model['target_email'] = $targetUser->getEmail(); $model['uid'] = $targetUser->getId(); $model['assets'] = $adminUtils->loadSongsByUserId($id); $model['roles'] = $userRoles; $model['all_roles'] = $allRoles; $model['diff_roles'] = $diffRoles; $model['screens'] = $screenUtils->listScreens(); $res = $screenUtils->getScreenById($rid);
public function actionEdit() { $id = $this->iGet('id'); $model = User::model()->findByPk($id); if ($model === null) { $this->redirect(Yii::app()->request->urlReferrer); } if (isset($_POST['User'])) { $model->attributes = $_POST['User']; $model->handleDate(); if ($model->save()) { Yii::app()->user->setFlash('success', '编辑用户成功'); $this->redirect($this->getReferrer()); } } $model->formatDate(); $roles = User::getRoles(); $identities = User::getIdentities(); $genders = User::getGenders(); $cities = Region::getAllCities(); $this->render('edit', array('model' => $model, 'roles' => $roles, 'identities' => $identities, 'genders' => $genders, 'cities' => $cities)); }
} }); Route::filter('member', function () { if (Auth::guest()) { return Redirect::guest('login'); } else { if (!User::getRoles('member')) { return Redirect::guest('login'); } } }); Route::filter('superadmin', function () { if (Auth::guest()) { return Redirect::guest('login'); } else { if (!User::getRoles('superadmin')) { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic(); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change.
* @param string privilege * @return bool */ function isAllowed($role = self::ALL, $resource = self::ALL, $privilege = self::ALL) { return $role === 'admin' && strpos($resource, 'jany') === FALSE; } } // delete cookies $_COOKIE = array(); $user = new User(); // guest echo "isAuthenticated?\n"; Debug::dump($user->isAuthenticated()); echo "getRoles()\n"; Debug::dump($user->getRoles()); echo "is admin?\n"; Debug::dump($user->isInRole('admin')); echo "is guest?\n"; Debug::dump($user->isInRole('guest')); // authenticated $handler = new AuthenticationHandler(); $user->setAuthenticationHandler($handler); echo "authenticate as john\n"; $user->authenticate('john', 'xxx'); echo "isAuthenticated?\n"; Debug::dump($user->isAuthenticated()); echo "getRoles()\n"; Debug::dump($user->getRoles()); echo "is admin?\n"; Debug::dump($user->isInRole('admin'));
/** * @inheritdoc */ public function getRoles() { $effectiveRoles = array_merge($this->roles, $this->user->getRoles()); return $effectiveRoles; }
include "../../src/Bouncer.class.php"; include "../Shared Classes/User.class.php"; $bouncer = new Bouncer(); // Add a role Name, Array of pages role provides $bouncer->addRole("Public", array("index.php", "about.php", "fail.php")); // Add a role Name, Array of pages role provides $bouncer->addRole("Registered User", array("myaccount.php", "editaccount.php", "viewusers.php")); // Add a role Name, Array of pages role provides List of pages that are overridden by other pages $bouncer->addRole("Admin", array("stats.php", "manageusers.php"), array("viewusers.php" => "manageusers.php")); // Here we add some users. The user class here extends the BouncerUser class, so it can still do whatever you // would normally create a user class to do.. $publicUser = new User(); $registeredUser = new User(); $adminUser = new User(); $registeredAndAdmin = new User(); $publicUser->addRole("Public"); $registeredUser->addRole("Public"); // We add the public group to all users since they need it to see index.php $registeredUser->addRole("Registered User"); $adminUser->addRole("Public"); // We add the public group to all users since they need it to see index.php $adminUser->addRole("Admin"); $registeredAndAdmin->addRole("Public"); // We add the public group to all users since they need it to see index.php $registeredAndAdmin->addRole("Registered User"); $registeredAndAdmin->addRole("Admin"); //$bouncer->manageAccess($publicUser->getRoles(), substr($_SERVER["PHP_SELF"], 1), "fail.php"); //$bouncer->manageAccess($registeredUser->getRoles(), substr($_SERVER["PHP_SELF"], 1), "fail.php"); //$bouncer->manageAccess($adminUser->getRoles(), substr($_SERVER["PHP_SELF"], 1), "fail.php"); $bouncer->manageAccess($registeredAndAdmin->getRoles(), substr($_SERVER["PHP_SELF"], 1), "fail.php");
/** * Returns an array of sites where the user has a GRANTED role over a * parent OwnedObject including Site and NGI, but not Project. * Important: This does <b>NOT</b> grant permissions over the returned sites, * it simply means that the user has a Role over one of the owning OwnedObjects. * * @param \User $user * @return array Of \Site objects */ public function getReachableSitesFromOwnedObjectRoles(\User $user) { // Build the list of sites a user is allowed to add an SE to $sites = array(); $roles = $user->getRoles(); foreach ($roles as $role) { if ($role->getStatus() == \RoleStatus::GRANTED) { if ($role->getOwnedEntity() instanceof \Site) { $sites[] = $role->getOwnedEntity(); } // If the role is over an NGI add all of the NGI's child sites to the list if ($role->getOwnedEntity() instanceof \NGI) { $ngiSites = $role->getOwnedEntity()->getSites(); foreach ($ngiSites as $site) { $sites[] = $site; } } } } $sites = array_unique($sites); usort($sites, function ($a, $b) { return strcmp($a, $b); }); return $sites; }
/** * returns the amount of directly childs (not recursivly) * * @param User $user * @return integer */ public function getChildAmount($objectTypes = array(Object::OBJECT_TYPE_OBJECT, Object::OBJECT_TYPE_FOLDER), $user = null) { if ($user and !$user->isAdmin()) { $userIds = $user->getRoles(); $userIds[] = $user->getId(); $query = "SELECT COUNT(*) AS count FROM objects o WHERE o_parentId = ? AND o_type IN ('" . implode("','", $objectTypes) . "')\r\n AND (select list as locate from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(o.o_path,o.o_key))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1;"; } else { $query = "SELECT COUNT(*) AS count FROM objects WHERE o_parentId = ? AND o_type IN ('" . implode("','", $objectTypes) . "')"; } $c = $this->db->fetchOne($query, $this->model->getId()); return $c; }
include "../../src/Bouncer.class.php"; include "../Shared Classes/User.class.php"; $bouncer = new Bouncer(); // Add a role Name, Array of pages role provides $bouncer->addRole("Public", array("index.php", "about.php")); // Add a role Name, Array of pages role provides $bouncer->addRole("Registered User", array("myaccount.php", "editaccount.php", "viewusers.php")); // Add a role Name, Array of pages role provides List of pages that are overridden by other pages $bouncer->addRole("Admin", array("stats.php", "manageusers.php"), array("viewusers.php" => "manageusers.php")); // Here we add some users. The user class here extends the BouncerUser class, so it can still do whatever you // would normally create a user class to do.. $user1 = new User(); $user2 = new User(); $user3 = new User(); $user1->addRole("Public"); $user2->addRole("Registered User"); $user3->addRole("Admin"); $bouncer->verifyAccess($user1->getRoles(), "index.php"); // True! $bouncer->verifyAccess($user1->getRoles(), "viewusers.php"); // False! User 1 does not have access to this page. $bouncer->verifyAccess($user2->getRoles(), "index.php"); // True! $bouncer->verifyAccess($user2->getRoles(), "viewusers.php"); // True! $bouncer->verifyAccess($user3->getRoles(), "index.php"); // True! $bouncer->verifyAccess($user3->getRoles(), "viewusers.php"); // False! As an Admin, viewusers.php has been replaced // with manageusers.php
/** * Set user token in the secured area * @param User $user */ public function refreshSecurityToken(User $user, $firewall = null) { $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles()); $this->get('security.token_storage')->setToken($token); }
/* * This file is part of the Eventum (Issue Tracking System) package. * * @copyright (c) Eventum Team * @license GNU General Public License, version 2 or later (GPL-2+) * * For the full copyright and license information, * please see the COPYING and AUTHORS files * that were distributed with this source code. */ require_once __DIR__ . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/general.tpl.html'); Auth::checkAuthentication(); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_REPORTER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } $tpl->assign('project_list', Project::getAll()); if (@$_POST['cat'] == 'update') { $smtp = $_POST['smtp']; $smtp['auth'] = (bool) $smtp['auth']; $setup = array('tool_caption' => $_POST['tool_caption'], 'support_email' => $_POST['support_email'], 'description_email_0' => $_POST['description_email_0'], 'spell_checker' => $_POST['spell_checker'], 'irc_notification' => $_POST['irc_notification'], 'update' => (bool) Misc::ifSet($_POST, 'update'), 'closed' => (bool) Misc::ifSet($_POST, 'closed'), 'emails' => (bool) Misc::ifSet($_POST, 'emails'), 'files' => (bool) Misc::ifSet($_POST, 'files'), 'smtp' => $smtp, 'open_signup' => $_POST['open_signup'], 'accounts_projects' => isset($_POST['accounts_projects']) ? $_POST['accounts_projects'] : null, 'accounts_role' => isset($_POST['accounts_role']) ? $_POST['accounts_role'] : null, 'subject_based_routing' => $_POST['subject_based_routing'], 'email_routing' => $_POST['email_routing'], 'note_routing' => $_POST['note_routing'], 'draft_routing' => $_POST['draft_routing'], 'email_error' => $_POST['email_error'], 'email_reminder' => $_POST['email_reminder'], 'handle_clock_in' => $_POST['handle_clock_in']); $res = Setup::save($setup); $tpl->assign('result', $res); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the setup information was saved successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to create the configuration file in the setup directory (%1\$s). " . 'Please contact your local system administrator and ask for write privileges on the provided path.', APP_CONFIG_PATH), Misc::MSG_NOTE_BOX), -2 => array(ev_gettext("ERROR: The system doesn't have the appropriate permissions to update the configuration file in the setup directory (%1\$s). " . 'Please contact your local system administrator and ask for write privileges on the provided filename.', APP_SETUP_FILE), Misc::MSG_NOTE_BOX))); } $tpl->assign(array('setup' => Setup::get(), 'user_roles' => User::getRoles(array('Customer')))); $tpl->displayTemplate();
<div class="row"> <div class="col-lg-12"> <div class="portlet portlet-default"> <div class="portlet-heading"> <div class="portlet-title"> <h4>用户列表</h4> </div> <div class="clearfix"></div> </div> <div class="panel-collapse collapse in"> <div class="portlet-body"> <?php $this->widget('GridView', array('dataProvider' => $model->search(), 'template' => '{pager}{items}{pager}', 'afterAjaxUpdate' => 'js:function(){$(".tips").tooltip()}', 'rowCssClassExpression' => '$data->isBanned() ? "danger" : ""', 'filter' => $model, 'columns' => array(array('header' => '操作', 'headerHtmlOptions' => array('class' => 'header-operation-3'), 'type' => 'raw', 'value' => '$data->operationButton'), array('headerHtmlOptions' => array('class' => 'header-id'), 'name' => 'id'), array('headerHtmlOptions' => array('class' => 'header-name'), 'name' => 'name'), array('headerHtmlOptions' => array('class' => 'header-name-cn'), 'name' => 'name_zh'), array('headerHtmlOptions' => array('class' => 'header-email'), 'name' => 'email', 'type' => 'raw', 'value' => '$data->getEmailLink()'), array('headerHtmlOptions' => array('class' => 'header-wcaid'), 'name' => 'wcaid', 'type' => 'raw', 'value' => '$data->getWcaLink($data->wcaid)'), array('headerHtmlOptions' => array('class' => 'header-gender'), 'filter' => User::getGenders(), 'name' => 'gender', 'value' => '$data->getGenderText()'), array('headerHtmlOptions' => array('class' => 'header-avatar'), 'filter' => User::getHasAvatars(), 'name' => 'avatar_id', 'value' => '$data->avatar ? $data->avatar->img : ""', 'type' => 'raw'), array('name' => 'birthday', 'headerHtmlOptions' => array('class' => 'header-birthday'), 'filter' => false, 'type' => 'raw', 'value' => 'date("Y-m-d", $data->birthday)'), array('headerHtmlOptions' => array('class' => 'header-country'), 'filter' => false, 'name' => 'country_id', 'type' => 'raw', 'value' => '$data->getRegionName($data->country)'), array('headerHtmlOptions' => array('class' => 'header-time'), 'filter' => false, 'name' => 'reg_time', 'type' => 'raw', 'value' => 'date("Y-m-d H:i:s", $data->reg_time)'), array('headerHtmlOptions' => array('class' => 'header-ip'), 'name' => 'reg_ip', 'type' => 'raw', 'value' => '$data->getRegIpDisplay("reg_ip")'), array('headerHtmlOptions' => array('class' => 'header-role'), 'filter' => User::getRoles(), 'name' => 'role', 'type' => 'raw', 'value' => '$data->getRoleName()'), array('headerHtmlOptions' => array('class' => 'header-role'), 'filter' => User::getIdentities(), 'name' => 'identity', 'type' => 'raw', 'value' => '$data->getIdentityName()')))); ?> </div> </div> </div> </div> </div> <div tabindex="-1" id="modal" class="modal fade"> <div class="modal-dialog" style="width: 800px; max-width: 100%"> <div class="modal-content"> <div class="modal-body"> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> </div> </div> </div> </div> <?php
/** * returns the amount of directly childs (not recursivly) * * @param User $user * @return integer */ public function getChildAmount($user = null) { if ($user and !$user->isAdmin()) { $userIds = $user->getRoles(); $userIds[] = $user->getId(); $query = "select count(*) from assets a where parentId = ?\r\n and (select list as locate from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(a.path,a.filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1;"; } else { $query = "SELECT COUNT(*) AS count FROM assets WHERE parentId = ?"; } $c = $this->db->fetchOne($query, $this->model->getId()); return $c; }
/** * @covers AppBundle\Entity\User::getRoles * Implement testGetRoles(). */ public function testGetRoles() { $this->assertNotEmpty($this->user->getRoles()); }
* that were distributed with this source code. */ require_once __DIR__ . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/link_filters.tpl.html'); Auth::checkAuthentication(); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_MANAGER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'new') { $res = Link_Filter::insert(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new link filter.'), Misc::MSG_INFO))); } elseif (@$_POST['cat'] == 'update') { $res = Link_Filter::update(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the link filter.'), Misc::MSG_INFO))); } elseif (@$_POST['cat'] == 'delete') { $res = Link_Filter::remove(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the link filter was deleted successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to delete the link filter.'), Misc::MSG_INFO))); } if (@$_GET['cat'] == 'edit') { $info = Link_Filter::getDetails($_GET['id']); $tpl->assign('info', $info); } $user_roles = User::getRoles(); $tpl->assign('list', Link_Filter::getList()); $tpl->assign('project_list', Project::getAll()); $tpl->assign('user_roles', $user_roles); $tpl->displayTemplate();
function testGetRoles() { $u1 = User::getOneFromDb(['user_id' => 101], $this->DB); $u2 = User::getOneFromDb(['user_id' => 110], $this->DB); $u3 = new User(['user_id' => 50, 'username' => 'fjones', 'screen_name' => 'jones, fred', 'DB' => $this->DB]); $u4 = User::getOneFromDb(['user_id' => 109], $this->DB); $r1 = $u1->getRoles(); $this->assertEqual(1, count($r1)); $this->assertEqual('field user', $r1[0]->name); $r2 = $u2->getRoles(); $this->assertEqual(1, count($r2)); $this->assertEqual('manager', $r2[0]->name); $r3 = $u3->getRoles(); $this->assertEqual(1, count($r3)); $this->assertEqual('public', $r3[0]->name); $r4 = $u4->getRoles(); $this->assertEqual(1, count($r4)); $this->assertEqual('public', $r4[0]->name); }
// | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/field_display.tpl.html'); Auth::checkAuthentication(APP_COOKIE); $tpl->assign('type', 'field_display'); $prj_id = @$_GET['prj_id']; $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_MANAGER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (count(@$_POST['fields']) > 0) { $res = Project::updateFieldDisplaySettings($prj_id, $_POST['fields']); $tpl->assign('result', $res); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the information was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the information.'), Misc::MSG_ERROR))); } $fields = Project::getDisplayFields(); $excluded_roles = array('viewer'); if (!CRM::hasCustomerIntegration($prj_id)) { $excluded_roles[] = 'customer'; } $user_roles = User::getRoles($excluded_roles); $user_roles[9] = 'Never Display'; $tpl->assign('prj_id', $prj_id); $tpl->assign('fields', $fields); $tpl->assign('user_roles', $user_roles); $tpl->assign('display_settings', Project::getFieldDisplaySettings($prj_id)); $tpl->displayTemplate();
$setup["allow_unassigned_issues"] = $HTTP_POST_VARS["allow_unassigned_issues"]; @($setup["update"] = $HTTP_POST_VARS["update"]); @($setup["closed"] = $HTTP_POST_VARS["closed"]); @($setup["notes"] = $HTTP_POST_VARS["notes"]); @($setup["emails"] = $HTTP_POST_VARS["emails"]); @($setup["files"] = $HTTP_POST_VARS["files"]); @($setup["smtp"] = $HTTP_POST_VARS["smtp"]); @($setup["scm_integration"] = $HTTP_POST_VARS["scm_integration"]); @($setup["checkout_url"] = $HTTP_POST_VARS["checkout_url"]); @($setup["diff_url"] = $HTTP_POST_VARS["diff_url"]); @($setup["open_signup"] = $HTTP_POST_VARS["open_signup"]); @($setup["accounts_projects"] = $HTTP_POST_VARS["accounts_projects"]); @($setup["accounts_role"] = $HTTP_POST_VARS["accounts_role"]); @($setup['subject_based_routing'] = $HTTP_POST_VARS['subject_based_routing']); @($setup['email_routing'] = $HTTP_POST_VARS['email_routing']); @($setup['note_routing'] = $HTTP_POST_VARS['note_routing']); @($setup['draft_routing'] = $HTTP_POST_VARS['draft_routing']); @($setup['email_error'] = $HTTP_POST_VARS['email_error']); @($setup['email_reminder'] = $HTTP_POST_VARS['email_reminder']); $options = Setup::load(); @($setup['downloading_emails'] = $options['downloading_emails']); $res = Setup::save($setup); $tpl->assign("result", $res); } $options = Setup::load(true); $tpl->assign("setup", $options); $tpl->assign("user_roles", User::getRoles(array('Customer'))); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
$api->get('/donation/{donation_id}/approve/{poc_id}', function ($donation_id, $poc_id) { $donation = new Donation(); $donation->approveDonation($donation_id, $poc_id); showSuccess("Donation approved", array('donation_id' => $donation_id)); }); $api->request("/user/login", function () { global $QUERY; $user = new User(); $phone = i($QUERY, 'phone'); $password = i($QUERY, 'password'); if (!$user->login($phone, $password)) { showError($user->error, array('')); exit; } $return = array('user' => $user->user); $return['user']['roles'] = $user->getRoles(); showSuccess("Login successful", $return); }); $api->handle(); function showSuccess($message, $extra = array()) { showSituation('success', $message, $extra); } function showError($message, $extra = array()) { showSituation('error', $message, $extra); } function showSituation($status, $message, $extra) { $other_status = $status == 'success' ? 'error' : 'success'; $return = array($status => true, $other_status => false);
<?php include 'classes/user.php'; $user = new User(); $user->getRoles();