public function upgrade() { if (php_sapi_name() == "cli") { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; } else { if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } } // Upgrade gallery and user first module::install("gallery"); module::install("user"); // Then upgrade the rest foreach (module::available() as $id => $module) { if ($id == "gallery") { continue; } if ($module->active && $module->code_version != $module->version) { module::install($id); } } if (php_sapi_name() == "cli") { print "Upgrade complete\n"; } else { url::redirect("upgrader?done=1"); } }
public function save() { access::verify_csrf(); $changes->activate = array(); $changes->deactivate = array(); $activated_names = array(); $deactivated_names = array(); foreach (module::available() as $module_name => $info) { if ($info->locked) { continue; } $desired = $this->input->post($module_name) == 1; if ($info->active && !$desired && module::is_active($module_name)) { $changes->deactivate[] = $module_name; $deactivated_names[] = $info->name; module::deactivate($module_name); } else { if (!$info->active && $desired && !module::is_active($module_name)) { $changes->activate[] = $module_name; $activated_names[] = $info->name; module::install($module_name); module::activate($module_name); } } } module::event("module_change", $changes); // @todo this type of collation is questionable from a i18n perspective if ($activated_names) { message::success(t("Activated: %names", array("names" => join(", ", $activated_names)))); } if ($deactivated_names) { message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names)))); } url::redirect("admin/modules"); }
/** * Builds the backend information for the Module Updates page. * * Builds an array of data containing the needed information about an installed copy of Gallery3 * to determine if versions stored in the GitHub are newer. * * List ID: The name of the folder the module resides in (obtained from module::available) * name: The given name of the module (obtained from module::available) * locked: If the module is considered locked by Gallery (obtained from module::available) * code_version: The version of the module in the modules directory (obtained from module::available) * active: If the module is installed and enabled (obtained from module::available) * version: The version installed and running (obtained from module::available) * description: The description of the module (obtained from module::available) * remote_version: The version of the code on GitHub (obtained from get_remote_module_version) * remote_server: The server the remote version is on (obtained from get_remote_module_version) * font_color: The color to display the update in depending on its status * * @author brentil <*****@*****.**> */ public function index() { $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 3 :: Manage Module Updates"); $view->content = new View("admin_moduleupdates.html"); $all_modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); foreach (module::available() as $this_module_name => $module_info) { list($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name); $font_color = "black"; if ($remote_version == "DNE") { $font_color = "blue"; } else { if ($remote_version < $module_info->code_version) { $font_color = "green"; } else { if ($remote_version > $module_info->code_version) { $font_color = "red"; } } } $all_modules->{$this_module_name} = array("name" => $module_info->name, "locked" => $module_info->locked, "code_version" => $module_info->code_version, "active" => $module_info->active, "version" => $module_info->version, "description" => $module_info->description, "remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color); } $view->content->vars = $all_modules; print $view; }
public function upgrade() { if (php_sapi_name() == "cli") { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; } else { if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } try { access::verify_csrf(); } catch (Exception $e) { url::redirect("upgrader"); } } $available = module::available(); // Upgrade gallery first $gallery = $available["gallery"]; if ($gallery->code_version != $gallery->version) { module::upgrade("gallery"); module::activate("gallery"); } // Then upgrade the rest $failed = array(); foreach (module::available() as $id => $module) { if ($id == "gallery") { continue; } if ($module->active && $module->code_version != $module->version) { try { module::upgrade($id); } catch (Exception $e) { // @todo assume it's MODULE_FAILED_TO_UPGRADE for now $failed[] = $id; } } } // If the upgrade failed, this will get recreated site_status::clear("upgrade_now"); // Clear any upgrade check strings, we are probably up to date. site_status::clear("upgrade_checker"); if (php_sapi_name() == "cli") { if ($failed) { print "Upgrade completed ** WITH FAILURES **\n"; print "The following modules were not successfully upgraded:\n"; print " " . implode($failed, "\n ") . "\n"; print "Try getting newer versions or deactivating those modules\n"; } else { print "Upgrade complete\n"; } } else { if ($failed) { url::redirect("upgrader?failed=" . join(",", $failed)); } else { url::redirect("upgrader"); } } }
/** * Return a list of installed Identity Drivers. * * @return boolean true if the driver supports updates; false if read only */ static function providers() { if (empty(self::$available)) { $drivers = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); foreach (module::available() as $module_name => $module) { if (file_exists(MODPATH . "{$module_name}/config/identity.php")) { $drivers->{$module_name} = $module->description; } } self::$available = $drivers; } return self::$available; }
private function _do_save() { $changes = new stdClass(); $changes->activate = array(); $changes->deactivate = array(); $activated_names = array(); $deactivated_names = array(); foreach (module::available() as $module_name => $info) { if ($info->locked) { continue; } try { $desired = Input::instance()->post($module_name) == 1; if ($info->active && !$desired && module::is_active($module_name)) { module::deactivate($module_name); $changes->deactivate[] = $module_name; $deactivated_names[] = t($info->name); } else { if (!$info->active && $desired && !module::is_active($module_name)) { if (module::is_installed($module_name)) { module::upgrade($module_name); } else { module::install($module_name); } module::activate($module_name); $changes->activate[] = $module_name; $activated_names[] = t($info->name); } } } catch (Exception $e) { message::warning(t("An error occurred while installing the <b>%module_name</b> module", array("module_name" => $info->name))); Kohana_Log::add("error", (string) $e); } } module::event("module_change", $changes); // If modules need upgrading, this will get recreated site_status::clear("upgrade_now"); // @todo this type of collation is questionable from an i18n perspective if ($activated_names) { message::success(t("Activated: %names", array("names" => join(", ", $activated_names)))); } if ($deactivated_names) { message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names)))); } }
public function save() { foreach (module::available() as $module_name => $info) { if ($info->locked) { continue; } $desired = $this->input->post($module_name) == 1; if ($info->installed && !$desired) { module::uninstall($module_name); message::success(t("Uninstalled %module_name module", array("module_name" => $info->name))); } else { if (!$info->installed && $desired) { module::install($module_name); message::success(t("Installed %module_name module", array("module_name" => $info->name))); } } } url::redirect("admin/modules"); }
private function _do_save() { $changes->activate = array(); $changes->deactivate = array(); $activated_names = array(); $deactivated_names = array(); foreach (module::available() as $module_name => $info) { if ($info->locked) { continue; } try { $desired = Input::instance()->post($module_name) == 1; if ($info->active && !$desired && module::is_active($module_name)) { module::deactivate($module_name); $changes->deactivate[] = $module_name; $deactivated_names[] = t($info->name); } else { if (!$info->active && $desired && !module::is_active($module_name)) { if (module::is_installed($module_name)) { module::upgrade($module_name); } else { module::install($module_name); } module::activate($module_name); $changes->activate[] = $module_name; $activated_names[] = t($info->name); } } } catch (Exception $e) { Kohana_Log::add("error", (string) $e); } } module::event("module_change", $changes); // @todo this type of collation is questionable from an i18n perspective if ($activated_names) { message::success(t("Activated: %names", array("names" => join(", ", $activated_names)))); } if ($deactivated_names) { message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names)))); } }
/** * Upgrade a module. This will call <module>_installer::upgrade(), which is responsible for * modifying database tables, changing module variables and calling module::set_version(). * Note that after upgrading, the module must be activated before it is available for use. * @param string $module_name */ static function upgrade($module_name) { $version_before = module::get_version($module_name); $installer_class = "{$module_name}_installer"; $available = module::available(); if (class_exists($installer_class) && method_exists($installer_class, "upgrade")) { call_user_func_array(array($installer_class, "upgrade"), array($version_before)); } else { if (isset($available->{$module_name}->code_version)) { module::set_version($module_name, $available->{$module_name}->code_version); } else { throw new Exception("@todo UNKNOWN_MODULE"); } } module::load_modules(); $version_after = module::get_version($module_name); if ($version_before != $version_after) { log::success("module", t("Upgraded module %module_name from %version_before to %version_after", array("module_name" => $module_name, "version_before" => $version_before, "version_after" => $version_after))); } if ($version_after != $available->{$module_name}->code_version) { throw new Exception("@todo MODULE_FAILED_TO_UPGRADE"); } }
function index() { if (!TEST_MODE) { throw new Kohana_404_Exception(); } // Force strict behavior to flush out bugs early ini_set("display_errors", true); error_reporting(-1); // Jump through some hoops to satisfy the way that we check for the site_domain in // config.php. We structure this such that the code in config will leave us with a // site_domain of "." (for historical reasons) // @todo: for tests, we should force the site_domain to something like example.com $_SERVER["SCRIPT_FILENAME"] = "index.php"; $_SERVER["SCRIPT_NAME"] = "./index.php"; $config = Kohana_Config::instance(); $original_config = DOCROOT . "var/database.php"; $test_config = VARPATH . "database.php"; if (!file_exists($original_config)) { print "Please copy kohana/config/database.php to {$original_config}.\n"; return; } else { copy($original_config, $test_config); $db_config = Kohana::config('database'); if (empty($db_config['unit_test'])) { $default = $db_config['default']; $conn = $default['connection']; $config->set('database.unit_test.benchmark', $default['benchmark']); $config->set('database.unit_test.persistent', $default['persistent']); $config->set('database.unit_test.connection.type', $conn['type']); $config->set('database.unit_test.connection.user', $conn['user']); $config->set('database.unit_test.connection.pass', $conn['pass']); $config->set('database.unit_test.connection.host', $conn['host']); $config->set('database.unit_test.connection.port', $conn['port']); $config->set('database.unit_test.connection.socket', $conn['socket']); $config->set('database.unit_test.connection.database', "{$conn['database']}_test"); $config->set('database.unit_test.character_set', $default['character_set']); $config->set('database.unit_test.table_prefix', $default['table_prefix']); $config->set('database.unit_test.object', $default['object']); $config->set('database.unit_test.cache', $default['cache']); $config->set('database.unit_test.escape', $default['escape']); $db_config = Kohana::config('database'); } if ($db_config['default']['connection']['database'] == $db_config['unit_test']['connection']['database']) { print "Don't use the default database for your unit tests or you'll lose all your data.\n"; return; } try { $db = Database::instance('unit_test'); $db->connect(); // Make this the default database for the rest of this run Database::set_default_instance($db); } catch (Exception $e) { print "{$e->getMessage()}\n"; return; } } try { // Clean out the database if ($tables = $db->list_tables()) { foreach ($db->list_tables() as $table) { $db->query("DROP TABLE {{$table}}"); } } // Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok // because we technically don't need it anymore. If this is confusing, we could always // arrange to preserve that one file. @system("rm -rf test/var"); @mkdir('test/var/logs', 0777, true); $active_modules = module::$active; // Reset our caches module::$modules = array(); module::$active = array(); module::$var_cache = array(); $db->clear_cache(); // Rest the cascading class path $config->set("core", $config->load("core")); // Install the active modules // Force gallery and user to be installed first to resolve dependencies. gallery_installer::install(true); module::load_modules(); module::install("user"); module::activate("user"); $modules = $paths = array(); foreach (module::available() as $module_name => $unused) { if (in_array($module_name, array("gallery", "user"))) { $paths[] = MODPATH . "{$module_name}/tests"; continue; } if (file_exists($path = MODPATH . "{$module_name}/tests")) { $paths[] = $path; module::install($module_name); module::activate($module_name); } } $config->set('unit_test.paths', $paths); // Trigger late-binding install actions (defined in gallery_event::user_login) graphics::choose_default_toolkit(); $filter = count($_SERVER["argv"]) > 2 ? $_SERVER["argv"][2] : null; print new Unit_Test($modules, $filter); } catch (ORM_Validation_Exception $e) { print "Validation Exception: {$e->getMessage()}\n"; print $e->getTraceAsString() . "\n"; foreach ($e->validation->errors() as $field => $msg) { print "{$field}: {$msg}\n"; } } catch (Exception $e) { print "Exception: {$e->getMessage()}\n"; print $e->getTraceAsString() . "\n"; } }
function install($module_name, $redirect = true) { $to_install = array(); if ($module_name == "*") { foreach (module::available() as $module_name => $info) { if (empty($info->installed)) { $to_install[] = $module_name; } } } else { $to_install[] = $module_name; } foreach ($to_install as $module_name) { if ($module_name != "gallery") { require_once DOCROOT . "modules/{$module_name}/helpers/{$module_name}_installer.php"; } module::install($module_name); } if ($redirect) { url::redirect("scaffold"); } }
/** * Upgrade a module. This will call <module>_installer::upgrade(), which is responsible for * modifying database tables, changing module variables and calling module::set_version(). * Note that after upgrading, the module must be activated before it is available for use. * @param string $module_name */ static function upgrade($module_name) { $kohana_modules = Kohana::config("core.modules"); array_unshift($kohana_modules, MODPATH . $module_name); Kohana::config_set("core.modules", $kohana_modules); $version_before = module::get_version($module_name); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "upgrade")) { call_user_func_array(array($installer_class, "upgrade"), array($version_before)); } else { $available = module::available(); if (isset($available->{$module_name}->code_version)) { module::set_version($module_name, $available->{$module_name}->code_version); } else { throw new Exception("@todo UNKNOWN_MODULE"); } } module::load_modules(); // Now the module is upgraded but inactive, so don't leave it in the active path array_shift($kohana_modules); Kohana::config_set("core.modules", $kohana_modules); $version_after = module::get_version($module_name); if ($version_before != $version_after) { log::success("module", t("Upgraded module %module_name from %version_before to %version_after", array("module_name" => $module_name, "version_before" => $version_before, "version_after" => $version_after))); } }
/** * Upgrade a module. This will call <module>_installer::upgrade(), which is responsible for * modifying database tables, changing module variables and calling module::set_version(). * Note that after upgrading, the module must be activated before it is available for use. * @param string $module_name */ static function upgrade($module_name) { $version_before = module::get_version($module_name); $installer_class = "{$module_name}_installer"; if (method_exists($installer_class, "upgrade")) { call_user_func_array(array($installer_class, "upgrade"), array($version_before)); } else { $available = module::available(); if (isset($available->{$module_name}->code_version)) { module::set_version($module_name, $available->{$module_name}->code_version); } else { throw new Exception("@todo UNKNOWN_MODULE"); } } // Now the module is upgraded so deactivate it, but we can'it deactivae gallery or the // current identity provider. $identity_provider = module::get_var("gallery", "identity_provider", "user"); if (!in_array($module_name, array("gallery", $identity_provider))) { self::deactivate($module_name); } module::load_modules(); $version_after = module::get_version($module_name); if ($version_before != $version_after) { log::success("module", t("Upgraded module %module_name from %version_before to %version_after", array("module_name" => $module_name, "version_before" => $version_before, "version_after" => $version_after))); } }
public function index() { //Start execution timer $bgtime = time(); $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 3 :: Manage Module Updates"); $view->content = new View("admin_moduleupdates.html"); $view->content->mu_version = module::get_version("moduleupdates"); $refreshCache = false; $cache = unserialize(Cache::instance()->get("moduleupdates_cache")); $cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates")); //if someone pressed the button to refresh now if (request::method() == "post") { access::verify_csrf(); $cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $cache_updates = array("date" => "", "updates" => 0); $refreshCache = true; } else { if (count($cache) < 1 or $cache_updates['date'] == "") { //if there are no items in the cache array or the update date is "" refresh the data $cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $cache_updates = array("date" => "", "updates" => 0); $refreshCache = true; } } //Check the ability to access the Gallery3 GitHub $GitHub = null; try { $GitHub = fopen("http://github.com", "r"); if ($GitHub != null) { $GitHub = '<font color=green>Online</font>'; } else { $GitHub = '<font color=red>Offline</font>'; } } catch (Exception $e) { } //Check the ability to access the Google $Google = null; try { $Google = fopen("http://google.com", "r"); if ($Google != null) { $Google = '<font color=green>Online</font>'; } else { $Google = '<font color=red>Offline</font>'; } } catch (Exception $e) { } $update_count = 0; if ($refreshCache == true) { // Only poll GalleryModules.com once for the ini file. $fp = fopen($this->gm_ini, 'w'); $fp2 = fopen($this->gm_core_ini, 'w'); if (function_exists("curl_init")) { $cp = curl_init("http://www.gallerymodules.com/gallerymodules.ini"); curl_setopt($cp, CURLOPT_FILE, $fp); $buffer = curl_exec($cp); curl_close($cp); fclose($fp); $cp = curl_init("http://www.gallerymodules.com/core.ini"); curl_setopt($cp, CURLOPT_FILE, $fp2); $buffer = curl_exec($cp); curl_close($cp); fclose($fp2); } else { fwrite($fp, file_get_contents("http://www.gallerymodules.com/gallerymodules.ini")); fclose($fp); fwrite($fp2, file_get_contents("http://www.gallerymodules.com/core.ini")); fclose($fp2); } foreach (module::available() as $this_module_name => $module_info) { $font_color_local = "black"; $core_version = ''; $core_server = ''; $core_dlink = ''; $font_color_core = "black"; $contrib_version = ''; $contrib_server = ''; $contrib_dlink = ''; $font_color_contrib = "black"; $gh_version = ''; $gh_server = ''; $gh_dlink = ''; $font_color_gh = "black"; $font_color_local = $this->get_local_module_version_color($module_info->version, $module_info->code_version); list($core_version, $core_server) = $this->get_remote_module_version($this_module_name, "CORE"); $font_color_core = $this->get_module_version_color($module_info->version, $module_info->code_version, $core_version); if (!is_numeric($core_version)) { list($gh_version, $gh_server) = $this->get_remote_module_version($this_module_name, "GH"); $font_color_gh = $this->get_module_version_color($module_info->version, $module_info->code_version, $gh_version); } if ($font_color_core == "red" or $font_color_contrib == "red" or $font_color_gh == "red") { $update_count++; } $module_info->name = "<a href=\"http://codex.gallery2.org/Gallery3:Modules:" . $this_module_name . "\" target=\"_new\">" . $module_info->name . "</a>"; if (is_numeric($core_version)) { if ($core_version > $module_info->version) { $core_dlink = "http://github.com/gallery/gallery3/tree/master/modules/" . $this_module_name; } } if (is_numeric($gh_version)) { if ($gh_version > $module_info->version) { $this_gm_repo = str_replace(".", "", substr_replace(gallery::VERSION, "", strpos(gallery::VERSION, " "))); if ($this_gm_repo == "30") { $gh_dlink = "http://www.gallerymodules.com/update/" . $this_module_name; } else { $gh_dlink = "http://www.gallerymodules.com/update" . $this_gm_repo . "/" . $this_module_name; } } } //populate the list fo modules and their data $cache->{$this_module_name} = array("name" => $module_info->name, "locked" => $module_info->locked, "code_version" => $module_info->code_version, "active" => $module_info->active, "version" => $module_info->version, "description" => $module_info->description, "core_version" => $core_version, "core_server" => $core_server, "font_color_core" => $font_color_core, "contrib_version" => $contrib_version, "contrib_server" => $contrib_server, "font_color_contrib" => $font_color_contrib, "gh_version" => $gh_version, "gh_server" => $gh_server, "font_color_gh" => $font_color_gh, "font_color_local" => $font_color_local, "core_dlink" => $core_dlink, "contrib_dlink" => $contrib_dlink, "gh_dlink" => $gh_dlink); } //Define right now as YYYY.MM.DD HH:MM with the # of updates that are out of date $cache_updates = array("date" => date("Y.m.d - H:i"), "updates" => $update_count); //Write out the new data to cache with a 30 day expiration & 0 for update data so it's always present Cache::instance()->set("moduleupdates_cache", serialize($cache), array("ModuleUpdates"), 30 * 86400); Cache::instance()->set("moduleupdates_cache_updates", serialize($cache_updates), array("ModuleUpdates"), null); log::success("moduleupdates", t("Completed checking remote GitHub for modules updates.")); } if (is_file($this->gm_ini)) { unlink($this->gm_ini); } if (is_file($this->gm_core_ini)) { unlink($this->gm_core_ini); } $view->content->vars = $cache; $view->content->update_time = $cache_updates['date']; $view->content->csrf = access::csrf_token(); $view->content->Google = $Google; $view->content->GitHub = $GitHub; $view->content->Gallery_Version = substr_replace(gallery::VERSION, "", strpos(gallery::VERSION, " ")); //End execution timer $ExecutionTime = time() - $bgtime; if ($ExecutionTime < 1) { $ExecutionTime = '<font color=green>1</font>'; } else { if ($ExecutionTime <= 30) { $ExecutionTime = '<font color=green>' . $ExecutionTime . '</font>'; } else { if ($ExecutionTime <= 60) { $ExecutionTime = '<font color=orange>' . $ExecutionTime . '</font>'; } else { $ExecutionTime = '<font color=red>' . $ExecutionTime . '</font>'; } } } $view->content->ExecutionTime = $ExecutionTime; print $view; }
public function index() { $this->template->content = View::factory('modules/index', array('modules' => module::available())); }
/** * Builds the backend information for the Module Updates page. * * Builds an array of data containing the needed information about an installed copy of Gallery3 * to determine if versions stored in the GitHub are newer. * * List ID: The name of the folder the module resides in (obtained from module::available) * name: The given name of the module (obtained from module::available) * locked: If the module is considered locked by Gallery (obtained from module::available) * code_version: The version of the module in the modules directory (obtained from module::available) * active: If the module is installed and enabled (obtained from module::available) * version: The version installed and running (obtained from module::available) * description: The description of the module (obtained from module::available) * remote_version: The version of the code on GitHub (obtained from get_remote_module_version) * remote_server: The server the remote version is on (obtained from get_remote_module_version) * font_color: The color to display the update in depending on its status * * @author brentil <*****@*****.**> */ public function index() { $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 3 :: Manage Module Updates"); $view->content = new View("admin_moduleupdates.html"); $devDebug = false; $refreshCache = false; $cache = unserialize(Cache::instance()->get("moduleupdates_cache")); $cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates")); //--------------------------------------------------------------------------------------------- //echo 'Message 01: ' .$cache_updates . '<br>'; //--------------------------------------------------------------------------------------------- //if someone pressed the button to refresh now if (request::method() == "post") { access::verify_csrf(); $cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $cache_updates = array("date" => "", "updates" => 0); $refreshCache = true; } else { if (count($cache) < 1 or $cache_updates['date'] == "") { //if there are no items in the cache array or the update date is "" refresh the data $cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $cache_updates = array("date" => "", "updates" => 0); $refreshCache = true; } } //Check the ability to access the Gallery3 GitHub $GitHub = null; try { $GitHub = fopen("http://github.com", "r"); if ($GitHub != null) { $GitHub = '<font color=green>Online</font>'; } else { $GitHub = '<font color=red>Offline</font>'; } } catch (Exception $e) { //echo 'Message: ' .$e->getMessage() . '<br>'; } //Check the ability to access the Google $Google = null; try { $Google = fopen("http://google.com", "r"); if ($Google != null) { $Google = '<font color=green>Online</font>'; } else { $Google = '<font color=red>Offline</font>'; } } catch (Exception $e) { //echo 'Message: ' .$e->getMessage() . '<br>'; } if ($refreshCache == true) { foreach (module::available() as $this_module_name => $module_info) { //example code for setting cache values //Cache::instance()->set($key, "$log{$msg}", array("task", "log", "import"), 2592000); //example delete cache //Cache::instance()->delete("update_l10n_cache:{$task->id}"); //example for reading cache //$log = Cache::instance()->get($key); $remote_version = ''; $remote_server = ''; $update_count = 0; list($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name, $devDebug); $font_color = "black"; //BLUE - DNE: Does Not Exist, this module was not found if ($remote_version == "DNE") { $font_color = "blue"; //PINK - Your installed version is newer than file version } else { if ($module_info->version != '' and $module_info->code_version < $module_info->version) { $font_color = "pink"; //ORANGE - Your file version is newer than the installed version } else { if ($module_info->version != '' and $module_info->code_version > $module_info->version) { $font_color = "orange"; //GREEN - Your version is newer than the GitHub } else { if ($remote_version < $module_info->code_version or $module_info->version != '' and $remote_version < $module_info->version) { $font_color = "green"; //RED - Your version is older than the GitHub } else { if ($remote_version > $module_info->code_version or $module_info->version != '' and $remote_version > $module_info->version) { $font_color = "red"; $update_count++; /* if($remote_server == "(G3)"){ $module_info->name = "<a href=\"http://github.com/gallery/gallery3/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>"; }else if($remote_server == "(G3CC)"){ $module_info->name = "<a href=\"http://github.com/gallery/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>"; }else if($remote_server == "(brentil)"){ $module_info->name = "<a href=\"http://github.com/brentil/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>"; } */ } } } } } $module_info->name = "<a href=\"http://codex.gallery2.org/Gallery3:Modules:" . $this_module_name . "\" target=\"_new\">" . $module_info->name . "</a>"; //populate the list fo modules and their data $cache->{$this_module_name} = array("name" => $module_info->name, "locked" => $module_info->locked, "code_version" => $module_info->code_version, "active" => $module_info->active, "version" => $module_info->version, "description" => $module_info->description, "remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color); } //Define right now as YYYY.MM.DD HH:MM with the # of updates that are out of date $cache_updates = array("date" => date("Y.m.d - H:i"), "updates" => $update_count); //--------------------------------------------------------------------------------------------- //echo 'Message 02: ' .$cache_updates . '<br>'; //--------------------------------------------------------------------------------------------- //Write out the new data to cache with a 30 day expiration & 0 for update data so it's always present Cache::instance()->set("moduleupdates_cache", serialize($cache), array("ModuleUpdates"), 30 * 86400); Cache::instance()->set("moduleupdates_cache_updates", serialize($cache_updates), array("ModuleUpdates"), null); log::success("moduleupdates", t("Completed checking remote GitHub for modules updates.")); } $view->content->vars = $cache; $view->content->update_time = $cache_updates['date']; $view->content->csrf = access::csrf_token(); $view->content->Google = $Google; $view->content->GitHub = $GitHub; print $view; }