Example #1
0
 /**
  * initializes the cache in question
  */
 protected static function _init()
 {
     $lastPriority = 1000;
     $locations = array('include/SugarCache', 'custom/include/SugarCache');
     foreach ($locations as $location) {
         if (sugar_is_dir($location) && ($dir = opendir($location))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || !is_file("{$location}/{$file}")) {
                     continue;
                 }
                 require_once "{$location}/{$file}";
                 $cacheClass = basename($file, ".php");
                 if (class_exists($cacheClass) && is_subclass_of($cacheClass, 'SugarCacheAbstract')) {
                     $GLOBALS['log']->debug("Found cache backend {$cacheClass}");
                     $cacheInstance = new $cacheClass();
                     if ($cacheInstance->useBackend() && $cacheInstance->getPriority() < $lastPriority) {
                         $GLOBALS['log']->debug("Using cache backend {$cacheClass}, since " . $cacheInstance->getPriority() . " is less than " . $lastPriority);
                         self::$_cacheInstance = $cacheInstance;
                         $lastPriority = $cacheInstance->getPriority();
                     }
                 }
             }
         }
     }
 }
Example #2
0
/**
 * sugar_mkdir
 * Call this function instead of mkdir to apply preconfigured permission
 * settings when creating the directory.  This method is basically
 * a wrapper to the PHP mkdir function except that it supports setting
 * the mode value by using the configuration file (if set).  The mode is
 * 0777 by default.
 *
 * @param $pathname - String value of the directory to create
 * @param $mode - The integer value of the permissions mode to set the created directory to
 * @param $recursive - boolean value indicating whether or not to create recursive directories if needed
 * @param $context
 * @return boolean - Returns true on success false on failure
 */
function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '')
{
    $mode = get_mode('dir_mode', $mode);
    if (sugar_is_dir($pathname, $mode)) {
        return true;
    }
    $result = false;
    if (empty($mode)) {
        $mode = 0777;
    }
    if (empty($context)) {
        $result = @mkdir($pathname, $mode, $recursive);
    } else {
        $result = @mkdir($pathname, $mode, $recursive, $context);
    }
    if ($result) {
        if (!sugar_chmod($pathname, $mode)) {
            return false;
        }
        if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
            if (!sugar_chown($pathname)) {
                return false;
            }
        }
        if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
            if (!sugar_chgrp($pathname)) {
                return false;
            }
        }
    } else {
        $GLOBALS['log']->error("Cannot create directory {$pathname} cannot be touched");
    }
    return $result;
}
Example #3
0
 /**
  * Scan Smarty plugins directories and relocate custom plugins to correct location
  */
 public function replaceCustomSmartyPlugins()
 {
     // Step 1: scan vendor/Smarty/plugin directory to get a list of system plugins
     $vendorSmartyPluginsList = array();
     $vendorSmartyPluginsPath = 'vendor/Smarty/plugins/';
     $failedToCopySmartyPluginsList = array();
     $customSmartyPluginsPaths = array('include/Smarty/plugins/', 'custom/include/Smarty/plugins/');
     $includeSmartyPluginsPath = 'include/SugarSmarty/plugins/';
     $correctCustomSmartyPluginsPath = 'custom/include/SugarSmarty/plugins/';
     if (is_dir($vendorSmartyPluginsPath)) {
         $iter = new FilesystemIterator($vendorSmartyPluginsPath, FilesystemIterator::UNIX_PATHS);
         foreach ($iter as $item) {
             if ($item->getFileName() == '.' || $item->getFileName() == '..' || $item->isDir() || $item->getExtension() != 'php') {
                 continue;
             }
             $filename = $item->getFilename();
             $vendorSmartyPluginsList[] = $filename;
         }
     }
     // Step 2: scan custom plugin directories and relocate ONLY custom plugins to correct location
     foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) {
         if (is_dir($customSmartyPluginsPath)) {
             $iter = new FilesystemIterator($customSmartyPluginsPath, FilesystemIterator::UNIX_PATHS);
             foreach ($iter as $item) {
                 if ($item->getFilename() == '.' || $item->getFilename() == '..' || $item->isDir() || $item->getExtension() != 'php') {
                     continue;
                 }
                 $file = $item->getPathname();
                 if (!in_array($item->getFilename(), $vendorSmartyPluginsList) && !is_file($includeSmartyPluginsPath . $item->getFilename())) {
                     $this->log("Copy custom plugin {$file} to {$correctCustomSmartyPluginsPath}");
                     if (!sugar_is_dir($correctCustomSmartyPluginsPath)) {
                         mkdir_recursive($correctCustomSmartyPluginsPath);
                     }
                     if (copy_recursive($file, $correctCustomSmartyPluginsPath . $item->getFilename())) {
                         $this->upgrader->fileToDelete($file);
                     } else {
                         $failedToCopySmartyPluginsList[] = $file;
                     }
                 }
             }
         }
     }
     //Step 3: remove all files from custom Smarty plugins destinations except the {$correctCustomSmartyPluginsPath}
     if (empty($failedToCopySmartyPluginsList)) {
         foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) {
             if (is_dir($customSmartyPluginsPath)) {
                 $this->log("Path {$customSmartyPluginsPath} is deleted from custom plugins directory due to a relocation of vendors");
                 rmdir_recursive($customSmartyPluginsPath);
             }
         }
     } else {
         foreach ($failedToCopySmartyPluginsList as $failedToCopySmartyPluginsItem) {
             $this->log("File {$failedToCopySmartyPluginsItem} cannot be copied to new location automatically");
         }
     }
 }
