예제 #1
0
function mkdir_recursive($path, $check_is_parent_dir = false)
{
    if (sugar_is_dir($path, 'instance')) {
        return true;
    }
    if (sugar_is_file($path, 'instance')) {
        if (!empty($GLOBALS['log'])) {
            $GLOBALS['log']->fatal("ERROR: mkdir_recursive(): argument {$path} is already a file.");
        }
        return false;
    }
    //make variables with file paths
    $pathcmp = $path = rtrim(clean_path($path), '/');
    $basecmp = $base = rtrim(clean_path(getcwd()), '/');
    if (is_windows()) {
        //make path variable lower case for comparison in windows
        $pathcmp = strtolower($path);
        $basecmp = strtolower($base);
    }
    if ($basecmp == $pathcmp) {
        return true;
    }
    $base .= "/";
    if (strncmp($pathcmp, $basecmp, strlen($basecmp)) == 0) {
        /* strip current path prefix */
        $path = substr($path, strlen($base));
    }
    $thePath = '';
    $dirStructure = explode("/", $path);
    if ($dirStructure[0] == '') {
        // absolute path
        $base = '/';
        array_shift($dirStructure);
    }
    if (is_windows()) {
        if (strlen($dirStructure[0]) == 2 && $dirStructure[0][1] == ':') {
            /* C: prefix */
            $base = array_shift($dirStructure) . "\\";
        } elseif ($dirStructure[0][0] . $dirStructure[0][1] == "\\\\") {
            /* UNC absolute path */
            $base = array_shift($dirStructure) . "\\" . array_shift($dirStructure) . "\\";
            // we won't try to mkdir UNC share name
        }
    }
    foreach ($dirStructure as $dirPath) {
        $thePath .= $dirPath . "/";
        $mkPath = $base . $thePath;
        if (!is_dir($mkPath)) {
            if (!sugar_mkdir($mkPath)) {
                return false;
            }
        }
    }
    return true;
}
예제 #2
0
/**
 * Retrieves the requested js language file, building it if it doesn't exist.
 */
function getJSLanguage()
{
    require_once 'include/language/jsLanguage.php';
    global $app_list_strings;
    if (empty($_REQUEST['lang'])) {
        echo "No language specified";
        return;
    }
    $lang = clean_path($_REQUEST['lang']);
    $languages = get_languages();
    if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang) || !isset($languages[$lang])) {
        if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang)) {
            echo "did not match regex<br/>";
        } else {
            echo "{$lang} was not in list . <pre>" . print_r($languages, true) . "</pre>";
        }
        echo "Invalid language specified";
        return;
    }
    if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') {
        $file = sugar_cached('jsLanguage/') . $lang . '.js';
        if (!sugar_is_file($file)) {
            $jsLanguage = new jsLanguage();
            $jsLanguage->createAppStringsCache($lang);
        }
    } else {
        $module = clean_path($_REQUEST['module']);
        $fullModuleList = array_merge($GLOBALS['moduleList'], $GLOBALS['modInvisList']);
        if (!isset($app_list_strings['moduleList'][$module]) && !in_array($module, $fullModuleList)) {
            echo "Invalid module specified";
            return;
        }
        $file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js';
        if (!sugar_is_file($file)) {
            jsLanguage::createModuleStringsCache($module, $lang);
        }
    }
    //Setup cache headers
    header("Content-Type: application/javascript");
    header("Cache-Control: max-age=31556940, private");
    header("Pragma: ");
    header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 31556940));
    readfile($file);
}
예제 #3
0
function mkdir_recursive($path, $check_is_parent_dir = false)
{
    if (sugar_is_dir($path, 'instance')) {
        return true;
    }
    if (sugar_is_file($path, 'instance')) {
        print "ERROR: mkdir_recursive(): argument {$path} is already a file.\n";
        return false;
    }
    $path = clean_path($path);
    $path = str_replace(clean_path(getcwd()), '', $path);
    $thePath = '';
    $dirStructure = explode("/", $path);
    $status = true;
    foreach ($dirStructure as $dirPath) {
        $thePath .= '/' . $dirPath;
        $mkPath = getcwd() . '/' . $thePath;
        if (!is_dir($mkPath)) {
            $status = $status & sugar_mkdir($mkPath);
        }
    }
    return $status;
}
예제 #4
0
 function uninstall($base_dir)
 {
     if (defined('TEMPLATE_URL')) {
         SugarTemplateUtilities::disableCache();
     }
     global $app_strings;
     $total_steps = 5;
     //min steps with no tasks
     $current_step = 0;
     $this->base_dir = $base_dir;
     $tasks = array('pre_uninstall', 'uninstall_relationships', 'uninstall_copy', 'uninstall_dcactions', 'uninstall_menus', 'uninstall_dashlets', 'uninstall_userpage', 'uninstall_administration', 'uninstall_connectors', 'uninstall_vardefs', 'uninstall_layoutdefs', 'uninstall_layoutfields', 'uninstall_languages', 'uninstall_logichooks', 'post_uninstall');
     $total_steps += count($tasks);
     //now the real number of steps
     if (file_exists($this->base_dir . '/manifest.php')) {
         if (!$this->silent) {
             $current_step++;
             display_progress_bar('install', $current_step, $total_steps);
             echo '<div id ="displayLoglink" ><a href="#" onclick="toggleDisplay(\'displayLog\')">' . $app_strings['LBL_DISPLAY_LOG'] . '</a> </div><div id="displayLog" style="display:none">';
         }
         global $moduleList;
         include $this->base_dir . '/manifest.php';
         $this->installdefs = $installdefs;
         $this->id_name = $this->installdefs['id'];
         $installed_modules = array();
         if (isset($this->installdefs['beans'])) {
             foreach ($this->installdefs['beans'] as $bean) {
                 $installed_modules[] = $bean['module'];
                 $this->uninstall_user_prefs($bean['module']);
             }
             $this->modulesInPackage = $installed_modules;
             $this->uninstall_beans($installed_modules);
             $this->uninstall_customizations($installed_modules);
             if (!$this->silent) {
                 $current_step++;
                 update_progress_bar('install', $total_steps, $total_steps);
             }
             if (sugar_is_file("custom/Extension/application/Ext/Include/{$this->id_name}.php", 'w')) {
                 rmdir_recursive("custom/Extension/application/Ext/Include/{$this->id_name}.php");
             } else {
                 if (sugar_is_file("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/{$this->id_name}.php", 'w')) {
                     rmdir_recursive("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/{$this->id_name}.php");
                 }
             }
             $this->rebuild_modules();
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
         }
         foreach ($tasks as $task) {
             $this->{$task}();
             if (!$this->silent) {
                 $current_step++;
                 update_progress_bar('install', $current_step, $total_steps);
             }
         }
         if (isset($installdefs['custom_fields']) && (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables'])) {
             $this->log(translate('LBL_MI_UN_CUSTOMFIELD'));
             $this->uninstall_custom_fields($installdefs['custom_fields']);
         }
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         //since we are passing $silent = true to rebuildAll() in that method it will set $this->silent = true, so
         //we need to save the setting to set it back after rebuildAll() completes.
         $silentBak = $this->silent;
         $this->rebuild_all(true);
         $this->silent = $silentBak;
         //#27877, If the request from MB redeploy a custom module , we will not remove the ACL actions for this package.
         if (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'DeployPackage') {
             $this->remove_acl_actions();
         }
         //end
         if (!$this->silent) {
             $current_step++;
             update_progress_bar('install', $current_step, $total_steps);
             echo '</div>';
         }
         UpdateSystemTabs('Restore', $installed_modules);
         //clear the unified_search_module.php file
         require_once 'modules/Home/UnifiedSearchAdvanced.php';
         UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
         $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
         if (!$this->silent) {
             update_progress_bar('install', $total_steps, $total_steps);
         }
     } else {
         die("No manifest.php Defined In {$this->base_dir}/manifest.php");
     }
 }
예제 #5
0
 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user;
     global $sugar_config;
     $selectedData = $this->_retrieveParams();
     $this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
     $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
     $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
     $this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"'));
     $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
     $this->ss->assign("JAVASCRIPT", $this->_getJS(isset($selectedData->source) ? $selectedData->source : false));
     // handle publishing and deleting import maps
     if (isset($_REQUEST['delete_map_id'])) {
         $import_map = new ImportMap();
         $import_map->mark_deleted($_REQUEST['delete_map_id']);
     }
     if (isset($_REQUEST['publish'])) {
         $import_map = new ImportMap();
         $result = 0;
         $import_map = $import_map->retrieve($_REQUEST['import_map_id'], false);
         if ($_REQUEST['publish'] == 'yes') {
             $result = $import_map->mark_published($current_user->id, true);
             if (!$result) {
                 $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']);
             }
         } elseif ($_REQUEST['publish'] == 'no') {
             // if you don't own this importmap, you do now!
             // unless you have a map by the same name
             $result = $import_map->mark_published($current_user->id, false);
             if (!$result) {
                 $this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']);
             }
         }
     }
     // trigger showing other software packages
     $this->ss->assign("show_salesforce", false);
     $this->ss->assign("show_outlook", false);
     $this->ss->assign("show_act", false);
     switch ($_REQUEST['import_module']) {
         case "Prospects":
             break;
         case "Accounts":
             $this->ss->assign("show_salesforce", true);
             $this->ss->assign("show_act", true);
             break;
         case "Contacts":
             $this->ss->assign("show_salesforce", true);
             $this->ss->assign("show_outlook", true);
             $this->ss->assign("show_act", true);
             break;
         default:
             $this->ss->assign("show_salesforce", true);
             break;
     }
     // show any custom mappings
     if (sugar_is_dir('custom/modules/Import') && ($dir = opendir('custom/modules/Import'))) {
         while (($file = readdir($dir)) !== false) {
             if (sugar_is_file("custom/modules/Import/{$file}") && strpos($file, ".php") !== false) {
                 require_once "custom/modules/Import/{$file}";
                 $classname = str_replace('.php', '', $file);
                 $mappingClass = new $classname();
                 $custom_mappings[] = $mappingClass->name;
             }
         }
     }
     // get user defined import maps
     $this->ss->assign('is_admin', is_admin($current_user));
     $import_map_seed = new ImportMap();
     $custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
     if (count($custom_imports_arr)) {
         $custom = array();
         foreach ($custom_imports_arr as $import) {
             $custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
         }
         $this->ss->assign('custom_imports', $custom);
     }
     // get globally defined import maps
     $published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
     if (count($published_imports_arr)) {
         $published = array();
         foreach ($published_imports_arr as $import) {
             $published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
         }
         $this->ss->assign('published_imports', $published);
     }
     $this->ss->display('modules/Import/tpls/step1.tpl');
 }
