Exemplo n.º 1
0
 /**
  * Detects when settings has changed and if the permalink
  * feature is activated.
  *
  * @param string $dirname <p>Module dirname</p>
  * @param array $save <p>Settings options saved with values</p>
  * @param array $add <p>Settings options added with values</p>
  * @param array $delete <p>Settings options deleted from database table</p>
  * @return string
  */
 public function eventRmcommonSavedSettings($dirname, $save, $add, $delete)
 {
     if ($dirname != 'rmcommon') {
         return $dirname;
     }
     $base = parse_url(XOOPS_URL . '/');
     $base = isset($base['path']) ? rtrim($base['path'], '/') . '/' : '/';
     $rules = "ErrorDocument 404 " . $base . "modules/rmcommon/404.php\n";
     foreach ($save['modules_path'] as $mod => $path) {
         $path = ltrim($path, "/");
         $rules .= "RewriteRule ^{$path}/?(.*)\$ modules/{$mod}/index.php/\$1 [L]\n";
         $rules .= "RewriteRule ^admin/{$path}/?(.*)\$ modules/{$mod}/admin/index.php/\$2 [L]\n";
     }
     if ($save['permalinks'] == 0) {
         $ht = new RMHtaccess('rmcommon');
         $htResult = $ht->removeRule();
         if ($htResult !== true) {
             showMessage(__('An error ocurred while trying to delete .htaccess rules!', 'rmcommon') . '<br>' . __('Please delete lines starting with <code># begin rmcommon</code> and ending with <code># end rmcommon</code>', 'rmcommon'), RMMSG_ERROR);
         }
         return $dirname;
     }
     $rules .= "RewriteRule ^rss/?(.*)\$ modules/rmcommon/rss.php\$1 [L]\n";
     $ht = new RMHtaccess('rmcommon');
     $htResult = $ht->write($rules);
     if ($htResult !== true) {
         showMessage(__('An error ocurred while trying to write .htaccess file!', 'rmcommon') . '<br>' . __('Please try to add manually next lines:', 'rmcommon') . '<br><code>' . nl2br($rules) . '</code>', RMMSG_ERROR);
     }
     RMSettings::write_rewrite_js($save['modules_path']);
     return null;
 }
Exemplo n.º 2
0
if ($cuSettings->updates && isset($xoopsOption['pagetype']) && $xoopsOption['pagetype'] == 'admin') {
    $interval = $cuSettings->updatesinterval <= 0 ? 7 : $cuSettings->updatesinterval;
    if (file_exists(XOOPS_CACHE_PATH . '/updates.chk')) {
        $updates = unserialize(base64_decode(file_get_contents(XOOPS_CACHE_PATH . '/updates.chk')));
    } else {
        $updates = array('date' => 0, 'total' => 0, 'updates' => array());
    }
    $rmTpl->add_script('updates.js', 'rmcommon', array('footer' => 1));
    if ($updates['date'] < time() - $cuSettings->updatesinterval * 86400) {
        $rmTpl->add_inline_script('(function(){rmCheckUpdates();})();', 1);
        define('RMC_CHECK_UPDATES', 1);
    } else {
        $rmTpl->add_inline_script('$(document).ready(function(){rmCallNotifier(' . $updates['total'] . ');});', 1);
    }
}
/**
 * Add ajax controller script
 */
if (defined("XOOPS_CPFUNC_LOADED") || isset($xoopsOption) && array_key_exists('pagetype', $xoopsOption) && $xoopsOption['pagetype'] == 'admin') {
    $rmTpl->add_script('cu-handler.js', 'rmcommon', array('footer' => 1, 'id' => 'cuhandler'));
    $rmTpl->add_script('jquery.validate.min.js', 'rmcommon', array('footer' => 1));
}
// Services Manager
$cuServices = Common\Core\Helpers\Services::getInstance();
$GLOBALS['cuServices'] = $cuServices;
// Icons manager
$cuIcons = Common\Core\Helpers\Icons::getInstance();
$GLOBALS['cuIcons'] = $cuIcons;
// Rewrite for JS
RMSettings::write_rewrite_js();
include_once RMCPATH . '/include/tpl_functions.php';