Example #1
0
/**
 * Listen to the saving of plugin settings, if the plugin is this plugin invalidate simplecache
 * 
 * @param string $hook        'action'
 * @param string $type        'plugins/settings/save'
 * @param bool   $returnvalue false to stop the action
 * @param null   $params      null
 * 
 * @return void
 */
function ckeditor_extended_plugins_settings_save_action_hook($hook, $type, $returnvalue, $params)
{
    $plugin_id = get_input("plugin_id");
    if ($plugin_id === "ckeditor_extended") {
        elgg_invalidate_simplecache();
    }
}
Example #2
0
/**
 * Listen to the saving of plugin settings, if the plugin is this plugin invalidate simplecache
 *
 * @param string $hook 'action'
 * @param string $type 'plugins/settings/save'
 * @param bool $returnvalue false to stop the action
 * @param null $params null
 *
 * @return void
 */
function target_blank_plugins_settings_save_action_hook($hook, $type, $returnvalue, $params)
{
    $plugin_id = get_input("plugin_id");
    if ($plugin_id === "target_blank") {
        elgg_invalidate_simplecache();
    }
}
Example #3
0
 /**
  * Flushes simple cache after saving the settings
  *
  * @param string $hook        hook name
  * @param string $entity_type hook type
  * @param bool   $returnvalue current return value
  * @param array  $params      parameters
  *
  * @return bool
  */
 public static function clearCache($hook, $entity_type, $returnvalue, $params)
 {
     $plugin = elgg_extract('plugin', $params);
     if (empty($plugin)) {
         return;
     }
     if ($plugin->getID() !== 'event_manager') {
         return;
     }
     elgg_invalidate_simplecache();
 }
Example #4
0
function rijkshuisstijl_plugins_settings_save($hook, $type, $value, $params)
{
    if (get_input('plugin_id') !== "rijkshuisstijl") {
        return;
    }
    $params = get_input('params');
    $params['colors'] = serialize($params['colors']);
    $params['footer'] = serialize($params['footer']);
    set_input('params', $params);
    // re-render CSS (less)
    elgg_invalidate_simplecache();
}
Example #5
0
function subsite_manager_fix_piwik_settings()
{
    global $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS;
    if (subsite_manager_on_subsite()) {
        $site = elgg_get_site_entity();
        if ($piwik_settings = $site->phloor_analytics_piwik_settings) {
            $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS = true;
            if ($site->canEdit()) {
                // log to the error log that we did something
                error_log("PIWIK saving settings for " . $site->name . " (" . $site->getGUID() . ")");
                error_log("PIWIK settings: " . $piwik_settings);
                if ($piwik_settings = json_decode($piwik_settings, true)) {
                    if (!empty($piwik_settings) && is_array($piwik_settings)) {
                        $enabled = elgg_extract("enable_tracking", $piwik_settings);
                        $piwik_url = elgg_extract("path_to_piwik", $piwik_settings);
                        $piwik_site_id = elgg_extract("site_guid", $piwik_settings);
                        if ($enabled == "true") {
                            if (!empty($piwik_url) && !empty($piwik_site_id)) {
                                // check if analytics is enabled
                                if (!elgg_is_active_plugin("analytics")) {
                                    // not active so enable
                                    if ($plugin = elgg_get_plugin_from_id("analytics")) {
                                        $plugin->activate();
                                        elgg_invalidate_simplecache();
                                        elgg_reset_system_cache();
                                    }
                                }
                                // save settings, if not exists
                                if (!elgg_get_plugin_setting("piwik_url", "analytics") && !elgg_get_plugin_setting("piwik_site_id", "analytics")) {
                                    elgg_set_plugin_setting("piwik_url", $piwik_url, "analytics");
                                    elgg_set_plugin_setting("piwik_site_id", $piwik_site_id, "analytics");
                                }
                            }
                        }
                    }
                }
                // remove the settings so we don't do this again
                unset($site->phloor_analytics_piwik_settings);
            }
            // unset write access
            $SUBSITE_MANAGER_IGNORE_WRITE_ACCESS = false;
        }
    }
}
Example #6
0
 /**
  * Run the upgrade process
  *
  * @return array
  */
 public function run()
 {
     $result = array('failure' => false, 'reason' => '');
     // prevent someone from running the upgrade script in parallel (see #4643)
     if (!$this->getUpgradeMutex()) {
         $result['failure'] = true;
         $result['reason'] = _elgg_services()->translator->translate('upgrade:locked');
         return $result;
     }
     // disable the system log for upgrades to avoid exceptions when the schema changes.
     _elgg_services()->events->unregisterHandler('log', 'systemlog', 'system_log_default_logger');
     _elgg_services()->events->unregisterHandler('all', 'all', 'system_log_listener');
     // turn off time limit
     set_time_limit(0);
     if ($this->getUnprocessedUpgrades()) {
         $this->processUpgrades();
     }
     _elgg_services()->events->trigger('upgrade', 'system', null);
     elgg_invalidate_simplecache();
     elgg_reset_system_cache();
     $this->releaseUpgradeMutex();
     return $result;
 }