예제 #6
0
/*********************************************************************************
 * Description:  controls which link show up in the upper right hand corner of the app
 ********************************************************************************/
global $app_strings, $current_user;
global $sugar_config, $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $action;
if (!isset($global_control_links)) {
    $global_control_links = array();
    $sub_menu = array();
}
if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
    require_once 'modules/Sync/headermenu.php';
}
$global_control_links['employees'] = array('linkinfo' => array($app_strings['LBL_EMPLOYEES'] => 'index.php?module=Employees&action=index&query=true'), 'submenu' => '');
if (is_admin($current_user)) {
    $global_control_links['admin'] = array('linkinfo' => array($app_strings['LBL_ADMIN'] => 'index.php?module=Administration&action=index'), 'submenu' => '');
}
$global_control_links['training'] = array('linkinfo' => array($app_strings['LBL_TRAINING'] => 'javascript:void(window.open(\'http://support.sugarcrm.com\'))'), 'submenu' => '');
/* no longer goes in the menubar - now implemented in the bottom bar.
$global_control_links['help'] = array(
    'linkinfo' => array($app_strings['LNK_HELP'] => ' javascript:void window.open(\'index.php?module=Administration&action=SupportPortal&view=documentation&version='.$sugar_version.'&edition='.$sugar_flavor.'&lang='.$current_language.'&help_module='.$GLOBALS['module'].'&help_action='.$action.'&key='.$server_unique_key.'\')'),
    'submenu' => ''
 );
*/
$global_control_links['users'] = array('linkinfo' => array($app_strings['LBL_LOGOUT'] => 'index.php?module=Users&action=Logout'), 'submenu' => '');
$global_control_links['about'] = array('linkinfo' => array($app_strings['LNK_ABOUT'] => 'index.php?module=Home&action=About'), 'submenu' => '');
if (sugar_is_file('custom/include/globalControlLinks.php')) {
    include 'custom/include/globalControlLinks.php';
}
if (sugar_is_file('custom/application/Ext/GlobalLinks/links.ext.php')) {
    include 'custom/application/Ext/GlobalLinks/links.ext.php';
}
예제 #7
0
 function uninstall_languages()
 {
     $languages = array();
     if (isset($this->installdefs['language'])) {
         $this->log(translate('LBL_MI_UN_LANG'));
         foreach ($this->installdefs['language'] as $packs) {
             $modules[] = $packs['to_module'];
             $languages[$packs['language']] = $packs['language'];
             $packs['from'] = str_replace('<basepath>', $this->base_dir, $packs['from']);
             $GLOBALS['log']->debug("Uninstalling Language Pack ..." . $packs['from'] . " for " . $packs['to_module']);
             $path = 'custom/Extension/modules/' . $packs['to_module'] . '/Ext/Language';
             if ($packs['to_module'] == 'application') {
                 $path = 'custom/Extension/' . $packs['to_module'] . '/Ext/Language';
             }
             if (sugar_is_file($path . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w')) {
                 rmdir_recursive($path . '/' . $packs['language'] . '.' . $this->id_name . '.php');
             } else {
                 if (sugar_is_file($path . '/' . DISABLED_PATH . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w')) {
                     rmdir_recursive($path . '/' . DISABLED_PATH . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w');
                 }
             }
         }
         $this->rebuild_languages($languages, $modules);
     }
 }
예제 #8
0
 // awu: Fixes the ProjectTasks pluralization issue -- must fix in later versions.
 if ($send_module == 'ProjectTasks') {
     $send_module = 'ProjectTask';
 }
 if ($send_module == 'ProductCatalog') {
     $send_module = 'ProductTemplates';
 }
 if ($send_module == 'TargetLists') {
     $send_module = 'ProspectLists';
 }
 if ($send_module == 'Targets') {
     $send_module = 'Prospects';
 }
 // FG - Bug 39819 - Check for custom help files
 $helpPath = 'modules/' . $send_module . '/language/' . $send_lang . '.help.' . $send_action . '.html';
 if (sugar_is_file("custom/" . $helpPath)) {
     $helpPath = 'custom/' . $helpPath;
 }
 $sugar_smarty = new Sugar_Smarty();
 //go to the support portal if the file is not found.
 // FG - Bug 39820 - Devs can write help files also in english, so skip check for language not equals "en_us" !
 if (file_exists($helpPath)) {
     $sugar_smarty->assign('helpFileExists', TRUE);
     $sugar_smarty->assign('MOD', $mod_strings);
     $sugar_smarty->assign('modulename', $send_module);
     $sugar_smarty->assign('helpPath', $helpPath);
     $sugar_smarty->assign('currentURL', getCurrentURL());
     $sugar_smarty->assign('title', $mod_strings['LBL_SUGARCRM_HELP'] . " - " . $send_module);
     $sugar_smarty->assign('styleSheet', SugarThemeRegistry::current()->getCSS());
     $sugar_smarty->assign('table', "<table class='tabForm'><tr><td>");
     $sugar_smarty->assign('endtable', "</td></tr></table>");
예제 #9
0
 /**
  * Save the dictionary object to the cache
  * @param string $module the name of the module
  * @param string $object the name of the object
  */
 static function saveCache($module, $object, $additonal_objects = array())
 {
     if (empty($GLOBALS['dictionary'][$object])) {
         $object = BeanFactory::getObjectName($module);
     }
     $file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php');
     $out = "<?php \n \$GLOBALS[\"dictionary\"][\"" . $object . "\"]=" . var_export($GLOBALS['dictionary'][$object], true) . ";";
     sugar_file_put_contents_atomic($file, $out);
     if (sugar_is_file($file) && is_readable($file)) {
         include $file;
     }
     // put the item in the sugar cache.
     $key = "VardefManager.{$module}.{$object}";
     //Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those.
     $data = self::cleanVardefs($GLOBALS['dictionary'][$object]);
     sugar_cache_put($key, $data);
 }
예제 #10
0
 /**
  * @see SugarCacheAbstract::_getExternal()
  */
 protected function _getExternal($key)
 {
     // load up the external cache file
     if (sugar_is_file($GLOBALS['sugar_config']['cache_dir'] . '/' . $this->_cacheFileName)) {
         $this->localCache = unserialize(file_get_contents($GLOBALS['sugar_config']['cache_dir'] . '/' . $this->_cacheFileName));
     }
     if (isset($this->_localStore[$key])) {
         return $this->_localStore[$key];
     }
     return null;
 }
예제 #11
0
// get the list_strings in order for module friendly name display.
$app_list_strings = return_app_list_strings_language($current_language);
foreach ($sm as $mod_dir_name => $links) {
    $module_friendly_name = $app_list_strings['moduleList'][$mod_dir_name];
    $temphtml = "";
    $temphtml .= '<h4><a href="javascript:window.location=\'index.php?module=' . $mod_dir_name . '&action=index\'">' . $module_friendly_name . '</a></h4><ul class=\'noBullet\'>';
    foreach ($links as $name => $href) {
        $temphtml .= '<li class=\'noBullet\'><a href="javascript:window.location=\'' . $href . '\'">' . $name . ' ' . '</a></li>';
    }
    $temphtml .= '</ul>';
    $sm_smarty->assign(strtoupper($mod_dir_name), $temphtml);
}
// Specify the sitemap template to use; allow developers to override this with a custom one to add/remove modules
// from the list
$tpl = 'modules/Home/sitemap.tpl';
if (sugar_is_file('custom/modules/Home/sitemap.tpl')) {
    $tpl = 'custom/modules/Home/sitemap.tpl';
}
echo $sm_smarty->fetch($tpl);
function sm_build_array()
{
    //if the sitemap array is already stored, then pass it back
    if (isset($_SESSION['SM_ARRAY']) && !empty($_SESSION['SM_ARRAY'])) {
        return $_SESSION['SM_ARRAY'];
    }
    include "include/modules.php";
    global $sugar_config, $mod_strings;
    // Need to set up mod_strings when we iterate through module menus.
    $orig_modstrings = array();
    if (!empty($mod_strings)) {
        $orig_modstrings = $mod_strings;
예제 #12
0
 /**
  * @see SugarCacheAbstract::_getExternal()
  */
 protected function _getExternal($key)
 {
     // load up the external cache file
     if (sugar_is_file($cachedfile = sugar_cached($this->_cacheFileName))) {
         $this->localCache = unserialize(file_get_contents($cachedfile));
     }
     if (isset($this->_localStore[$key])) {
         return $this->_localStore[$key];
     }
     return null;
 }
    /**
     * Determine whether or not to dispay the header on the page.
     */
    function displayHeader()
    {
        global $theme;
        global $max_tabs;
        global $app_strings;
        global $current_user;
        global $sugar_config;
        global $app_list_strings;
        $GLOBALS['app']->headerDisplayed = true;
        if (!function_exists('get_new_record_form') && (file_exists('modules/' . $this->module . '/metadata/sidecreateviewdefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/sidecreateviewdefs.php'))) {
            require_once 'include/EditView/SideQuickCreate.php';
        }
        if (!$this->_menuExists($this->module) && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {
            $GLOBALS['module_menu'][] = array("index.php?module={$this->module}&action=EditView&return_module={$this->module}&return_action=DetailView", $GLOBALS['mod_strings']['LNK_NEW_RECORD'], "{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}{$this->module}", $this->module);
            $GLOBALS['module_menu'][] = array("index.php?module={$this->module}&action=index", $GLOBALS['mod_strings']['LNK_LIST'], $this->module, $this->module);
        }
        $themeObject = SugarThemeRegistry::current();
        $theme = $themeObject->__toString();
        $ss = new Sugar_Smarty();
        $ss->assign("APP", $app_strings);
        $ss->assign("THEME", $theme);
        $ss->assign("MODULE_NAME", $this->module);
        // get css
        $css = $themeObject->getCSS();
        if ($this->_getOption('view_print')) {
            $css .= '\\n<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
        }
        $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
        $user_module_favicon = $current_user->getPreference('module_favicon');
        if (!isset($user_module_favicon) && isset($GLOBALS['sugar_config']['default_module_favicon'])) {
            $user_module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
        } elseif (!isset($user_module_favicon)) {
            $user_module_favicon = false;
        }
        $favicon = $themeObject->getImageURL($this->module . '.gif', false);
        if (!sugar_is_file($favicon) || !$user_module_favicon) {
            $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
        }
        $ss->assign('FAVICON_URL', getJSPath($favicon));
        // get the module menu
        $shortcut_menu = array();
        $module_menu = load_menu("modules/" . $this->module . "/");
        foreach ($module_menu as $key => $menu_item) {
            $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', false);
        $ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL));
        $company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
        if (!empty($company_logo_attributes) && md5_file($companyLogoURL) == $company_logo_attributes[0]) {
            $ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
            $ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
        } else {
            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)));
                sugar_cache_put('company_logo_attributes', array(md5_file($companyLogoURL), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
            } else {
                $ss->assign("COMPANY_LOGO_WIDTH", $width);
                $ss->assign("COMPANY_LOGO_HEIGHT", $height);
            }
        }
        // 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));
                }
                // 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);
        if (isset($_REQUEST['query_string'])) {
            $ss->assign("SEARCH", $_REQUEST['query_string']);
        }
        if ($this->action == "EditView" || $this->action == "Login") {
            $ss->assign("ONLOAD", 'onload="set_focus()"');
        }
        $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
        if (isset($_SESSION["authenticated_user_id"])) {
            $ss->assign('selectThemeOptions', get_select_options_with_id(SugarThemeRegistry::availableThemes(), SugarThemeRegistry::current()->__toString()));
            // build json string of theme properties
            $allThemes = array();
            foreach (SugarThemeRegistry::availableThemes() as $dirName => $themeName) {
                $selectedTheme = SugarThemeRegistry::get($dirName);
                $allThemes[$dirName] = array('name' => $themeName, 'description' => $selectedTheme->description, 'previewImage' => $selectedTheme->getImageURL('themePreview.png'), 'colorSelect' => '', 'fontSelect' => '');
                // foreach color
                if (count($selectedTheme->colors) > 1) {
                    $startingColorName = $selectedTheme->colors[0];
                    if (!empty($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $themeObject->colors)) {
                        $startingColorName = $_SESSION['authenticated_user_theme_color'];
                    }
                    $startingColorIcon = $selectedTheme->getImageURL("colors.{$startingColorName}.icon.gif");
                    $allThemes[$dirName]['colorSelect'] = <<<EOHTML
                    
<script type="text/javascript">

function change_color(color) {
\t\tvar callback = {
            success: function(o){
\t\t\t\tSUGAR.themes.changeColor(color);
            },
            failure: function(o){
            alert("Ajax failure");
            }
        }   
\t\tvar postData = '&usercolor='+color;
        YAHOO.util.Connect.asyncRequest('POST','index.php?module=Home&action=index', callback, postData); 
}

function change_font(font) { 
\tvar callback = {
            success: function(o){
\t\t\t\tSUGAR.themes.changeFont(font);
            },
            failure: function(o){
            alert("Ajax failure");
            }
        }   
\t\tvar postData = '&userfont='+font;
        YAHOO.util.Connect.asyncRequest('POST','index.php?module=Home&action=index', callback, postData);
}
</script>
<input type="hidden" name="usercolor" id="usercolor" value="">
<ul id="color_menu">
EOHTML;
                    foreach ($selectedTheme->colors as $color) {
                        $colorIcon = $selectedTheme->getImageURL("colors.{$color}.icon.gif");
                        $allThemes[$dirName]['colorSelect'] .= <<<EOHTML
<li style="background: url({$colorIcon})  no-repeat center;" onclick="change_color('{$color}');"></li>
EOHTML;
                    }
                    $allThemes[$dirName]['colorSelect'] .= '</ul></span>';
                }
                // foreach font
                if (count($selectedTheme->fonts) > 1) {
                    $startingFontName = $selectedTheme->fonts[0];
                    if (!empty($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $themeObject->fonts)) {
                        $startingFontName = $_SESSION['authenticated_user_theme_font'];
                    }
                    $startingFontIcon = $selectedTheme->getImageURL("fonts.{$startingFontName}.icon.gif");
                    $allThemes[$dirName]['fontSelect'] = <<<EOHTML
<input type="hidden" name="userfont" id="userfont" value="">
<ul id="font_menu">
EOHTML;
                    foreach ($selectedTheme->fonts as $font) {
                        $fontIcon = $selectedTheme->getImageURL("fonts.{$font}.icon.gif");
                        $allThemes[$dirName]['fontSelect'] .= <<<EOHTML
<li style="background: url({$fontIcon}) no-repeat;" onclick="change_font('{$font}');"></li>
EOHTML;
                    }
                    $allThemes[$dirName]['fontSelect'] .= '</ul></span>';
                }
            }
            $json = getJSONobj();
            $ss->assign('allThemes', $json->encode($allThemes));
            $ss->assign("CURRENTTHEME_NAME", $themeObject->name);
            $ss->assign("CURRENTTHEME_DESCRIPTION", $themeObject->description);
            $ss->assign("CURRENTTHEME_FONTSELECT", $allThemes[$themeObject->dirName]['fontSelect']);
            $ss->assign("CURRENTTHEME_COLORSELECT", $allThemes[$themeObject->dirName]['colorSelect']);
            // get the current user name and id
            $ss->assign("CURRENT_USER", $current_user->first_name != '' ? $current_user->first_name : $current_user->user_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) {
                $history[$key]['item_summary_short'] = getTrackerSubstring($row['item_summary']);
                $history[$key]['image'] = SugarThemeRegistry::current()->getImage($row['module_name'], 'border="0" align="absmiddle" alt="' . $row['item_summary'] . '"');
            }
            $ss->assign("recentRecords", $history);
            // new record
            require_once "modules/" . $this->module . "/Forms.php";
            if ($this->action == "index" && function_exists('get_new_record_form')) {
                $ss->assign("NEW_RECORD", get_new_record_form());
            }
            // Get preference for shortcuts and last_viewed list placement
            $last_view_swap = $current_user->getPreference('swap_last_viewed');
            if (!isset($last_view_swap)) {
                $last_view_swap = $GLOBALS['sugar_config']['default_swap_last_viewed'];
            }
            $ss->assign("LEFT_FORM_LAST_VIEWED", $last_view_swap);
            $shortcuts_swap = $current_user->getPreference('swap_shortcuts');
            if (!isset($shortcuts_swap)) {
                $shortcuts_swap = $GLOBALS['sugar_config']['default_swap_shortcuts'];
            }
            $ss->assign("LEFT_FORM_SHORTCUTS", !$shortcuts_swap);
        }
        if (isset($_SESSION["authenticated_user_id"]) || $sugar_config['login_nav']) {
            // get the module list
            $moduleTopMenu = array();
            $max_tabs = $current_user->getPreference('max_tabs');
            if (!isset($max_tabs) || $max_tabs <= 0) {
                $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
            }
            $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
            if (!isset($user_navigation_paradigm)) {
                $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
            }
            if ($user_navigation_paradigm == 'gm') {
                require_once 'include/GroupedTabs/GroupedTabStructure.php';
                $groupedTabsClass = new GroupedTabStructure();
                $modules = query_module_access_list($current_user);
                $ss->assign('groupTabs', $groupedTabsClass->get_tab_structure(get_val_array($modules)));
                $ss->assign('moduleNames', $app_list_strings['moduleList']);
                $ss->assign('defaultFirst', !in_array($this->module, $modules));
                $ss->assign('USE_GROUP_TABS', true);
            } else {
                $moduleExtraMenu = array();
                $i = 1;
                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])) {
                        if ($i < $max_tabs) {
                            $moduleTopMenu[$module] = $app_list_strings['moduleList'][$module];
                        } else {
                            $moduleExtraMenu[$module] = $app_list_strings['moduleList'][$module];
                        }
                        ++$i;
                    }
                }
                // Now, we'll push the current module into the end of top menu list if it's not
                // already there. In addition, we'll preserve this last entry for this session
                // until a new value is added there.
                if (isset($moduleTopMenu[$this->module])) {
                    if (isset($_SESSION['moreTab']) && isset($app_list_strings['moduleList'][$_SESSION['moreTab']])) {
                        $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                        unset($moduleExtraMenu[$_SESSION['moreTab']]);
                    } else {
                        $moduleTopMenu += array_slice($moduleExtraMenu, 0, 1);
                        array_shift($moduleExtraMenu);
                    }
                } elseif (isset($moduleExtraMenu[$this->module])) {
                    $_SESSION['moreTab'] = $this->module;
                    $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                    unset($moduleExtraMenu[$_SESSION['moreTab']]);
                } elseif (isset($_SESSION['moreTab']) && isset($app_list_strings['moduleList'][$_SESSION['moreTab']])) {
                    $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                    unset($moduleExtraMenu[$_SESSION['moreTab']]);
                }
                $ss->assign("moduleTopMenu", $moduleTopMenu);
                $ss->assign("moduleExtraMenu", $moduleExtraMenu);
            }
        }
        $headerTpl = $themeObject->getTemplate('header.tpl');
        if (isset($GLOBALS['sugar_config']['developerMode']) && $GLOBALS['sugar_config']['developerMode']) {
            $ss->clear_compiled_tpl($headerTpl);
        }
        $ss->display($headerTpl);
        $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
    }
 /**
  * Builds the theme registry
  */
 public static function buildRegistry()
 {
     self::$_themes = array();
     $dirs = array("themes/", "custom/themes/");
     foreach ($dirs as $dirPath) {
         if (sugar_is_dir('./' . $dirPath) && ($dir = opendir('./' . $dirPath))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" || !sugar_is_dir("./{$dirPath}" . $file) || !sugar_is_file("./{$dirPath}{$file}/themedef.php")) {
                     continue;
                 }
                 $themedef = array();
                 require "./{$dirPath}{$file}/themedef.php";
                 $themedef['dirName'] = $file;
                 // check for theme already existing in the registry
                 // if so, then it will override the current one
                 if (self::exists($themedef['dirName'])) {
                     $existingTheme = self::get($themedef['dirName']);
                     foreach (SugarTheme::getThemeDefFields() as $field) {
                         if (!isset($themedef[$field])) {
                             $themedef[$field] = $existingTheme->{$field};
                         }
                     }
                     self::remove($themedef['dirName']);
                 }
                 if (isset($themedef['name'])) {
                     self::add($themedef);
                 }
             }
             closedir($dir);
         }
     }
     // default to setting the default theme as the current theme
     self::set($GLOBALS['sugar_config']['default_theme']);
 }
