function display() { require_once 'modules/ACLRoles/ACLRole.php'; //Get the current user's role $objACLRole = new ACLRole(); $roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id); //check if they are in the Admin or Admin Manager's role if (in_array('Admin', $roles) || in_array('Branch Manager - Delhi', $roles)) { $this->ev->ss->assign('ReadOnly', ''); } else { //If not pass in a variable with the value readonly $this->ev->ss->assign('ReadOnly', 'readonly'); } //Call the parent display function parent::display(); }
/** * Override - Called from process(). This method will display subpanels. * include/MVC/View/SugarView.php */ protected function _displaySubPanels() { if (isset($this->bean) && !empty($this->bean->id) && (file_exists("modules/" . $this->module . "/metadata/subpaneldefs.php") || file_exists("custom/modules/" . $this->module . "/Ext/Layoutdefs/layoutdefs.ext.php"))) { $GLOBALS["focus"] = $this->bean; require_once 'include/SubPanel/SubPanelTiles.php'; $subpanel = new SubPanelTiles($this->bean, $this->module); //Dependent Logic global $current_user; require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $user_id = $current_user->id; $roles = $role->getUserRoleNames($user_id); if (in_array("Technical support", $roles)) { //Subpanels to hide $hide_subpanels = array("bugs"); if (isset($subpanel->subpanel_definitions->layout_defs['subpanel_setup']["bugs"])) { unset($subpanel->subpanel_definitions->layout_defs['subpanel_setup']["bugs"]); } } echo $subpanel->display(); } }
/** * Rebuilds cache files for dropdown filters extension */ protected function rebuild_dropdown_filters() { $roles = ACLRole::getAllRoles(); foreach ($roles as $role) { $this->rebuild_role_dropdown_filters($role->id); } }
private function getRoleUsers($roleId) { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($roleId); $role_users = $role->get_linked_beans('users', 'User'); $r_users = array(); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } return $r_users; }
/** * Create a user in the seed data. */ function _create_seed_user($id, $last_name, $first_name, $user_name, $title, $is_admin, $reports_to, $reports_to_name, $email) { $u = new User(); $u->id = $id; $u->new_with_id = true; $u->last_name = $last_name; $u->first_name = $first_name; $u->user_name = $user_name; $u->title = $title; $u->status = 'Active'; $u->employee_status = 'Active'; $u->is_admin = $is_admin; $u->is_group = 0; //$u->user_password = $u->encrypt_password($user_name); $u->user_hash = User::getPasswordHash($user_name); $u->reports_to_id = $reports_to; $u->reports_to_name = $reports_to_name; //$u->email1 = $email; $u->emailAddress->addAddress($email, true); $u->emailAddress->addAddress("reply." . $email, false, true); $u->emailAddress->addAddress("alias." . $email); // bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain $u->setPreference('max_tabs', '7'); $u->savePreferencesToDB(); $u->picture = $this->_copy_user_image($id); $u->save(); if ($id == "seed_jim_id") { // add to Sales Administrator Role $acl_roles = new ACLRole(); $arrRoles = $acl_roles->getAllRoles(true); foreach ($arrRoles as $role) { if ($role['name'] == "Sales Administrator") { $u->load_relationship('aclroles'); $u->aclroles->add($role['id']); // re-save user manually. otherwise the relation to role set will not be saved // because One2MBeanRelationship::add() doesn't call SugarRelationship::addToResaveList() // in workflow and during installation $u->save(); break; } } } }
/** * Returns object storage containing available roles as keys * and flags indicating if there is role specific metadata as value * * @param callable $callback Callback that checks if there is role specific metadata * @return SplObjectStorage */ public static function getRoles($callback = null) { global $current_user; $roles = new SplObjectStorage(); //Only super user should have access to all roles $allRoles = $current_user->isAdmin() ? ACLRole::getAllRoles() : ACLRole::getUserRoles($current_user->id, false); foreach ($allRoles as $role) { if (in_array($role->name, static::$hiddenRoles)) { continue; } $roles[$role] = $callback ? $callback(array('role' => $role->id)) : null; } return $roles; }
global $dictionary; $sugar_smarty = new Sugar_Smarty(); $sugar_smarty->assign('MOD', $mod_strings); $sugar_smarty->assign('APP', $app_strings); //nsingh bug: 21669. Messes up localization /*foreach($modInvisList as $modinvisname){ if(empty($app_list_strings['moduleList'][$modinvisname])){ $app_list_strings['moduleList'][$modinvisname] = $modinvisname; } }*/ $sugar_smarty->assign('APP_LIST', $app_list_strings); /*foreach($modInvisList as $modinvisname){ unset($app_list_strings['moduleList'][$modinvisname]); }*/ $role = BeanFactory::getBean('ACLRoles', $_REQUEST['record']); $categories = ACLRole::getRoleActions($_REQUEST['record']); $names = ACLAction::setupCategoriesMatrix($categories); // Skipping modules that have 'hidden_to_role_assignment' property foreach ($categories as $name => $category) { if (isset($dictionary[$name]) && isset($dictionary[$name]['hidden_to_role_assignment']) && $dictionary[$name]['hidden_to_role_assignment']) { unset($categories[$name]); } } $categories2 = array(); $categories2 = $categories; $hidden_categories = array("KBDocuments", "Campaigns", "Forecasts", "Emails", "EmailTemplates", "EmailMarketing", "Reports", "PdfManager"); foreach ($hidden_categories as $v) { if (isset($categories2[$v])) { unset($categories2[$v]); } }
private function getEmailsFromParams(SugarBean $bean, $params) { $emails = array(); //backward compatible if (isset($params['email_target_type']) && !is_array($params['email_target_type'])) { $email = ''; switch ($params['email_target_type']) { case 'Email Address': $params['email'] = array($params['email']); break; case 'Specify User': $params['email'] = array($params['email_user_id']); break; case 'Related Field': $params['email'] = array($params['email_target']); break; } $params['email_target_type'] = array($params['email_target_type']); $params['email_to_type'] = array('to'); } //end backward compatible if (isset($params['email_target_type'])) { foreach ($params['email_target_type'] as $key => $field) { switch ($field) { case 'Email Address': if (trim($params['email'][$key]) != '') { $emails[$params['email_to_type'][$key]][] = $params['email'][$key]; } break; case 'Specify User': $user = new User(); $user->retrieve($params['email'][$key]); $user_email = $user->emailAddress->getPrimaryAddress($user); if (trim($user_email) != '') { $emails[$params['email_to_type'][$key]][] = $user_email; $emails['template_override'][$user_email] = array('Users' => $user->id); } break; case 'Users': $users = array(); switch ($params['email'][$key][0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($params['email'][$key][1]); $users = $security_group->get_linked_beans('users', 'User'); $r_users = array(); if ($params['email'][$key][2] != '') { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } } foreach ($users as $user_id => $user) { if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) { unset($users[$user_id]); } } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $users = $role->get_linked_beans('users', 'User'); break; case 'all': default: global $db; $sql = "SELECT id from users WHERE status='Active' AND portal_only=0 "; $result = $db->query($sql); while ($row = $db->fetchByAssoc($result)) { $user = new User(); $user->retrieve($row['id']); $users[$user->id] = $user; } break; } foreach ($users as $user) { $user_email = $user->emailAddress->getPrimaryAddress($user); if (trim($user_email) != '') { $emails[$params['email_to_type'][$key]][] = $user_email; $emails['template_override'][$user_email] = array('Users' => $user->id); } } break; case 'Related Field': $emailTarget = $params['email'][$key]; $relatedFields = array_merge($bean->get_related_fields(), $bean->get_linked_fields()); $field = $relatedFields[$emailTarget]; if ($field['type'] == 'relate') { $linkedBeans = array(); $idName = $field['id_name']; $id = $bean->{$idName}; $linkedBeans[] = BeanFactory::getBean($field['module'], $id); } else { if ($field['type'] == 'link') { $relField = $field['name']; if (isset($field['module']) && $field['module'] != '') { $rel_module = $field['module']; } else { if ($bean->load_relationship($relField)) { $rel_module = $bean->{$relField}->getRelatedModuleName(); } } $linkedBeans = $bean->get_linked_beans($relField, $rel_module); } else { $linkedBeans = $bean->get_linked_beans($field['link'], $field['module']); } } if ($linkedBeans) { foreach ($linkedBeans as $linkedBean) { $rel_email = $linkedBean->emailAddress->getPrimaryAddress($linkedBean); if (trim($rel_email) != '') { $emails[$params['email_to_type'][$key]][] = $rel_email; $emails['template_override'][$rel_email] = array($linkedBean->module_dir => $linkedBean->id); } } } break; case 'Record Email': $recordEmail = $bean->emailAddress->getPrimaryAddress($bean); if ($recordEmail == '' && isset($bean->email1)) { $recordEmail = $bean->email1; } if (trim($recordEmail) != '') { $emails[$params['email_to_type'][$key]][] = $recordEmail; } break; } } } return $emails; }
$aclrole->setAction($aclrole->id, $action['id'], ACL_ALLOW_NONE); } echo 'Only owner Peon user should have editaccess to contacts<br>'; $aclrole->setAction($aclrole->id, $action_results['Contacts']['edit']['id'], ACL_ALLOW_OWNER); echo 'Some one made a mistake and added delete access on Contacts<br>'; $aclrole->setAction($aclrole->id, $action_results['Contacts']['delete']['id'], ACL_ALLOW_ALL); $action_results = ACLAction::getUserActions('will_id', true); echo 'Actions Peon role for will<br>'; foreach ($action_results as $category_name => $category) { foreach ($category as $action_name => $action) { _pp($category_name . ':' . $action_name . ':' . acl_translate($action['access'])); } } echo 'Will is a bad peon user<br>'; echo 'Create a role for Bad Peon Users<br>'; $aclrole = new ACLRole(); $aclrole->name = 'Bad Peon User'; $aclrole->description = 'The Bad Peon Role For All Bad Peons'; $aclrole->user_id = 'will_id'; $aclrole->save(); echo 'No Bad Peon user should have access to contacts <br>'; foreach ($action_results['Contacts'] as $action) { $aclrole->setAction($aclrole->id, $action['id'], ACL_ALLOW_NONE); } $action_results = ACLAction::getUserActions('will_id', true); echo 'Actions Peon role for will<br>'; foreach ($action_results as $category_name => $category) { foreach ($category as $action_name => $action) { _pp($category_name . ':' . $action_name . ':' . acl_translate($action['access'])); } }
//set cookies if (isset($_SESSION['authenticated_user_id'])) { setCookie('ck_login_id_20', $_SESSION['authenticated_user_id'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme'])) { setCookie('ck_login_theme_20', $_SESSION['authenticated_user_theme'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme_color'])) { setCookie('ck_login_theme_color_20', $_SESSION['authenticated_user_theme_color'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_theme_font'])) { setCookie('ck_login_theme_font_20', $_SESSION['authenticated_user_theme_font'], time() + 86400 * 90); } if (isset($_SESSION['authenticated_user_language'])) { setCookie('ck_login_language_20', $_SESSION['authenticated_user_language'], time() + 86400 * 90); } require_once 'modules/ACLRoles/ACLRole.php'; $objACLRole = new ACLRole(); $roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id); if (in_array('Lawyer', $roles)) { print "<h2>You do not have permissions to access this function.</h2>"; exit; } chdir($current_directory); $_POST = $post; $_GET = $get; /*foreach(array_keys($GLOBALS) as $key) { if (!in_array($key, array('_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_REQUEST', 'GLOBALS'))) { unset($GLOBALS[$key]); } }*/
/** * The Quick edit for case updates which appears under update stream * Also includes the javascript for AJAX update * * @return string - the html to be displayed and javascript */ function quick_edit_case_updates() { //current record id $record = $_GET['record']; //Get Users roles require_once 'modules/ACLRoles/ACLRole.php'; $user = $GLOBALS['current_user']; $id = $user->id; $acl = new ACLRole(); $roles = $acl->getUserRoles($id); //Return if user cannot edit cases if (in_array("no edit cases", $roles) || $roles === "no edit cases") { return; } //Javascript for Asynchronous update $javascript = <<<A <script> function caseUpdates(){ loadingMessgPanl = new YAHOO.widget.SimpleDialog('loading', { width: '200px', close: true, modal: true, visible: true, fixedcenter: true, constraintoviewport: true, draggable: false }); loadingMessgPanl.setHeader(SUGAR.language.get('app_strings', 'LBL_EMAIL_PERFORMING_TASK')); loadingMessgPanl.setBody(SUGAR.language.get('app_strings', 'LBL_EMAIL_ONE_MOMENT')); loadingMessgPanl.render(document.body); loadingMessgPanl.show(); var update_data = document.getElementById('update_text').value; var checkbox = document.getElementById('internal').checked; var internal = ""; if(checkbox){ internal=1; } //Post parameters var params = "record={$record}&module=Cases&return_module=Cases&action=Save&return_id={$record}&return_action=DetailView&relate_to=Cases&relate_id={$record}&offset=1&update_text=" + update_data + "&internal=" + internal; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", "index.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); //When button is clicked xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { showSubPanel('history', null, true); //Reload the case updates stream and history panels \t\t \$("#LBL_AOP_CASE_UPDATES").load("index.php?module=Cases&action=DetailView&record={$record}" + " #LBL_AOP_CASE_UPDATES", function(){ //Collapse all except newest update \$('.caseUpdateImage').attr("src",showUpdateImage); \$('.caseUpdate').slideUp('fast'); var id = \$('.caseUpdate').last().attr('id'); if(id){ toggleCaseUpdate(id.replace('caseUpdate','')); } loadingMessgPanl.hide(); } ); \t} } xmlhttp.send(params); } </script> A; $html = <<<EOD <form id='case_updates' enctype="multipart/form-data"> <textarea id="update_text" name="update_text" cols="80" rows="4"></textarea> <input id='internal' type='checkbox' name='internal' tabindex=0 title='' value='1'> Internal</input> </br> <input type='button' value='Save' onclick="caseUpdates()" title="Save" name="button"> </input> </br> </form> EOD; return $javascript . $html; }
* "Powered by SugarCRM". ********************************************************************************/ global $app_list_strings; // $modInvisList $sugar_smarty = new Sugar_Smarty(); $sugar_smarty->assign('MOD', $mod_strings); $sugar_smarty->assign('APP', $app_strings); //mass localization /*foreach($modInvisList as $modinvisname){ $app_list_strings['moduleList'][$modinvisname] = $modinvisname; }*/ $sugar_smarty->assign('APP_LIST', $app_list_strings); /*foreach($modInvisList as $modinvisname){ unset($app_list_strings['moduleList'][$modinvisname]); }*/ $role = new ACLRole(); $role_name = ''; $return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => ''); if (!empty($_REQUEST['record'])) { $role->retrieve($_REQUEST['record']); $categories = ACLRole::getRoleActions($_REQUEST['record']); $role_name = $role->name; if (!empty($_REQUEST['isDuplicate'])) { //role id is stripped here in duplicate so anything using role id after this will not have it $role->id = ''; } else { $return['record'] = $role->id; $return['action'] = 'DetailView'; } } else { $categories = ACLRole::getRoleActions('');
function addDefaultRoles($defaultRoles = array()) { global $db; foreach ($defaultRoles as $roleName => $role) { $ACLField = new ACLField(); $role1 = new ACLRole(); $role1->name = $roleName; $role1->description = $roleName . " Role"; $role1_id = $role1->save(); foreach ($role as $category => $actions) { foreach ($actions as $name => $access_override) { if ($name == 'fields') { foreach ($access_override as $field_id => $access) { $ACLField->setAccessControl($category, $role1_id, $field_id, $access); } } else { $queryACL = "SELECT id FROM acl_actions where category='{$category}' and name='{$name}'"; $result = $db->query($queryACL); $actionId = $db->fetchByAssoc($result); if (isset($actionId['id']) && !empty($actionId['id'])) { $role1->setAction($role1_id, $actionId['id'], $access_override); } } } } } }
function set_record(SugarBean $record, SugarBean $bean, $params = array(), $in_save = false) { global $app_list_strings, $timedate; $record_vardefs = $record->getFieldDefinitions(); if (isset($params['field'])) { foreach ($params['field'] as $key => $field) { if ($field == '') { continue; } switch ($params['value_type'][$key]) { case 'Field': if ($params['value'][$key] == '') { continue; } $data = $bean->field_defs[$params['value'][$key]]; if ($data['type'] == 'relate' && isset($data['id_name'])) { $params['value'][$key] = $data['id_name']; } $value = $bean->{$params}['value'][$key]; break; case 'Date': $dformat = 'Y-m-d H:i:s'; if ($record_vardefs[$field]['type'] == 'date') { $dformat = 'Y-m-d'; } switch ($params['value'][$key][3]) { case 'business_hours': if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) { require_once 'modules/AOBH_BusinessHours/AOBH_BusinessHours.php'; $businessHours = new AOBH_BusinessHours(); $dateToUse = $params['value'][$key][0]; $sign = $params['value'][$key][1]; $amount = $params['value'][$key][2]; if ($sign != "plus") { $amount = 0 - $amount; } if ($dateToUse == "now") { $value = $businessHours->addBusinessHours($amount); } else { if ($dateToUse == "field") { $dateToUse = $params['field'][$key]; $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse})); } else { $value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse})); } } $value = $timedate->asDb($value); break; } $params['value'][$key][3] = 'hours'; //No business hours module found - fall through. //No business hours module found - fall through. default: if ($params['value'][$key][0] == 'now') { $date = gmdate($dformat); } else { if ($params['value'][$key][0] == 'field') { $date = $record->fetched_row[$params['field'][$key]]; } else { $date = $bean->fetched_row[$params['value'][$key][0]]; } } if ($params['value'][$key][1] != 'now') { $value = date($dformat, strtotime($date . ' ' . $app_list_strings['aow_date_operator'][$params['value'][$key][1]] . $params['value'][$key][2] . ' ' . $params['value'][$key][3])); } else { $value = date($dformat, strtotime($date)); } break; } break; case 'Round_Robin': case 'Least_Busy': case 'Random': switch ($params['value'][$key][0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($params['value'][$key][1]); $group_users = $security_group->get_linked_beans('users', 'User'); $users = array(); $r_users = array(); if ($params['value'][$key][2] != '') { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['value'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } } foreach ($group_users as $group_user) { if ($params['value'][$key][2] != '' && !isset($r_users[$group_user->id])) { continue; } $users[$group_user->id] = $group_user->name; } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['value'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); $users = array(); foreach ($role_users as $role_user) { $users[$role_user->id] = $role_user->name; } break; case 'all': default: $users = get_user_array(false); break; } // format the users array $users = array_values(array_flip($users)); if (empty($users)) { $value = ''; } else { if (sizeof($users) == 1) { $value = $users[0]; } else { switch ($params['value_type'][$key]) { case 'Round_Robin': $value = getRoundRobinUser($users, $this->id); break; case 'Least_Busy': $user_id = 'assigned_user_id'; if (isset($record_vardefs[$field]['id_name']) && $record_vardefs[$field]['id_name'] != '') { $user_id = $record_vardefs[$field]['id_name']; } $value = getLeastBusyUser($users, $user_id, $record); break; case 'Random': default: shuffle($users); $value = $users[0]; break; } } } setLastUser($value, $this->id); break; case 'Value': default: $value = $params['value'][$key]; break; } if ($record_vardefs[$field]['type'] == 'relate' && isset($record_vardefs[$field]['id_name'])) { $field = $record_vardefs[$field]['id_name']; } $record->{$field} = $value; } } $bean_processed = isset($record->processed) ? $record->processed : false; if ($in_save) { global $current_user; $record->processed = true; $check_notify = $record->assigned_user_id != $current_user->id && $record->assigned_user_id != $record->fetched_row['assigned_user_id']; } else { $check_notify = $record->assigned_user_id != $record->fetched_row['assigned_user_id']; } $record->process_save_dates = false; $record->new_with_id = false; $record->save($check_notify); $record->processed = $bean_processed; }
function NotifySalesManagers($bean) { global $sugar_config; $amount_limit = 1000; if ($bean->sales_stage === "Negotiation/Review" && $bean->fetched_row['sales_stage'] === "Proposal/Price Quote" && $bean->amount >= $amount_limit) { SugarApplication::appendErrorMessage('You have changed the opportunity ' . $bean->name . ' (greater than ' . $amount_limit . ') to Negotiation/Review.'); $emailsTo = array(); $emailSubject = "Opportunity Alert"; $emailBody = "The Opportunity " . $bean->name . " has changed to Negotiation/Review<br />\n\t\t\tYou can see the opportunity here:<br />\n\t\t\t<a href=\"" . $sugar_config['site_url'] . "/index.php?module=Opportunities&action=DetailView&record=" . $bean->id . "\">" . $bean->name . "</a>"; $role_id = "<sales-manager-role-id>"; $aclrole = new ACLRole(); if (!is_null($aclrole->retrieve($role_id))) { $users = $aclrole->get_linked_beans('users', 'User'); foreach ($users as $user) { $emailsTo[] = $user->email1; } } $this->SendEmail($emailsTo, $emailSubject, $emailBody); } }
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * 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". ********************************************************************************/ $role = new ACLRole(); if (isset($_REQUEST['record'])) { $role->mark_deleted($_REQUEST['record']); } require_once 'include/formbase.php'; handleRedirect();
$role = BeanFactory::getBean('ACLRoles'); $role_name = ''; $return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => ''); if (!empty($_REQUEST['record'])) { $role->retrieve($_REQUEST['record']); $categories = ACLRole::getRoleActions($_REQUEST['record']); $role_name = $role->name; if (!empty($_REQUEST['isDuplicate'])) { //role id is stripped here in duplicate so anything using role id after this will not have it $role->id = ''; } else { $return['record'] = $role->id; $return['action'] = 'DetailView'; } } else { $categories = ACLRole::getRoleActions(''); } // Skipping modules that have 'hidden_to_role_assignment' property foreach ($categories as $name => $category) { if (isset($dictionary[$name]) && isset($dictionary[$name]['hidden_to_role_assignment']) && $dictionary[$name]['hidden_to_role_assignment']) { unset($categories[$name]); } } if (in_array('Project', $modInvisList)) { unset($categories['Project']); unset($categories['ProjectTask']); } $sugar_smarty->assign('ROLE', $role->toArray()); $tdwidth = 10; if (isset($_REQUEST['return_module'])) { $return['module'] = $_REQUEST['return_module'];
/** * The Quick edit for case updates which appears under update stream * Also includes the javascript for AJAX update * * @return string - the html to be displayed and javascript */ function quick_edit_case_updates() { global $action; //on DetailView only if ($action != 'DetailView') { return; } //current record id $record = $_GET['record']; //Get Users roles require_once 'modules/ACLRoles/ACLRole.php'; $user = $GLOBALS['current_user']; $id = $user->id; $acl = new ACLRole(); $roles = $acl->getUserRoles($id); //Return if user cannot edit cases if (in_array("no edit cases", $roles) || $roles === "no edit cases") { return; } $html = <<<EOD <form id='case_updates' enctype="multipart/form-data"> <textarea id="update_text" name="update_text" cols="80" rows="4"></textarea> <input id='internal' type='checkbox' name='internal' tabindex=0 title='' value='1'> Internal</input> </br> <input type='button' value='Save' onclick="caseUpdates('{$record}')" title="Save" name="button"> </input> </br> </form> EOD; return $html; }
/** * Returns all the user data to be sent in the REST API call for a normal * `/me` call. * * This data is dependent on the platform used. Each own platform has a * different data set to be sent in the response. * * @param string $platform The platform of the request. * @param array $options A list of options like `category` to retrieve the * basic user info. Will use `global` if no `category` is supplied. * @return array The user's data to be used in a `/me` request. */ protected function getUserData($platform, array $options) { $current_user = $this->getUserBean(); // Get the basics $category = isset($options['category']) ? $options['category'] : 'global'; $user_data = $this->getBasicUserInfo($platform, $category); // Fill in the rest $user_data['type'] = self::TYPE_USER; if ($current_user->isAdmin()) { $user_data['type'] = self::TYPE_ADMIN; } $user_data['show_wizard'] = $this->shouldShowWizard($category); $user_data['id'] = $current_user->id; $current_user->_create_proper_name_field(); $user_data['full_name'] = $current_user->full_name; $user_data['user_name'] = $current_user->user_name; $user_data['roles'] = ACLRole::getUserRoles($current_user->id); $user_data = $this->setExpiredPassword($user_data); $user_data['picture'] = $current_user->picture; $user_data['acl'] = $this->getAcls($platform); $user_data['is_manager'] = User::isManager($current_user->id); $user_data['is_top_level_manager'] = false; $user_data['reports_to_id'] = $current_user->reports_to_id; $user_data['reports_to_name'] = $current_user->reports_to_name; if ($user_data['is_manager']) { $user_data['is_top_level_manager'] = User::isTopLevelManager($current_user->id); } // Address information $user_data['address_street'] = $current_user->address_street; $user_data['address_city'] = $current_user->address_city; $user_data['address_state'] = $current_user->address_state; $user_data['address_country'] = $current_user->address_country; $user_data['address_postalcode'] = $current_user->address_postalcode; require_once 'modules/Teams/TeamSetManager.php'; $teams = $current_user->get_my_teams(); $my_teams = array(); foreach ($teams as $id => $name) { $my_teams[] = array('id' => $id, 'name' => $name); } $user_data['my_teams'] = $my_teams; $defaultTeams = TeamSetManager::getTeamsFromSet($current_user->team_set_id); foreach ($defaultTeams as $id => $team) { $defaultTeams[$id]['primary'] = false; if ($team['id'] == $current_user->team_id) { $defaultTeams[$id]['primary'] = true; } } $user_data['preferences']['default_teams'] = $defaultTeams; // Send back a hash of this data for use by the client $user_data['_hash'] = $current_user->getUserMDHash(); return array('current_user' => $user_data); }
/** * Returns user's ACL roles * * @param User $user * @return ACLRole[] */ protected function getUserRoles(User $user) { return ACLRole::getUserRoles($user->id, false); }
* 02110-1301 USA. * * 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". ********************************************************************************/ $role = new ACLRole(); if (isset($_REQUEST['record'])) { $role->id = $_POST['record']; } if (!empty($_REQUEST['name'])) { $role->name = $_POST['name']; $role->description = $_POST['description']; $role->save(); //if duplicate if (isset($_REQUEST['isduplicate']) && !empty($_REQUEST['isduplicate'])) { //duplicate actions $role_actions = $role->getRoleActions($_REQUEST['isduplicate']); foreach ($role_actions as $module) { foreach ($module as $type) { foreach ($type as $act) { $role->setAction($role->id, $act['id'], $act['aclaccess']);
/** * The Quick edit for case updates which appears under update stream * Also includes the javascript for AJAX update * * @return string - the html to be displayed and javascript */ function quick_edit_case_updates($case) { global $action, $app_strings, $mod_strings; //on DetailView only if ($action != 'DetailView') { return; } //current record id $record = $_GET['record']; //Get Users roles require_once 'modules/ACLRoles/ACLRole.php'; $user = $GLOBALS['current_user']; $id = $user->id; $acl = new ACLRole(); $roles = $acl->getUserRoles($id); //Return if user cannot edit cases if (in_array("no edit cases", $roles) || $roles === "no edit cases") { return; } $internalChecked = ''; if (isset($case->internal) && $case->internal) { $internalChecked = "checked='checked'"; } $internal = $mod_strings['LBL_AOP_INTERNAL']; $saveBtn = $app_strings['LBL_SAVE_BUTTON_LABEL']; $saveTitle = $app_strings['LBL_SAVE_BUTTON_TITLE']; $html = <<<EOD <form id='case_updates' enctype="multipart/form-data"> <textarea id="update_text" name="update_text" cols="80" rows="4"></textarea> <input id='internal' type='checkbox' name='internal' tabindex=0 title='' value='1' {$internalChecked} > {$internal}</input> </br> <input type='button' value='{$saveBtn}' onclick="caseUpdates('{$record}')" title="{$saveTitle}" name="button"> </input> </br> </form> EOD; return $html; }
function get_email_recipients() { $params = unserialize(base64_decode($this->email_recipients)); $emails = array(); if (isset($params['email_target_type'])) { foreach ($params['email_target_type'] as $key => $field) { switch ($field) { case 'Email Address': $emails[] = $params['email'][$key]; break; case 'Specify User': $user = new User(); $user->retrieve($params['email'][$key]); $emails[] = $user->emailAddress->getPrimaryAddress($user); break; case 'Users': $users = array(); switch ($params['email'][$key][0]) { case 'security_group': if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $security_group = new SecurityGroup(); $security_group->retrieve($params['email'][$key][1]); $users = $security_group->get_linked_beans('users', 'User'); $r_users = array(); if ($params['email'][$key][2] != '') { require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $role_users = $role->get_linked_beans('users', 'User'); foreach ($role_users as $role_user) { $r_users[$role_user->id] = $role_user->name; } } foreach ($users as $user_id => $user) { if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) { unset($users[$user_id]); } } break; } //No Security Group module found - fall through. //No Security Group module found - fall through. case 'role': require_once 'modules/ACLRoles/ACLRole.php'; $role = new ACLRole(); $role->retrieve($params['email'][$key][2]); $users = $role->get_linked_beans('users', 'User'); break; case 'all': default: global $db; $sql = "SELECT id from users WHERE status='Active' AND portal_only=0 "; $result = $db->query($sql); while ($row = $db->fetchByAssoc($result)) { $user = new User(); $user->retrieve($row['id']); $users[$user->id] = $user; } break; } foreach ($users as $user) { $emails[] = $user->emailAddress->getPrimaryAddress($user); } break; } } } return $emails; }
public function testfromArray() { $aclRole = new ACLRole(); $arr = array('id' => '1', 'name' => 'test', 'description' => 'some description text'); $aclRole->fromArray($arr); //verify that it sets the object attributes correctly $this->assertSame($aclRole->id, '1'); $this->assertSame($aclRole->name, 'test'); $this->assertSame($aclRole->description, 'some description text'); }
********************************************************************************/ //global $modInvisList; $sugar_smarty = new Sugar_Smarty(); $sugar_smarty->assign('MOD', $mod_strings); $sugar_smarty->assign('APP', $app_strings); //nsingh bug: 21669. Messes up localization /*foreach($modInvisList as $modinvisname){ if(empty($app_list_strings['moduleList'][$modinvisname])){ $app_list_strings['moduleList'][$modinvisname] = $modinvisname; } }*/ $sugar_smarty->assign('APP_LIST', $app_list_strings); /*foreach($modInvisList as $modinvisname){ unset($app_list_strings['moduleList'][$modinvisname]); }*/ $role = new ACLRole(); $role->retrieve($_REQUEST['record']); $categories = ACLRole::getRoleActions($_REQUEST['record']); $names = ACLAction::setupCategoriesMatrix($categories); $categories2 = array(); $categories2 = $categories; $hidden_categories = array("KBDocuments", "Campaigns", "Forecasts", "ForecastSchedule", "Emails", "EmailTemplates", "EmailMarketing", "Reports"); foreach ($hidden_categories as $v) { if (isset($categories2[$v])) { unset($categories2[$v]); } } if (!empty($names)) { $tdwidth = 100 / sizeof($names); } $sugar_smarty->assign('ROLE', $role->toArray());
//***AlineaSol Premium***// //***********************// $hasPremiumFeatures = asol_ReportsUtils::managePremiumFeature("managePremiumFeature", "reportFunctions.php", "hasPremiumFeatures", null); //***********************// //***AlineaSol Premium***// //***********************// //****************************// //***Display Edition Screen***// //****************************// //Calculate SubSelectQueries Scope $mySQLcheckInsecurity = false; if ($mySQLinsecurityScope === 1 && !$current_user->is_admin || $mySQLinsecurityScope === 2) { $mySQLcheckInsecurity = true; } else { if ($mySQLinsecurityScope === 3 && !$current_user->is_admin) { $userRoles = $_SESSION['asolUserRoles'] = isset($_SESSION['asolUserRoles']) && !empty($_SESSION['asolUserRoles']) ? $_SESSION['asolUserRoles'] : ACLRole::getUserRoles($current_user->id); foreach ($userRoles as $userRole) { if (!in_array($userRole, $sugar_config["asolReportsMySQLinsecuritySubSelectRoles"])) { $mySQLcheckInsecurity = true; break; } } } } //Calculate SubSelectQueries Scope $PHPcheckInsecurity = $current_user->is_admin ? false : true; //Get predefined color palette schemas for Nvd3 charts $predefinedColorPaletteSchemas = isset($sugar_config['asolReportsNvd3ChartPredefinedColorPaletteSchemas']) ? $sugar_config['asolReportsNvd3ChartPredefinedColorPaletteSchemas'] : array(); $predefinedColorPaletteSchemasJson = htmlentities(json_encode($predefinedColorPaletteSchemas)); //Get predefined color palette schemas for Nvd3 charts //Set configuration flags
/** * static getAllRoles($returnAsArray = false) * * @param boolean $returnAsArray - should it return the results as an array of arrays or as an array of ACLRoles * * @return either an array of array representations of acl roles or an array of ACLRoles */ function getAllRoles($returnAsArray = false) { $db = DBManagerFactory::getInstance(); $query = "SELECT acl_roles.* FROM acl_roles\n WHERE acl_roles.deleted=0 ORDER BY name"; $result = $db->query($query); $roles = []; while ($row = $db->fetchByAssoc($result)) { $role = new ACLRole(); $role->populateFromRow($row); if ($returnAsArray) { $roles[] = $role->toArray(); } else { $roles[] = $role; } } return $roles; }
global $app_list_strings; // $modInvisList; $sugar_smarty = new Sugar_Smarty(); $sugar_smarty->assign('MOD', $mod_strings); $sugar_smarty->assign('APP', $app_strings); $sugar_smarty->assign('ISDUPLICATE', ''); $duplicateString = ''; //mass localization /*foreach($modInvisList as $modinvisname){ $app_list_strings['moduleList'][$modinvisname] = $modinvisname; }*/ $sugar_smarty->assign('APP_LIST', $app_list_strings); /*foreach($modInvisList as $modinvisname){ unset($app_list_strings['moduleList'][$modinvisname]); }*/ $role = new ACLRole(); $role_name = ''; $return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => ''); if (!empty($_REQUEST['record'])) { $role->retrieve($_REQUEST['record']); $categories = ACLRole::getRoleActions($_REQUEST['record']); $role_name = $role->name; if (!empty($_REQUEST['isDuplicate'])) { //role id is stripped here in duplicate so anything using role id after this will not have it $role->id = ''; $sugar_smarty->assign('ISDUPLICATE', $_REQUEST['record']); $duplicateString = translate('LBL_DUPLICATE_OF', 'ACLRoles'); } else { $return['record'] = $role->id; $return['action'] = 'DetailView'; }
/** * @return boolean true if the user is a member of the role_name, false otherwise * @param string $role_name - Must be the exact name of the acl_role * @param string $user_id - The user id to check for the role membership, empty string if current user * @desc Determine whether or not a user is a member of an ACL Role. This function caches the * results in the session or to prevent running queries after the first time executed. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. * All Rights Reserved.. * Contributor(s): ______________________________________.. */ function check_role_membership($role_name, $user_id = '') { global $current_user; if (empty($user_id)) { $user_id = $current_user->id; } // Check the Sugar External Cache to see if this users memberships were cached $role_array = sugar_cache_retrieve("RoleMemberships_" . $user_id); // If we are pulling the roles for the current user if ($user_id == $current_user->id) { // If the Session doesn't contain the values if (!isset($_SESSION['role_memberships'])) { // This means the external cache already had it loaded if (!empty($role_array)) { $_SESSION['role_memberships'] = $role_array; } else { $_SESSION['role_memberships'] = ACLRole::getUserRoleNames($user_id); $role_array = $_SESSION['role_memberships']; } } else { $role_array = $_SESSION['role_memberships']; } } else { // If the external cache didn't contain the values, we get them and put them in cache if (!$role_array) { $role_array = ACLRole::getUserRoleNames($user_id); sugar_cache_put("RoleMemberships_" . $user_id, $role_array); } } // If the role doesn't exist in the list of the user's roles if (!empty($role_array) && in_array($role_name, $role_array)) { return true; } else { return false; } }
public function __construct() { parent::__construct(); }