/** * Save Email.Flag preference list in config for easier access. */ public function UserModel_BeforeSaveSerialized_Handler($Sender) { if (Gdn::Session()->CheckPermission('Plugins.Flagging.Notify')) { if ($Sender->EventArguments['Column'] == 'Preferences' && is_array($Sender->EventArguments['Name'])) { // Shorten our arguments $UserID = $Sender->EventArguments['UserID']; $Prefs = $Sender->EventArguments['Name']; $FlagPref = GetValue('Email.Flag', $Prefs, NULL); if ($FlagPref !== NULL) { // Add or remove user from config array $NotifyUsers = C('Plugins.Flagging.NotifyUsers', array()); $IsNotified = array_search($UserID, $NotifyUsers); // beware '0' key if ($IsNotified !== FALSE && !$FlagPref) { // Remove from NotifyUsers unset($NotifyUsers[$IsNotified]); } elseif ($IsNotified === FALSE && $FlagPref) { // Add to NotifyUsers $NotifyUsers[] = $UserID; } // Save new list of users to notify SaveToConfig('Plugins.Flagging.NotifyUsers', array_values($NotifyUsers)); } } } }
/** Add button, remove options, increase click area on discussions list. */ public function DiscussionsController_Render_Before($Sender) { $Sender->ShowOptions = FALSE; SaveToConfig('Vanilla.AdminCheckboxes.Use', FALSE, FALSE); $this->AddButton($Sender, 'Discussion'); $this->DiscussionsClickable($Sender); }
/** * First time setup of CountriesOnline plugin. */ public function Setup() { // Time threshold, in seconds, for signed in users grouped by country. SaveToConfig('Plugin.CountriesOnline.TimeThreshold', $this->default_time_threshold); $Structure = Gdn::Structure(); $Structure->Table('CountriesOnline')->Column('UserID', 'int(11)', false, 'primary')->Column('CountryCode', 'char(2)', 'VF')->Column('Timestamp', 'int(10)', false, 'key')->Set(false, false); }
public function OnDisable() { $OldFormat = C('Garden.InputFormatterBak'); if ($OldFormat !== FALSE) { SaveToConfig('Garden.InputFormatter', $OldFormat); } }
/** * Reads in known/config servers and adds them to the instance. * * This method is called when the cache object is invoked by the framework * automatically, and needs to configure itself from the values in the global * config file. */ public function autorun() { $Servers = Gdn_Cache::activeStore('memcached'); if (!is_array($Servers)) { $Servers = explode(',', $Servers); } // No servers, cache temporarily offline if (!sizeof($Servers)) { SaveToConfig('Cache.Enabled', false, false); return false; } // Persistent, and already have servers. Short circuit adding. if ($this->Config(Gdn_Cache::CONTAINER_PERSISTENT) && count($this->servers())) { return true; } $Keys = array(Gdn_Cache::CONTAINER_LOCATION, Gdn_Cache::CONTAINER_PERSISTENT, Gdn_Cache::CONTAINER_WEIGHT, Gdn_Cache::CONTAINER_TIMEOUT, Gdn_Cache::CONTAINER_ONLINE, Gdn_Cache::CONTAINER_CALLBACK); foreach ($Servers as $CacheServer) { $CacheServer = explode(' ', $CacheServer); $CacheServer = array_pad($CacheServer, count($Keys), null); $CacheServer = array_combine($Keys, $CacheServer); foreach ($Keys as $KeyName) { $Value = val($KeyName, $CacheServer, null); if (is_null($Value)) { unset($CacheServer[$KeyName]); } } $this->addContainer($CacheServer); } }
public function __construct() { parent::__construct(); if (!C('Garden.Locales.DeveloperMode', FALSE)) { SaveToConfig('Garden.Locales.DeveloperMode', TRUE); } }
public function Controller_Index($Sender) { $Form =& $Sender->Form; if ($Form->AuthenticatedPostBack()) { $FormValues = $Form->FormValues(); extract($FormValues, EXTR_SKIP); $Options = array('RemoveEmpty' => $RemoveEmpty); if ($Name) { // 1) Simple SaveToConfig(Name, Value) settype($Value, $Type); SaveToConfig($Name, $Value, $Options); self::InformMessage(T('Saved'), 'Check'); } elseif ($Configuration) { $NewLines = self::EvalConfigurationCode($Configuration); if (!is_array($NewLines)) { $Form->AddError($NewLines); } if ($Form->ErrorCount() == 0) { $ValueCode = "\n" . implode("\n", $NewLines); file_put_contents(PATH_CONF . '/config.php', $ValueCode, FILE_APPEND | LOCK_EX); self::InformMessage(T('Saved'), 'Check'); } } } $Sender->Title($this->GetPluginKey('Name')); $Sender->AddSideMenu('plugin/' . $this->GetPluginIndex()); $Sender->View = $this->GetView('index' . '.php'); $Sender->Render(); }
public function Initialize($Schema = NULL) { if ($Schema !== NULL) { $this->Schema($Schema); } $Form = $this->Form(); if ($Form->IsPostBack()) { // Grab the data from the form. $Data = array(); foreach ($this->_Schema as $Row) { $Name = $Row['Name']; $Value = $Form->GetFormValue($Name); if ($Value == GetValue('Default', $Value, '')) { $Value = ''; } $Data[$Name] = $Value; } // Save it to the config. SaveToConfig($Data, array('RemoveEmpty' => TRUE)); $this->_Sender->InformMessage(T('Saved')); } else { // Load the form data from the config. $Data = array(); foreach ($this->_Schema as $Row) { $Data[$Row['Name']] = C($Row['Name'], GetValue('Default', $Row, '')); } $Form->SetData($Data); } }
public function Controller_Cookie($Sender) { $ExplodedDomain = explode('.', Gdn::Request()->RequestHost()); if (sizeof($ExplodedDomain) == 1) { $GuessedCookieDomain = ''; } else { $GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2)); } $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugin.ProxyConnect.NewCookieDomain')); // Set the model on the form. $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack()) { $NewCookieDomain = $Sender->Form->GetValue('Plugin.ProxyConnect.NewCookieDomain', ''); SaveToConfig('Garden.Cookie.Domain', $NewCookieDomain); } else { $NewCookieDomain = $GuessedCookieDomain; } $Sender->SetData('GuessedCookieDomain', $GuessedCookieDomain); $CurrentCookieDomain = C('Garden.Cookie.Domain'); $Sender->SetData('CurrentCookieDomain', $CurrentCookieDomain); $Sender->Form->SetData(array('Plugin.ProxyConnect.NewCookieDomain' => $NewCookieDomain)); $Sender->Form->SetFormValue('Plugin.ProxyConnect.NewCookieDomain', $NewCookieDomain); return $this->GetView('cookie.php'); }
public function Setup() { // Set default configuration. Does not overwrite previous settings. SaveToConfig('Plugins.OldDiscussion.Age', C('Plugins.OldDiscussion.Age', 90)); SaveToConfig('Plugins.OldDiscussion.IgnoreEdits', C('Plugins.OldDiscussion.IgnoreEdits', false)); SaveToConfig('Plugins.OldDiscussion.RequireCheck', C('Plugins.OldDiscussion.RequireCheck', true)); }
/** * Update or add a route to the config table * * @return */ public function SetRoute($Route, $Destination, $Type) { $Key = $this->_EncodeRouteKey($Route); SaveToConfig('Routes.' . $Key . '.0', $Destination); SaveToConfig('Routes.' . $Key . '.1', $Type); $this->_LoadRoutes(); }
public function Setup() { SaveToConfig('Plugin.PrestigeSlider.RenderCondition', 'all'); SaveToConfig('Plugin.PrestigeSlider.ImageCount', '1'); SaveToConfig('Plugin.PrestigeSlider.Image1url', 'http://placehold.it/730x200'); SaveToConfig('Plugin.PrestigeSlider.Image2url', 'http://placehold.it/730x200'); }
private function _TogglePanel($Sender) { $Sender->Permission('Garden.Themes.Manage'); $TransientKey = GetValue(0, $Sender->RequestArgs); if (Gdn::Session()->ValidateTransientKey($TransientKey)) { SaveToConfig('Themes.EmbedFriendly.SingleColumn', C('Themes.EmbedFriendly.SingleColumn') ? FALSE : TRUE); } }
/** * Turn sigs on or off. */ public function SettingsController_ToggleSignatures_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); if (Gdn::Session()->ValidateTransientKey(GetValue(0, $Sender->RequestArgs))) { SaveToConfig('Plugins.Signatures.Enabled', C('Plugins.Signatures.Enabled') ? FALSE : TRUE); } Redirect('settings/signatures'); }
/** * Special function automatically run upon clicking 'Enable' on your application. * Change the word 'Helloworld' anywhere you see it. */ public function Setup() { // You need to manually include structure.php here for it to get run at install. include PATH_APPLICATIONS . DS . 'helloworld' . DS . 'settings' . DS . 'structure.php'; // Stores a value in the config to indicate it has previously been installed. // You can use if(C('Helloworld.Setup', FALSE)) to test whether to repeat part of your setup. SaveToConfig('Helloworld.Setup', TRUE); }
public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender) { // Remove plugins so they don't mess up layout or functionality. if (in_array($Sender->Application(), array('vanilla', 'conversations')) && IsMobile() || $Sender->Application() == 'dashboard' && in_array($Sender->Controller(), array('Activity', 'Profile', 'Search'))) { Gdn::PluginManager()->RemoveMobileUnfriendlyPlugins(); } SaveToConfig('Garden.Format.EmbedSize', '240x135', FALSE); }
public function Structure() { // Get a user for operations. $UserID = Gdn::SQL()->GetWhere('User', array('Name' => 'Mollom', 'Admin' => 2))->Value('UserID'); if (!$UserID) { $UserID = Gdn::SQL()->Insert('User', array('Name' => 'Mollom', 'Password' => RandomString('20'), 'HashMethod' => 'Random', 'Email' => '*****@*****.**', 'DateInserted' => Gdn_Format::ToDateTime(), 'Admin' => '2')); } SaveToConfig('Plugins.Mollom.UserID', $UserID); }
/** * Default search functionality. * * @since 2.0.0 * @access public * @param int $Page Page number. */ public function Index($Page = '') { $this->AddJsFile('search.js'); $this->Title(T('Search')); SaveToConfig('Garden.Format.EmbedSize', '160x90', FALSE); Gdn_Theme::Section('SearchResults'); list($Offset, $Limit) = OffsetLimit($Page, C('Garden.Search.PerPage', 20)); $this->SetData('_Limit', $Limit); $Search = $this->Form->GetFormValue('Search'); $Mode = $this->Form->GetFormValue('Mode'); if ($Mode) { $this->SearchModel->ForceSearchMode = $Mode; } try { $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit); } catch (Gdn_UserException $Ex) { $this->Form->AddError($Ex); $ResultSet = array(); } catch (Exception $Ex) { LogException($Ex); $this->Form->AddError($Ex); $ResultSet = array(); } Gdn::UserModel()->JoinUsers($ResultSet, array('UserID')); // Fix up the summaries. $SearchTerms = explode(' ', Gdn_Format::Text($Search)); foreach ($ResultSet as &$Row) { $Row['Summary'] = SearchExcerpt(Gdn_Format::PlainText($Row['Summary'], $Row['Format']), $SearchTerms); $Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']); $Row['Format'] = 'Html'; } $this->SetData('SearchResults', $ResultSet, TRUE); $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE); if ($ResultSet) { $NumResults = count($ResultSet); } else { $NumResults = 0; } if ($NumResults == $Offset + $Limit) { $NumResults++; } // Build a pager $PagerFactory = new Gdn_PagerFactory(); $this->Pager = $PagerFactory->GetPager('MorePager', $this); $this->Pager->MoreCode = 'More Results'; $this->Pager->LessCode = 'Previous Results'; $this->Pager->ClientID = 'Pager'; $this->Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search)); // if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { // $this->SetJson('LessRow', $this->Pager->ToString('less')); // $this->SetJson('MoreRow', $this->Pager->ToString('more')); // $this->View = 'results'; // } $this->CanonicalUrl(Url('search', TRUE)); $this->Render(); }
public function SaveStep($Step) { if (Gdn::Config($Step, '') != '1') { SaveToConfig($Step, '1'); } // If all of the steps are now completed, disable this plugin if (Gdn::Config('Plugins.GettingStarted.Registration', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Plugins', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Categories', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Profile', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Discussion', '0') == '1') { Gdn::PluginManager()->DisablePlugin('GettingStarted'); } }
/** * Special function automatically run upon clicking 'Enable' on your application. * Change the word 'skeleton' anywhere you see it. */ public function Setup() { // You need to manually include structure.php here for it to get run at install. include(PATH_APPLICATIONS . DS . 'skeleton' . DS . 'settings' . DS . 'structure.php'); // This just gets the version number and stores it in the config file. Good practice but optional. $ApplicationInfo = array(); include(CombinePaths(array(PATH_APPLICATIONS . DS . 'skeleton' . DS . 'settings' . DS . 'about.php'))); $Version = ArrayValue('Version', ArrayValue('Skeleton', $ApplicationInfo, array()), 'Undefined'); SaveToConfig('Skeleton.Version', $Version); }
public function PostController_AfterDiscussionSave_Handler(&$Sender) { $Discussion = $Sender->EventArguments['Discussion']; $DiscussionPostDate = strtotime($Discussion->DateInserted); $DiscussionPostIndex = (int) date('Y', $DiscussionPostDate) + (int) date('d', $DiscussionPostDate); $LastDiscussionIndex = C('Plugin.Sitemaps.LastDiscussionIndex', 0); if ($DiscussionPostIndex > $LastDiscussionIndex) { SaveToConfig('Plugin.Sitemaps.LastDiscussionIndex', $DiscussionPostIndex); SaveToConfig('Plugin.Sitemaps.Regenerate', TRUE); } }
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 Index() { $this->Permission('Garden.Settings.Manage'); $this->AddSideMenu('dashboard/statistics'); //$this->AddJsFile('statistics.js'); $this->Title(T('Vanilla Statistics')); $this->EnableSlicing($this); if ($this->Form->IsPostBack()) { $Flow = TRUE; if ($Flow && $this->Form->GetFormValue('ClearCredentials')) { Gdn::InstallationID(FALSE); Gdn::InstallationSecret(FALSE); Gdn::Statistics()->Tick(); $Flow = FALSE; } if ($Flow && $this->Form->GetFormValue('SaveIdentity')) { Gdn::InstallationID($this->Form->GetFormValue('InstallationID')); Gdn::InstallationSecret($this->Form->GetFormValue('InstallationSecret')); $this->InformMessage(T("Your settings have been saved.")); } if ($Flow && $this->Form->GetFormValue('AllowLocal')) { SaveToConfig('Garden.Analytics.AllowLocal', TRUE); } if ($Flow && $this->Form->GetFormValue('Allow')) { SaveToConfig('Garden.Analytics.Enabled', TRUE); } } $AnalyticsEnabled = Gdn_Statistics::CheckIsEnabled(); if ($AnalyticsEnabled) { $ConfFile = PATH_LOCAL_CONF.DS.'config.php'; $this->SetData('ConfWritable', $ConfWritable = is_writable($ConfFile)); if (!$ConfWritable) $AnalyticsEnabled = FALSE; } $this->SetData('AnalyticsEnabled', $AnalyticsEnabled); $NotifyMessage = Gdn::Get('Garden.Analytics.Notify', FALSE); $this->SetData('NotifyMessage', $NotifyMessage); if ($NotifyMessage !== FALSE) Gdn::Set('Garden.Analytics.Notify', NULL); $this->Form->SetFormValue('InstallationID', Gdn::InstallationID()); $this->Form->SetFormValue('InstallationSecret', Gdn::InstallationSecret()); $this->Render(); }
/** * Initialy set SystemUserID as config value Plugins.Incognito.UserID * and set up category permissions * */ public function Setup() { // set config value if (!is_numeric(C('Plugins.Incognito.UserID'))) { $SystemUserID = Gdn::UserModel()->GetSystemUserID(); SaveToConfig('Plugins.Incognito.UserID', $SystemUserID); } // add category permissions $PermissionModel = Gdn::PermissionModel(); $PermissionModel->Define(array('Vanilla.Discussions.Incognito' => 0, 'Vanilla.Comments.Incognito' => 0), 'tinyint', 'Category', 'PermissionCategoryID'); }
/** * Use 404 handler to look for a SimplePage. */ public function gdn_dispatcher_notFound_handler($dispatcher, $args) { $requestUri = Gdn::Request()->Path(); $discussionModel = new DiscussionModel(); $result = $discussionModel->GetWhere(array('Type' => 'SimplePage', 'ForeignID' => $requestUri))->FirstRow(DATASET_TYPE_ARRAY); // Page exists with requested slug, so dispatch; no redirect. if ($discussionID = val('DiscussionID', $result)) { SaveToConfig('SimplePage.Found', true, false); Gdn::Dispatcher()->Dispatch('/discussion/' . $discussionID); exit; } }
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 EnableTheme($ThemeName) { // Make sure to run the setup $this->TestTheme($ThemeName); // Set the theme $ThemeFolder = ArrayValue('Folder', ArrayValue($ThemeName, $this->AvailableThemes(), array()), ''); if ($ThemeFolder == '') { throw new Exception(T('The theme folder was not properly defined.')); } else { SaveToConfig('Garden.Theme', $ThemeFolder); } return TRUE; }
/** * Get profile fields imported and add to ProfileFields list. */ public function ProfileExtenderPrep() { $ProfileKeyData = $this->SQL->Select('m.Name')->Distinct()->From('UserMeta m')->Like('m.Name', 'Profile_%')->Get(); $ExistingKeys = array_filter((array) explode(',', C('Plugins.ProfileExtender.ProfileFields', ''))); foreach ($ProfileKeyData->Result() as $Key) { $Name = str_replace('Profile.', '', $Key->Name); if (!in_array($Name, $ExistingKeys)) { $ExistingKeys[] = $Name; } } if (count($ExistingKeys)) { SaveToConfig('Plugins.ProfileExtender.ProfileFields', implode(',', $ExistingKeys)); } }
public function Setup() { // Got Setup? $Database = Gdn::Database(); $Config = Gdn::Factory(Gdn::AliasConfig); $Drop = C('Skeleton.Version') === FALSE ? TRUE : FALSE; $Explicit = TRUE; $Validation = new Gdn_Validation(); // This is going to be needed by structure.php to validate permission names include PATH_APPLICATIONS . DS . 'skeleton' . DS . 'settings' . DS . 'structure.php'; $ApplicationInfo = array(); include CombinePaths(array(PATH_APPLICATIONS . DS . 'skeleton' . DS . 'settings' . DS . 'about.php')); $Version = ArrayValue('Version', ArrayValue('Skeleton', $ApplicationInfo, array()), 'Undefined'); SaveToConfig('Skeleton.Version', $Version); }
public function Update(SplSubject $Subject) { $Status = $Subject->getStatus(); //retrieve status array $Results = $Status['Results']; $Sender = $Status['Sender']; //store stats ...perform this after the search since we grab the indivdual search words //that sphinx has search against. This saves us processing time of each and seperating other things if ($Sender->ControllerName == 'searchcontroller') { if (isset($Results['MainSearch']['words'])) { $this->InsertStats($Results['MainSearch']['words']); } if (isset($Results[$this->NameTKeywords]['matches'])) { $SingleKeywords = $this->SingleKeywords($Results[$this->NameTKeywords], $this->Settings['Admin']->LimitTopKeywords); //single keywords (apple, vanilla, cool) foreach ($SingleKeywords as $Row) { $KeywordsArray[] = $Row->keywords; } if (isset($KeywordsArray)) { $Module = new KeywordsCloudModule($KeywordsArray); $Sender->AddModule($Module); } } if (isset($Results[$this->NameTSearches]['matches'])) { $TopSearches = $this->FullSearches($Results[$this->NameTSearches], $this->Settings['Admin']->LimitTopSearches); $Module = new TopSearchesModule($TopSearches); $Sender->AddModule($Module); } if (isset($Results[$this->NameRSearches]['matches'])) { $RelatedSearches = $this->FullSearches($Results[$this->NameRSearches], $this->Settings['Admin']->LimitRelatedSearches); // full search ("vanllia is cool") $Module = new RelatedSearchesModule($RelatedSearches); $Sender->AddModule($Module); } } else { if (isset($Results[$this->NameTMainSearches]['matches'])) { SaveToConfig('Plugin.SphinxSearch.IndexerMainTotal', $Results[$this->NameTMainSearches]['total_found']); } else { if (isset($Results[$this->NameTDeltaSearches]['matches'])) { SaveToConfig('Plugin.SphinxSearch.IndexerDeltaTotal', $Results[$this->NameTDeltaSearches]['total_found']); } else { if (isset($Results[$this->NameTStatsSearches]['matches'])) { SaveToConfig('Plugin.SphinxSearch.IndexerStatsTotal', $Results[$this->NameTStatsSearches]['total_found']); } } } } }