예제 #15
0
 /**
  * Determine whether or not to dispay the header on the page.
  */
 function displayHeader()
 {
     global $theme;
     global $max_tabs;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $app_list_strings;
     $GLOBALS['app']->headerDisplayed = true;
     if (!function_exists('get_new_record_form') && (file_exists('modules/' . $this->module . '/metadata/sidecreateviewdefs.php') || file_exists('custom/modules/' . $this->module . '/metadata/sidecreateviewdefs.php'))) {
         require_once 'include/EditView/SideQuickCreate.php';
     }
     if (!$this->_menuExists($this->module) && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {
         $GLOBALS['module_menu'][] = array("index.php?module={$this->module}&action=EditView&return_module={$this->module}&return_action=DetailView", $GLOBALS['mod_strings']['LNK_NEW_RECORD'], "{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}{$this->module}", $this->module);
         $GLOBALS['module_menu'][] = array("index.php?module={$this->module}&action=index", $GLOBALS['mod_strings']['LNK_LIST'], $this->module, $this->module);
     }
     $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 css
     $css = $themeObject->getCSS();
     if ($this->_getOption('view_print')) {
         $css .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
     }
     $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('sugar_icon.ico', false);
     }
     $ss->assign('FAVICON_URL', getJSPath($favicon));
     // get the module menu
     $shortcut_menu = array();
     $module_menu = load_menu("modules/" . $this->module . "/");
     foreach ($module_menu as $key => $menu_item) {
         $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")));
     }
     $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));
             }
             // 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);
     if (isset($_REQUEST['query_string'])) {
         $ss->assign("SEARCH", $_REQUEST['query_string']);
     }
     if ($this->action == "EditView" || $this->action == "Login") {
         $ss->assign("ONLOAD", 'onload="set_focus()"');
     }
     $ss->assign("AUTHENTICATED", isset($_SESSION["authenticated_user_id"]));
     // awu: moving allThemes json array out of authenticated if block for IE6 check on Login screen
     // build json string of theme properties
     $allThemes = array();
     foreach (SugarThemeRegistry::availableThemes() as $dirName => $themeName) {
         $selectedTheme = SugarThemeRegistry::get($dirName);
         $allThemes[$dirName] = array('name' => $themeName, 'description' => $selectedTheme->description, 'ie6compat' => $selectedTheme->ie6compat);
     }
     // get other things needed for page style popup
     $json = getJSONobj();
     $ss->assign('allThemes', $json->encode($allThemes));
     if (isset($_SESSION["authenticated_user_id"])) {
         $ss->assign('currentTheme_fonts', $themeObject->fonts);
         $ss->assign('currentTheme_colors', $themeObject->colors);
         $ss->assign('currentTheme_groupedTabscompat', $themeObject->group_tabs);
         $ss->assign('selectThemeOptions', get_select_options_with_id(SugarThemeRegistry::availableThemes(), SugarThemeRegistry::current()->__toString()));
         $ss->assign('USERS_MOD', return_module_language($GLOBALS['current_language'], 'Users'));
         $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
         if (isset($user_navigation_paradigm)) {
             $ss->assign("NAVADIGMS", get_select_options_with_id($app_list_strings['navigation_paradigms'], $user_navigation_paradigm));
         } else {
             $ss->assign("NAVADIGMS", get_select_options_with_id($app_list_strings['navigation_paradigms'], $GLOBALS['sugar_config']['default_navigation_paradigm']));
         }
         // get the current user name and id
         $ss->assign("CURRENT_USER", $current_user->first_name != '' ? $current_user->first_name : $current_user->user_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) {
             $history[$key]['item_summary_short'] = getTrackerSubstring($row['item_summary']);
             $history[$key]['image'] = SugarThemeRegistry::current()->getImage($row['module_name'], 'border="0" align="absmiddle" alt="' . $row['item_summary'] . '"');
         }
         $ss->assign("recentRecords", $history);
         // new record
         require_once "modules/" . $this->module . "/Forms.php";
         if ($this->action == "index" && function_exists('get_new_record_form')) {
             $ss->assign("NEW_RECORD", get_new_record_form());
         }
         // Get preference for shortcuts and last_viewed list placement
         $last_view_swap = $current_user->getPreference('swap_last_viewed');
         if (!isset($last_view_swap)) {
             $last_view_swap = $GLOBALS['sugar_config']['default_swap_last_viewed'];
         }
         $ss->assign("LEFT_FORM_LAST_VIEWED", $last_view_swap);
         $shortcuts_swap = $current_user->getPreference('swap_shortcuts');
         if (!isset($shortcuts_swap)) {
             $shortcuts_swap = $GLOBALS['sugar_config']['default_swap_shortcuts'];
         }
         $ss->assign("LEFT_FORM_SHORTCUTS", !$shortcuts_swap);
     }
     if (isset($_SESSION["authenticated_user_id"]) || $sugar_config['login_nav']) {
         // get the module list
         $moduleTopMenu = array();
         $max_tabs = $current_user->getPreference('max_tabs');
         if (!isset($max_tabs) || $max_tabs <= 0) {
             $max_tabs = $GLOBALS['sugar_config']['default_max_tabs'];
         }
         $user_navigation_paradigm = $current_user->getPreference('navigation_paradigm');
         if (!isset($user_navigation_paradigm)) {
             $user_navigation_paradigm = $GLOBALS['sugar_config']['default_navigation_paradigm'];
         }
         // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
         if (!empty($_REQUEST['module_tab'])) {
             $moduleTab = $_REQUEST['module_tab'];
         } elseif (isset($GLOBALS['moduleTabMap'][$this->module])) {
             $moduleTab = $GLOBALS['moduleTabMap'][$this->module];
         } else {
             $moduleTab = $this->module;
         }
         $ss->assign('MODULE_TAB', $moduleTab);
         if ($user_navigation_paradigm == 'gm' && isset($themeObject->group_tabs) && $themeObject->group_tabs) {
             require_once 'include/GroupedTabs/GroupedTabStructure.php';
             $groupedTabsClass = new GroupedTabStructure();
             $modules = query_module_access_list($current_user);
             //handle with submoremodules
             $max_subtabs = $current_user->getPreference('max_subtabs');
             if (!isset($max_subtabs) || $max_subtabs <= 0) {
                 $max_subtabs = $GLOBALS['sugar_config']['default_max_subtabs'];
             }
             $subMoreModules = false;
             $groupTabs = $groupedTabsClass->get_tab_structure(get_val_array($modules));
             foreach ($groupTabs as $key => $groupTab) {
                 $count = count($groupTab['modules']);
                 if ($count > $max_subtabs) {
                     for ($i = $max_subtabs - 1; $i < $count; $i++) {
                         if (!isset($groupTabs[$key]['modules'][$i])) {
                             continue;
                         }
                         $subMoreModules[$key]['modules'][$i] = $groupTabs[$key]['modules'][$i];
                         unset($groupTabs[$key]['modules'][$i]);
                     }
                 }
             }
             $ss->assign('groupTabs', $groupTabs);
             $ss->assign('subMoreModules', $subMoreModules);
             $ss->assign('moduleNames', $app_list_strings['moduleList']);
             $ss->assign('defaultFirst', !in_array($moduleTab, $modules));
             $ss->assign('parentTab', !empty($_REQUEST['parentTab']) ? $_REQUEST['parentTab'] : false);
             $ss->assign('USE_GROUP_TABS', true);
         } else {
             $moduleExtraMenu = array();
             $i = 1;
             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])) {
                     if ($i < $max_tabs) {
                         $moduleTopMenu[$module] = $app_list_strings['moduleList'][$module];
                     } else {
                         $moduleExtraMenu[$module] = $app_list_strings['moduleList'][$module];
                     }
                     ++$i;
                 }
             }
             $iFrame = new iFrame();
             $frames = $iFrame->lookup_frames('tab');
             foreach ($frames as $key => $values) {
                 if ($i < $max_tabs) {
                     $moduleTopMenu[$key] = $values;
                 } else {
                     $moduleExtraMenu[$key] = $values;
                 }
                 ++$i;
             }
             // Now, we'll push the current module into the end of top menu list if it's not
             // already there. In addition, we'll preserve this last entry for this session
             // until a new value is added there.
             if (isset($moduleTopMenu[$moduleTab])) {
                 if (isset($_SESSION['moreTab']) && isset($app_list_strings['moduleList'][$_SESSION['moreTab']])) {
                     $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                     unset($moduleExtraMenu[$_SESSION['moreTab']]);
                 } else {
                     $moduleTopMenu += array_slice($moduleExtraMenu, 0, 1);
                     array_shift($moduleExtraMenu);
                 }
             } elseif (isset($moduleExtraMenu[$moduleTab])) {
                 $_SESSION['moreTab'] = $moduleTab;
                 $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                 unset($moduleExtraMenu[$_SESSION['moreTab']]);
             } elseif (isset($_SESSION['moreTab']) && isset($app_list_strings['moduleList'][$_SESSION['moreTab']])) {
                 $moduleTopMenu[$_SESSION['moreTab']] = $app_list_strings['moduleList'][$_SESSION['moreTab']];
                 unset($moduleExtraMenu[$_SESSION['moreTab']]);
             }
             $ss->assign("moduleTopMenu", $moduleTopMenu);
             $ss->assign("moduleExtraMenu", $moduleExtraMenu);
         }
     }
     $headerTpl = $themeObject->getTemplate('header.tpl');
     if (isset($GLOBALS['sugar_config']['developerMode']) && $GLOBALS['sugar_config']['developerMode']) {
         $ss->clear_compiled_tpl($headerTpl);
     }
     $ss->display($headerTpl);
     $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
 }
