Example #1
0
/**
 * Enables the simple cache.
 * 
 * @see elgg_view_register_simplecache
 *
 */
function elgg_view_enable_simplecache()
{
    global $CONFIG;
    if (!$CONFIG->simplecache_enabled) {
        datalist_set('simplecache_enabled', 1);
        $CONFIG->simplecache_enabled = 1;
        elgg_view_regenerate_simplecache();
    }
}
Example #2
0
    header("Location: install.php");
    exit;
}
// Trigger events
if (!substr_count($_SERVER["PHP_SELF"], "install.php") && !substr_count($_SERVER["PHP_SELF"], "setup.php") && !$lightmode && !(defined('upgrading') && upgrading == 'upgrading')) {
    // If default settings haven't been installed, forward to the default settings page
    trigger_elgg_event('init', 'system');
    //if (!datalist_get('default_settings')) {
    //forward("setup.php");
    //}
}
// System booted, return to normal view
set_input('view', $oldview);
if (empty($oldview)) {
    if (empty($CONFIG->view)) {
        $oldview = 'default';
    } else {
        $oldview = $CONFIG->view;
    }
}
if ($installed && $db_installed) {
    $lastupdate = datalist_get('simplecache_lastupdate');
    $lastcached = datalist_get('simplecache_' . $oldview);
    if ($lastupdate == 0 || $lastcached < $lastupdate) {
        elgg_view_regenerate_simplecache();
        $lastcached = time();
        datalist_set('simplecache_lastupdate', $lastcached);
        datalist_set('simplecache_' . $oldview, $lastcached);
    }
    $CONFIG->lastcache = $lastcached;
}
/**
 * Regenerates the list of known plugins and saves it to the current site
 * 
 * Important: You should regenerate simplecache and the viewpath cache after executing this function
 * otherwise you may experience view display artifacts. Do this with the following code:
 * 
 * 		elgg_view_regenerate_simplecache();
 *		elgg_filepath_cache_reset();
 *
 * @param array $pluginorder Optionally, a list of existing plugins and their orders
 * @return array The new list of plugins and their orders
 */
function regenerate_plugin_list($pluginorder = false)
{
    global $CONFIG;
    $CONFIG->pluginlistcache = null;
    if ($site = get_entity($CONFIG->site_guid)) {
        if (empty($pluginorder)) {
            $pluginorder = $site->pluginorder;
            $pluginorder = unserialize($pluginorder);
        } else {
            ksort($pluginorder);
        }
        if (empty($pluginorder)) {
            $pluginorder = array();
        }
        $max = 0;
        if (sizeof($pluginorder)) {
            foreach ($pluginorder as $key => $plugin) {
                if (is_dir($CONFIG->pluginspath . "/" . $plugin)) {
                    if ($key > $max) {
                        $max = $key;
                    }
                } else {
                    unset($pluginorder[$key]);
                }
            }
        }
        // Add new plugins to the end
        if ($handle = opendir($CONFIG->pluginspath)) {
            while ($mod = readdir($handle)) {
                if (!in_array($mod, array('.', '..', '.svn', 'CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
                    if (!in_array($mod, $pluginorder)) {
                        $max = $max + 10;
                        $pluginorder[$max] = $mod;
                    }
                }
            }
        }
        ksort($pluginorder);
        // Now reorder the keys ..
        $key = 10;
        $plugins = array();
        if (sizeof($pluginorder)) {
            foreach ($pluginorder as $plugin) {
                $plugins[$key] = $plugin;
                $key = $key + 10;
            }
        }
        $plugins = serialize($plugins);
        $site->pluginorder = $plugins;
        // Regenerate caches
        elgg_view_regenerate_simplecache();
        elgg_filepath_cache_reset();
        return $plugins;
    }
    return false;
}