$securitysuite_inherit_assigned = ''; if (isset($sugar_config['securitysuite_inherit_assigned']) && $sugar_config['securitysuite_inherit_assigned'] == true) { $securitysuite_inherit_assigned = 'CHECKED'; } $xtpl->assign('securitysuite_inherit_assigned', $securitysuite_inherit_assigned); //default security groups $groupFocus = new SecurityGroup(); $defaultGroups = $groupFocus->retrieveDefaultGroups(); $defaultGroup_string = ""; foreach ($defaultGroups as $default_id => $defaultGroup) { $defaultGroup_string .= "\n\t<tr>\n\t<td class='dataLabel' width='30%'>\n\t\t" . $mod_strings['LBL_GROUP'] . " " . $defaultGroup['group'] . "\n\t</td>\n\t<td class='dataField' width='30%'>\n\t\t" . $mod_strings['LBL_MODULE'] . " " . $defaultGroup['module'] . "\n\t</td>\n\t<td class='dataLabel' width='40%'>\n\t\t<input type='submit' tabindex='1' class='button' onclick=\"this.form.remove_default_id.value='" . $default_id . "'; this.form.action.value='SaveConfig'; this.form.return_module.value='SecurityGroups'; this.form.return_action.value='config';\" value='" . $mod_strings['LBL_REMOVE_BUTTON_LABEL'] . "'/>\n\t</td>\n\t</tr>"; } $xtpl->assign("DEFAULT_GROUPS", $defaultGroup_string); $groups = $groupFocus->get_list("name"); $options = array("" => ""); foreach ($groups['list'] as $group) { $options[$group->id] = $group->name; } $xtpl->assign("SECURITY_GROUP_OPTIONS", get_select_options_with_id($options, "")); //$moduleList = $app_list_strings['moduleList']; //require_once('modules/Studio/DropDowns/DropDownHelper.php'); //$dh = new DropDownHelper(); //$dh->getDropDownModules(); //$moduleList = array_keys($dh->modules); $security_modules = $groupFocus->getSecurityModules(); $security_modules["All"] = $mod_strings["LBL_ALL_MODULES"]; //rost fix ksort($security_modules); $xtpl->assign("MODULE_OPTIONS", get_select_options_with_id($security_modules, "All")); $xtpl->parse("main"); $xtpl->out("main");
function inherit_parent(&$focus, $isUpdate) { global $sugar_config; //new record or if update from soap api for cases or bugs //TEST FOR PORTAL NOTES //if((!$isUpdate || ($isUpdate && !empty($focus->note_id) && ($focus->object_name == "Case" || $focus->object_name == "Bug"))) if (!$isUpdate && isset($sugar_config['securitysuite_inherit_parent']) && $sugar_config['securitysuite_inherit_parent'] == true) { $focus_module_dir = $focus->module_dir; $focus_id = $focus->id; //inherit only for those that support Security Groups $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); //if(!in_array($focus_module_dir,$security_modules)) { if (!in_array($focus_module_dir, array_keys($security_modules))) { //rost fix2 return; //don't inherit for this module } //from subpanel //PHP Notice error fix $parent_type = ""; $parent_id = ""; if (isset($_REQUEST['relate_to']) && isset($_REQUEST['relate_id'])) { //relate_to is not guaranteed to be a module name anymore. //if it isn't load the relationship and find the module name that way if (!in_array($_REQUEST['relate_to'], array_keys($security_modules))) { //check to see if relate_to is the relationship name require_once 'modules/Relationships/Relationship.php'; $rel_module = Relationship::get_other_module($_REQUEST['relate_to'], $focus_module_dir, $focus->db); if (isset($rel)) { $parent_type = $rel_module; $parent_id = $_REQUEST['relate_id']; } } else { $parent_type = $_REQUEST['relate_to']; $parent_id = $_REQUEST['relate_id']; } } if (isset($_SESSION['portal_id'])) { $parent_id = $_SESSION['user_id']; //soap stores contact id in user_id field $parent_type = "Contacts"; } //from activity type creation if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['parent_type']) && isset($_REQUEST['parent_id'])) { $parent_type = $_REQUEST['parent_type']; $parent_id = $_REQUEST['parent_id']; } //full form from subpanel if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['return_module']) && isset($_REQUEST['return_id'])) { $parent_type = $_REQUEST['return_module']; $parent_id = $_REQUEST['return_id']; } /** need to find relate fields...for example for Cases look to see if account_id is set */ //allow inheritance for all relate field types....iterate through and inherit each related field //if(empty($parent_type) || empty($parent_id)) { foreach ($focus->field_name_map as $name => $def) { if ($def['type'] == 'relate' && isset($def['id_name']) && isset($def['module']) && strtolower($def['module']) != "users") { if (isset($_REQUEST[$def['id_name']])) { $relate_parent_id = $_REQUEST[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } else { if (isset($_SESSION['portal_id']) && isset($_SESSION[$def['id_name']])) { //catch soap account $relate_parent_id = $_SESSION[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } } } } //} if (!empty($parent_type) && !empty($parent_id)) { // && $parent_type != "Emails" && $parent_type != "Meetings") { SecurityGroup::inherit_parentQuery($focus, $parent_type, $parent_id, $focus_id, $focus_module_dir); } //end if parent type/id } //end if new record }
/** * display * This method makes the Smarty variable assignments and then displays the * generated view. * @param $showTitle boolean value indicating whether or not to show a title on the resulting page * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request * @return HTML display for view as String */ function display($showTitle = true, $ajaxSave = false) { global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user; if (isset($this->defs['templateMeta']['javascript'])) { if (is_array($this->defs['templateMeta']['javascript'])) { //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js'); $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']); } else { $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']); } } $this->th->ss->assign('id', $this->fieldDefs['id']['value']); $this->th->ss->assign('offset', $this->offset + 1); $this->th->ss->assign('APP', $app_strings); $this->th->ss->assign('MOD', $mod_strings); $this->th->ss->assign('fields', $this->fieldDefs); $this->th->ss->assign('sectionPanels', $this->sectionPanels); $this->th->ss->assign('config', $sugar_config); $this->th->ss->assign('returnModule', $this->returnModule); $this->th->ss->assign('returnAction', $this->returnAction); $this->th->ss->assign('returnId', $this->returnId); $this->th->ss->assign('isDuplicate', $this->isDuplicate); $this->th->ss->assign('def', $this->defs); $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false); $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2); $this->th->ss->assign('module', $this->module); $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl'); $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl'); $this->th->ss->assign('current_user', $current_user); $this->th->ss->assign('bean', $this->focus); $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled()); $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0'); $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false); $this->th->ss->assign('VERSION_MARK', getVersionedPath('')); global $js_custom_version; global $sugar_version; $this->th->ss->assign('SUGAR_VERSION', $sugar_version); $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version); //this is used for multiple forms on one page if (!empty($this->formName)) { $form_id = $this->formName; $form_name = $this->formName; } else { $form_id = $this->view; $form_name = $this->view; } if ($ajaxSave && empty($this->formName)) { $form_id = 'form_' . $this->view . '_' . $this->module; $form_name = $form_id; $this->view = $form_name; //$this->defs['templateMeta']['form']['buttons'] = array(); //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>'); } $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name; $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id; if (isset($this->defs['templateMeta']['preForm'])) { $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']); } if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) { $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']); } if (isset($this->defs['templateMeta']['form']['enctype'])) { $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"'); } //for SugarFieldImage, we must set form enctype to "multipart/form-data" foreach ($this->fieldDefs as $field) { if (isset($field['type']) && $field['type'] == 'image') { $this->th->ss->assign('enctype', 'enctype="multipart/form-data"'); break; } } $this->th->ss->assign('showDetailData', $this->showDetailData); $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles); $this->th->ss->assign('form_id', $form_id); $this->th->ss->assign('form_name', $form_name); $this->th->ss->assign('set_focus_block', get_set_focus_js()); $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null); $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null); $this->th->ss->assign('view', $this->view); //Calculate time & date formatting (may need to calculate this depending on a setting) global $timedate; $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format()); $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format()); $time_format = $timedate->get_user_time_format(); $this->th->ss->assign('TIME_FORMAT', $time_format); $date_format = $timedate->get_cal_date_format(); $time_separator = ':'; if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) { $time_separator = $match[1]; } // Create Smarty variables for the Calendar picker widget $t23 = strpos($time_format, '23') !== false ? '%H' : '%I'; if (!isset($match[2]) || $match[2] == '') { $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M'); } else { $pm = $match[2] == 'pm' ? '%P' : '%p'; $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm); } $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week()); $this->th->ss->assign('TIME_SEPARATOR', $time_separator); $seps = get_number_seperators(); $this->th->ss->assign('NUM_GRP_SEP', $seps[0]); $this->th->ss->assign('DEC_SEP', $seps[1]); if ($this->view == 'EditView') { $height = $current_user->getPreference('text_editor_height'); $width = $current_user->getPreference('text_editor_width'); $height = isset($height) ? $height : '300px'; $width = isset($width) ? $width : '95%'; $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height); $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width); } else { $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px'); $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%'); } $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl); $str = $this->showTitle($showTitle); //Use the output filter to trim the whitespace $this->th->ss->load_filter('output', 'trimwhitespace'); $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs); /* BEGIN - SECURITY GROUPS */ //if popup select add panel if user is a member of multiple groups to metadataFile global $sugar_config; if (isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true && empty($this->focus->fetched_row['id']) && $this->focus->module_dir != "Users" && $this->focus->module_dir != "SugarFeed") { //there are cases such as uploading an attachment to an email template where the request module may //not be the same as the current bean module. If that happens we can just skip it //however...let quickcreate through if ($this->view != 'QuickCreate' && (empty($_REQUEST['module']) || $_REQUEST['module'] != $this->focus->module_dir)) { return $str; } require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); if (in_array($this->focus->module_dir, array_keys($security_modules))) { global $current_user; $group_count = $groupFocus->getMembershipCount($current_user->id); if ($group_count > 1) { $groups = $groupFocus->getUserSecurityGroups($current_user->id); $group_options = ''; foreach ($groups as $group) { $group_options .= '<option value="' . $group['id'] . '" label="' . $group['name'] . '" selected="selected">' . $group['name'] . '</option>'; } //multilingual support global $current_language; $ss_mod_strings = return_module_language($current_language, 'SecurityGroups'); $lbl_securitygroups_select = $ss_mod_strings['LBL_GROUP_SELECT']; $lbl_securitygroups = $ss_mod_strings['LBL_LIST_FORM_TITLE']; $group_panel = <<<EOQ <div class="edit view edit508 " id="detailpanel_securitygroups"> <h4> {$lbl_securitygroups_select} </h4> <table width="100%" cellspacing="1" cellpadding="0" border="0" class="edit view panelContainer" id="LBL_PANEL_SECURITYGROUPS"> <tbody><tr> <td width="12.5%" valign="top" scope="col" id="account_type_label"> {$lbl_securitygroups}: </td> <td width="37.5%" valign="top"> <select title="" id="securitygroup_list" name="securitygroup_list[]" multiple="multiple" size="{$group_count}"> {$group_options} </select> </td> </tr> </tbody></table> </div> EOQ; $group_panel = preg_replace("/[\r\n]+/", "", $group_panel); $group_panel_append = <<<EOQ <script> \$('#{$form_name}_tabs div:first').append(\$('{$group_panel}')); </script> EOQ; $str .= $group_panel_append; } } } /* END - SECURITY GROUPS */ return $str; }
function mass_assign($event, $arguments) { $action = $_REQUEST['action']; $module = $_REQUEST['module']; $no_mass_assign_list = array("Emails" => "Emails", "ACLRoles" => "ACLRoles"); //,"Users"=>"Users"); //check if security suite enabled $action = strtolower($action); if (isset($module) && ($action == "list" || $action == "index" || $action == "listview") && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != true) && !array_key_exists($module, $no_mass_assign_list)) { global $current_user; if (is_admin($current_user) || ACLAction::getUserAccessLevel($current_user->id, "SecurityGroups", 'access') == ACL_ALLOW_ENABLED) { require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); //if(in_array($module,$security_modules)) { if (in_array($module, array_keys($security_modules))) { global $app_strings; global $current_language; $current_module_strings = return_module_language($current_language, 'SecurityGroups'); $form_header = get_form_header($current_module_strings['LBL_MASS_ASSIGN'], '', false); $groups = $groupFocus->get_list("name", "", 0, -99, -99); $options = array("" => ""); foreach ($groups['list'] as $group) { $options[$group->id] = $group->name; } $group_options = get_select_options_with_id($options, ""); $mass_assign = <<<EOQ <script type="text/javascript" language="javascript"> function confirm_massassign(del,start_string, end_string) { \tif (del == 1) { \t\treturn confirm( start_string + sugarListView.get_num_selected() + end_string); \t} \telse { \t\treturn confirm( start_string + sugarListView.get_num_selected() + end_string); \t} } function send_massassign(mode, no_record_txt, start_string, end_string, del) { \tif(!sugarListView.confirm_action(del, start_string, end_string)) \t\treturn false; \tif(document.MassAssign_SecurityGroups.massassign_group.selectedIndex == 0) { \t\talert("Please select a group and try again."); \t\treturn false;\t \t} \t \tif (document.MassUpdate.select_entire_list && \t\tdocument.MassUpdate.select_entire_list.value == 1) \t\tmode = 'entire'; \telse if (document.MassUpdate.massall.checked == true) \t\tmode = 'page'; \telse \t\tmode = 'selected'; \tvar ar = new Array(); \tif(del == 1) { \t\tvar deleteInput = document.createElement('input'); \t\tdeleteInput.name = 'Delete'; \t\tdeleteInput.type = 'hidden'; \t\tdeleteInput.value = true; \t\tdocument.MassAssign_SecurityGroups.appendChild(deleteInput); \t} \tswitch(mode) { \t\tcase 'page': \t\t\tdocument.MassAssign_SecurityGroups.uid.value = ''; \t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) { \t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined' \t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]' && document.MassUpdate.elements[wp].checked) { \t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value); \t\t\t\t} \t\t\t} \t\t\tdocument.MassAssign_SecurityGroups.uid.value = ar.join(','); \t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') { \t\t\t\talert(no_record_txt); \t\t\t\treturn false; \t\t\t} \t\t\tbreak; \t\tcase 'selected': \t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) { \t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined' \t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]' \t\t\t\t\t\t&& document.MassUpdate.elements[wp].checked) { \t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value); \t\t\t\t} \t\t\t} \t\t\tif(document.MassAssign_SecurityGroups.uid.value != '') document.MassAssign_SecurityGroups.uid.value += ','; \t\t\tdocument.MassAssign_SecurityGroups.uid.value += ar.join(','); \t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') { \t\t\t\talert(no_record_txt); \t\t\t\treturn false; \t\t\t} \t\t\tbreak; \t\tcase 'entire': \t\t\tvar entireInput = document.createElement('input'); \t\t\tentireInput.name = 'entire'; \t\t\tentireInput.type = 'hidden'; \t\t\tentireInput.value = 'index'; \t\t\tdocument.MassAssign_SecurityGroups.appendChild(entireInput); \t\t\t//confirm(no_record_txt); \t\t\tbreak; \t} \tdocument.MassAssign_SecurityGroups.submit(); \treturn false; } </script> \t\t<form action='index.php' method='post' name='MassAssign_SecurityGroups' id='MassAssign_SecurityGroups'> \t\t\t<input type='hidden' name='action' value='MassAssign' /> \t\t\t<input type='hidden' name='module' value='SecurityGroups' /> \t\t\t<input type='hidden' name='return_action' value='{$action}' /> \t\t\t<input type='hidden' name='return_module' value='{$module}' /> \t\t\t<textarea style='display: none' name='uid'></textarea> \t\t<div id='massassign_form'>{$form_header} \t\t<table cellpadding='0' cellspacing='0' border='0' width='100%'> \t\t<tr> \t\t<td style='padding-bottom: 2px;' class='listViewButtons'> \t\t<input type='submit' name='Assign' value='{$current_module_strings['LBL_ASSIGN']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_ASSIGN_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',0);" class='button'> \t\t<input type='submit' name='Remove' value='{$current_module_strings['LBL_REMOVE']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_REMOVE_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',1);" class='button'> \t\t</td></tr></table> \t\t<table cellpadding='0' cellspacing='0' border='0' width='100%' class='tabForm' id='mass_update_table'> \t\t<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'> \t\t<tr> \t\t<td>{$current_module_strings['LBL_GROUP']}</td> \t\t<td><select name='massassign_group' id="massassign_group" tabindex='1'>{$group_options}</select></td> \t\t</tr> \t\t</table></td></tr></table></div>\t\t\t \t\t</form>\t\t EOQ; echo $mass_assign; } } } //if after a save... if (!empty($_SESSION['securitysuite_error'])) { $lbl_securitysuite_error = $_SESSION['securitysuite_error']; unset($_SESSION['securitysuite_error']); echo <<<EOQ <script> \t\t\t\t var oNewP = document.createElement("div"); oNewP.className = 'error'; var oText = document.createTextNode("{$lbl_securitysuite_error}"); oNewP.appendChild(oText); var beforeMe = document.getElementsByTagName("div")[0]; document.body.insertBefore(oNewP, beforeMe); </script> EOQ; } }
public function testgetSecurityModules() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $securityGroup = new SecurityGroup(); $expected = array('Meetings', 'Cases', 'AOS_Products', 'Opportunities', 'FP_Event_Locations', 'Tasks', 'jjwg_Markers', 'EmailTemplates', 'Campaigns', 'jjwg_Areas', 'Contacts', 'AOS_Contracts', 'AOS_Quotes', 'Bugs', 'Users', 'Documents', 'AOS_Invoices', 'Notes', 'AOW_WorkFlow', 'ProspectLists', 'AOK_KnowledgeBase', 'AOS_PDF_Templates', 'Calls', 'Accounts', 'Leads', 'Emails', 'ProjectTask', 'Project', 'FP_events', 'AOR_Reports', 'Prospects', 'ACLRoles', 'jjwg_Maps', 'AOS_Product_Categories', 'Spots' => 'Spots'); $actual = $securityGroup->getSecurityModules(); $actualKeys = array_keys($actual); sort($expected); sort($actualKeys); $this->assertSame($expected, $actualKeys); }