本文整理汇总了PHP中ModuleManager::downgrade方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::downgrade方法的具体用法?PHP ModuleManager::downgrade怎么用?PHP ModuleManager::downgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::downgrade方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($data)
{
if (DEMO_MODE) {
print 'You cannot modify installed modules in demo';
return false;
}
@set_time_limit(0);
$installed = array();
$install = array();
$uninstall = array();
$anonymous_setup = false;
foreach ($data as $k => $v) {
${$k} = $v;
}
foreach ($installed as $name => $new_version) {
$old_version = ModuleManager::is_installed($name);
if ($old_version == $new_version) {
continue;
}
if ($old_version == -1 && $new_version >= 0) {
$install[$name] = $new_version;
continue;
}
if ($new_version == -2) {
$uninstall[$name] = 1;
$install[$name] = $old_version;
continue;
}
if ($old_version >= 0 && $new_version == -1) {
$uninstall[$name] = 1;
continue;
}
if ($old_version < $new_version) {
if (!ModuleManager::upgrade($name, $new_version)) {
return false;
}
continue;
}
if ($old_version > $new_version) {
if (!ModuleManager::downgrade($name, $new_version)) {
return false;
}
continue;
}
}
//uninstall
$modules_prio_rev = array();
foreach (ModuleManager::$modules as $k => $v) {
$modules_prio_rev[] = $k;
}
$modules_prio_rev = array_reverse($modules_prio_rev);
foreach ($modules_prio_rev as $k) {
if (array_key_exists($k, $uninstall)) {
if (!ModuleManager::uninstall($k)) {
return false;
}
if (count(ModuleManager::$modules) == 0) {
print 'No modules installed';
}
}
}
//install
foreach ($install as $i => $v) {
$post_install[$i] = $v;
if (isset($uninstall[$i])) {
if (!ModuleManager::install($i, $v, true, false)) {
return false;
}
} else {
if (!ModuleManager::install($i, $v)) {
return false;
}
}
}
$processed = ModuleManager::get_processed_modules();
$this->set_module_variable('post-install', $processed['install']);
Base_ThemeCommon::create_cache();
if (empty($post_install)) {
Epesi::redirect();
}
return true;
}