Example #4
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;
}
Example #5
0
function refresh_price_formulas()
{
    $GLOBALS['price_formulas'] = array('Fixed' => 'modules/ProductTemplates/formulas/price_fixed.php', 'ProfitMargin' => 'modules/ProductTemplates/formulas/price_profit_margin.php', 'PercentageMarkup' => 'modules/ProductTemplates/formulas/price_cost_markup.php', 'PercentageDiscount' => 'modules/ProductTemplates/formulas/price_list_discount.php', 'IsList' => 'modules/ProductTemplates/formulas/price_list.php');
    // FG - Bug 44515 - Added inclusion of all .php formula files in custom/modules/ProductTemplates/formulas (if exists).
    //                  Every file must contain a class whose name must equals the file name (without extension) all lowercase except the first letter, uppercase.
    //                  Here devs can add classes for custom formulas - The Upgrade Safe Way
    if (sugar_is_dir("custom/modules/ProductTemplates/formulas")) {
        $_files = glob("custom/modules/ProductTemplates/formulas/*.php");
        foreach ($_files as $filename) {
            $_formulaId = ucfirst(basename(strtolower($filename), ".php"));
            $GLOBALS['price_formulas'][$_formulaId] = $filename;
        }
    }
}
Example #6
0
/**
 * sugar_mkdir
 * Call this function instead of mkdir to apply preconfigured permission
 * settings when creating the directory.  This method is basically
 * a wrapper to the PHP mkdir function except that it supports setting
 * the mode value by using the configuration file (if set).  The mode is
 * 0777 by default.
 *
 * @param $pathname - String value of the directory to create
 * @param $mode - The integer value of the permissions mode to set the created directory to
 * @param $recursive - boolean value indicating whether or not to create recursive directories if needed
 * @param $context
 * @return boolean - Returns true on success false on failure
 */
