Exemplo n.º 1
0
 /**
  * Disable some (or all) modules in SafeMode
  *
  * @return void
  */
 protected static function performSafeModeProtection()
 {
     if (\Includes\SafeMode::isSafeModeStarted()) {
         if (!\Includes\SafeMode::isRestoreDateSet()) {
             // Get unsafe modules list
             $modules = \Includes\SafeMode::isSoftResetRequested() ? static::getSoftDisableList() : static::getHardDisableList();
             // Disable modules
             array_walk($modules, array('static', 'disableModule'));
         } else {
             $restorePoint = static::getRestorePoint(\Includes\SafeMode::getRestoreDate());
             if (static::isRestorePointValid($restorePoint)) {
                 //modules to disable
                 static::restoreToPoint($restorePoint);
             }
         }
         \Includes\SafeMode::cleanupIndicator();
     }
 }
Exemplo n.º 2
0
 /**
  * Disable some (or all) modules in SafeMode
  *
  * @return void
  */
 protected static function performSafeModeProtection()
 {
     if (\Includes\SafeMode::isSafeModeStarted()) {
         if (!\Includes\SafeMode::isRestoreDateSet()) {
             // Get unsafe modules list
             $modules = \Includes\SafeMode::isSoftResetRequested() ? \Includes\SafeMode::getUnsafeModulesList() : array_keys(static::$activeModules);
         } else {
             $restorePoint = static::getRestorePoint(\Includes\SafeMode::getRestoreDate());
             if (!empty($restorePoint)) {
                 //modules to disable
                 $modules = array();
                 $active = static::getActiveModules();
                 foreach ($active as $key => $module) {
                     $toDisable = true;
                     foreach ($restorePoint['current'] as $id => $moduleName) {
                         if ($moduleName != null && $key === $moduleName) {
                             $moduleName = null;
                             $toDisable = false;
                             break;
                         }
                     }
                     if ($toDisable) {
                         $modules[] = $key;
                     }
                 }
                 //modules to enable
                 $toEnable = array();
                 $installed = static::getModulesList();
                 foreach ($restorePoint['current'] as $id => $moduleName) {
                     $isInstalled = array_key_exists($moduleName, $installed);
                     $isActive = array_key_exists($moduleName, $active);
                     if ($isInstalled && !$isActive) {
                         $toEnable[] = $moduleName;
                     }
                 }
                 // Enable modules
                 array_walk($toEnable, array('static', 'enableModule'));
                 $date = \DateTime::createFromFormat(static::RESTORE_DATE_FORMAT, $restorePoint["date"]);
                 \Includes\Decorator\Utils\PersistentInfo::set('restoredTo', $date->getTimestamp());
                 $restorationRecord = static::getRestorationRecord($restorePoint["date"]);
                 static::updateModuleMigrationLog($restorationRecord);
             }
         }
         // Disable modules
         array_walk($modules, array('static', 'disableModule'));
         \Includes\SafeMode::cleanupIndicator();
     }
 }