예제 #16
0
 protected function loadRelationships()
 {
     if (sugar_is_file($this->getCacheFile())) {
         include $this->getCacheFile();
         $this->relationships = $relationships;
     } else {
         $this->buildRelationshipCache();
     }
 }
예제 #17
0
 /**
  * Restores files from deleted folder
  *
  * @return bool success of operation
  */
 protected function restoreFiles()
 {
     if (!$this->id) {
         return true;
     }
     if (!$this->haveFiles()) {
         return true;
     }
     $files = $this->getFiles();
     if (empty($files)) {
         return true;
     }
     $directory = $this->deleteFileDirectory();
     foreach ($files as $file) {
         if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) {
             if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) {
                 $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory');
             }
         }
     }
     /**
      * @var DBManager $db
      */
     global $db;
     $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id));
     return true;
 }
예제 #18
0
 /**
  * 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;
     $GLOBALS['app']->headerDisplayed = true;
     $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 .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
     }
     $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('sugar_icon.ico', false);
     }
     $ss->assign('FAVICON_URL', getJSPath($favicon));
     // build the shortcut menu
     $shortcut_menu = array();
     foreach ($this->getMenu() as $key => $menu_item) {
         $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")));
     }
     $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());
                 if (substr($gcls[$key]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]["ONCLICK"] = substr($gcls[$key]["URL"], 11);
                     $gcls[$key]["URL"] = "#";
                 }
             }
             // 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));
                 }
                 if (substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 0, 11) == "javascript:") {
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["ONCLICK"] = substr($gcls[$key]['SUBMENU'][$submenulinkkey]["URL"], 11);
                     $gcls[$key]['SUBMENU'][$submenulinkkey]["URL"] = "#";
                 }
             }
         }
     }
     $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) {
             $history[$key]['item_summary_short'] = getTrackerSubstring($row['item_summary']);
             $history[$key]['image'] = SugarThemeRegistry::current()->getImage($row['module_name'], 'border="0" align="absmiddle" alt="' . $row['item_summary'] . '"');
         }
         $ss->assign("recentRecords", $history);
     }
     $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) {
             // We are using grouped tabs
             require_once 'include/GroupedTabs/GroupedTabStructure.php';
             $groupedTabsClass = new GroupedTabStructure();
             $modules = query_module_access_list($current_user);
             //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;
                 }
             }
             $subMoreModules = false;
             $groupTabs = $groupedTabsClass->get_tab_structure(get_val_array($modules));
             // We need to put this here, so the "All" group is valid for the user's preference.
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
             // Setup the default group tab.
             $allGroup = $app_strings['LBL_TABGROUP_ALL'];
             $ss->assign('currentGroupTab', $allGroup);
             $currentGroupTab = $allGroup;
             $usersGroup = $current_user->getPreference('theme_current_group');
             // Figure out which tab they currently have selected (stored as a user preference)
             if (!empty($usersGroup) && isset($groupTabs[$usersGroup])) {
                 $currentGroupTab = $usersGroup;
             } else {
                 $current_user->setPreference('theme_current_group', $currentGroupTab);
             }
             $ss->assign('currentGroupTab', $currentGroupTab);
             $usingGroupTabs = true;
         } else {
             // Setup the default group tab.
             $ss->assign('currentGroupTab', $app_strings['LBL_TABGROUP_ALL']);
             $usingGroupTabs = false;
             $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules'] = $fullModuleList;
         }
         $topTabList = array();
         // Now time to go through each of the tab sets and fix them up.
         foreach ($groupTabs as $tabIdx => $tabData) {
             $topTabs = $tabData['modules'];
             if (!is_array($topTabs)) {
                 $topTabs = array();
             }
             $extraTabs = array();
             // Split it in to the tabs that go across the top, and the ones that are on the extra menu.
             if (count($topTabs) > $max_tabs) {
                 $extraTabs = array_splice($topTabs, $max_tabs);
             }
             // Make sure the current module is accessable through one of the top tabs
             if (!isset($topTabs[$moduleTab])) {
                 // Nope, we need to add it.
                 // First, take it out of the extra menu, if it's there
                 if (isset($extraTabs[$moduleTab])) {
                     unset($extraTabs[$moduleTab]);
                 }
                 if (count($topTabs) >= $max_tabs - 1) {
                     // We already have the maximum number of tabs, so we need to shuffle the last one
                     // from the top to the first one of the extras
                     $lastElem = array_splice($topTabs, $max_tabs - 1);
                     $extraTabs = $lastElem + $extraTabs;
                 }
                 if (!empty($moduleTab)) {
                     $topTabs[$moduleTab] = $app_list_strings['moduleList'][$moduleTab];
                 }
             }
             /*
             // This was removed, but I like the idea, so I left the code in here in case we decide to turn it back on
             // If we are using group tabs, add all the "hidden" tabs to the end of the extra menu
             if ( $usingGroupTabs ) {
                 foreach($fullModuleList as $moduleKey => $module ) {
                     if ( !isset($topTabs[$moduleKey]) && !isset($extraTabs[$moduleKey]) ) {
                         $extraTabs[$moduleKey] = $module;
                     }
                 }
             }
             */
             // Get a unique list of the top tabs so we can build the popup menus for them
             foreach ($topTabs as $moduleKey => $module) {
                 $topTabList[$moduleKey] = $module;
             }
             $groupTabs[$tabIdx]['modules'] = $topTabs;
             $groupTabs[$tabIdx]['extra'] = $extraTabs;
         }
     }
     if (isset($topTabList) && is_array($topTabList)) {
         // Adding shortcuts array to menu array for displaying shortcuts associated with each module
         $shortcutTopMenu = array();
         foreach ($topTabList as $module_key => $label) {
             global $mod_strings;
             $mod_strings = return_module_language($current_language, $module_key);
             foreach ($this->getMenu($module_key) as $key => $menu_item) {
                 $shortcutTopMenu[$module_key][$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("groupTabs", $groupTabs);
         $ss->assign("shortcutTopMenu", $shortcutTopMenu);
         $ss->assign('USE_GROUP_TABS', $usingGroupTabs);
         // This is here for backwards compatibility, someday, somewhere, it will be able to be removed
         $ss->assign("moduleTopMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['modules']);
         $ss->assign("moduleExtraMenu", $groupTabs[$app_strings['LBL_TABGROUP_ALL']]['extra']);
     }
     global $mod_strings;
     $mod_strings = $bakModStrings;
     $headerTpl = $themeObject->getTemplate('header.tpl');
     if (isset($GLOBALS['sugar_config']['developerMode']) && $GLOBALS['sugar_config']['developerMode']) {
         $ss->clear_compiled_tpl($headerTpl);
     }
     $ss->display($headerTpl);
     $this->includeClassicFile('modules/Administration/DisplayWarnings.php');
     $errorMessages = SugarApplication::getErrorMessages();
     if (!empty($errorMessages)) {
         foreach ($errorMessages as $error_message) {
             echo '<p class="error">' . $error_message . '</p>';
         }
     }
 }
예제 #19
0
 function getDashlets($category = '')
 {
     global $app_strings, $current_language, $mod_strings;
     require_once $GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php';
     $categories = array('module' => 'Module Views', 'portal' => 'Portal', 'charts' => 'Charts', 'tools' => 'Tools', 'misc' => 'Miscellaneous', 'web' => 'Web');
     $dashletStrings = array();
     $dashletsList = array();
     if (!empty($category)) {
         $dashletsList[$categories[$category]] = array();
     } else {
         $dashletsList['Module Views'] = array();
         $dashletsList['Charts'] = array();
         $dashletsList['Tools'] = array();
         $dashletsList['Web'] = array();
     }
     asort($dashletsFiles);
     foreach ($dashletsFiles as $className => $files) {
         if (!empty($files['meta']) && SugarAutoLoader::fileExists($files['meta'])) {
             require_once $files['meta'];
             // get meta file
             $directory = substr($files['meta'], 0, strrpos($files['meta'], '/') + 1);
             foreach (SugarAutoLoader::existing($directory . $files['class'] . '.' . $current_language . '.lang.php', $directory . $files['class'] . '.en_us.lang.php') as $file) {
                 require $file;
             }
             // try to translate the string
             if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']])) {
                 $title = $dashletMeta[$files['class']]['title'];
             } else {
                 $title = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']];
             }
             // try to translate the string
             if (empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']])) {
                 $description = $dashletMeta[$files['class']]['description'];
             } else {
                 $description = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']];
             }
             // generate icon
             if (!empty($dashletMeta[$files['class']]['icon'])) {
                 // here we'll support image inheritance if the supplied image has a path in it
                 // i.e. $dashletMeta[$files['class']]['icon'] = 'themes/default/images/dog.gif'
                 // in this case, we'll strip off the path information to check for the image existing
                 // in the current theme.
                 $imageName = SugarThemeRegistry::current()->getImageURL(basename($dashletMeta[$files['class']]['icon']), false);
                 if (!empty($imageName)) {
                     if (sugar_is_file($imageName)) {
                         $icon = '<img src="' . $imageName . '" alt="" border="0" align="absmiddle" />';
                     } else {
                         $icon = '';
                     }
                 }
             } else {
                 if (empty($dashletMeta[$files['class']]['module'])) {
                     $icon = get_dashlets_dialog_icon('default');
                 } else {
                     if (!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList']) && !in_array('Activities', $GLOBALS['moduleList'])) {
                         unset($dashletMeta[$files['class']]);
                         continue;
                     } else {
                         $icon = get_dashlets_dialog_icon($dashletMeta[$files['class']]['module']);
                     }
                 }
             }
             // determine whether to display
             if (!empty($dashletMeta[$files['class']]['hidden']) && $dashletMeta[$files['class']]['hidden'] === true) {
                 $displayDashlet = false;
             } elseif (!empty($dashletMeta[$files['class']]['module']) && (!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList'])) && !in_array('Activities', $GLOBALS['moduleList'])) {
                 $displayDashlet = false;
             } else {
                 $displayDashlet = true;
                 //check ACL ACCESS
                 if (!empty($dashletMeta[$files['class']]['module'])) {
                     if (!SugarACL::checkAccess($dashletMeta[$files['class']]['module'], 'view', array('owner_override' => true))) {
                         $displayDashlet = false;
                     }
                     if (!SugarACL::checkAccess($dashletMeta[$files['class']]['module'], 'list', array('owner_override' => true))) {
                         $displayDashlet = false;
                     }
                 }
             }
             if ($dashletMeta[$files['class']]['category'] == 'Charts') {
                 $type = 'predefined_chart';
             } else {
                 $type = 'module';
             }
             if ($displayDashlet && isset($dashletMeta[$files['class']]['dynamic_hide']) && $dashletMeta[$files['class']]['dynamic_hide']) {
                 if (SugarAutoLoader::fileExists($files['file'])) {
                     require_once $files['file'];
                     if (class_exists($files['class'])) {
                         $dashletClassName = $files['class'];
                         $displayDashlet = call_user_func(array($files['class'], 'shouldDisplay'));
                     }
                 }
             }
             if ($displayDashlet) {
                 $cell = array('title' => $title, 'description' => $description, 'onclick' => 'return SUGAR.mySugar.addDashlet(\'' . $className . '\', \'' . $type . '\', \'' . (!empty($dashletMeta[$files['class']]['module']) ? $dashletMeta[$files['class']]['module'] : '') . '\');', 'icon' => $icon, 'id' => $files['class'] . '_select');
                 if (!empty($category) && $dashletMeta[$files['class']]['category'] == $categories[$category]) {
                     array_push($dashletsList[$categories[$category]], $cell);
                 } else {
                     if (empty($category)) {
                         array_push($dashletsList[$dashletMeta[$files['class']]['category']], $cell);
                     }
                 }
             }
         }
     }
     if (!empty($category)) {
         asort($dashletsList[$categories[$category]]);
     } else {
         foreach ($dashletsList as $key => $value) {
             asort($dashletsList[$key]);
         }
     }
     $this->dashlets = $dashletsList;
 }
예제 #20
0
 /**
  * Save the dictionary object to the cache
  * @param string $module the name of the module
  * @param string $object the name of the object
  */
 static function saveCache($module, $object, $additonal_objects = array())
 {
     $file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php');
     write_array_to_file('GLOBALS["dictionary"]["' . $object . '"]', $GLOBALS['dictionary'][$object], $file);
     if (sugar_is_file($file) && is_readable($file)) {
         include $file;
     }
     // put the item in the sugar cache.
     $key = "VardefManager.{$module}.{$object}";
     //Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those.
     $data = self::cleanVardefs($GLOBALS['dictionary'][$object]);
     sugar_cache_put($key, $data);
 }
예제 #21
0
 /**
  * Builds the theme registry
  */
 public static function buildRegistry()
 {
     self::$_themes = array();
     $dirs = array("themes/", "custom/themes/");
     // check for a default themedef file
     $themedefDefault = array();
     if (sugar_is_file("custom/themes/default/themedef.php")) {
         $themedef = array();
         require "custom/themes/default/themedef.php";
         $themedefDefault = $themedef;
     }
     foreach ($dirs as $dirPath) {
         if (sugar_is_dir('./' . $dirPath) && is_readable('./' . $dirPath) && ($dir = opendir('./' . $dirPath))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" || $file == "default" || !sugar_is_dir("./{$dirPath}" . $file) || !sugar_is_file("./{$dirPath}{$file}/themedef.php")) {
                     continue;
                 }
                 $themedef = array();
                 require "./{$dirPath}{$file}/themedef.php";
                 $themedef = array_merge($themedef, $themedefDefault);
                 $themedef['dirName'] = $file;
                 // check for theme already existing in the registry
                 // if so, then it will override the current one
                 if (self::exists($themedef['dirName'])) {
                     $existingTheme = self::get($themedef['dirName']);
                     foreach (SugarTheme::getThemeDefFields() as $field) {
                         if (!isset($themedef[$field])) {
                             $themedef[$field] = $existingTheme->{$field};
                         }
                     }
                     self::remove($themedef['dirName']);
                 }
                 if (isset($themedef['name'])) {
                     self::add($themedef);
                 }
             }
             closedir($dir);
         }
     }
     // default to setting the default theme as the current theme
     if (!isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme'])) {
         if (count(self::availableThemes()) == 0) {
             sugar_die('No valid themes are found on this instance');
         } else {
             self::set(self::getDefaultThemeKey());
         }
     }
 }
예제 #22
0
 /**
  * Returns the bean object of the given module
  *
  * @return object
  */
 public function loadBean($beanList = null, $beanFiles = null, $returnObject = true)
 {
     // Populate these reference arrays
     if (empty($beanList)) {
         global $beanList;
     }
     if (empty($beanFiles)) {
         global $beanFiles;
     }
     if (!isset($beanList) || !isset($beanFiles)) {
         require 'include/modules.php';
     }
     if (isset($beanList[$this->_moduleName])) {
         $bean = $beanList[$this->_moduleName];
         if (isset($beanFiles[$bean])) {
             if (!$returnObject) {
                 return true;
             }
             if (!sugar_is_file($beanFiles[$bean])) {
                 return false;
             }
             require_once $beanFiles[$bean];
             $focus = new $bean();
         } else {
             return false;
         }
     } else {
         return false;
     }
     return $focus;
 }
예제 #23
0
if (isset($_REQUEST['login_language'])) {
    $lang = $_REQUEST['login_language'];
    $_REQUEST['ck_login_language_20'] = $lang;
    $current_language = $lang;
    $_SESSION['authenticated_user_language'] = $lang;
    $mod_strings = return_module_language($lang, "Users");
    $app_strings = return_application_language($lang);
}
$sugar_smarty = new Sugar_Smarty();
echo '<link rel="stylesheet" type="text/css" media="all" href="' . getJSPath('modules/Users/login.css') . '">';
echo '<script type="text/javascript" src="' . getJSPath('modules/Users/login.js') . '"></script>';
global $app_language, $sugar_config;
//we don't want the parent module's string file, but rather the string file specifc to this subpanel
global $current_language;
// Get the login page image
if (sugar_is_file('custom/include/images/sugar_md.png')) {
    $login_image = '<IMG src="custom/include/images/sugar_md.png" alt="Sugar" width="340" height="25">';
} else {
    $login_image = '<IMG src="include/images/sugar_md_open.png" alt="Sugar" width="340" height="25" style="margin: 5px 0;">';
}
$sugar_smarty->assign('LOGIN_IMAGE', $login_image);
// See if any messages were passed along to display to the user.
if (isset($_COOKIE['loginErrorMessage'])) {
    if (!isset($_REQUEST['loginErrorMessage'])) {
        $_REQUEST['loginErrorMessage'] = $_COOKIE['loginErrorMessage'];
    }
    SugarApplication::setCookie('loginErrorMessage', '', time() - 42000, '/');
}
if (isset($_REQUEST['loginErrorMessage'])) {
    if (isset($mod_strings[$_REQUEST['loginErrorMessage']])) {
        echo "<p align='center' class='error' > " . $mod_strings[$_REQUEST['loginErrorMessage']] . "</p>";
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU 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".
 ********************************************************************************/
/*********************************************************************************
 * Description:  controls which link show up in the upper right hand corner of the app
 ********************************************************************************/
global $app_strings, $current_user;
if (!isset($global_control_links)) {
    $global_control_links = array();
    $sub_menu = array();
}
if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
    require_once 'modules/Sync/headermenu.php';
}
$global_control_links['myaccount'] = array('linkinfo' => array($app_strings['LBL_MY_ACCOUNT'] => 'index.php?module=Users&action=DetailView&record=' . $current_user->id . ''), 'submenu' => '');
$global_control_links['employees'] = array('linkinfo' => array($app_strings['LBL_EMPLOYEES'] => 'index.php?module=Employees&action=index'), 'submenu' => '');
if (is_admin($current_user)) {
    $global_control_links['admin'] = array('linkinfo' => array($app_strings['LBL_ADMIN'] => 'index.php?module=Administration&action=index'), 'submenu' => '');
}
$global_control_links['training'] = array('linkinfo' => array($app_strings['LBL_TRAINING'] => 'index.php?module=Home&action=TrainingPortal'), 'submenu' => '');
$global_control_links['users'] = array('linkinfo' => array($app_strings['LBL_LOGOUT'] => 'index.php?module=Users&action=Logout'), 'submenu' => '');
$global_control_links['about'] = array('linkinfo' => array($app_strings['LNK_ABOUT'] => 'index.php?module=Home&action=About'), 'submenu' => '');
if (sugar_is_file('custom/include/globalControlLinks.php')) {
    include 'custom/include/globalControlLinks.php';
}
예제 #25
0
 /**
  * Retrieves favicon corresponding to currently requested module
  *
  * @return array
  */
 protected function getFavicon()
 {
     // get favicon
     if (isset($GLOBALS['sugar_config']['default_module_favicon'])) {
         $module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
     } else {
         $module_favicon = false;
     }
     $themeObject = SugarThemeRegistry::current();
     $favicon = '';
     if ($module_favicon) {
         $favicon = $themeObject->getImageURL($this->module . '.gif', false);
     }
     if (!sugar_is_file($favicon) || !$module_favicon) {
         $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
     }
     $extension = pathinfo($favicon, PATHINFO_EXTENSION);
     switch ($extension) {
         case 'png':
             $type = 'image/png';
             break;
         case 'ico':
             // fall through
         // fall through
         default:
             $type = 'image/x-icon';
             break;
     }
     return array('url' => getJSPath($favicon), 'type' => $type);
 }
예제 #26
0
 /**
  * Returns the URL for an image in the current theme. If not found in the current theme, will revert
  * to looking in the base theme.
  *
  * @param  string $jsFileName js file name
  * @param  bool   $returnURL if true, returns URL with unique image mark, otherwise returns path to the file
  * @return string path to js file
  */
 public function getJSURL($jsFileName, $returnURL = true)
 {
     if (isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName]))) {
         if ($returnURL) {
             return getJSPath("cache/" . $this->_jsCache[$jsFileName]);
         } else {
             return sugar_cached($this->_jsCache[$jsFileName]);
         }
     }
     $jsFileContents = '';
     $fullFileName = $this->getJSPath() . '/' . $jsFileName;
     $defaultFileName = $this->getDefaultJSPath() . '/' . $jsFileName;
     if (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName, false)) != '' && !in_array($jsFileName, $this->ignoreParentFiles)) {
         $jsFileContents .= file_get_contents($filename);
     } else {
         foreach (SugarAutoLoader::existingCustom($defaultFileName) as $jsFile) {
             $jsFileContents .= file_get_contents($jsFile);
         }
     }
     foreach (SugarAutoLoader::existingCustom($fullFileName) as $jsFile) {
         $jsFileContents .= file_get_contents($jsFile);
     }
     if (empty($jsFileContents)) {
         $GLOBALS['log']->warn("Javascript File {$jsFileName} not found");
         return false;
     }
     // create the cached file location
     $jsFilePath = create_cache_directory($fullFileName);
     // minify the js
     if (!inDeveloperMode() && !sugar_is_file(str_replace('.js', '-min.js', $jsFilePath))) {
         $jsFileContents = SugarMin::minify($jsFileContents);
         $jsFilePath = str_replace('.js', '-min.js', $jsFilePath);
         $fullFileName = str_replace('.js', '-min.js', $fullFileName);
     }
     // now write the js to cache
     sugar_file_put_contents($jsFilePath, $jsFileContents);
     $this->_jsCache[$jsFileName] = $fullFileName;
     if ($returnURL) {
         return getJSPath("cache/" . $fullFileName);
     }
     return sugar_cached($fullFileName);
 }
