function subsite_manager_upgrade_system_handler($event, $type, $entity) { if (get_input("all") == "true") { // find subsites and do stuff $options = array("type" => "site", "subtype" => Subsite::SUBTYPE, "limit" => false); // this could take a while set_time_limit(0); $batch = new ElggBatch("elgg_get_entities", $options); $viewtypes = elgg_get_config("view_types"); $dataroot = elgg_get_config("dataroot"); foreach ($batch as $subsite) { // clear simplecache $dir = $dataroot . "views_simplecache/" . $subsite->getGUID() . "/"; if (file_exists($dir) && ($handle = opendir($dir))) { // remove files while (false !== ($file = readdir($handle))) { if (!is_dir($dir . $file)) { unlink($dir . $file); } } closedir($handle); } if (!empty($viewtypes) && is_array($viewtypes)) { foreach ($viewtypes as $viewtype) { datalist_set("sc_lastupdate_" . $viewtype . "_" . $subsite->getGUID(), 0); datalist_set("sc_lastcached_" . $viewtype . "_" . $subsite->getGUID(), 0); } } // clear system cache $system_cache = new ElggFileCache($dataroot . "system_cache/" . $subsite->getGUID() . "/"); $system_cache->clear(); // cleanup cron cache $cron_cache = $dataroot . "subsite_manager/" . $subsite->getGUID() . "/cron_cache.json"; if (file_exists($cron_cache)) { unlink($cron_cache); } // reset translation editor cache // can't use remove_private_setting because of 'name like' not 'name =' $sql = "DELETE FROM " . get_config("dbprefix") . "private_settings"; $sql .= " WHERE name LIKE 'te_last_update_%'"; $sql .= " AND entity_guid = " . $subsite->getGUID(); delete_data($sql); } } }
/** * 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'); return TRUE; }
} else { unset_config('https_login', $site->getGUID()); } // activate some plugins by default if (isset($CONFIG->default_plugins)) { if (!is_array($CONFIG->default_plugins)) { $plugins = explode(',', $CONFIG->default_plugins); } else { $CONFIG->default_plugins = $CONFIG->default_plugins; } foreach ($plugins as $plugin) { enable_plugin(trim($plugin), $site->getGUID()); } } else { enable_plugin('profile', $site->getGUID()); enable_plugin('logbrowser', $site->getGUID()); enable_plugin('diagnostics', $site->getGUID()); enable_plugin('uservalidationbyemail', $site->getGUID()); enable_plugin('htmlawed', $site->getGUID()); enable_plugin('search', $site->getGUID()); } // reset the views path in case of installing over an old data dir. // @todo should this warn / error first? $dataroot = datalist_get('dataroot'); $cache = new ElggFileCache($dataroot); $cache->delete('view_paths'); system_message(elgg_echo("installation:configuration:success")); header("Location: ../../account/register.php"); exit; } }