Beispiel #1
0
 function addDashlet()
 {
     if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php')) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once $GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php';
     global $current_user;
     if (isset($_REQUEST['id'])) {
         $pages = $current_user->getPreference('pages', $this->type);
         $dashlets = $current_user->getPreference('dashlets', $this->type);
         $guid = create_guid();
         if (isset($_REQUEST['type_module'])) {
             $dashlet_module = $_REQUEST['type_module'];
         } elseif (isset($dashletsFiles[$_REQUEST['id']]['module'])) {
             $dashlet_module = $dashletsFiles[$_REQUEST['id']]['module'];
         } else {
             $dashlet_module = 'Home';
         }
         $dashlets[$guid] = array('className' => $dashletsFiles[$_REQUEST['id']]['class'], 'module' => $dashlet_module, 'fileLocation' => $dashletsFiles[$_REQUEST['id']]['file']);
         // add to beginning of the array
         array_unshift($pages[$_REQUEST['activeTab']]['columns'][0]['dashlets'], $guid);
         $current_user->setPreference('dashlets', $dashlets, 0, $this->type);
         echo $guid;
     } else {
         echo 'ofdaops';
     }
 }
 public function run()
 {
     if (is_file(sugar_cached('dashlets/dashlets.php'))) {
         unlink(sugar_cached('dashlets/dashlets.php'));
     }
     require_once 'include/Dashlets/DashletCacheBuilder.php';
     $dc = new DashletCacheBuilder();
     $dc->buildCache();
 }
function rebuild_dashlets()
{
    if (is_file('cache/dashlets/dashlets.php')) {
        unlink('cache/dashlets/dashlets.php');
    }
    require_once 'include/Dashlets/DashletCacheBuilder.php';
    $dc = new DashletCacheBuilder();
    $dc->buildCache();
}
Beispiel #4
0
 function addDashlet()
 {
     if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php')) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once $GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php';
     global $current_user;
     if (isset($_REQUEST['id'])) {
         $pages = $current_user->getPreference('pages', $this->type);
         $dashlets = $current_user->getPreference('dashlets', $this->type);
         $guid = create_guid();
         $options = array();
         if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'web') {
             $dashlet_module = 'Home';
             $options['url'] = $_REQUEST['type_module'];
             $fp = @fopen($options['url'], 'r');
             if ($fp) {
                 $page = fread($fp, 8192);
                 $matches = array();
                 preg_match("/<title>(.*)<\\/title>/i", $page, $matches);
                 if (isset($matches[1])) {
                     $options['title'] = str_replace('<![CDATA[', '', str_replace(']]>', '', $matches[1]));
                 }
                 fclose($fp);
             }
         } elseif (isset($_REQUEST['type_module'])) {
             $dashlet_module = $_REQUEST['type_module'];
         } elseif (isset($dashletsFiles[$_REQUEST['id']]['module'])) {
             $dashlet_module = $dashletsFiles[$_REQUEST['id']]['module'];
         } else {
             $dashlet_module = 'Home';
         }
         $dashlets[$guid] = array('className' => $dashletsFiles[$_REQUEST['id']]['class'], 'module' => $dashlet_module, 'options' => $options, 'fileLocation' => $dashletsFiles[$_REQUEST['id']]['file']);
         // add to beginning of the array
         array_unshift($pages[$_REQUEST['activeTab']]['columns'][0]['dashlets'], $guid);
         //check to see whether the preference is too large to store
         if ($current_user->isPreferenceSizeTooLarge($this->type)) {
             //user preference is too large, do not attempt to store.  echo error string and return.  This will be processed by mySugar.js
             echo 'userpref_error';
             return false;
         }
         //store preference and echo guid
         $current_user->setPreference('dashlets', $dashlets, 0, $this->type);
         echo $guid;
     } else {
         echo 'ofdaops';
     }
 }