예제 #27
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
     global $import_mod_strings;
     $this->instruction = 'LBL_SELECT_UPLOAD_INSTRUCTION';
     $this->ss->assign('INSTRUCTION', $this->getInstruction());
     $this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false));
     $this->ss->assign("IMP", $import_mod_strings);
     $this->ss->assign("CURRENT_STEP", $this->currentStep);
     $this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
     $this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
     $this->ss->assign("CUSTOM_ENCLOSURE", htmlentities(!empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other' ? $_REQUEST['custom_enclosure'] : (!empty($_REQUEST['custom_enclosure_other']) ? $_REQUEST['custom_enclosure_other'] : "")));
     $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
     $this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
     $this->ss->assign("JAVASCRIPT", $this->_getJS());
     $this->ss->assign("SAMPLE_URL", "<a href=\"javascript: void(0);\" onclick=\"window.location.href='index.php?entryPoint=export&module=" . $_REQUEST['import_module'] . "&action=index&all=true&sample=true'\" >" . $mod_strings['LBL_EXAMPLE_FILE'] . "</a>");
     $displayBackBttn = isset($_REQUEST['action']) && $_REQUEST['action'] != 'index' ? TRUE : FALSE;
     $this->ss->assign("displayBackBttn", $displayBackBttn);
     $importSource = isset($_REQUEST['source']) ? $_REQUEST['source'] : 'csv';
     //Start custom mapping
     // show any custom mappings
     if (sugar_is_dir('custom/modules/Import') && ($dir = opendir('custom/modules/Import'))) {
         while (($file = readdir($dir)) !== false) {
             if (sugar_is_file("custom/modules/Import/{$file}") && strpos($file, ".php") !== false) {
                 require_once "custom/modules/Import/{$file}";
                 $classname = str_replace('.php', '', $file);
                 $mappingClass = new $classname();
                 $custom_mappings[] = $mappingClass->name;
             }
         }
     }
     // get user defined import maps
     $is_admin = is_admin($current_user);
     if ($is_admin) {
         $savedMappingHelpText = $mod_strings['LBL_MY_SAVED_ADMIN_HELP'];
     } else {
         $savedMappingHelpText = $mod_strings['LBL_MY_SAVED_HELP'];
     }
     $this->ss->assign('savedMappingHelpText', $savedMappingHelpText);
     $this->ss->assign('is_admin', $is_admin);
     $import_map_seed = new ImportMap();
     $custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
     if (count($custom_imports_arr)) {
         $custom = array();
         foreach ($custom_imports_arr as $import) {
             $custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
         }
         $this->ss->assign('custom_imports', $custom);
     }
     // get globally defined import maps
     $published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
     if (count($published_imports_arr)) {
         $published = array();
         foreach ($published_imports_arr as $import) {
             $published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
         }
         $this->ss->assign('published_imports', $published);
     }
     //End custom mapping
     // add instructions for anything other than custom_delimited
     $instructions = array();
     $lang_key = "CUSTOM";
     for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_{$i}"]); $i++) {
         $instructions[] = array("STEP_NUM" => $mod_strings["LBL_NUM_{$i}"], "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_{$i}"]);
     }
     $this->ss->assign("INSTRUCTIONS_TITLE", $mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
     $this->ss->assign("instructions", $instructions);
     $content = $this->ss->fetch('modules/Import/tpls/step2.tpl');
     $this->ss->assign("CONTENT", $content);
     $this->ss->display('modules/Import/tpls/wizardWrapper.tpl');
 }
