/** * This function allows a user with Forecasts admin rights to reset the Forecasts settings so that the Forecasts wizard * dialog will appear once again. * */ public function action_resetSettings() { global $current_user; if ($current_user->isAdminForModule('Forecasts')) { $db = DBManagerFactory::getInstance(); $db->query("UPDATE config SET value = '0' WHERE category = 'Forecasts' and name in ('is_setup', 'has_commits')"); MetaDataManager::refreshModulesCache(array('Forecasts')); MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CONFIG)); echo '<script>' . navigateToSidecar(buildSidecarRoute("Forecasts")) . ';</script>'; exit; } $this->view = 'noaccess'; }
/** * Redirect to another URL. * * If the module is not in BWC it will try to map to sidecar url. * If it loads only temporarily, please check if the module is pointing to * a layout/view in BWC. * * This function writes session data, ends the session and exists the app. * * @param string $url The URL to redirect to. */ public function redirect($url) { global $disable_redirects; //Dirty hack to enable the inclusion of BWC style scripts that wish to redirect without breaking REST requests. if ($disable_redirects) { return; } /* * Parse the module from the URL first using regular expression. * This is faster than parse_url + parse_str in first place and most of * our redirects won't go to sidecar (at least for now). */ if (preg_match('/module=([^&]+)/', $url, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($url, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); echo "<script>{$script}</script>"; exit; } session_write_close(); header('HTTP/1.1 301 Moved Permanently'); header("Location: {$url}"); exit; }
$this->ss->assign('disabled_subs', $orig_vals_array[1]); $this->ss->assign('enabled_subs_string', $orig_vals_str[0]); $this->ss->assign('disabled_subs_string', $orig_vals_str[1]); // FIXME we are doing this way since this view is going to be removed later // this should be with proper buttons from smarty tpls. require_once 'include/formbase.php'; $url = buildRedirectURL(); $cancelButtonClick = "SUGAR.ajaxUI.loadContent('{$url}'); return false;"; /* * Parse the module from the URL first using regular expression. * This is faster than parse_url + parse_str in first place and most of * our redirects won't go to sidecar (at least for now). */ if (preg_match('/module=([^&]+)/', $url, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($url, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); $cancelButtonClick = "{$script} return false;"; } $buttons = array('<input id="save_button" title="' . $app_strings['LBL_SAVE_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_SAVE_BUTTON_KEY'] . '" class="button" onclick="save();this.form.action.value=\'Subscriptions\'; " type="submit" name="button" value="' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '">', '<input id="cancel_button" title="' . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_CANCEL_BUTTON_KEY'] . '" class="button" onclick="' . $cancelButtonClick . '" type="submit" name="button" value="' . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . '">'); $this->ss->assign('BUTTONS', $buttons); $this->ss->display('modules/Campaigns/Subscriptions.tpl'); /* *This function constructs Drag and Drop multiselect box of subscriptions for display in manage subscription form */ function constructDDSubscriptionList($focus, $classname = '') { require_once "include/templates/TemplateDragDropChooser.php"; global $mod_strings; $unsubs_arr = ''; $subs_arr = ''; // Lets start by creating the subscription and unsubscription arrays
/** * Display "access denied" message * @api */ public function displayNoAccess($redirect_home = false) { echo '<script>function set_focus(){}</script><p class="error">' . translate('LBL_NO_ACCESS', 'ACL') . '</p>'; if ($redirect_home) { $script = navigateToSidecar(buildSidecarRoute('Home')); // FIXME this old ugly code should go away from here... echo translate('LBL_REDIRECT_TO_HOME', 'ACL') . ' <span id="seconds_left">3</span> ' . translate('LBL_SECONDS', 'ACL') . "<script>\n function redirect_countdown(left){\n document.getElementById('seconds_left').innerHTML = left;\n if (left == 0) {\n {$script}\n } else {\n left--;\n setTimeout('redirect_countdown(' + left + ')', 1000);\n }\n };\n setTimeout('redirect_countdown(3)', 1000);\n </script>"; } }
/** * Builds an appropriate Sidecar or BWC href attribute for the additional * details buttons, using the link supplied from the additional details * module metadata. * * @private * @param string $link (optional) The link from additional details module * metadata. The function returns an empty string if none is supplied. * @return string The href attribute used for the button. */ private function buildButtonLink($link = '') { if (preg_match('/module=([^&]+)/', $link, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($link, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); $link = "javascript:{$script};"; } return $link; }
/** * Format a link to a record. * * @param SugarBean $focus The record. * @return string The formatted HTML link. */ function get_href_link($focus) { global $sugar_config; $link = $sugar_config['site_url']; if (isModuleBWC($focus->module_name)) { $link .= "/#bwc/index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}"; } else { $link .= '/#' . buildSidecarRoute($focus->module_dir, $focus->id); } if (!empty($focus->name)) { $label = $focus->name; } else { $label = translate('LBL_EMAIL_LINK_RECORD', $focus->module_dir); } return '<a href="' . $link . '">' . $label . '</a>'; }
session_destroy(); sugar_cleanup(); die("The contact id doesn't exist"); } $current_entity = $result; } else { if (!empty($_REQUEST['lead_id'])) { $result = BeanFactory::retrieveBean('Leads', $_REQUEST['lead_id'], array('disable_row_level_security' => true)); if (empty($result)) { session_destroy(); sugar_cleanup(); die("The lead id doesn't exist"); } $current_entity = $result; } } } $focus = BeanFactory::retrieveBean(clean_string($_REQUEST['module']), $_REQUEST['record'], array('disable_row_level_security' => true)); if (empty($focus)) { session_destroy(); sugar_cleanup(); die("The focus id doesn't exist"); } $focus->set_accept_status($current_entity, $_REQUEST['accept_status']); $url = $sugar_config['site_url'] . '#' . buildSidecarRoute($currentModule, $focus->id); print $app_strings['LBL_STATUS_UPDATED'] . "<BR><BR>"; print $app_strings['LBL_STATUS'] . " " . $app_list_strings['dom_meeting_accept_status'][$_REQUEST['accept_status']]; print "<BR><BR>"; print "<a href='{$url}'>" . $app_strings['LBL_MEETING_GO_BACK'] . "</a><br />"; sugar_cleanup(); exit;
/** * Reformats a sugar url to meet sidecar rules * @param $url * @return string */ public static function reformatURL($url) { global $sugar_config; $site_url = str_replace("http://", '', $sugar_config['site_url']); $site_url = str_replace("https://", '', $site_url); if (!self::hasString($site_url, $url)) { return self::setClickableURLs($url); } $original_url = $url; $properties = parse_url($url); $module = ''; $record = ''; $action = ''; //if ajax if (isset($properties['fragment'])) { if (self::hasString("ajaxUILoc=", $properties['fragment'])) { $decoded = urldecode(str_replace("ajaxUILoc=index.php%3F", '', $properties['fragment'])); parse_str($decoded); } else { if (self::hasString("module=Home&action=index", $properties['query']) && !empty($properties['fragment'])) { return self::setClickableURLs($url); } else { if (self::hasString("bwc/index.php", $properties['fragment'])) { //url is already bwc return self::setClickableURLs($url); } } } } else { if (isset($properties['query'])) { if (self::hasString("index.php", $properties['path'])) { parse_str(str_replace("index.php?", '', $properties['query'])); } } } if (isModuleBWC($module) && !self::hasString("#bwc", $url)) { $url = self::setClickableURLs(rtrim($sugar_config['site_url'], '/') . "/#bwc/index.php?module={$module}&action={$action}&record={$record}"); } else { if (!isModuleBWC($module) && self::hasString(array("index.php/#", "index.php#"), $url)) { //ignore as this is a valid url $url = self::setClickableURLs($url); } else { if (!isModuleBWC($module) && self::hasString("index.php", $url)) { $url = self::setClickableURLs(rtrim($sugar_config['site_url'], '/') . "/#" . buildSidecarRoute($module, $record, $action)); } } } if ($original_url != $url) { return trim($url) . '<a href="javacript:void(0)" class="btn btn-invisible worklog-popovers" rel="popover" data-content="' . $original_url . '" data-original-title="Parsed from:"><i class="icon-info-sign"></i></a>'; } return self::setClickableURLs($url); }