Example #7
0
/**
 * Sync the plugins for a specific subsite
 *
 * @param ElggSite   $subsite
 *
 * @return array ($sorted, $activated)  number of sorted and activated plugins.
 */
function subsite_manager_sync_plugins(Subsite $subsite)
{
    $main_site = elgg_get_config('site');
    $plugins_by_id_map = elgg_get_config('plugins_by_id_map');
    $global_order = subsite_manager_get_main_plugin_order();
    $global_plugins_active = subsite_manager_get_global_enabled_plugins();
    // pretend to be on the subsite
    elgg_set_config('site', $subsite);
    elgg_set_config('site_guid', $subsite->guid);
    elgg_set_config('plugins_by_id_map', array());
    // make sure all plugins exist in the database
    elgg_generate_plugin_entities();
    // mark plugins to activate
    $private_setting = $subsite->getPrivateSetting('subsite_manager_plugins_activate');
    if (isset($private_setting)) {
        $to_activate = unserialize($private_setting);
    } else {
        $to_activate = array();
    }
    $sorted = 0;
    $activated = 0;
    // reorder plugins according to global order and activate global plugins
    $plugins = subsite_manager_get_plugins();
    foreach ($plugins as $plugin) {
        $priority = array_search($plugin->getID(), $global_order) + 1;
        if ($priority === false) {
            $priority = 'last';
        }
        $priority_name = elgg_namespace_plugin_private_setting('internal', 'priority');
        if ($plugin->get($priority_name) != $priority) {
            $plugin->set($priority_name, $priority);
            $sorted++;
        }
        if (!$plugin->isActive() && in_array($plugin->getID(), $global_plugins_active)) {
            if (!in_array($plugin->getID(), $to_activate)) {
                $to_activate[] = $plugin->getID();
                $activated++;
            }
        }
    }
    $subsite->setPrivateSetting('subsite_manager_plugins_activate', serialize($to_activate));
    // clean the caches
    elgg_invalidate_simplecache();
    elgg_reset_system_cache();
    // restore original "main" site
    elgg_set_config('site', $main_site);
    elgg_set_config('site_guid', $main_site->guid);
    elgg_set_config('plugins_by_id_map', $plugins_by_id_map);
    return array($sorted, $activated);
}
Example #8
0
/**
 * Clear Cache after setting change
 *
 */
function follow_tags_setting($hook_name, $entity_type, $return_value, $params)
{
    if (!empty($params) && is_array($params)) {
        if (($plugin = elgg_extract("plugin", $params)) && $plugin->getID() == "your_plugin_name") {
            elgg_invalidate_simplecache();
        }
    }
}
Example #9
0
 /**
  * Removes all settings for this plugin.
  *
  * @todo Should be a better way to do this without dropping to raw SQL.
  * @todo If we could namespace the plugin settings this would be cleaner.
  * @return bool
  */
 public function unsetAllSettings()
 {
     $db_prefix = get_config('dbprefix');
     $ps_prefix = elgg_namespace_plugin_private_setting('internal', '');
     $q = "DELETE FROM {$db_prefix}private_settings\n\t\t\tWHERE entity_guid = {$this->guid}\n\t\t\tAND name NOT LIKE '{$ps_prefix}%'\n\t\t\tAND name <> 'path'";
     $result = delete_data($q);
     // check memcache
     if ($result !== false && is_memcache_available()) {
         $private_setting_cache = new ElggMemcache("private_settings");
         // remove settings from memcache
         $private_setting_cache->delete($this->guid);
     }
     // unvalidate cache to reset to default behaviour
     elgg_invalidate_simplecache();
     return $result;
 }