예제 #28
0
 /**
  * Takes in the request params from a save request and processes
  * them for the save.
  *
  * @param REQUEST params  $params
  */
 public function saveDropDown($params)
 {
     global $locale;
     $emptyMarker = translate('LBL_BLANK');
     if (!empty($_REQUEST['dropdown_lang'])) {
         $selected_lang = $_REQUEST['dropdown_lang'];
     } else {
         $selected_lang = $locale->getAuthenticatedUserLanguage();
     }
     $type = $_REQUEST['view_package'];
     $dropdown_name = $params['dropdown_name'];
     $json = getJSONobj();
     $list_value = str_replace('&quot;&quot;:&quot;&quot;', '&quot;__empty__&quot;:&quot;&quot;', $params['list_value']);
     //Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes.
     $temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES));
     $dropdown = array();
     // dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order
     // we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered
     if (is_array($temp)) {
         foreach ($temp as $item) {
             $dropdown[SugarCleaner::stripTags(from_html($item[0]), false)] = SugarCleaner::stripTags(from_html($item[1]), false);
         }
     }
     if (array_key_exists($emptyMarker, $dropdown)) {
         $output = array();
         foreach ($dropdown as $key => $value) {
             if ($emptyMarker === $key) {
                 $output[''] = '';
             } else {
                 $output[$key] = $value;
             }
         }
         $dropdown = $output;
     }
     if ($type != 'studio') {
         $mb = new ModuleBuilder();
         $module = $mb->getPackageModule($params['view_package'], $params['view_module']);
         $this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module);
         //Can't use synch on selected lang as we want to overwrite values, not just keys
         $module->mblanguage->appListStrings[$selected_lang . '.lang.php'][$dropdown_name] = $dropdown;
         $module->mblanguage->save($module->key_name, false, true);
         // tyoung - key is required parameter as of
     } else {
         $contents = return_custom_app_list_strings_file_contents($selected_lang);
         $my_list_strings = return_app_list_strings_language($selected_lang);
         if ($selected_lang == $GLOBALS['current_language']) {
             $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown;
         }
         //write to contents
         $contents = str_replace("?>", '', $contents);
         if (empty($contents)) {
             $contents = "<?php";
         }
         // Skip saveExemptDropdowns on upgrades
         if (empty($params['skipSaveExemptDropdowns'])) {
             $dropdown = $this->saveExemptDropdowns($dropdown, $dropdown_name, $my_list_strings, $selected_lang);
         }
         //add new drop down to the bottom
         if (!empty($params['use_push'])) {
             //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed
             $app_list_strings = array();
             $filePath = $this->getExtensionFilePath($dropdown_name, $selected_lang);
             //Include the original extension to ensure any values sourced from it are kept.
             if (sugar_is_file($filePath)) {
                 include $filePath;
             }
             foreach ($dropdown as $key => $value) {
                 //only if the value has changed or does not exist do we want to add it this way
                 if (!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0) {
                     $app_list_strings[$dropdown_name][$key] = $value;
                 }
             }
             //Now that we have all the values, save the overrides to the extension
             if (!empty($app_list_strings[$dropdown_name])) {
                 $contents = "<?php\n //created: " . date('Y-m-d H:i:s') . "\n";
                 foreach ($app_list_strings[$dropdown_name] as $key => $value) {
                     $contents .= "\n\$app_list_strings['{$dropdown_name}']['{$key}']=" . var_export_helper($value) . ";";
                 }
                 $this->saveContents($dropdown_name, $contents, $selected_lang);
             }
         } else {
             if (empty($params['skip_sync'])) {
                 // Now synch up the keys in other languages to ensure that removed/added
                 // Drop down values work properly under all langs.
                 // If skip_sync, we don't want to sync ALL languages
                 $this->synchDropDown($dropdown_name, $dropdown, $selected_lang);
             }
             $contents = $this->getExtensionContents($dropdown_name, $dropdown);
             $this->saveContents($dropdown_name, $contents, $selected_lang);
         }
     }
     $this->finalize($selected_lang);
 }