Ejemplo n.º 1
0
 public function EnableTheme($ThemeName)
 {
     // 1. Make sure that the theme's requirements are met
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $AvailableThemes = $this->AvailableThemes();
     $NewThemeInfo = ArrayValue($ThemeName, $AvailableThemes, array());
     $RequiredApplications = ArrayValue('RequiredApplications', $NewThemeInfo, FALSE);
     CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
     // Applications
     // 5. Set the theme
     $ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
     if ($ThemeFolder == '') {
         throw new Exception(Gdn::Translate('The theme folder was not properly defined.'));
     } else {
         SaveToConfig('Garden.Theme', $ThemeFolder);
     }
     return TRUE;
 }
Ejemplo n.º 2
0
 /**
  * Test to see if a plugin throws fatal errors.
  */
 public function TestPlugin($PluginName, &$Validation, $Setup = FALSE)
 {
     // Make sure that the plugin's requirements are met
     // Required Plugins
     $PluginInfo = $this->GetPluginInfo($PluginName);
     $RequiredPlugins = GetValue('RequiredPlugins', $PluginInfo, FALSE);
     CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins(), 'plugin');
     // Required Themes
     $EnabledThemes = Gdn::ThemeManager()->EnabledThemeInfo();
     $RequiredThemes = ArrayValue('RequiredTheme', $PluginInfo, FALSE);
     CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
     // Required Applications
     $EnabledApplications = Gdn::ApplicationManager()->EnabledApplications();
     $RequiredApplications = ArrayValue('RequiredApplications', $PluginInfo, FALSE);
     CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
     // Include the plugin, instantiate it, and call its setup method
     $PluginClassName = ArrayValue('ClassName', $PluginInfo, FALSE);
     $PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
     if ($PluginFolder == '') {
         throw new Exception(T('The plugin folder was not properly defined.'));
     }
     $this->_PluginHook($PluginName, self::ACTION_ENABLE, $Setup);
     // If setup succeeded, register any specified permissions
     $PermissionName = GetValue('RegisterPermissions', $PluginInfo, FALSE);
     if ($PermissionName != FALSE) {
         $PermissionModel = Gdn::PermissionModel();
         $PermissionModel->Define($PermissionName);
     }
     return TRUE;
 }
Ejemplo n.º 3
0
 /**
  * Undocumented method.
  *
  * @param string $ApplicationName Undocumented variable.
  * @todo Document CheckRequirements() method.
  */
 public function CheckRequirements($ApplicationName)
 {
     $AvailableApplications = $this->AvailableApplications();
     $RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($ApplicationName, $AvailableApplications, array()), FALSE);
     $EnabledApplications = $this->EnabledApplications();
     CheckRequirements($ApplicationName, $RequiredApplications, $EnabledApplications, 'application');
 }
Ejemplo n.º 4
0
 public function TestTheme($ThemeName)
 {
     // Get some info about the currently enabled theme.
     $EnabledTheme = $this->EnabledThemeInfo();
     $EnabledThemeFolder = GetValue('Folder', $EnabledTheme, '');
     $OldClassName = $EnabledThemeFolder . 'ThemeHooks';
     // Make sure that the theme's requirements are met
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $NewThemeInfo = $this->GetThemeInfo($ThemeName);
     $ThemeName = GetValue('Index', $NewThemeInfo, $ThemeName);
     $RequiredApplications = ArrayValue('RequiredApplications', $NewThemeInfo, FALSE);
     $ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
     CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
     // Applications
     // If there is a hooks file, include it and run the setup method.
     $ClassName = "{$ThemeFolder}ThemeHooks";
     $HooksFile = GetValue("HooksFile", $NewThemeInfo, NULL);
     if (!is_null($HooksFile) && file_exists($HooksFile)) {
         include_once $HooksFile;
         if (class_exists($ClassName)) {
             $ThemeHooks = new $ClassName();
             $ThemeHooks->Setup();
         }
     }
     // If there is a hooks in the old theme, include it and run the ondisable method.
     if (class_exists($OldClassName)) {
         $ThemeHooks = new $OldClassName();
         if (method_exists($ThemeHooks, 'OnDisable')) {
             $ThemeHooks->OnDisable();
         }
     }
     return TRUE;
 }
