Example #1
0
 /**
  * Get addon list for super admin
  *
  * @return Object
  */
 function getAddonListForSuperAdmin()
 {
     $addonList = $this->getAddonList(0, 'site');
     $oAutoinstallModel = getModel('autoinstall');
     foreach ($addonList as $key => $addon) {
         // check blacklist
         $addonList[$key]->isBlacklisted = Context::isBlacklistedPlugin($addon->addon);
         // get easyinstall remove url
         $packageSrl = $oAutoinstallModel->getPackageSrlByPath($addon->path);
         $addonList[$key]->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl);
         // get easyinstall need update
         if ($addonList[$key]->isBlacklisted) {
             $addonList[$key]->need_update = 'N';
         } else {
             $package = $oAutoinstallModel->getInstalledPackages($packageSrl);
             $addonList[$key]->need_update = $package[$packageSrl]->need_update;
         }
         // get easyinstall update url
         if ($addonList[$key]->need_update == 'Y') {
             $addonList[$key]->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
         }
     }
     return $addonList;
 }
Example #2
0
 /**
  * call a trigger
  * @param string $trigger_name trigger's name to call
  * @param string $called_position called position
  * @param object $obj an object as a parameter to trigger
  * @return Object
  * */
 public static function triggerCall($trigger_name, $called_position, &$obj)
 {
     // skip if not installed
     if (!Context::isInstalled()) {
         return new Object();
     }
     $oModuleModel = getModel('module');
     $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
     if (!$triggers) {
         $triggers = array();
     }
     //store before trigger call time
     $before_trigger_time = microtime(true);
     foreach ($triggers as $item) {
         $module = $item->module;
         $type = $item->type;
         $called_method = $item->called_method;
         // todo why don't we call a normal class object ?
         $oModule = getModule($module, $type);
         if (!$oModule || !method_exists($oModule, $called_method)) {
             continue;
         }
         // do not call if module is blacklisted
         if (Context::isBlacklistedPlugin($oModule->module)) {
             continue;
         }
         $before_each_trigger_time = microtime(true);
         $output = $oModule->{$called_method}($obj);
         $after_each_trigger_time = microtime(true);
         if ($trigger_name !== 'common.flushDebugInfo') {
             $trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method;
             Rhymix\Framework\Debug::addTrigger(array('name' => $trigger_name . '.' . $called_position, 'target' => $trigger_target, 'target_plugin' => $module, 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time));
         }
         if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) {
             return $output;
         }
         unset($oModule);
     }
     $trigger_functions = $oModuleModel->getTriggerFunctions($trigger_name, $called_position);
     foreach ($trigger_functions as $item) {
         $before_each_trigger_time = microtime(true);
         $output = $item($obj);
         $after_each_trigger_time = microtime(true);
         if ($trigger_name !== 'common.writeSlowlog') {
             if (is_string($item)) {
                 $trigger_target = $item;
             } elseif (is_array($item) && count($item)) {
                 if (is_object($item[0])) {
                     $trigger_target = get_class($item[0]) . '.' . strval($item[1]);
                 } else {
                     $trigger_target = implode('.', $item);
                 }
             } else {
                 $trigger_target = 'closure';
             }
             Rhymix\Framework\Debug::addTrigger(array('name' => $trigger_name . '.' . $called_position, 'target' => $trigger_target, 'target_plugin' => null, 'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time));
         }
         if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) {
             return $output;
         }
     }
     return new Object();
 }
Example #3
0
 /**
  * @brief Get a type and information of the module
  */
 function getModuleList()
 {
     // Create DB Object
     $oDB =& DB::getInstance();
     // Get a list of downloaded and installed modules
     $searched_list = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/');
     sort($searched_list);
     $searched_count = count($searched_list);
     if (!$searched_count) {
         return;
     }
     for ($i = 0; $i < $searched_count; $i++) {
         // module name
         $module_name = $searched_list[$i];
         $path = ModuleHandler::getModulePath($module_name);
         if (!is_dir(FileHandler::getRealPath($path))) {
             continue;
         }
         // Get the number of xml files to create a table in schemas
         $tmp_files = FileHandler::readDir($path . 'schemas', '/(\\.xml)$/');
         $table_count = count($tmp_files);
         // Check if the table is created
         $created_table_count = 0;
         for ($j = 0; $j < $table_count; $j++) {
             list($table_name) = explode('.', $tmp_files[$j]);
             if ($oDB->isTableExists($table_name)) {
                 $created_table_count++;
             }
         }
         // Get information of the module
         $info = NULL;
         $info = $this->getModuleInfoXml($module_name);
         if (!$info) {
             continue;
         }
         $info->module = $module_name;
         $info->category = $info->category;
         $info->created_table_count = $created_table_count;
         $info->table_count = $table_count;
         $info->path = $path;
         $info->admin_index_act = $info->admin_index_act;
         if (!Context::isBlacklistedPlugin($module_name)) {
             // Check if DB is installed
             if ($table_count > $created_table_count) {
                 $info->need_install = true;
             } else {
                 $info->need_install = false;
             }
             // Check if it is upgraded to module.class.php on each module
             $oDummy = null;
             $oDummy = getModule($module_name, 'class');
             if ($oDummy && method_exists($oDummy, "checkUpdate")) {
                 $info->need_update = $oDummy->checkUpdate();
             } else {
                 continue;
             }
         }
         $list[] = $info;
     }
     return $list;
 }
