function popup_onload($event, $arguments) { global $sugar_config; $module = $_REQUEST['module']; $action = $_REQUEST['action']; if (isset($action) && ($action == "Save" || $action == "SetTimezone")) { return; } if ((isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true || $module == "Users" && isset($sugar_config['securitysuite_user_popup']) && $sugar_config['securitysuite_user_popup'] == true) && isset($_SESSION['securitygroups_popup_' . $module]) && !empty($_SESSION['securitygroups_popup_' . $module])) { $record_id = $_SESSION['securitygroups_popup_' . $module]; unset($_SESSION['securitygroups_popup_' . $module]); //$record_id = $_REQUEST['record']; require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); if ($module == 'Users') { $rel_name = "SecurityGroups"; } else { $rel_name = $groupFocus->getLinkName($module, "SecurityGroups"); } $auto_popup = <<<EOQ <script type="text/javascript" language="javascript"> \topen_popup("SecurityGroups",600,400,"",true,true,{"call_back_function":"set_return_and_save_background","form_name":"DetailView","field_to_name_array":{"id":"subpanel_id"},"passthru_data":{"child_field":"{$rel_name}","return_url":"index.php%3Fmodule%3D{$module}%26action%3DSubPanelViewer%26subpanel%3D{$rel_name}%26record%3D{$record_id}%26sugar_body_only%3D1","link_field_name":"{$rel_name}","module_name":"{$rel_name}","refresh_page":"1"}},"MultiSelect",true); </script> EOQ; echo $auto_popup; } }
function popup_onload($event, $arguments) { if (!empty($_REQUEST['to_pdf']) || !empty($_REQUEST['sugar_body_only'])) { return; } /** //test user popup //always have this loaded echo '<script type="text/javascript" src="modules/SecurityGroups/javascript/popup_relate.js"></script>'; */ global $sugar_config; $module = $_REQUEST['module']; $action = $_REQUEST['action']; if (isset($action) && ($action == "Save" || $action == "SetTimezone")) { return; } if ($module == "Users" && isset($sugar_config['securitysuite_user_popup']) && $sugar_config['securitysuite_user_popup'] == true && !empty($_SESSION['securitygroups_popup'])) { foreach ($_SESSION['securitygroups_popup'] as $popup_index => $popup) { $record_id = $popup['id']; $module = $popup['module']; unset($_SESSION['securitygroups_popup'][$popup_index]); require_once 'modules/SecurityGroups/SecurityGroup.php'; $groupFocus = new SecurityGroup(); if ($module == 'Users') { $rel_name = "SecurityGroups"; } else { $rel_name = $groupFocus->getLinkName($module, "SecurityGroups"); } //this only works if on the detail view of the record actually saved... //so ajaxui breaks this as it stays on the parent $auto_popup = <<<EOQ <script type="text/javascript" language="javascript"> \topen_popup("SecurityGroups",600,400,"",true,true,{"call_back_function":"securitysuite_set_return_and_save_background","form_name":"DetailView","field_to_name_array":{"id":"subpanel_id"},"passthru_data":{"module":"{$module}","record":"{$record_id}","child_field":"{$rel_name}","return_url":"","link_field_name":"{$rel_name}","module_name":"{$rel_name}","refresh_page":"1"}},"MultiSelect",true); </script> EOQ; echo $auto_popup; } unset($_SESSION['securitygroups_popup']); } }
array_push($new_arr, $val['id']); } $_POST['mass'] = $new_arr; } if (isset($_POST['mass']) && is_array($_POST['mass'])) { $rel_name = ""; foreach ($_POST['mass'] as $id) { if (isset($_POST['Delete'])) { $sugarbean->retrieve($id); //if($sugarbean->ACLAccess('Delete')){ $GLOBALS['log']->debug("MassAssign - deleting relationship: {$groupFocus->name}"); if ($sugarbean->module_dir == 'Users') { $rel_name = "SecurityGroups"; } else { if (empty($rel_name) || !isset($rel_name)) { $rel_name = $groupFocus->getLinkName($sugarbean->module_dir, "SecurityGroups"); } } $sugarbean->load_relationship($rel_name); $sugarbean->{$rel_name}->delete($sugarbean->id, $groupFocus->id); //As of 6.3.0 many-to-many requires a link field set in both modules...so lets bypass that //$groupFocus->removeGroupFromRecord($sugarbean->module_dir, $id, $groupFocus->id); //} } else { $sugarbean->retrieve($id); //if($sugarbean->ACLAccess('Save')){ $GLOBALS['log']->debug("MassAssign - adding relationship: {$groupFocus->name}"); if ($sugarbean->module_dir == 'Users') { $rel_name = "SecurityGroups"; } else { if (empty($rel_name) || !isset($rel_name)) {
public function testgetLinkName() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $securityGroup = new SecurityGroup(); $result = $securityGroup->getLinkName('Accounts', 'Contacts'); $this->assertEquals('contacts', $result); $result = $securityGroup->getLinkName('SecurityGroups', 'ACLRoles'); $this->assertEquals('aclroles', $result); error_reporting(E_ALL); //error_reporting(E_ERROR | E_PARSE); }