Ejemplo n.º 5
0
 public function EnablePlugin($PluginName, $Validation, $Setup = FALSE)
 {
     // 1. Make sure that the plugin's requirements are met
     // Required Plugins
     $AvailablePlugins = $this->AvailablePlugins();
     $RequiredPlugins = ArrayValue('RequiredPlugins', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins, 'plugin');
     // Required Themes
     $ThemeManager = new Gdn_ThemeManager();
     $EnabledThemes = $ThemeManager->EnabledThemeInfo();
     $RequiredThemes = ArrayValue('RequiredTheme', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
     // Required Applications
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
     // 2. Include the plugin, instantiate it, and call its setup method
     $PluginInfo = ArrayValue($PluginName, $AvailablePlugins, FALSE);
     $PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
     if ($PluginFolder == '') {
         throw new Exception(Gdn::Translate('The plugin folder was not properly defined.'));
     }
     $this->_PluginHook($PluginName, self::ACTION_ENABLE, $Setup);
     // 3. If setup succeeded, register any specified permissions
     $PermissionName = ArrayValue('RegisterPermissions', $PluginInfo, FALSE);
     if ($PermissionName != FALSE) {
         $PermissionModel = Gdn::PermissionModel();
         $PermissionModel->Define($PermissionName);
     }
     if (is_object($Validation) && count($Validation->Results()) > 0) {
         return FALSE;
     }
     // 4. If everything succeeded, add the plugin to the
     // $EnabledPlugins array in conf/plugins.php
     // $EnabledPlugins['PluginClassName'] = 'Plugin Folder Name';
     SaveToConfig('EnabledPlugins' . '.' . $PluginName, $PluginFolder);
     $ApplicationManager = new Gdn_ApplicationManager();
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
     return TRUE;
 }
Ejemplo n.º 6
0
 public function TestTheme($ThemeName)
 {
     // Get some info about the currently enabled theme.
     $EnabledTheme = $this->EnabledThemeInfo();
     $EnabledThemeFolder = GetValue('Folder', $EnabledTheme, '');
     $OldClassName = $EnabledThemeFolder . 'ThemeHooks';
     // Make sure that the theme's requirements are met
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $AvailableThemes = $this->AvailableThemes();
     $NewThemeInfo = ArrayValue($ThemeName, $AvailableThemes, array());
     $RequiredApplications = ArrayValue('RequiredApplications', $NewThemeInfo, FALSE);
     $ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
     CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
     // Applications
     // If there is a hooks file, include it and run the setup method.
     $ClassName = $ThemeFolder . 'ThemeHooks';
     $HooksFile = PATH_THEMES . DS . $ThemeFolder . DS . 'class.' . strtolower($ClassName) . '.php';
     if (file_exists($HooksFile)) {
         include $HooksFile;
         if (class_exists($ClassName)) {
             $ThemeHooks = new $ClassName();
             $ThemeHooks->Setup();
         }
     }
     // If there is a hooks in the old theme, include it and run the ondisable method.
     if (class_exists($OldClassName)) {
         $ThemeHooks = new $OldClassName();
         $ThemeHooks->OnDisable();
     }
     return TRUE;
 }
Ejemplo n.º 7
0
 public function EnablePlugin($PluginName, $Validation, $Setup = FALSE)
 {
     // 1. Make sure that the plugin's requirements are met
     // Required Plugins
     $AvailablePlugins = $this->AvailablePlugins();
     $RequiredPlugins = ArrayValue('RequiredPlugins', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins, 'plugin');
     // Required Themes
     $ThemeManager = new Gdn_ThemeManager();
     $EnabledThemes = $ThemeManager->EnabledThemeInfo();
     $RequiredThemes = ArrayValue('RequiredTheme', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
     // Required Applications
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
     CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
     // 2. Include the plugin, instantiate it, and call it's setup method
     $PluginInfo = ArrayValue($PluginName, $AvailablePlugins, FALSE);
     $PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
     if ($PluginFolder == '') {
         throw new Exception(Gdn::Translate('The plugin folder was not properly defined.'));
     }
     $PluginClassName = ArrayValue('ClassName', $PluginInfo, FALSE);
     if ($PluginFolder !== FALSE && $PluginClassName !== FALSE && class_exists($PluginClassName) === FALSE) {
         $this->IncludePlugins(array($PluginName => $PluginFolder));
         if (class_exists($PluginClassName)) {
             $Plugin = new $PluginClassName();
             $Plugin->Setup();
         }
     } elseif (class_exists($PluginClassName, FALSE) !== FALSE && $Setup === TRUE) {
         $Plugin = new $PluginClassName();
         $Plugin->Setup();
     }
     // 3. If setup succeeded, register any specified permissions
     $PermissionName = ArrayValue('RegisterPermissions', $PluginInfo, FALSE);
     if ($PermissionName != FALSE) {
         $PermissionModel = Gdn::PermissionModel();
         $PermissionModel->Define($PermissionName);
     }
     if (is_object($Validation) && count($Validation->Results()) > 0) {
         return FALSE;
     }
     // 4. If everything succeeded, add the plugin to the
     // $EnabledPlugins array in conf/plugins.php
     // $EnabledPlugins['PluginClassName'] = 'Plugin Folder Name';
     $Config = Gdn::Factory(Gdn::AliasConfig);
     $Config->Load(PATH_CONF . DS . 'config.php', 'Save');
     $Config->Set('EnabledPlugins' . '.' . $PluginName, $PluginFolder);
     $Config->Save();
     $ApplicationManager = new Gdn_ApplicationManager();
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
     return TRUE;
 }
Ejemplo n.º 8
0
function AddNewKey($Key)
{
    global $Db, $nsProduct, $BF, $Logs, $Lang;
    $Key = str_replace("\n", "", $Key);
    $KEY_DECODE = $BF->decrypt($Key);
    $License = GetLicenseText($KEY_DECODE);
    if (!$License) {
        $Logs->Err($Lang['KeyHasNoInfo']);
        return;
    }
    if ($nsProduct->LICENSE == 1 && !isset($License['P'])) {
        $Logs->Err($Lang['SecondaryKeyErr']);
        return;
    }
    $KeyId = intval(ValidVar($License['ID']));
    if (!ValidId($KeyId) || $KeyId == 0) {
        $Logs->Err($Lang['KeyIsInvalid']);
        return;
    }
    if (ValidVar($License['L']) != intval(ValidVar($License['L']))) {
        $Logs->Err($Lang['KeyIsInvalid']);
        return;
    }
    $Query = "SELECT ID FROM " . PFX . "_tracker_license WHERE KEY_ID={$KeyId} OR LICENSE_KEY='{$Key}'";
    $CheckId = $Db->ReturnValue($Query);
    if (ValidId($CheckId)) {
        $Logs->Err($Lang['KeyExists']);
        return;
    }
    if (CompareVersions($License['V'], $nsProduct->VERSION, 1) != 0) {
        $Logs->Err($Lang['KeyIsInvalid']);
        return;
    }
    if (isset($License['REQ']) && !CheckRequirements($License['REQ'])) {
        $Logs->Err($Lang['RequiredNotFound']);
        return false;
    }
    $Query = "INSERT INTO " . PFX . "_tracker_license (LICENSE_KEY, STAMP, KEY_ID) VALUES ('{$Key}', NOW(), {$KeyId})";
    $Db->Query($Query);
    $nsProduct->Redir("license", "RCrt=1", "admin");
}