Example #10
0
 /**
  * Initialize the site including site entity, plugins, and configuration
  *
  * @param array $submissionVars Submitted vars
  *
  * @return bool
  */
 protected function saveSiteSettings($submissionVars)
 {
     global $CONFIG;
     // ensure that file path, data path, and www root end in /
     $submissionVars['path'] = sanitise_filepath($submissionVars['path']);
     $submissionVars['dataroot'] = sanitise_filepath($submissionVars['dataroot']);
     $submissionVars['wwwroot'] = sanitise_filepath($submissionVars['wwwroot']);
     $site = new ElggSite();
     $site->name = $submissionVars['sitename'];
     $site->url = $submissionVars['wwwroot'];
     $site->access_id = ACCESS_PUBLIC;
     $site->email = $submissionVars['siteemail'];
     $guid = $site->save();
     if (!$guid) {
         register_error(elgg_echo('install:error:createsite'));
         return FALSE;
     }
     // bootstrap site info
     $CONFIG->site_guid = $guid;
     $CONFIG->site = $site;
     datalist_set('installed', time());
     datalist_set('path', $submissionVars['path']);
     datalist_set('dataroot', $submissionVars['dataroot']);
     datalist_set('default_site', $site->getGUID());
     datalist_set('version', get_version());
     datalist_set('simplecache_enabled', 1);
     datalist_set('viewpath_cache_enabled', 1);
     // new installations have run all the upgrades
     $upgrades = elgg_get_upgrade_files($submissionVars['path'] . 'engine/lib/upgrades/');
     datalist_set('processed_upgrades', serialize($upgrades));
     set_config('view', 'default', $site->getGUID());
     set_config('language', 'en', $site->getGUID());
     set_config('default_access', $submissionVars['siteaccess'], $site->getGUID());
     set_config('allow_registration', TRUE, $site->getGUID());
     set_config('walled_garden', FALSE, $site->getGUID());
     $this->enablePlugins();
     // reset the views path in case of installing over an old data dir.
     $dataroot = $submissionVars['dataroot'];
     $CONFIG->dataroot = $dataroot;
     $cache = new ElggFileCache($dataroot);
     $cache->delete('view_paths');
     elgg_invalidate_simplecache();
     elgg_regenerate_simplecache();
     return TRUE;
 }
Example #11
0
 /**
  * Controller for last step
  *
  * @return void
  */
 protected function complete()
 {
     $params = array();
     if ($this->autoLogin) {
         $params['destination'] = 'admin';
     } else {
         $params['destination'] = 'index.php';
     }
     elgg_invalidate_simplecache();
     $this->render('complete', $params);
 }
Example #12
0
function event_calendar_invalidate_cache($hook, $type, $return, $params)
{
    if (isset($params["plugin"]) && $params["plugin"]->getID() == "event_calendar") {
        elgg_invalidate_simplecache();
    }
}
Example #13
0
/**
 * This event will be triggered when plugin are reordered in in 'boot' 'system'
 *
 * @param string $event
 * @param string $type
 * @param mixed $entity
 */
function subsite_manager_ready_system_handler($event, $type, $entity)
{
    elgg_reset_system_cache();
    elgg_invalidate_simplecache();
}
Example #14
0
/**
 * Regenerates the simple cache.
 *
 * Not required any longer since cached files are created on demand.
 *
 * @warning This does not invalidate the cache, but actively rebuilds it.
 *
 * @param string $viewtype Optional viewtype to regenerate. Defaults to all valid viewtypes.
 *
 * @return void
 * @since 1.8.0
 * @deprecated 1.9 Use elgg_invalidate_simplecache()
 */
function elgg_regenerate_simplecache($viewtype = NULL)
{
    elgg_deprecated_notice(__FUNCTION__ . ' is deprecated by elgg_invalidate_simplecache()', 1.9);
    elgg_invalidate_simplecache();
}
Example #15
0
 /**
  * Enables the simple cache.
  *
  * @see elgg_register_simplecache_view()
  * @return void
  */
 function enable()
 {
     _elgg_services()->datalist->set('simplecache_enabled', 1);
     _elgg_services()->config->set('simplecache_enabled', 1);
     elgg_invalidate_simplecache();
 }
Example #16
0
function custom_css_invalidate_cache($hook, $type, $return, $params)
{
    if (isset($params["plugin"]) && $params["plugin"]->getID() == "custom_css") {
        elgg_invalidate_simplecache();
    }
}
/**
 * Enables the simple cache.
 *
 * @see elgg_register_simplecache_view()
 * @return void
 * @since 1.8.0
 */
function elgg_enable_simplecache()
{
    datalist_set('simplecache_enabled', 1);
    elgg_set_config('simplecache_enabled', 1);
    elgg_invalidate_simplecache();
}
}
foreach ($plugin_guids as $guid) {
    $plugin = get_entity($guid);
    if (!$plugin instanceof ElggPlugin) {
        register_error(elgg_echo('admin:plugins:deactivate:no', array($guid)));
        continue;
    }
    if ($plugin->deactivate()) {
        //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->getManifest()->getName())));
    } else {
        $msg = $plugin->getError();
        $string = $msg ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
        register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
    }
}
// don't regenerate the simplecache because the plugin won't be
// loaded until next run.  Just invalidate and let it regnerate as needed
elgg_invalidate_simplecache();
elgg_reset_system_cache();
if (count($plugin_guids) == 1) {
    $url = 'admin/plugins';
    $query = (string) parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
    if ($query) {
        $url .= "?{$query}";
    }
    $plugin = get_entity($plugin_guids[0]);
    $id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
    forward("{$url}#{$id}");
} else {
    forward(REFERER);
}
function theme_haarlem_intranet_invalidate_cache($hook, $type, $return, $params)
{
    if (isset($params["plugin"]) && $params["plugin"]->getID() == "theme_haarlem_intranet") {
        elgg_invalidate_simplecache();
    }
}