Beispiel #5
0
 function addDashlet()
 {
     if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php')) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once $GLOBALS['sugar_config']['cache_dir'] . 'dashlets/dashlets.php';
     global $current_user;
     if (isset($_REQUEST['id'])) {
         $pages = $current_user->getPreference('pages', $this->type);
         $dashlets = $current_user->getPreference('dashlets', $this->type);
         $guid = create_guid();
         $options = array();
         if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'web') {
             $dashlet_module = 'Home';
             $options['url'] = $_REQUEST['type_module'];
             $fp = @fopen($options['url'], 'r');
             if ($fp) {
                 $page = fread($fp, 8192);
                 $matches = array();
                 preg_match("/<title>(.*)<\\/title>/i", $page, $matches);
                 if (isset($matches[1])) {
                     $options['title'] = str_replace('<![CDATA[', '', str_replace(']]>', '', $matches[1]));
                 }
                 fclose($fp);
             }
         } elseif (!empty($_REQUEST['type_module'])) {
             $dashlet_module = $_REQUEST['type_module'];
         } elseif (isset($dashletsFiles[$_REQUEST['id']]['module'])) {
             $dashlet_module = $dashletsFiles[$_REQUEST['id']]['module'];
         } else {
             $dashlet_module = 'Home';
         }
         $dashlets[$guid] = array('className' => $dashletsFiles[$_REQUEST['id']]['class'], 'module' => $dashlet_module, 'options' => $options, 'fileLocation' => $dashletsFiles[$_REQUEST['id']]['file']);
         // add to beginning of the array
         array_unshift($pages[$_REQUEST['activeTab']]['columns'][0]['dashlets'], $guid);
         $current_user->setPreference('dashlets', $dashlets, 0, $this->type);
         echo $guid;
     } else {
         echo 'ofdaops';
     }
 }
Beispiel #6
0
 function addDashlet()
 {
     if (!is_file(sugar_cached('dashlets/dashlets.php'))) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once sugar_cached('dashlets/dashlets.php');
     global $current_user;
     if (isset($_REQUEST['id'])) {
         $pages = $current_user->getPreference('pages', $this->type);
         $dashlets = $current_user->getPreference('dashlets', $this->type);
         $guid = create_guid();
         $options = array();
         if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'web') {
             $dashlet_module = 'Home';
             require_once 'include/Dashlets/DashletRssFeedTitle.php';
             $options['url'] = $_REQUEST['type_module'];
             $webDashlet = new DashletRssFeedTitle($options['url']);
             $options['title'] = $webDashlet->generateTitle();
             unset($webDashlet);
         } elseif (!empty($_REQUEST['type_module'])) {
             $dashlet_module = $_REQUEST['type_module'];
         } elseif (isset($dashletsFiles[$_REQUEST['id']]['module'])) {
             $dashlet_module = $dashletsFiles[$_REQUEST['id']]['module'];
         } else {
             $dashlet_module = 'Home';
         }
         $dashlets[$guid] = array('className' => $dashletsFiles[$_REQUEST['id']]['class'], 'module' => $dashlet_module, 'options' => $options, 'fileLocation' => $dashletsFiles[$_REQUEST['id']]['file']);
         if (!array_key_exists('current_tab', $_SESSION)) {
             $_SESSION["current_tab"] = '0';
         }
         array_unshift($pages[$_SESSION['current_tab']]['columns'][0]['dashlets'], $guid);
         $current_user->setPreference('dashlets', $dashlets, 0, $this->type);
         echo $guid;
     } else {
         echo 'ofdaops';
     }
 }
