Example #1
0
 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");
 }
 static function uninstall()
 {
     // deactivate
     module::deactivate("image_optimizer");
     // delete vars from database
     module::clear_all_vars("image_optimizer");
 }
Example #3
0
 public function change()
 {
     access::verify_csrf();
     $active_provider = module::get_var("gallery", "identity_provider", "user");
     $providers = identity::providers();
     $new_provider = Input::instance()->post("provider");
     if ($new_provider != $active_provider) {
         module::deactivate($active_provider);
         // Switch authentication
         identity::reset();
         module::set_var("gallery", "identity_provider", $new_provider);
         module::install($new_provider);
         module::activate($new_provider);
         module::event("identity_provider_changed", $active_provider, $new_provider);
         module::uninstall($active_provider);
         message::success(t("Changed to %description", array("description" => $providers->{$new_provider})));
         try {
             Session::instance()->destroy();
         } catch (Exception $e) {
             // We don't care if there was a problem destroying the session.
         }
         url::redirect(item::root()->abs_url());
     }
     message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider})));
     url::redirect("admin/identity");
 }
Example #4
0
 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))));
     }
 }
Example #5
0
 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))));
     }
 }
Example #6
0
 /**
  * Deactivate modules that are unavailable or missing, yet still active.
  * This happens when a user deletes a module without deactivating it.
  */
 static function deactivate_missing_modules()
 {
     foreach (self::$modules as $module_name => $module) {
         if (module::is_active($module_name) && !module::info($module_name)) {
             module::deactivate($module_name);
         }
     }
 }