function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '')
{
    $mode = get_mode('dir_mode', $mode);
    if (sugar_is_dir($pathname, $mode)) {
        return true;
    }
    $result = false;
    if (empty($mode)) {
        $mode = 0777;
    }
    if (empty($context)) {
        $result = @mkdir($pathname, $mode, $recursive);
    } else {
        $result = @mkdir($pathname, $mode, $recursive, $context);
    }
    if ($result) {
        if (!sugar_chmod($pathname, $mode)) {
            return false;
        }
        if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
            if (!sugar_chown($pathname)) {
                return false;
            }
        }
        if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
            if (!sugar_chgrp($pathname)) {
                return false;
            }
        }
    } else {
        $errorMessage = "Cannot create directory {$pathname} cannot be touched";
        if (is_null($GLOBALS['log'])) {
            throw new Exception("Error occurred but the system doesn't have logger. Error message: \"{$errorMessage}\"");
        }
        $GLOBALS['log']->error($errorMessage);
    }
    return $result;
}
Example #7
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;
}
Example #8
0
 /**
  * function to save XML contents into a file
  *
  * @param 	string $xmlFilename location of the xml file
  *			string $xmlContents contents of the xml file
  * @return	string boolean denoting whether save has failed
  */
 function saveXMLFile($xmlFilename, $xmlContents)
 {
     global $app_strings;
     global $locale;
     $xmlContents = chr(255) . chr(254) . $GLOBALS['locale']->translateCharset($xmlContents, 'UTF-8', 'UTF-16LE');
     // Create dir if it doesn't exist
     $dir = dirname($xmlFilename);
     if (!sugar_is_dir($dir)) {
         sugar_mkdir($dir, null, true);
     }
     // open file
     if (!($fh = sugar_fopen($xmlFilename, 'w'))) {
         $GLOBALS['log']->debug("Cannot open file ({$xmlFilename})");
         return;
     }
     // write the contents to the file
     if (fwrite($fh, $xmlContents) === FALSE) {
         $GLOBALS['log']->debug("Cannot write to file ({$xmlFilename})");
         return false;
     }
     $GLOBALS['log']->debug("Success, wrote ({$xmlContents}) to file ({$xmlFilename})");
     fclose($fh);
     return true;
 }
Example #9
0
 function copy_path($from, $to, $backup_path = '', $uninstall = false)
 {
     //function copy_path($from, $to){
     /* END - RESTORE POINT - by MR. MILK August 31, 2005 02:22:18 PM */
     $to = str_replace('<basepath>', $this->base_dir, $to);
     if (!$uninstall) {
         $from = str_replace('<basepath>', $this->base_dir, $from);
         $GLOBALS['log']->debug('Copy ' . $from);
     } else {
         $from = str_replace('<basepath>', $backup_path, $from);
         //$GLOBALS['log']->debug('Restore ' . $from);
     }
     $from = clean_path($from);
     $to = clean_path($to);
     $dir = dirname($to);
     //there are cases where if we need to create a directory in the root directory
     if ($dir == '.' && is_dir($from)) {
         $dir = $to;
     }
     if (!sugar_is_dir($dir, 'instance')) {
         mkdir_recursive($dir, true);
     }
     /* BEGIN - RESTORE POINT - by MR. MILK August 31, 2005 02:22:18 PM */
     if (empty($backup_path)) {
         /* END - RESTORE POINT - by MR. MILK August 31, 2005 02:22:18 PM */
         if (!copy_recursive($from, $to)) {
             die('Failed to copy ' . $from . ' ' . $to);
         }
         /* BEGIN - RESTORE POINT - by MR. MILK August 31, 2005 02:22:18 PM */
     } elseif (!$this->copy_recursive_with_backup($from, $to, $backup_path, $uninstall)) {
         die('Failed to copy ' . $from . ' to ' . $to);
     }
     /* END - RESTORE POINT - by MR. MILK August 31, 2005 02:22:18 PM */
 }
Example #10
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());
         }
     }
 }