Beispiel #7
0
function deleteCache()
{
    //Clean modules from cache
    $cachedir = sugar_cached('modules');
    if (is_dir($cachedir)) {
        $allModFiles = array();
        $allModFiles = findAllFiles($cachedir, $allModFiles, true);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                if (is_dir($file)) {
                    rmdir_recursive($file);
                } else {
                    unlink($file);
                }
            }
        }
    }
    //Clean jsLanguage from cache
    $cachedir = sugar_cached('jsLanguage');
    if (is_dir($cachedir)) {
        $allModFiles = array();
        $allModFiles = findAllFiles($cachedir, $allModFiles);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    //Clean smarty from cache
    $cachedir = sugar_cached('smarty');
    if (is_dir($cachedir)) {
        $allModFiles = array();
        $allModFiles = findAllFiles($cachedir, $allModFiles);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    //Rebuild dashlets cache
    require_once 'include/Dashlets/DashletCacheBuilder.php';
    $dc = new DashletCacheBuilder();
    $dc->buildCache();
}
Beispiel #8
0
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero 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".
 ********************************************************************************/
global $current_user;
$silent = isset($_REQUEST['silent']) ? true : false;
if (is_admin($current_user)) {
    global $mod_strings;
    if (!$silent) {
        echo $mod_strings['LBL_REBUILD_DASHLETS_DESC'];
    }
    if (is_file($cachedfile = sugar_cached('dashlets/dashlets.php'))) {
        unlink($cachedfile);
    }
    require_once 'include/Dashlets/DashletCacheBuilder.php';
    $dc = new DashletCacheBuilder();
    $dc->buildCache();
    if (!$silent) {
        echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS'];
    }
} else {
    sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
}
 /**
  * Rename all module strings within the application for dashlets.
  *
  * @return RenameModules
  */
 private function renameAllDashlets()
 {
     //Load the Dashlet metadata so we know what needs to be changed
     if (!is_file(sugar_cached('dashlets/dashlets.php'))) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     include sugar_cached('dashlets/dashlets.php');
     foreach ($this->changedModules as $moduleName => $replacementLabels) {
         $this->changeModuleDashletStrings($moduleName, $replacementLabels, $dashletsFiles);
     }
     return $this;
 }
Beispiel #10
0
function deleteCache()
{
    //Clean modules from cache
    if (is_dir($GLOBALS['sugar_config']['cache_dir'] . 'modules')) {
        $allModFiles = array();
        $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'modules', $allModFiles);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    //Clean jsLanguage from cache
    if (is_dir($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage')) {
        $allModFiles = array();
        $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage', $allModFiles);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    //Clean smarty from cache
    if (is_dir($GLOBALS['sugar_config']['cache_dir'] . 'smarty')) {
        $allModFiles = array();
        $allModFiles = findAllFiles($GLOBALS['sugar_config']['cache_dir'] . 'smarty', $allModFiles);
        foreach ($allModFiles as $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
    //Rebuild dashlets cache
    require_once 'include/Dashlets/DashletCacheBuilder.php';
    $dc = new DashletCacheBuilder();
    $dc->buildCache();
}
Beispiel #11
0
 /**
  * @todo the css is not fully inherited in this file
  */
 function retrievePage()
 {
     global $current_user, $sugar_version, $sugar_config, $sugar_flavor, $current_language;
     global $app_strings, $theme;
     // build dashlet cache file if not found
     if (!is_file(sugar_cached('dashlets/dashlets.php'))) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     require_once sugar_cached('dashlets/dashlets.php');
     $pages = $current_user->getPreference('pages', $this->type);
     $dashlets = $current_user->getPreference('dashlets', $this->type);
     $count = 0;
     $dashletIds = array();
     // collect ids to pass to javascript
     $display = array();
     $predefinedChartsList = array('MyPipelineBySalesStageDashlet', 'OpportunitiesByLeadSourceDashlet', 'OpportunitiesByLeadSourceByOutcomeDashlet', 'OutcomeByMonthDashlet', 'PipelineBySalesStageDashlet', 'CampaignROIChartDashlet', 'MyOpportunitiesGaugeDashlet', 'MyForecastingChartDashlet', 'MyModulesUsedChartDashlet', 'MyTeamModulesUsedChartDashlet');
     $pageData = array();
     $chartsArray = array();
     $chartStyleCSS = SugarThemeRegistry::current()->getCSSURL('chart.css');
     $chartColorsXML = SugarThemeRegistry::current()->getImageURL('sugarColors.xml');
     $chartStringsXML = $sugar_config['tmp_dir'] . 'chart_strings.' . $current_language . '.lang.xml';
     require_once 'include/SugarCharts/SugarChartFactory.php';
     $sugarChart = SugarChartFactory::getInstance();
     if (!file_exists($chartStringsXML)) {
         $sugarChart->generateChartStrings($chartStringsXML);
     }
     $selectedPage = $_REQUEST['pageId'];
     $numCols = $pages[$selectedPage]['numColumns'];
     $trackerScript = '';
     $dashletScript = '';
     $trackerScriptArray = "<script>var trackerGridArray = [";
     $toggleHeaderToolsetScript = "";
     foreach ($pages[$selectedPage]['columns'] as $colNum => $column) {
         if ($colNum == $numCols) {
             break;
         }
         $display[$colNum]['width'] = $column['width'];
         $display[$colNum]['dashlets'] = array();
         foreach ($column['dashlets'] as $num => $id) {
             if (!empty($id) && isset($dashlets[$id]) && is_file($dashlets[$id]['fileLocation'])) {
                 // clint - fixes bug #20398
                 // only display dashlets that are from visibile modules and that the user has permission to list
                 $module = 'Home';
                 if (isset($dashletsFiles[$dashlets[$id]['className']]['module'])) {
                     $module = $dashletsFiles[$dashlets[$id]['className']]['module'];
                 }
                 $myDashlet = new MySugar($module);
                 if ($myDashlet->checkDashletDisplay()) {
                     require_once $dashlets[$id]['fileLocation'];
                     if ($dashlets[$id]['className'] == 'ChartsDashlet') {
                         $dashlet = new $dashlets[$id]['className']($id, $dashlets[$id]['reportId'], isset($dashlets[$id]['options']) ? $dashlets[$id]['options'] : array());
                         $chartsArray[$id] = array();
                         $chartsArray[$id]['id'] = $id;
                         $chartsArray[$id]['xmlFile'] = sugar_cached("xml/") . $dashlets[$id]['reportId'] . '_saved_chart.xml';
                         $chartsArray[$id]['width'] = '100%';
                         $chartsArray[$id]['height'] = '480';
                         $chartsArray[$id]['styleSheet'] = $chartStyleCSS;
                         $chartsArray[$id]['colorScheme'] = $chartColorsXML;
                         $chartsArray[$id]['langFile'] = $chartStringsXML;
                     } else {
                         $dashlet = new $dashlets[$id]['className']($id, isset($dashlets[$id]['options']) ? $dashlets[$id]['options'] : array());
                         if (in_array($dashlets[$id]['className'], $predefinedChartsList)) {
                             $chartsArray[$id] = array();
                             $chartsArray[$id]['id'] = $id;
                             $chartsArray[$id]['xmlFile'] = $sugarChart->getXMLFileName($id);
                             $chartsArray[$id]['width'] = '100%';
                             $chartsArray[$id]['height'] = '480';
                             $chartsArray[$id]['styleSheet'] = $chartStyleCSS;
                             $chartsArray[$id]['colorScheme'] = $chartColorsXML;
                             $chartsArray[$id]['langFile'] = $chartStringsXML;
                         }
                     }
                     // Need to add support to dynamically display/hide dashlets
                     // If it has a method 'shouldDisplay' we will call it to see if we should display it or not
                     if (method_exists($dashlet, 'shouldDisplay')) {
                         if (!$dashlet->shouldDisplay()) {
                             // This dashlet doesn't want us to show it, skip it.
                             continue;
                         }
                     }
                     array_push($dashletIds, $id);
                     try {
                         $dashlet->process();
                         $display[$colNum]['dashlets'][$id]['display'] = $dashlet->display();
                         $display[$colNum]['dashlets'][$id]['displayHeader'] = $dashlet->getHeader();
                         $display[$colNum]['dashlets'][$id]['displayFooter'] = $dashlet->getFooter();
                         if ($dashlet->hasScript) {
                             $dashletScript .= $dashlet->displayScript();
                         }
                         if ($dashlets[$id]['className'] == 'TrackerDashlet') {
                             $trackerScriptArray .= "'{$id}',";
                             $trackerScript = empty($trackerScript) ? $dashlet->displayScript() : $trackerScript;
                         }
                         $toggleHeaderToolsetScript .= "SUGAR.mySugar.attachToggleToolsetEvent('{$id}');";
                     } catch (Exception $ex) {
                         $display[$colNum]['dashlets'][$id]['display'] = $ex->getMessage();
                         $display[$colNum]['dashlets'][$id]['displayHeader'] = $dashlet->getHeader();
                         $display[$colNum]['dashlets'][$id]['displayFooter'] = $dashlet->getFooter();
                     }
                 }
             }
         }
     }
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('sugarVersion', $sugar_version);
     $sugar_smarty->assign('sugarFlavor', $sugar_flavor);
     $sugar_smarty->assign('currentLanguage', $GLOBALS['current_language']);
     $sugar_smarty->assign('serverUniqueKey', $GLOBALS['server_unique_key']);
     $sugar_smarty->assign('imagePath', $GLOBALS['image_path']);
     $sugar_smarty->assign('lblLnkHelp', $GLOBALS['app_strings']['LNK_HELP']);
     $sugar_smarty->assign('mod', return_module_language($current_language, 'Home'));
     $sugar_smarty->assign('app', $GLOBALS['app_strings']);
     $sugar_smarty->assign('maxCount', empty($sugar_config['max_dashboards']) ? 15 : $sugar_config['max_dashboards']);
     $sugar_smarty->assign('dashletCount', $count);
     $sugar_smarty->assign('columns', $display);
     $sugar_smarty->assign('selectedPage', $selectedPage);
     $sugar_smarty->assign('numCols', $numCols);
     if (!empty($sugar_config['lock_homepage']) && $sugar_config['lock_homepage'] == true) {
         $sugar_smarty->assign('lock_homepage', true);
     }
     $htmlOutput = $sugar_smarty->fetch('include/MySugar/tpls/retrievePage.tpl');
     $json = getJSONobj();
     $scriptResponse = array();
     $scriptResponse['dashletScript'] = $dashletScript;
     $scriptResponse['newDashletsToReg'] = $dashletIds;
     $scriptResponse['numCols'] = sizeof($pages[$selectedPage]['columns']);
     //custom chart code
     $scriptResponse['chartsArray'] = $chartsArray;
     $scriptResponse['trackerScript'] = $trackerScript . (strpos($trackerScriptArray, ',') ? substr($trackerScriptArray, 0, strlen($trackerScriptArray) - 1) . ']; </script>' : $trackerScriptArray . ']; </script>');
     $scriptResponse['toggleHeaderToolsetScript'] = "<script>" . $toggleHeaderToolsetScript . "</script>";
     $scriptOutput = 'var scriptResponse = ' . $json->encode($scriptResponse);
     return $json->encode(array('html' => $htmlOutput, 'script' => $scriptOutput));
 }
Beispiel #12
0
 private static function _loadCache($refresh = false)
 {
     if ($refresh || !is_file(sugar_cached('dashlets/dashlets.php'))) {
         require_once 'include/Dashlets/DashletCacheBuilder.php';
         $dc = new DashletCacheBuilder();
         $dc->buildCache();
     }
     $dashletsFiles = array();
     require_once sugar_cached('dashlets/dashlets.php');
     DashletManager::$dashletCache = $dashletsFiles;
 }