Example #4
0
 /**
  * Re-generate the cache file
  *
  * @param int $site_srl Site srl
  * @param string $type pc or mobile
  * @param string $gtype site or global
  * @return void
  */
 function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site')
 {
     // Add-on module for use in creating the cache file
     $buff = array('<?php if(!defined("__XE__")) exit();', '$_m = Context::get(\'mid\');');
     $oAddonModel = getAdminModel('addon');
     $addon_list = $oAddonModel->getInsertedAddons($site_srl, $gtype);
     foreach ($addon_list as $addon => $val) {
         if (Context::isBlacklistedPlugin($addon) || $type == "pc" && $val->is_used != 'Y' || $type == "mobile" && $val->is_used_m != 'Y' || $gtype == 'global' && $val->is_fixed != 'Y' || !is_dir(RX_BASEDIR . 'addons/' . $addon)) {
             continue;
         }
         $extra_vars = unserialize($val->extra_vars);
         if (!$extra_vars) {
             $extra_vars = new stdClass();
         }
         $mid_list = $extra_vars->mid_list;
         if (!is_array($mid_list)) {
             $mid_list = array();
         }
         // Initialize
         $buff[] = '$before_time = microtime(true);';
         // Run method and mid list
         $run_method = $extra_vars->xe_run_method ?: 'run_selected';
         $buff[] = '$rm = \'' . $run_method . "';";
         $buff[] = '$ml = ' . var_export(array_fill_keys($mid_list, true), true) . ';';
         // Addon filename
         $buff[] = sprintf('$addon_file = RX_BASEDIR . \'addons/%s/%s.addon.php\';', $addon, $addon);
         // Addon configuration
         $buff[] = '$addon_info = unserialize(' . var_export(serialize($extra_vars), true) . ');';
         // Decide whether to run in this mid
         if ($run_method === 'no_run_selected') {
             $buff[] = '$run = !isset($ml[$_m]);';
         } elseif (!count($mid_list)) {
             $buff[] = '$run = true;';
         } else {
             $buff[] = '$run = isset($ml[$_m]);';
         }
         // Write debug info
         $buff[] = 'if ($run && file_exists($addon_file)):';
         $buff[] = '  include($addon_file);';
         $buff[] = '  $after_time = microtime(true);';
         $buff[] = '  if (class_exists("Rhymix\\\\Framework\\\\Debug")):';
         $buff[] = '    Rhymix\\Framework\\Debug::addTrigger(array(';
         $buff[] = '      "name" => "addon." . $called_position,';
         $buff[] = '      "target" => "' . $addon . '",';
         $buff[] = '      "target_plugin" => "' . $addon . '",';
         $buff[] = '      "elapsed_time" => $after_time - $before_time,';
         $buff[] = '    ));';
         $buff[] = '  endif;';
         $buff[] = 'endif;';
         $buff[] = '';
     }
     // Write file in new location
     $addon_path = RX_BASEDIR . 'files/cache/addons/';
     $addon_file = $addon_path . 'addons.' . ($gtype == 'site' ? intval($site_srl) : 'G') . '.' . $type . '.php';
     FileHandler::writeFile($addon_file, join(PHP_EOL, $buff));
     // Remove file from old location
     $old_addon_file = $addon_path . ($gtype == 'site' ? $site_srl : '') . $type . '.acivated_addons.cache.php';
     if (file_exists($old_addon_file)) {
         FileHandler::removeFile($old_addon_file);
     }
 }