Example #11
0
 /**
  * Moves file to deleted folder
  *
  * @return bool success of movement
  */
 public function deleteFiles()
 {
     if (!$this->id) {
         return true;
     }
     if (!$this->haveFiles()) {
         return true;
     }
     $files = $this->getFiles();
     if (empty($files)) {
         return true;
     }
     $directory = $this->deleteFileDirectory();
     $isCreated = sugar_is_dir('upload://deleted/' . $directory);
     if (!$isCreated) {
         sugar_mkdir('upload://deleted/' . $directory, 0777, true);
         $isCreated = sugar_is_dir('upload://deleted/' . $directory);
     }
     if (!$isCreated) {
         return false;
     }
     foreach ($files as $file) {
         if (file_exists('upload://' . $file)) {
             if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) {
                 $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory');
             }
         }
     }
     /**
      * @var DBManager $db
      */
     global $db;
     $record = array('bean_id' => $db->quoted($this->id), 'module' => $db->quoted($this->module_name), 'date_modified' => $db->convert($db->quoted(date('Y-m-d H:i:s')), 'datetime'));
     $recordDB = $db->fetchOne("SELECT id FROM cron_remove_documents WHERE module={$record['module']} AND bean_id={$record['bean_id']}");
     if (!empty($recordDB)) {
         $record['id'] = $db->quoted($recordDB['id']);
     }
     if (empty($record['id'])) {
         $record['id'] = $db->quoted(create_guid());
         $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')');
     } else {
         $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}");
     }
     return true;
 }
 /**
  * @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');
 }
Example #13
0
 /**
  * Returns the URL for the css file in the current theme. If not found in the current theme, will revert
  * to looking in the base theme.
  *
  * @param  string $cssFileName css file name
  * @param  bool   $returnURL if true, returns URL with unique image mark, otherwise returns path to the file
  * @return string path of css file to include
  */
 public function getCSSURL($cssFileName, $returnURL = true)
 {
     if (isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName]))) {
         if ($returnURL) {
             return getJSPath("cache/" . $this->_cssCache[$cssFileName]);
         } else {
             return sugar_cached($this->_cssCache[$cssFileName]);
         }
     }
     $cssFileContents = '';
     $defaultFileName = $this->getDefaultCSSPath() . '/' . $cssFileName;
     $fullFileName = $this->getCSSPath() . '/' . $cssFileName;
     if (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName, false)) != '') {
         $cssFileContents .= file_get_contents($filename);
     } else {
         foreach (SugarAutoLoader::existingCustom($defaultFileName) as $cssFile) {
             $cssFileContents .= file_get_contents($cssFile);
         }
     }
     foreach (SugarAutoLoader::existingCustom($fullFileName) as $cssFile) {
         $cssFileContents .= file_get_contents($cssFile);
     }
     if (empty($cssFileContents)) {
         $GLOBALS['log']->warn("CSS File {$cssFileName} not found");
         return false;
     }
     // fix any image references that may be defined in css files
     $cssFileContents = str_ireplace("entryPoint=getImage&", "entryPoint=getImage&themeName={$this->dirName}&", $cssFileContents);
     // create the cached file location
     $cssFilePath = create_cache_directory($fullFileName);
     // if this is the style.css file, prepend the base.css and calendar-win2k-cold-1.css
     // files before the theme styles
     if ($cssFileName == 'style.css' && !isset($this->parentTheme)) {
         if (inDeveloperMode()) {
             $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents;
         } else {
             $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents;
         }
     }
     // minify the css
     if (!inDeveloperMode() && !sugar_is_file($cssFilePath)) {
         $cssFileContents = cssmin::minify($cssFileContents);
     }
     // now write the css to cache
     sugar_file_put_contents($cssFilePath, $cssFileContents);
     // make sure that there is the font folder in the cache for the given theme
     $path = sugar_cached($this->getFilePath() . '/font');
     if (!sugar_is_dir($path)) {
         sugar_mkdir($path, null, true);
         $defaultPath = $this->getDefaultFontPath();
         foreach (glob($defaultPath . "/*") as $filename) {
             $name = substr($filename, strrpos($filename, '/'));
             sugar_file_put_contents($path . $name, sugar_file_get_contents($filename));
         }
     }
     $this->_cssCache[$cssFileName] = $fullFileName;
     if ($returnURL) {
         return getJSPath("cache/" . $fullFileName);
     }
     return sugar_cached($fullFileName);
 }
Example #14
0
 /**
  * Finds all the available loggers in the application
  */
 protected function _findAvailableLoggers()
 {
     $locations = array('include/SugarLogger', 'custom/include/SugarLogger');
     foreach ($locations as $location) {
         if (sugar_is_dir($location) && ($dir = opendir($location))) {
             while (($file = readdir($dir)) !== false) {
                 if ($file == ".." || $file == "." || $file == "LoggerTemplate.php" || $file == "LoggerManager.php" || !is_file("{$location}/{$file}")) {
                     continue;
                 }
                 require_once "{$location}/{$file}";
                 $loggerClass = basename($file, ".php");
                 if (class_exists($loggerClass) && class_implements($loggerClass, 'LoggerTemplate')) {
                     self::$_loggers[$loggerClass] = new $loggerClass();
                 }
             }
         }
     }
 }
 /**
  * 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']);
 }
Example #16
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');
 }