/** * Updates. */ public function Structure() { // Backwards compatibility with v1. if (C('Plugins.TouchIcon.Uploaded')) { SaveToConfig('Garden.TouchIcon', 'TouchIcon/apple-touch-icon.png'); RemoveFromConfig('Plugins.TouchIcon.Uploaded'); } }
public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender) { if (!C('Plugin.Sitemaps.Regenerate')) { return; } RemoveFromConfig('Plugin.Sitemaps.Regenerate'); $Sender->AddJsFile($this->GetResource('js/sitemaps.js', FALSE, FALSE)); }
public function Controller_Toggle($Sender) { if (Gdn::Session()->ValidateTransientKey(GetValue(1, $Sender->RequestArgs))) { if (C('Plugins.SEO.Enabled')) { RemoveFromConfig('Plugins.SEO.Enabled'); } else { SaveToConfig('Plugins.SEO.Enabled', TRUE); } } redirect('plugin/seo'); }
public function DeleteRoute($Route) { $Route = $this->GetRoute($Route); // Is a valid route? if ($Route !== FALSE) { if (!in_array($Route['Route'], $this->ReservedRoutes)) { RemoveFromConfig('Routes.' . $Route['Key']); $this->_LoadRoutes(); } } }
public function Controller_Toggle($Sender) { // Enable/Disable Content Flagging if (Gdn::Session()->ValidateTransientKey(GetValue(1, $Sender->RequestArgs))) { if (C('Plugins.Kudos.Enabled')) { RemoveFromConfig('Plugins.Kudos.Enabled'); } else { SaveToConfig('Plugins.Kudos.Enabled', TRUE); } Redirect('plugin/kudos'); } }
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; }
public function UnsetDefaultAuthenticator($AuthenticationSchemeAlias) { $AuthenticationSchemeAlias = strtolower($AuthenticationSchemeAlias); if (C('Garden.Authenticator.DefaultScheme') == $AuthenticationSchemeAlias) { RemoveFromConfig('Garden.Authenticator.DefaultScheme'); return TRUE; } return FALSE; }
public function EnableTheme($ThemeName, $IsMobile = FALSE) { // Make sure to run the setup $this->TestTheme($ThemeName); // Set the theme. $ThemeInfo = $this->GetThemeInfo($ThemeName); $ThemeFolder = GetValue('Folder', $ThemeInfo, ''); $oldTheme = $IsMobile ? C('Garden.MobileTheme', 'mobile') : C('Garden.Theme', 'default'); if ($ThemeFolder == '') { throw new Exception(T('The theme folder was not properly defined.')); } else { $Options = GetValueR("{$ThemeName}.Options", $this->AvailableThemes()); if ($Options) { if ($IsMobile) { SaveToConfig(array('Garden.MobileTheme' => $ThemeName, 'Garden.MobileThemeOptions.Name' => GetValueR("{$ThemeName}.Name", $this->AvailableThemes(), $ThemeFolder))); } else { SaveToConfig(array('Garden.Theme' => $ThemeName, 'Garden.ThemeOptions.Name' => GetValueR("{$ThemeName}.Name", $this->AvailableThemes(), $ThemeFolder))); } } else { if ($IsMobile) { SaveToConfig('Garden.MobileTheme', $ThemeName); RemoveFromConfig('Garden.MobileThemeOptions'); } else { SaveToConfig('Garden.Theme', $ThemeName); RemoveFromConfig('Garden.ThemeOptions'); } } } Logger::event('theme_changed', LogLevel::NOTICE, 'The {themeType} theme changed from {oldTheme} to {newTheme}.', array('themeType' => $IsMobile ? 'mobile' : 'desktop', 'oldTheme' => $oldTheme, 'newTheme' => $ThemeName)); // Tell the locale cache to refresh itself. Gdn::Locale()->Refresh(); return TRUE; }
$RoleModel->Define(array('Name' => 'Moderator', 'RoleID' => 32, 'Sort' => '5', 'Deletable' => '1', 'CanSession' => '1', 'Description' => T('Moderator Role Description', 'Moderators have permission to edit most content.'))); $RoleModel->Define(array('Name' => 'Administrator', 'RoleID' => 16, 'Sort' => '6', 'Deletable' => '1', 'CanSession' => '1', 'Description' => T('Administrator Role Description', 'Administrators have permission to do anything.'))); unset($RoleModel); } // User Table $Construct->Table('User'); $PhotoIDExists = $Construct->ColumnExists('PhotoID'); $PhotoExists = $Construct->ColumnExists('Photo'); $Construct->PrimaryKey('UserID')->Column('Name', 'varchar(50)', FALSE, 'key')->Column('Password', 'varbinary(100)')->Column('HashMethod', 'varchar(10)', TRUE)->Column('Photo', 'varchar(255)', NULL)->Column('Title', 'varchar(100)', NULL)->Column('Location', 'varchar(100)', NULL)->Column('About', 'text', TRUE)->Column('Email', 'varchar(200)', FALSE, 'index')->Column('ShowEmail', 'tinyint(1)', '0')->Column('Gender', array('u', 'm', 'f'), 'u')->Column('CountVisits', 'int', '0')->Column('CountInvitations', 'int', '0')->Column('CountNotifications', 'int', NULL)->Column('InviteUserID', 'int', TRUE)->Column('DiscoveryText', 'text', TRUE)->Column('Preferences', 'text', TRUE)->Column('Permissions', 'text', TRUE)->Column('Attributes', 'text', TRUE)->Column('DateSetInvitations', 'datetime', TRUE)->Column('DateOfBirth', 'datetime', TRUE)->Column('DateFirstVisit', 'datetime', TRUE)->Column('DateLastActive', 'datetime', TRUE, 'index')->Column('LastIPAddress', 'varchar(39)', TRUE)->Column('AllIPAddresses', 'varchar(100)', TRUE)->Column('DateInserted', 'datetime', FALSE, 'index')->Column('InsertIPAddress', 'varchar(39)', TRUE)->Column('DateUpdated', 'datetime', TRUE)->Column('UpdateIPAddress', 'varchar(39)', TRUE)->Column('HourOffset', 'int', '0')->Column('Score', 'float', NULL)->Column('Admin', 'tinyint(1)', '0')->Column('Verified', 'tinyint(1)', '0')->Column('Banned', 'tinyint(1)', '0')->Column('Deleted', 'tinyint(1)', '0')->Column('Points', 'int', 0)->Set($Explicit, $Drop); // Make sure the system user is okay. $SystemUserID = C('Garden.SystemUserID'); if ($SystemUserID) { $SysUser = Gdn::UserModel()->GetID($SystemUserID); if (!$SysUser || GetValue('Deleted', $SysUser) || GetValue('Admin', $SysUser) != 2) { $SystemUserID = FALSE; RemoveFromConfig('Garden.SystemUserID'); } } if (!$SystemUserID) { // Try and find a system user. $SystemUserID = Gdn::SQL()->GetWhere('User', array('Name' => 'System', 'Admin' => 2))->Value('UserID'); if ($SystemUserID) { SaveToConfig('Garden.SystemUserID', $SystemUserID); } } // UserRole Table $Construct->Table('UserRole'); $UserRoleExists = $Construct->TableExists(); $Construct->Column('UserID', 'int', FALSE, 'primary')->Column('RoleID', 'int', FALSE, 'primary')->Set($Explicit, $Drop); if (!$UserRoleExists) { // Assign the guest user to the guest role
/** * * * @return bool */ public function initialize() { if ($this->GenerateSQL()) { $this->SQL->CaptureModifications = true; Gdn::structure()->CaptureOnly = true; $this->Database->CapturedSql = array(); $SQLPath = $this->data('SQLPath'); if (!$SQLPath) { $SQLPath = 'import/import_' . date('Y-m-d_His') . '.sql'; $this->data('SQLPath', $SQLPath); } } else { // Importing will overwrite our System user record. // Our CustomFinalization step (e.g. vbulletinimportmodel) needs this to be regenerated. RemoveFromConfig('Garden.SystemUserID'); } return true; }
/** * Remove the mobile logo from config & delete it. * * @since 2.0.0 * @access public */ public function removeMobileLogo() { if (Gdn::request()->isAuthenticatedPostBack(true) && Gdn::session()->checkPermission('Garden.Community.Manage')) { $MobileLogo = c('Garden.MobileLogo', ''); RemoveFromConfig('Garden.MobileLogo'); safeUnlink(PATH_ROOT . "/{$MobileLogo}"); $this->informMessage(sprintf(t('%s deleted.'), t('Mobile logo'))); } $this->render('blank', 'utility', 'dashboard'); }
/** * Gets/Sets the Garden Installation Secret * * @staticvar string $InstallationSecret * @param string $SetInstallationSecret * @return string Installation Secret or NULL */ public static function InstallationSecret($SetInstallationSecret = NULL) { static $InstallationSecret = FALSE; if (!is_null($SetInstallationSecret)) { if ($SetInstallationSecret !== FALSE) { SaveToConfig ('Garden.InstallationSecret', $SetInstallationSecret); } else { RemoveFromConfig('Garden.InstallationSecret'); } $InstallationSecret = $SetInstallationSecret; } if ($InstallationSecret === FALSE) $InstallationSecret = C('Garden.InstallationSecret', NULL); return $InstallationSecret; }
/** * 1-Time on Disable */ public function OnDisable() { RemoveFromConfig('Plugins.AllViewed.Enabled'); }
/** * Delete a field. */ public function SettingsController_ProfileFieldDelete_Create($Sender, $Args) { $Sender->Permission('Garden.Settings.Manage'); $Sender->SetData('Title', 'Delete Field'); if (isset($Args[0])) { if ($Sender->Form->IsPostBack()) { RemoveFromConfig('ProfileExtender.Fields.' . $Args[0]); $Sender->RedirectUrl = Url('/settings/profileextender'); } else { $Sender->SetData('Field', $this->GetProfileField($Args[0])); } } $Sender->Render('delete', '', 'plugins/ProfileExtender'); }
/** * Plugin cleanup * * This method is fired only once, immediately before the plugin is disabled, and is a great place to * perform cleanup tasks such as deletion of unsued files and folders. */ public function OnDisable() { RemoveFromConfig('Plugins.Chat.Domain'); }
/** * Gets/Sets the Garden Installation Secret * * @staticvar string $InstallationSecret * @param string $SetInstallationSecret * @return string Installation Secret or NULL */ public static function installationSecret($SetInstallationSecret = null) { static $InstallationSecret = false; if (!is_null($SetInstallationSecret)) { if ($SetInstallationSecret !== false) { SaveToConfig('Garden.InstallationSecret', $SetInstallationSecret); } else { RemoveFromConfig('Garden.InstallationSecret'); } $InstallationSecret = $SetInstallationSecret; } if ($InstallationSecret === false) { $InstallationSecret = c('Garden.InstallationSecret', null); } return $InstallationSecret; }
public function Delete($RouteIndex = FALSE, $TransientKey = FALSE) { $this->Permission('Garden.Routes.Manage'); $this->DeliveryType(DELIVERY_TYPE_BOOL); $Session = Gdn::Session(); $Routes = Gdn::Config('Routes'); $Key = FALSE; if (is_numeric($RouteIndex) && $RouteIndex !== FALSE) { $Keys = array_keys($Routes); $Key = ArrayValue($RouteIndex, $Keys); } // If seeing the form for the first time... if ($TransientKey !== FALSE && $Session->ValidateTransientKey($TransientKey) && !in_array($Key, $this->ReservedRoutes) && $Key !== FALSE) { RemoveFromConfig('Routes' . '.' . $Key); } if ($this->_DeliveryType === DELIVERY_TYPE_ALL) { Redirect('garden/routes'); } $this->Render(); }
public function DisablePlugin($PluginName) { // 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 => $CheckingInfo) { $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); $ApplicationManager = new Gdn_ApplicationManager(); $Locale = Gdn::Locale(); $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE); }
/** * Remove the mobile logo from config & delete it. * * @since 2.0.0 * @access public * @param string $TransientKey Security token. */ public function removeMobileLogo($TransientKey = '') { $Session = Gdn::session(); if ($Session->validateTransientKey($TransientKey) && $Session->checkPermission('Garden.Community.Manage')) { $MobileLogo = c('Garden.MobileLogo', ''); RemoveFromConfig('Garden.MobileLogo'); @unlink(PATH_ROOT . DS . $MobileLogo); } redirect('/settings/banner'); }
/** * 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'); }
public function OnDisable() { RemoveFromConfig('Plugin.Chatwee.Code'); RemoveFromConfig('Plugin.Chatwee.APIKey'); RemoveFromConfig('Plugin.Chatwee.Chatid'); }
/** * Database changes needed for this plugin. */ public function Structure() { $Structure = Gdn::Structure(); $Structure->Table('Flag')->Column('DiscussionID', 'int(11)', TRUE)->Column('InsertUserID', 'int(11)', FALSE, 'key')->Column('InsertName', 'varchar(64)')->Column('AuthorID', 'int(11)')->Column('AuthorName', 'varchar(64)')->Column('ForeignURL', 'varchar(255)', FALSE, 'key')->Column('ForeignID', 'int(11)')->Column('ForeignType', 'varchar(32)')->Column('Comment', 'text')->Column('DateInserted', 'datetime')->Set(FALSE, FALSE); // Turn off disabled Flagging plugin (deprecated) if (C('Plugins.Flagging.Enabled', NULL) === FALSE) { RemoveFromConfig('EnabledPlugins.Flagging'); } }
public function DeleteState() { RemoveFromConfig('Garden.Import'); }
public function Setup() { if (!is_dir('uploads/tmp')) { mkdir('uploads/tmp', 0777, True); } if (!is_dir('uploads/i')) { mkdir('uploads/i', 0777, True); } RemoveFromConfig('EnabledPlugins.LoadUp'); RemoveFromConfig('Plugins.LoadUp'); $this->Structure(); }
/** * 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 = ArrayValue($ApplicationName, $this->AvailableApplications(), array()); 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); // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, TRUE); $PluginManager = Gdn::Factory('PluginManager'); $Locale = Gdn::Locale(); $Locale->Set($Locale->Current(), $this->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE); }
/** * * * @throws Gdn_UserException */ public function disableTheme() { if ($this->currentTheme() == 'default') { throw new Gdn_UserException(T('You cannot disable the default theme.')); } $oldTheme = $this->enabledTheme(); RemoveFromConfig('Garden.Theme'); $newTheme = $this->enabledTheme(); if ($oldTheme != $newTheme) { $this->themeHook($oldTheme, self::ACTION_DISABLE, true); Logger::event('theme_changed', 'The {themeType} theme was changed from {oldTheme} to {newTheme}.', array('themeType' => 'desktop', 'oldTheme' => $oldTheme, 'newTheme' => $newTheme)); } }
public function RemoveLogo($TransientKey = '') { $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey) && $Session->CheckPermission('Garden.Themes.Manage')) { $Logo = C('Garden.Logo', ''); RemoveFromConfig('Garden.Logo'); @unlink(PATH_ROOT . DS . $Logo); } Redirect('/settings/banner'); }
public function EnableTheme($ThemeName) { // Make sure to run the setup $this->TestTheme($ThemeName); // Set the theme. $ThemeInfo = $this->GetThemeInfo($ThemeName); $ThemeFolder = GetValue('Folder', $ThemeInfo, ''); if ($ThemeFolder == '') { throw new Exception(T('The theme folder was not properly defined.')); } else { $Options = GetValueR("{$ThemeName}.Options", $this->AvailableThemes()); if ($Options) { SaveToConfig(array('Garden.Theme' => $ThemeName, 'Garden.ThemeOptions.Name' => GetValueR("{$ThemeName}.Name", $this->AvailableThemes(), $ThemeFolder))); } else { SaveToConfig('Garden.Theme', $ThemeName); RemoveFromConfig('Garden.ThemeOptions'); } } // Tell the locale cache to refresh itself. Gdn::Locale()->Refresh(); return TRUE; }
protected function _Disable() { RemoveFromConfig('Plugins.Flagging.Enabled'); }
/** * 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. @unlink(PATH_LOCAL_CACHE.'/controller_map.ini'); @unlink(PATH_LOCAL_CACHE.'/library_map.ini'); // 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); }