public function DisablePlugin($PluginName)
 {
     // Get the plugin and make sure its name is the correct case.
     $Plugin = $this->GetPluginInfo($PluginName);
     if ($Plugin) {
         $PluginName = $Plugin['Index'];
     }
     Gdn_Autoloader::SmartFree(Gdn_Autoloader::CONTEXT_PLUGIN, $Plugin);
     // 1. Check to make sure that no other enabled plugins rely on this one
     // Get all available plugins and compile their requirements
     foreach ($this->EnabledPlugins() as $CheckingName => $Trash) {
         $CheckingInfo = $this->GetPluginInfo($CheckingName);
         $RequiredPlugins = ArrayValue('RequiredPlugins', $CheckingInfo, FALSE);
         if (is_array($RequiredPlugins) && array_key_exists($PluginName, $RequiredPlugins) === TRUE) {
             throw new Exception(sprintf(T('You cannot disable the %1$s plugin because the %2$s plugin requires it in order to function.'), $PluginName, $CheckingName));
         }
     }
     // 2. Perform necessary hook action
     $this->_PluginHook($PluginName, self::ACTION_DISABLE, TRUE);
     // 3. Disable it
     RemoveFromConfig("EnabledPlugins.{$PluginName}");
     unset($this->EnabledPlugins[$PluginName]);
     // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, TRUE);
     Gdn::Locale()->Refresh();
     return TRUE;
 }
Esempio n. 2
0
 /**
  * Clear the contents of the supplied cache, and remove it from disk
  *
  * @param string $CacheName name of cache library
  * @return void
  */
 public static function ClearCache($CacheName = FALSE)
 {
     Gdn_Autoloader::SmartFree();
     if ($CacheName != 'locale') {
         return;
     }
     if (!array_key_exists($CacheName, self::$_Caches)) {
         return self::PrepareCache($CacheName);
     }
     self::$_Caches[$CacheName]['cache'] = array();
     @unlink(PATH_LOCAL_CACHE . DS . self::$_Caches[$CacheName]['ondisk']);
 }
 /**
  * Undocumented method.
  *
  * @param string $ApplicationName Undocumented variable.
  * @todo Document DisableApplication() method.
  */
 public function DisableApplication($ApplicationName)
 {
     // 1. Check to make sure that this application is allowed to be disabled
     $ApplicationInfo = ArrayValueI($ApplicationName, $this->AvailableApplications(), array());
     $ApplicationName = $ApplicationInfo['Index'];
     if (!ArrayValue('AllowDisable', $ApplicationInfo, TRUE)) {
         throw new Exception(sprintf(T('You cannot disable the %s application.'), $ApplicationName));
     }
     // 2. Check to make sure that no other enabled applications rely on this one
     foreach ($this->EnabledApplications() as $CheckingName => $CheckingInfo) {
         $RequiredApplications = ArrayValue('RequiredApplications', $CheckingInfo, FALSE);
         if (is_array($RequiredApplications) && array_key_exists($ApplicationName, $RequiredApplications) === TRUE) {
             throw new Exception(sprintf(T('You cannot disable the %1$s application because the %2$s application requires it in order to function.'), $ApplicationName, $CheckingName));
         }
     }
     // 2. Disable it
     RemoveFromConfig("EnabledApplications.{$ApplicationName}");
     // Clear the object caches.
     Gdn_Autoloader::SmartFree(Gdn_Autoloader::CONTEXT_APPLICATION, $ApplicationInfo);
     // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, TRUE);
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $this->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders(), TRUE);
     $this->EventArguments['AddonName'] = $ApplicationName;
     Gdn::PluginManager()->CallEventHandlers($this, 'ApplicationManager', 'AddonDisabled');
 }
 /**
  * Clear the contents of the supplied cache, and remove it from disk
  *
  * @param string $CacheName name of cache library
  * @return void
  */
 public static function ClearCache($CacheName = FALSE)
 {
     Gdn_Autoloader::SmartFree();
     if ($CacheName != 'locale') {
         return;
     }
     if (!array_key_exists($CacheName, self::$Caches)) {
         return self::PrepareCache($CacheName);
     }
     $UseCache = Gdn::Cache()->Type() == Gdn_Cache::CACHE_TYPE_MEMORY && Gdn::Cache()->ActiveEnabled();
     if ($UseCache) {
         $CacheKey = sprintf(Gdn_LibraryMap::CACHE_CACHE_NAME_FORMAT, $CacheName);
         $Deleted = Gdn::Cache()->Remove($CacheKey);
     } else {
         @unlink(PATH_CACHE . DS . self::$Caches[$CacheName]['ondisk']);
     }
     self::$Caches[$CacheName]['cache'] = array();
 }