public function action_roles($id = false) { $toret = new stdClass(); if ($id) { $toret->role = Role::retrieve($id, 'dbobject'); if ($toret->role) { $query = new SelectQuery('Permission'); $query->filter('`role` = :role'); $toret->permissions = $query->fetchAll(array(':role' => $toret->role->array['name'])); $query = new SelectQuery('Assignment'); $query->leftJoin('BackendUser', array('`backend_users`.`id` = `assignments`.`access_id`'))->filter("`assignments`.`access_type` = 'users'")->filter('`role_id` = :role OR `role_id` = 0'); $toret->assignments = $query->fetchAll(array(':role' => $toret->role->array['id'])); } else { $toret->permissions = null; } } else { $toret->roles = Role::retrieve(); } return $toret; }
public static function assign($role_id, $access_type, $access_id) { $result = false; //if (!self::barredRole($role)) { if (!is_numeric($role_id)) { $role_id = Role::retrieve($role_id); $role_id = $role_id['id']; } $params = array(':role_id' => $role_id, ':access_type' => $access_type, ':access_id' => $access_id); $query = new SelectQuery('Assignment'); $query->filter('`role_id`= :role_id')->filter('`access_type` = :access_type')->filter('`access_id` = :access_id'); $id = $query->fetchColumn($params); if ($id) { $result = true; } else { $keys = array('role_id', 'access_type', 'access_id'); $data = array_combine($keys, array_values($params)); $query = new InsertQuery('Assignment'); $query->data($data); $result = $query->execute() ? true : false; } //} return $result; }
* * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ $focus = new Role(); $focus->retrieve($_REQUEST['record']); $focus->set_user_relationship($focus->id, $_REQUEST['mass']); $header_URL = $sugar_config["site_url"] . "/index.php?action=PopupUsers&form=UsersForm&module=Users&record={$_REQUEST['record']}"; $GLOBALS['log']->debug("about to post header URL of: {$header_URL}"); echo "<script language=javascript>\n"; echo "<!-- //\n"; echo " window.opener.location.reload();\n"; echo "\twindow.location=\"{$header_URL}\";\n"; echo "// -->\n"; echo "</script>";
* requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ require_once 'modules/Roles/Role.php'; require_once 'include/utils.php'; $focus = new Role(); $tabs_def = urldecode($_REQUEST['display_tabs_def']); $tabs_hide = urldecode($_REQUEST['hide_tabs_def']); $allow_modules = explode(':::', $tabs_def); $disallow_modules = explode(':::', $tabs_hide); $focus->retrieve($_POST['record']); print_r($_POST); unset($_POST['id']); foreach ($focus->column_fields as $field) { if (isset($_POST[$field])) { $value = $_POST[$field]; $focus->{$field} = $value; } } $check_notify = FALSE; $focus->save($check_notify); $return_id = $focus->id; $focus->clear_module_relationship($return_id); $focus->set_module_relationship($return_id, $allow_modules, 1); $focus->set_module_relationship($return_id, $disallow_modules, 0); if (isset($_POST['return_module']) && $_POST['return_module'] != "") {
public function html_roles($userRoles) { Backend::add('Sub Title', 'User Roles'); $vars = array('user_id' => Controller::$parameters[0], 'user_roles' => $userRoles, 'system_roles' => Role::retrieve(false, 'list')); Backend::addContent(Render::file('backend_user.roles.tpl.php', $vars)); }