本文整理汇总了PHP中module::deactivate方法的典型用法代码示例。如果您正苦于以下问题:PHP module::deactivate方法的具体用法?PHP module::deactivate怎么用?PHP module::deactivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module
的用法示例。
在下文中一共展示了module::deactivate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
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");
}
示例2: uninstall
static function uninstall()
{
// deactivate
module::deactivate("image_optimizer");
// delete vars from database
module::clear_all_vars("image_optimizer");
}
示例3: change
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");
}
示例4: _do_save
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))));
}
}
示例5: _do_save
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))));
}
}
示例6: deactivate_missing_modules
/**
* 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);
}
}
}