true,
'show_title' => true,
'show_subpanels' => false,
'show_search' => true,
'show_footer' => true,
'show_javascript' => true,
'view_print' => false
);
var $type = null;
var $responseTime;
var $fileResources;
/**
* Constructor which will peform the setup.
*/
public function SugarView($bean = null, $view_object_map = array()) {
// add mz
// dziwny błąd w EcmCalls - this->module jest puste
// if (!$this->module && $this->module=='') $this->module=$GLOBALS['module'];
}
public function init($bean = null, $view_object_map = array()) {
global $moduleList;
$this->bean = &$bean;
$this->view_object_map = $view_object_map;
$this->action = $GLOBALS ['action'];
$this->module = $GLOBALS ['module'];
$this->_initSmarty();
}
protected function _initSmarty() {
$this->ss = new Sugar_Smarty ();
$this->ss->assign('MOD', $GLOBALS ['mod_strings']);
$this->ss->assign('APP', $GLOBALS ['app_strings']);
}
/**
* This method will be called from the controller and is not meant to be overridden.
*/
public function process() {
$LogicHook = new LogicHook();
$LogicHook->initialize();
$this->_checkModule();
// trackView has to be here in order to track for breadcrumbs
$this->_trackView();
if ($this->_getOption('show_header')) {
$this->displayHeader();
} else {
$this->renderJavascript();
}
$this->_buildModuleList();
$this->preDisplay();
$this->displayErrors();
$this->display();
$GLOBALS ['logic_hook']->call_custom_logic('', 'after_ui_frame');
if ($this->_getOption('show_subpanels'))
$this->_displaySubPanels();
if ($this->action === 'Login') {
// this is needed for a faster loading login page ie won't render unless the tables are closed
ob_flush();
}
if ($this->_getOption('show_footer'))
$this->displayFooter();
$GLOBALS ['logic_hook']->call_custom_logic('', 'after_ui_footer');
// Do not track if there is no module or if module is not a String
$this->_track();
}
/**
* This method will display the errors on the page.
*/
public function displayErrors() {
foreach ($this->errors as $error) {
echo '' . $error . '
';
}
}
/**
* [OVERRIDE] - This method is meant to overidden in a subclass.
* The purpose of this method is
* to allow a view to do some preprocessing before the display method is called. This becomes
* useful when you have a view defined at the application level and then within a module
* have a sub-view that extends from this application level view. The application level
* view can do the setup in preDisplay() that is common to itself and any subviews
* and then the subview can just override display(). If it so desires, can also override
* preDisplay().
*/
public function preDisplay() {
}
/**
* [OVERRIDE] - This method is meant to overidden in a subclass.
* This method
* will handle the actual display logic of the view.
*/
public function display() {
}
/**
* trackView
*/
protected function _trackView() {
$action = strtolower($this->action);
// Skip save, tracked in SugarBean instead
if ($action == 'save') {
return;
}
$trackerManager = TrackerManager::getInstance();
$timeStamp = gmdate($GLOBALS ['timedate']->get_db_date_time_format());
if ($monitor = $trackerManager->getMonitor('tracker')) {
$monitor->setValue('action', $action);
$monitor->setValue('user_id', $GLOBALS ['current_user']->id);
$monitor->setValue('module_name', $this->module);
$monitor->setValue('date_modified', $timeStamp);
$monitor->setValue('visible', (($monitor->action == 'detailview') || ($monitor->action == 'editview')) ? 1 : 0 );
if (!empty($this->bean->id)) {
$monitor->setValue('item_id', $this->bean->id);
$monitor->setValue('item_summary', $this->bean->get_summary_text());
}
// If visible is true, but there is no bean, do not track (invalid/unauthorized reference)
// Also, do not track save actions where there is no bean id
if ($monitor->visible && empty($this->bean->id)) {
$trackerManager->unsetMonitor($monitor);
return;
}
$trackerManager->saveMonitor($monitor, true, true);
}
}
/**
*
*
* Displays the header on section of the page; basically everything before the content
*/
public function displayHeader() {
global $theme;
global $max_tabs;
global $app_strings;
global $current_user;
global $sugar_config;
global $app_list_strings;
global $mod_strings;
global $current_language;
//wlacza/wylacza logo sugarcrmna dole strony
$GLOBALS ['app']->headerDisplayed = false;
$themeObject = SugarThemeRegistry::current();
$theme = $themeObject->__toString();
$ss = new Sugar_Smarty ();
$ss->assign("APP", $app_strings);
$ss->assign("THEME", $theme);
$ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false' );
$ss->assign("MODULE_NAME", $this->module);
// get browser title
$ss->assign("SYSTEM_NAME", $this->getBrowserTitle());
// get css
$css = $themeObject->getCSS();
if ($this->_getOption('view_print')) {
$css .= '';
}
$ss->assign("SUGAR_CSS", $css);
// get javascript
ob_start();
$this->renderJavascript();
$ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
ob_end_clean();
// get favicon
if (isset($GLOBALS ['sugar_config'] ['default_module_favicon'])) {
$module_favicon = $GLOBALS ['sugar_config'] ['default_module_favicon'];
} else {
$module_favicon = false;
}
$favicon = '';
if ($module_favicon) {
$favicon = $themeObject->getImageURL($this->module . '.gif', false);
}
if (!sugar_is_file($favicon) || !$module_favicon) {
$favicon = $themeObject->getImageURL('favicon.ico', false);
if (!sugar_is_file($favicon)) {
$favicon = $themeObject->getImageURL('sugar_icon.ico', false);
}
}
$ss->assign('FAVICON_URL', getJSPath($favicon));
// build the shortcut menu
$shortcut_menu = array();
foreach ($this->getMenu() as $key => $menu_item) {
if (!isset($menu_item[0]) && isset($menu_item['link'])) {
$menu_item[0] = $menu_item['link'];
} elseif (!isset($menu_item[0]) && isset($menu_item['module']) && isset($menu_item['action'])) {
$menu_item[0] = 'index.php?module=' . $menu_item['module'] . '&action=' . $menu_item['action'];
}
if (!isset($menu_item[1]) && isset($menu_item['showName'])) {
$menu_item[1] = $menu_item['showName'];
}
if (!isset($menu_item[2]) && isset($menu_item['icon'])) {
$menu_item[2] = str_replace(substr($menu_item['icon'], -4), '', $menu_item['icon']);
}
$shortcut_menu [$key] = array(
"URL" => $menu_item [0],
"LABEL" => $menu_item [1],
"MODULE_NAME" => $menu_item [2],
"IMAGE" => $themeObject->getImage($menu_item [2], "alt='" . $menu_item [1] . "' border='0' align='absmiddle'")
);
}
$ss->assign("SHORTCUT_MENU", $shortcut_menu);
// handle rtl text direction
if (isset($_REQUEST ['RTL']) && $_REQUEST ['RTL'] == 'RTL') {
$_SESSION ['RTL'] = true;
}
if (isset($_REQUEST ['LTR']) && $_REQUEST ['LTR'] == 'LTR') {
unset($_SESSION ['RTL']);
}
if (isset($_SESSION ['RTL']) && $_SESSION ['RTL']) {
$ss->assign("DIR", 'dir="RTL"');
}
// handle resizing of the company logo correctly on the fly
$companyLogoURL = $themeObject->getImageURL('company_logo.png');
$companyLogoURL_arr = explode('?', $companyLogoURL);
$companyLogoURL = $companyLogoURL_arr [0];
$company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
if (!empty($company_logo_attributes)) {
$ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes [0]);
$ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes [1]);
$ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes [2]);
} else {
// Always need to md5 the file
$ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
list ( $width, $height ) = getimagesize($companyLogoURL);
if ($width > 212 || $height > 40) {
$resizePctWidth = ($width - 212) / 212;
$resizePctHeight = ($height - 40) / 40;
if ($resizePctWidth > $resizePctHeight)
$resizeAmount = $width / 212;
else
$resizeAmount = $height / 40;
$ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
$ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
} else {
$ss->assign("COMPANY_LOGO_WIDTH", $width);
$ss->assign("COMPANY_LOGO_HEIGHT", $height);
}
// Let's cache the results
sugar_cache_put('company_logo_attributes', array(
$ss->get_template_vars("COMPANY_LOGO_MD5"),
$ss->get_template_vars("COMPANY_LOGO_WIDTH"),
$ss->get_template_vars("COMPANY_LOGO_HEIGHT")
));
}
require_once 'modules/EcmSysInfos/EcmSysInfo.php';
$info = new EcmSysInfo();
if($info->getDatabaseName()!=''){
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
$query="select value7 from operating_values where id=19";
$z=$GLOBALS['db']->query($query);
$b=$GLOBALS['db']->fetchByAssoc($z);
if($b['value7']!=''){
$ss->assign("COMPANY_LOGO_URL", 'upload/'.$b['value7']);
} else {
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
}
} else {
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
}
// get the global links
$gcls = array();
$global_control_links = array();
require ("include/globalControlLinks.php");
foreach ($global_control_links as $key => $value) {
if ($key == 'users') { // represents logout link.
$ss->assign("LOGOUT_LINK", $value ['linkinfo'] [key($value ['linkinfo'])]);
$ss->assign("LOGOUT_LABEL", key($value ['linkinfo'])); // key value for first element.
continue;
}
foreach ($value as $linkattribute => $attributevalue) {
// get the main link info
if ($linkattribute == 'linkinfo')
$gcls [$key] = array(
"LABEL" => key($attributevalue),
"URL" => current($attributevalue),
"SUBMENU" => array()
);
// and now the sublinks
if ($linkattribute == 'submenu' && is_array($attributevalue)) {
foreach ($attributevalue as $submenulinkkey => $submenulinkinfo) {
$gcls [$key] ['SUBMENU'] [$submenulinkkey] = array(
"LABEL" => key($submenulinkinfo),
"URL" => current($submenulinkinfo)
);
}
}
}
}
$ss->assign("GCLS", $gcls);
$ss->assign("SEARCH", isset($_REQUEST ['query_string']) ? $_REQUEST ['query_string'] : '' );
if ($this->action == "EditView" || $this->action == "Login") {
$ss->assign("ONLOAD", 'onload="set_focus()"');
}
$ss->assign("AUTHENTICATED", isset($_SESSION ["authenticated_user_id"]));
// get other things needed for page style popup
if (isset($_SESSION ["authenticated_user_id"])) {
// get the current user name and id
$ss->assign("CURRENT_USER", $current_user->full_name == '' || !showFullName() ? $current_user->user_name : $current_user->full_name );
$ss->assign("CURRENT_USER_ID", $current_user->id);
// get the last viewed records
$tracker = new Tracker ();
$history = $tracker->get_recently_viewed($current_user->id);
foreach ($history as $key => $row) {
if ($row ['module_name'] == "EcmStockDocIns" || $row ['module_name'] == "EcmStockDocInsideIns" || $row ['module_name'] == "EcmStockDocInsideOuts" || $row ['module_name'] == "EcmStockDocOuts" || $row ['module_name'] == "EcmStockDocMoves" || $row ['module_name'] == "EcmStockDocCorrects" || $row ['module_name'] == "EcmInvoiceOuts" || $row ['module_name'] == "EcmQuotes" || $row ['module_name'] == "EcmSales" || $row ['module_name'] == "EcmPurchaseOrders" || $row ['module_name'] == "EcmDeliveryNotes" || $row ['module_name'] == "EcmInsideOrders") {
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select document_no from " . strtolower($row['module_name']) . " where id='" . $row ['item_id'] . "'"));
$rfield = $r ['document_no'];
} else {
$rfield = getTrackerSubstring($row ['item_summary']);
}
$history [$key] ['item_summary_short'] = $rfield;
$history [$key] ['image'] = SugarThemeRegistry::current()->getImage($row ['module_name'], 'border="0" align="absmiddle" alt="' . $row ['item_summary'] . '"');
}
$ss->assign("recentRecords", $history);
}
// menu start
$bakModStrings = $mod_strings;
if (isset($_SESSION ["authenticated_user_id"])) {
// get the module list
// $moduleTopMenu = array();
$max_tabs = $current_user->getPreference('max_tabs');
// Attempt to correct if max tabs count is waaay too high.
if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
$max_tabs = $GLOBALS ['sugar_config'] ['default_max_tabs'];
$current_user->setPreference('max_tabs', $max_tabs, 0, 'global');
}
$moduleTab = $this->_getModuleTab();
$ss->assign('MODULE_TAB', $moduleTab);
// See if they are using grouped tabs or not (removed in 6.0, returned in 6.1)
$user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
if (!isset($user_navigation_paradigm)) {
$user_navigation_paradigm = $GLOBALS ['sugar_config'] ['default_navigation_paradigm'];
}
// Get the full module list for later use
foreach (query_module_access_list($current_user) as $module) {
// Bug 25948 - Check for the module being in the moduleList
if (isset($app_list_strings ['moduleList'] [$module])) {
$fullModuleList [$module] = $app_list_strings ['moduleList'] [$module];
}
}
if (!should_hide_iframes()) {
$iFrame = new iFrame ();
$frames = $iFrame->lookup_frames('tab');
foreach ($frames as $key => $values) {
$fullModuleList [$key] = $values;
}
} elseif (isset($fullModuleList ['iFrames'])) {
unset($fullModuleList ['iFrames']);
}
// if ( $user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
global $current_user;
// if ($current_user->id=='4e5bd519-0978-2271-8a7c-4e708fbf540d')
// $user_navigation_paradigm='mz';
// if ($current_user->id=='1')
$user_navigation_paradigm = 'mz';
if ($user_navigation_paradigm == 'gm' || $user_navigation_paradigm == 'mz') {
// We are using grouped tabs
require_once ('include/GroupedTabs/GroupedTabStructure.php');
$groupedTabsClass = new GroupedTabStructure ();
$modules = query_module_access_list($current_user);
// create module div
// handle with submoremodules
$max_tabs = $current_user->getPreference('max_tabs');
// If the max_tabs isn't set incorrectly, set it within the range, to the default max sub tabs size
if (!isset($max_tabs) || $max_tabs <= 0 || $max_tabs > 10) {
// We have a default value. Use it
if (isset($GLOBALS ['sugar_config'] ['default_max_tabs'])) {
$max_tabs = $GLOBALS ['sugar_config'] ['default_max_tabs'];
} else {
$max_tabs = 8;
}
}
$max_tabs = 50;
$subMoreModules = false;
$groupTabs = $groupedTabsClass->get_tab_structure(get_val_array($modules));
$g = array();
foreach ($groupTabs as $k => $v) {
foreach ($v ['modules'] as $kk => $vv)
$g [$kk] = $k;
}
// add mz
// get module submenu
// global $module_menu;
// if ($current_user->id=='1') var_dump($groupTabs);
if (!empty($get_result)) {
$MMenuDivs = $get_result;
} else {
$MMenuDivs = null;
}
if ($MMenuDivs == null || $MMenuDivs == '') {
$MMenuDivs = '';
foreach ($modules as $module_name) {
// load_menu('modules/'.$module.'/');
$menu = '
' . $error_message . '
'); // } // } } } // menu end /** * If the view is classic then this method will include the file and * setup any global variables. * * @param string $file */ public function includeClassicFile($file) { global $sugar_config, $theme, $current_user, $sugar_version, $sugar_flavor, $mod_strings, $app_strings, $app_list_strings, $action, $timezones; global $gridline, $request_string, $modListHeader, $dashletData, $authController, $locale, $currentModule, $import_bean_map, $image_path, $license; global $user_unique_key, $server_unique_key, $barChartColors, $modules_exempt_from_availability_check, $dictionary, $current_language, $beanList, $beanFiles, $sugar_build, $sugar_codename; global $timedate, $login_error; // cn: bug 13855 - timedate not available to classic views. $currentModule = $this->module; require_once ($file); } protected function _displayLoginJS() { global $sugar_config; if (isset($this->bean->module_dir)) { echo ""; } if (isset($_REQUEST ['action'])) { echo ""; } echo ''; if (!is_file("include/javascript/sugar_grp1.js")) { $_REQUEST ['root_directory'] = "."; require_once ("jssource/minify_utils.php"); ConcatenateFiles("."); } echo ''; echo ''; echo ''; echo <<