/** * Display the embedded forum. * * @since 2.0.18 * @access public */ public function Index() { $this->AddSideMenu('dashboard/embed'); $this->Title('Embed Vanilla'); $this->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Garden.TrustedDomains')); $this->Form->SetModel($ConfigurationModel); if ($this->Form->AuthenticatedPostBack() === FALSE) { // Format trusted domains as a string $TrustedDomains = GetValue('Garden.TrustedDomains', $ConfigurationModel->Data); if (is_array($TrustedDomains)) { $TrustedDomains = implode("\n", $TrustedDomains); } $ConfigurationModel->Data['Garden.TrustedDomains'] = $TrustedDomains; // Apply the config settings to the form. $this->Form->SetData($ConfigurationModel->Data); } else { // Format the trusted domains as an array based on newlines & spaces $TrustedDomains = $this->Form->GetValue('Garden.TrustedDomains'); $TrustedDomains = explode(' ', str_replace("\n", ' ', $TrustedDomains)); $TrustedDomains = array_unique(array_map('trim', $TrustedDomains)); $this->Form->SetFormValue('Garden.TrustedDomains', $TrustedDomains); if ($this->Form->Save() !== FALSE) { $this->InformMessage(T("Your settings have been saved.")); } // Reformat array as string so it displays properly in the form $this->Form->SetFormValue('Garden.TrustedDomains', implode("\n", $TrustedDomains)); } $this->Render(); }
public function PluginController_SingleSignOn_Create($Sender, $EventArguments) { $Sender->Head->Title('Single Sign-on'); $Sender->AddSideMenu('garden/plugin/singlesignon'); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Garden.Authenticator.Type', 'Garden.Authenticator.Encoding', 'Garden.Authenticator.AuthenticateUrl', 'Garden.Authenticator.SignInUrl', 'Garden.Authenticator.SignOutUrl', 'Garden.Authenticator.RegisterUrl', 'Garden.Cookie.Path')); // Set the model on the form. $Sender->Form = new Gdn_Form(); $Sender->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if ($Sender->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $Sender->Form->SetData($ConfigurationModel->Data); $Sender->Form->SetValue('EnableSSO', Gdn::Config('Garden.Authenticator.Type') == 'Handshake' ? 'TRUE' : ''); } else { // Make sure to force some values $Sender->Form->SetFormValue('Garden.Authenticator.Type', $Sender->Form->GetFormValue('EnableSSO', '') == 'TRUE' ? 'Handshake' : 'Password'); $Sender->Form->SetFormValue('Garden.Authenticator.Encoding', 'ini'); $Sender->Form->SetFormValue('Garden.Cookie.Path', '/'); // <-- Make sure that Vanilla's cookies don't have a path if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = Translate("Your changes have been saved successfully."); } } $Sender->Render(PATH_PLUGINS . DS . 'SingleSignOn' . DS . 'views' . DS . 'index.php'); }
/** * Get flagged content & show settings. * * Default method of virtual Flagging controller. */ public function controller_index($Sender) { $Sender->addCssFile('admin.css'); $Sender->addCssFile($this->getResource('design/flagging.css', false, false)); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Plugins.Flagging.UseDiscussions', 'Plugins.Flagging.CategoryID')); // Set the model on the form. $Sender->Form->setModel($ConfigurationModel); // If seeing the form for the first time... if ($Sender->Form->authenticatedPostBack() === false) { // Apply the config settings to the form. $Sender->Form->setData($ConfigurationModel->Data); } else { $Saved = $Sender->Form->save(); if ($Saved) { $Sender->informMessage(t("Your changes have been saved.")); } } $FlaggedItems = Gdn::sql()->select('*')->from('Flag fl')->orderBy('DateInserted', 'DESC')->get(); $Sender->FlaggedItems = array(); while ($Flagged = $FlaggedItems->nextRow(DATASET_TYPE_ARRAY)) { $URL = $Flagged['ForeignURL']; $Index = $Flagged['DateInserted'] . '-' . $Flagged['InsertUserID']; $Flagged['EncodedURL'] = str_replace('=', '-', base64_encode($Flagged['ForeignURL'])); $Sender->FlaggedItems[$URL][$Index] = $Flagged; } unset($FlaggedItems); Gdn_Theme::section('Moderation'); $Sender->render($this->getView('flagging.php')); }
public function Spam() { $this->Permission('Vanilla.Spam.Manage'); $this->AddSideMenu('vanilla/settings/spam'); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel('Configuration', PATH_CONF . DS . 'config.php', $Validation); $ConfigurationModel->SetField(array('Vanilla.Discussion.SpamCount', 'Vanilla.Discussion.SpamTime', 'Vanilla.Discussion.SpamLock', 'Vanilla.Comment.SpamCount', 'Vanilla.Comment.SpamTime', 'Vanilla.Comment.SpamLock', 'Vanilla.Comment.MaxLength')); // Set the model on the form. $this->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if ($this->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $this->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamCount', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamTime', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussion.SpamLock', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamCount', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamTime', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.SpamLock', 'Integer'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Required'); $ConfigurationModel->Validation->ApplyRule('Vanilla.Comment.MaxLength', 'Integer'); if ($this->Form->Save() !== FALSE) { $this->StatusMessage = Translate("Your changes have been saved."); } } $this->Render(); }
public function Controller_Index($Sender) { // Prevent non-admins from accessing this page $Sender->Permission('Vanilla.Settings.Manage'); $Sender->SetData('PluginDescription', $this->GetPluginKey('Description')); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugin.PrestigeSlider.RenderCondition' => 'all', 'Plugin.PrestigeSlider.ImageCount' => 0, 'Plugin.PrestigeSlider.Image1url' => '', 'Plugin.PrestigeSlider.Image2url' => '', 'Plugin.PrestigeSlider.Image3url' => '', 'Plugin.PrestigeSlider.Image4url' => '', 'Plugin.PrestigeSlider.Image5url' => '', 'Plugin.PrestigeSlider.Image1href' => '', 'Plugin.PrestigeSlider.Image2href' => '', 'Plugin.PrestigeSlider.Image3href' => '', 'Plugin.PrestigeSlider.Image4href' => '', 'Plugin.PrestigeSlider.Image5href' => '')); // Set the model on the form. $Sender->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if ($Sender->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $Sender->Form->SetData($ConfigurationModel->Data); } else { $ConfigurationModel->Validation->ApplyRule('Plugin.PrestigeSlider.ImageCount', 'Required'); $ConfigurationModel->Validation->ApplyRule('Plugin.PrestigeSlider.Image1url', 'Required'); $Saved = $Sender->Form->Save(); if ($Saved) { $Sender->StatusMessage = T("Your changes have been saved."); } } // GetView() looks for files inside plugins/PluginFolderName/views/ and returns their full path. Useful! $Sender->Render($this->GetView('settings.php')); }
/** * Allows customization of categories which allow new discussions to be events * Sets config value Plugins.EventCalendar.CategoryIDs * * @param object $Sender SettingsController */ public function SettingsController_EventCalendar_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Sender->Title(T('Event Calendar Settings')); $Sender->AddSideMenu('settings/EventCalendar'); $Sender->SetData('Info', T('Event Calendar Info', 'Creation of events can be regulated by category <strong>and</strong> user role. You can set up the categories here, but don\'t forget to assign some permissions in the <a href="/index.php?p=dashboard/role">standard permission section</a> in the dashboard, otherwise you users wouldn\'t be able to use this plugin!')); $Sender->SetData('CategoriesLabel', 'Please choose categories in which the creation of events should be allowed'); $Validation = new Gdn_Validation(); // $Validation->ApplyRule('Plugins.EventCalendar.CategoryIDs', 'RequiredArray', T('You have to choose at least one category. If you don\'t want to use the plugin any longer, please deactivate it')); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.EventCalendar.CategoryIDs')); $Form = $Sender->Form; $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() != FALSE) { if ($Sender->Form->Save() != FALSE) { $Sender->StatusMessage = T('Saved'); } } else { $Sender->Form->SetData($ConfigurationModel->Data); } $CategoryModel = new Gdn_Model('Category'); $Sender->CategoryData = $CategoryModel->GetWhere(array('AllowDiscussions' => 1, 'CategoryID <>' => -1)); $Sender->EventCategory = C('Plugins.EventCalendar.CategoryIDs'); $Sender->Render('settings', '', 'plugins/EventCalendar'); }
/** * Settings page. */ public function PluginController_ShareThis_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Sender->Title('ShareThis'); $Sender->AddSideMenu('plugin/sharethis'); $Sender->Form = new Gdn_Form(); $PublisherNumber = C('Plugin.ShareThis.PublisherNumber', 'Publisher Number'); $ViaHandle = C('Plugin.ShareThis.ViaHandle', ''); $CopyNShare = C('Plugin.ShareThis.CopyNShare', false); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigArray = array('Plugin.ShareThis.PublisherNumber', 'Plugin.ShareThis.ViaHandle', 'Plugin.ShareThis.CopyNShare'); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $ConfigArray['Plugin.ShareThis.PublisherNumber'] = $PublisherNumber; $ConfigArray['Plugin.ShareThis.ViaHandle'] = $ViaHandle; $ConfigArray['Plugin.ShareThis.CopyNShare'] = $CopyNShare; } $ConfigurationModel->SetField($ConfigArray); $Sender->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if ($Sender->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $Sender->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Plugin.ShareThis.PublisherNumber', 'Required'); if ($Sender->Form->Save() !== FALSE) { $Sender->InformMessage(T("Your changes have been saved.")); } } $Sender->Render('sharethis', '', 'plugins/ShareThis'); }
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 Edit($RouteIndex = FALSE) { $this->Permission('Garden.Routes.Manage'); $this->AddSideMenu('dashboard/routes'); $this->Route = Gdn::Router()->GetRoute($RouteIndex); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Route', 'Target', 'Type')); // Set the model on the form. $this->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if (!$this->Form->AuthenticatedPostBack()) { // Apply the route info to the form. if ($this->Route !== FALSE) $this->Form->SetData(array( 'Route' => $this->Route['Route'], 'Target' => $this->Route['Destination'], 'Type' => $this->Route['Type'] )); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Route', 'Required'); $ConfigurationModel->Validation->ApplyRule('Target', 'Required'); $ConfigurationModel->Validation->ApplyRule('Type', 'Required'); // Validate & Save $FormPostValues = $this->Form->FormValues(); // Dunno. if ($this->Route['Reserved']) $FormPostValues['Route'] = $this->Route['Route']; if ($ConfigurationModel->Validate($FormPostValues)) { $NewRouteName = ArrayValue('Route', $FormPostValues); if ($this->Route !== FALSE && $NewRouteName != $this->Route['Route']) Gdn::Router()->DeleteRoute($this->Route['Route']); Gdn::Router()->SetRoute( $NewRouteName, ArrayValue('Target', $FormPostValues), ArrayValue('Type', $FormPostValues) ); $this->InformMessage(T("The route was saved successfully.")); $this->RedirectUrl = Url('dashboard/routes'); } else { $this->Form->SetValidationResults($ConfigurationModel->ValidationResults()); } } $this->Render(); }
public function PluginController_Embed_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Sender->Title('Embed Vanilla'); $Sender->AddCssFile($this->GetResource('design/settings.css', FALSE, FALSE)); $Sender->AddSideMenu('plugin/embed'); $Sender->Form = new Gdn_Form(); $ThemeManager = new Gdn_ThemeManager(); $Sender->SetData('AvailableThemes', $ThemeManager->AvailableThemes()); $Sender->SetData('EnabledThemeFolder', $ThemeManager->EnabledTheme()); $Sender->SetData('EnabledTheme', $ThemeManager->EnabledThemeInfo()); $Sender->SetData('EnabledThemeName', $Sender->Data('EnabledTheme.Name', $Sender->Data('EnabledTheme.Folder'))); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.EmbedVanilla.RemoteUrl', 'Plugins.EmbedVanilla.ForceRemoteUrl', 'Plugins.EmbedVanilla.EmbedDashboard')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $Sender->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Plugins.EmbedVanilla.RemoteUrl', 'WebAddress', 'The remote url you specified could not be validated as a functional url to redirect to.'); if ($Sender->Form->Save() !== FALSE) $Sender->InformMessage(T("Your settings have been saved.")); } // Handle changing the theme to the recommended one $ThemeFolder = GetValue(0, $Sender->RequestArgs); $TransientKey = GetValue(1, $Sender->RequestArgs); $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey) && $ThemeFolder != '') { try { foreach ($Sender->Data('AvailableThemes') as $ThemeName => $ThemeInfo) { if ($ThemeInfo['Folder'] == $ThemeFolder) $ThemeManager->EnableTheme($ThemeName); } } catch (Exception $Ex) { $Sender->Form->AddError($Ex); } if ($Sender->Form->ErrorCount() == 0) Redirect('/plugin/embed'); } $Sender->Render(PATH_PLUGINS.'/embedvanilla/views/settings.php'); }
public function Controller_Toggle($Sender) { $FileUploadStatus = Gdn::Config('Plugins.FileUpload.Enabled', FALSE); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('FileUploadStatus')); // Set the model on the form. $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack()) { $FileUploadStatus = $Sender->Form->GetValue('FileUploadStatus') == 'ON' ? TRUE : FALSE; SaveToConfig('Plugins.FileUpload.Enabled', $FileUploadStatus); } $Sender->SetData('FileUploadStatus', $FileUploadStatus); $Sender->Form->SetData(array('FileUploadStatus' => $FileUploadStatus)); $Sender->Render($this->GetView('toggle.php')); }
public function settings($Toggle = '', $TransientKey = '') { $this->permission('Garden.Settings.Manage'); // try { // if ($this->toggle($Toggle, $TransientKey)) { // redirect('embed/advanced'); // } // } catch (Gdn_UserException $Ex) { // $this->Form->addError($Ex); // } $this->setHighlightRoute('embed/forum'); $this->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Garden.Embed.RemoteUrl', 'Garden.Embed.ForceDashboard', 'Garden.Embed.ForceForum', 'Garden.Embed.ForceMobile', 'Garden.SignIn.Popup', 'Garden.Embed.CommentsPerPage', 'Garden.Embed.SortComments', 'Garden.Embed.PageToForum')); $this->Form->setModel($ConfigurationModel); if ($this->Form->authenticatedPostBack()) { if ($this->Form->save() !== false) { $this->informMessage(t("Your settings have been saved.")); } } else { // Apply the config settings to the form. $this->Form->setData($ConfigurationModel->Data); } $this->title(t('Embed Settings')); $this->render(); }
public function Edit($RouteIndex = FALSE) { $this->Permission('Garden.Routes.Manage'); $this->AddSideMenu('garden/routes'); $Routes = Gdn::Config('Routes'); $this->Route = FALSE; if (is_numeric($RouteIndex) && $RouteIndex !== FALSE) { $Keys = array_keys($Routes); $this->Route = ArrayValue($RouteIndex, $Keys); } $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel('Configuration', PATH_CONF . DS . 'config.php', $Validation); $ConfigurationModel->SetField(array('Route', 'Target')); // Set the model on the form. $this->Form->SetModel($ConfigurationModel); // If seeing the form for the first time... if (!$this->Form->AuthenticatedPostBack()) { // Apply the config settings to the form. if ($this->Route !== FALSE) { $this->Form->SetData(array('Route' => $this->Route, 'Target' => $Routes[$this->Route])); } } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Route', 'Required'); $ConfigurationModel->Validation->ApplyRule('Target', 'Required'); // Validate & Save $FormPostValues = $this->Form->FormValues(); if (in_array($this->Route, $this->ReservedRoutes)) { $FormPostValues['Route'] = $this->Route; } if ($ConfigurationModel->Validate($FormPostValues)) { $Config = Gdn::Factory(Gdn::AliasConfig); $Path = PATH_CONF . DS . 'config.php'; $Config->Load($Path, 'Save'); $Config->Set('Routes' . '.' . ArrayValue('Route', $FormPostValues), ArrayValue('Target', $FormPostValues)); $Config->Save($Path); $this->StatusMessage = Translate("The route was saved successfully."); if ($this->_DeliveryType == DELIVERY_TYPE_ALL) { $this->RedirectUrl = Url('garden/routes'); } } else { $this->Form->SetValidationResults($ConfigurationModel->ValidationResults()); } } $this->Render(); }
public function PluginController_HidePanel_Create(&$Sender, $Args = array()) { $Sender->Permission('Garden.Settings.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.HidePanel.HideToggle', 'Plugins.HidePanel.AllDisc', 'Plugins.HidePanel.Page1', 'Plugins.HidePanel.Page2', 'Plugins.HidePanel.Page3')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->Render($this->GetView('hpan-settings.php')); }
public function SettingsController_DiscussionEvent_create($Sender) { $Sender->permission('Garden.Settings.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Plugins.DiscussionEvent.DisplayInSidepanel', 'Plugins.DiscussionEvent.MaxDiscussionEvents')); $Sender->Form->setModel($ConfigurationModel); if ($Sender->Form->authenticatedPostBack()) { if ($Sender->Form->save() !== false) { $Sender->informMessage(sprite('Check', 'InformSprite') . T('Your changes have been saved.'), 'Dismissable AutoDismiss HasSprite'); } } else { $Sender->Form->setData($ConfigurationModel->Data); } $Sender->title(T('Discussion Event Settings')); $Sender->addSideMenu(); $Sender->render($this->GetView('settings.php')); }
public function PluginController_AuthorTimeView_Create(&$Sender, $Args = array()) { $Sender->Title('Author Time view'); $Sender->AddSideMenu('plugin/authortimeview'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.AuthorTimeView.Show_AuthorTime', 'Plugins.AuthorTimeView.Show_Vcount')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->Render($this->GetView('atv-settings.php')); }
public function PluginController_OldDiscussion_Create($Sender, $Args = array()) { $Sender->Permission('Plugins.OldDiscussion.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.OldDiscussion.Age', 'Plugins.OldDiscussion.IgnoreEdits', 'Plugins.OldDiscussion.RequireCheck')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->AddSideMenu('plugin/olddiscussion'); $Sender->SetData('Title', T('Old Discussion')); $Sender->Render($this->GetView('plugin-settings.php')); }
public function PluginController_Meta_Create(&$Sender) { $Sender->AddSideMenu('plugin/meta'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Meta.Description', 'Meta.Keywords')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); //$ConfigurationModel->Validation->ApplyRule('DescriptionAndKeywords.Description', 'Required'); //$ConfigurationModel->Validation->ApplyRule('DescriptionAndKeywords.Keywords', 'Required'); if ($Sender->Form->Save() !== FALSE) { } } $Sender->View = dirname(__FILE__) . DS . 'view' . DS . 'manager.php'; $Sender->Render(); }
public function Controller_Index($Sender) { $Sender->Permission('Vanilla.Settings.Manage'); $Sender->SetData('PluginDescription', $this->GetPluginKey('Description')); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField("Plugin.Chatwee.Code"); $ConfigurationModel->SetField("Plugin.Chatwee.APIKey"); $ConfigurationModel->SetField("Plugin.Chatwee.Chatid"); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->Render($this->GetView('chatwee.php')); }
/** * * * @param $Sender * @param array $Args */ public function pluginController_tongue_create($Sender, $Args = array()) { $Sender->permission('Garden.Settings.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Plugins.CivilTongue.Words', 'Plugins.CivilTongue.Replacement')); $Sender->Form->setModel($ConfigurationModel); if ($Sender->Form->authenticatedPostBack() === FALSE) { $Sender->Form->setData($ConfigurationModel->Data); } else { $Data = $Sender->Form->formValues(); if ($Sender->Form->save() !== FALSE) { $Sender->StatusMessage = t("Your settings have been saved."); } } $Sender->addSideMenu('plugin/tongue'); $Sender->setData('Title', t('Civil Tongue')); $Sender->render($this->getView('index.php')); }
public function PluginController_PageNavigator_Create(&$Sender, $Args = array()) { $Sender->Title('Page Navigator'); $Sender->AddSideMenu('plugin/pagenavigator'); $Sender->Permission('Garden.Settings.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.PageNavigator.Show_First', 'Plugins.PageNavigator.Show_Last', 'Plugins.PageNavigator.Show_Top', 'Plugins.PageNavigator.Show_Bottom')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->Render($this->GetView('pn-settings.php')); }
/** * Edit a route. * * @since 2.0.0 * @access public * @param string $RouteIndex Name of route. */ public function edit($RouteIndex = false) { $this->permission('Garden.Settings.Manage'); $this->addSideMenu('dashboard/routes'); $this->Route = Gdn::router()->getRoute($RouteIndex); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Route', 'Target', 'Type')); // Set the model on the form. $this->Form->setModel($ConfigurationModel); // If seeing the form for the first time... if (!$this->Form->authenticatedPostBack()) { // Apply the route info to the form. if ($this->Route !== false) { $this->Form->setData(array('Route' => $this->Route['Route'], 'Target' => $this->Route['Destination'], 'Type' => $this->Route['Type'])); } } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->applyRule('Route', 'Required'); $ConfigurationModel->Validation->applyRule('Target', 'Required'); $ConfigurationModel->Validation->applyRule('Type', 'Required'); // Validate & Save $FormPostValues = $this->Form->formValues(); // Dunno. if ($this->Route['Reserved']) { $FormPostValues['Route'] = $this->Route['Route']; } if ($ConfigurationModel->validate($FormPostValues)) { $NewRouteName = val('Route', $FormPostValues); if ($this->Route !== false && $NewRouteName != $this->Route['Route']) { Gdn::router()->deleteRoute($this->Route['Route']); } Gdn::router()->setRoute($NewRouteName, val('Target', $FormPostValues), val('Type', $FormPostValues)); $this->informMessage(t("The route was saved successfully.")); $this->RedirectUrl = url('dashboard/routes'); } else { $this->Form->setValidationResults($ConfigurationModel->validationResults()); } } $this->render(); }
/** * Create a method called "QnA" on the SettingController. * * @param $sender Sending controller instance */ public function settingsController_QnA_create($sender) { // Prevent non-admins from accessing this page $sender->permission('Garden.Settings.Manage'); $sender->title(sprintf(t('%s settings'), t('Q&A'))); $sender->setData('PluginDescription', $this->getPluginKey('Description')); $sender->addSideMenu('settings/QnA'); $sender->Form = new Gdn_Form(); $validation = new Gdn_Validation(); $configurationModel = new Gdn_ConfigurationModel($validation); $configurationModel->setField(array('QnA.Points.Enabled' => c('QnA.Points.Enabled', false), 'QnA.Points.Answer' => c('QnA.Points.Answer', 1), 'QnA.Points.AcceptedAnswer' => c('QnA.Points.AcceptedAnswer', 1))); $sender->Form->setModel($configurationModel); // If seeing the form for the first time... if ($sender->Form->authenticatedPostBack() === false) { $sender->Form->setData($configurationModel->Data); } else { $configurationModel->Validation->applyRule('QnA.Points.Enabled', 'Boolean'); if ($sender->Form->getFormValue('QnA.Points.Enabled')) { $configurationModel->Validation->applyRule('QnA.Points.Answer', 'Required'); $configurationModel->Validation->applyRule('QnA.Points.Answer', 'Integer'); $configurationModel->Validation->applyRule('QnA.Points.AcceptedAnswer', 'Required'); $configurationModel->Validation->applyRule('QnA.Points.AcceptedAnswer', 'Integer'); if ($sender->Form->getFormValue('QnA.Points.Answer') < 0) { $sender->Form->setFormValue('QnA.Points.Answer', 0); } if ($sender->Form->getFormValue('QnA.Points.AcceptedAnswer') < 0) { $sender->Form->setFormValue('QnA.Points.AcceptedAnswer', 0); } } if ($sender->Form->save() !== false) { // Update the AcceptAnswer reaction points. try { Gdn::sql()->update('ReactionType', ['Points' => c('QnA.Points.AcceptedAnswer')], ['UrlCode' => 'AcceptAnswer'])->put(); } catch (Exception $e) { // Do nothing; no reaction was found to update so just press on. } $sender->StatusMessage = t('Your changes have been saved.'); } } $sender->render($this->getView('configuration.php')); }
public function SettingsController_MembersListEnh_Create($Sender) { $Session = Gdn::Session(); $Sender->Title('Members List Enhanced'); $Sender->AddSideMenu('plugin/memberslistenh'); $Sender->Permission('Garden.Settings.Manage'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.MembersListEnh.DCount', 'Plugins.MembersListEnh.ShowPhoto', 'Plugins.MembersListEnh.ShowSymbol', 'Plugins.MembersListEnh.ShowLike', 'Plugins.MembersListEnh.ShowThank', 'Plugins.MembersListEnh.ShowKarma', 'Plugins.MembersListEnh.ShowAnswers', 'Plugins.MembersListEnh.ShowID', 'Plugins.MembersListEnh.ShowRoles', 'Plugins.MembersListEnh.ShowFVisit', 'Plugins.MembersListEnh.ShowLVisit', 'Plugins.MembersListEnh.ShowEmail', 'Plugins.MembersListEnh.ShowIP', 'Plugins.MembersListEnh.ShowVisits', 'Plugins.MembersListEnh.ShowDiCount', 'Plugins.MembersListEnh.ShowCoCount')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->Render($this->GetView('mle-settings.php')); }
/** * Creates a settings page at /dashboard/settins/discussionpolls * @param VanillaController $Sender SettingsController */ public function SettingsController_DiscussionPolls_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Sender->AddCSSFile($this->GetResource('design/settings.discussionpolls.css', FALSE, FALSE)); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.DiscussionPolls.EnableShowResults')); $ConfigurationModel->SetField(array('Plugins.DiscussionPolls.DisablePollTitle')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { if ($Sender->Form->Save() !== FALSE) { $Sender->InformMessage('<span class="InformSprite Sliders"></span>' . T('Your changes have been saved.'), 'HasSprite'); } } // Makes it look like a dashboard page $Sender->AddSideMenu('/dashboard/settings/discussionpolls'); $Sender->Title('Discussion Polls Settings'); $Sender->Render($this->ThemeView('settings')); }
public function PluginController_MaxImageSize_Create(&$Sender) { $Sender->AddSideMenu('plugin/maximagesize'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('MaxImageSize.Width')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); $ConfigurationModel->Validation->ApplyRule('MaxImageSize.Width', array('Required', 'Integer')); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } // creates the page for the plugin options such as display options $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'maximagesize.php'; $Sender->Render(); }
public function PluginController_TopPosters_Create(&$Sender) { $Sender->AddSideMenu('plugin/topposters'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('TopPosters.Location.Show', 'TopPosters.Limit', 'TopPosters.Excluded', 'TopPosters.Show.Medal')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); $ConfigurationModel->Validation->ApplyRule('TopPosters.Limit', array('Required', 'Integer')); $ConfigurationModel->Validation->ApplyRule('TopPosters.Location.Show', 'Required'); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = Gdn::Translate("Your settings have been saved."); } } $TopPostersModule = new TopPostersModule($Sender); $Sender->AllUsers = $TopPostersModule->GetAllUsers(); $Sender->Render($this->GetView('topposters.php')); }
public function PluginController_WhosOnline_Create(&$Sender) { $Sender->Permission('Plugins.WhosOnline.Manage'); $Sender->AddSideMenu('plugin/whosonline'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('WhosOnline.Location.Show', 'WhosOnline.Frequency', 'WhosOnline.Hide')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); $ConfigurationModel->Validation->ApplyRule('WhosOnline.Frequency', array('Required', 'Integer')); $ConfigurationModel->Validation->ApplyRule('WhosOnline.Location.Show', 'Required'); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } // creates the page for the plugin options such as display options $Sender->Render($this->GetView('whosonline.php')); }
/** * Build the setting page. * @param $Sender */ public function SettingsController_Vanoogle_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array("Plugins.Vanoogle.CSE")); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); $ConfigurationModel->Validation->ApplyRule("Plugins.Vanoogle.CSE", "Required"); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = T("Your settings have been saved."); } } $Sender->AddSideMenu(); $Sender->SetData("Title", T("Vanoogle Settings")); $CategoryModel = new CategoryModel(); $Sender->SetData("CategoryData", $CategoryModel->GetAll(), TRUE); array_shift($Sender->CategoryData->Result()); $Sender->Render($this->GetView("settings.php")); }
public function PluginController_LatestComment_Create(&$Sender) { $Sender->AddSideMenu('plugin/latestcomment'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('LatestComment.Show.LatestComment', 'LatestComment.Location.Show', 'LatestComment.Limit', 'LatestComment.Show.User')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { $Sender->Form->SetData($ConfigurationModel->Data); } else { $Data = $Sender->Form->FormValues(); $ConfigurationModel->Validation->ApplyRule('LatestComment.Show.LatestComment', 'Required'); $ConfigurationModel->Validation->ApplyRule('LatestComment.Location.Show', 'Required'); $ConfigurationModel->Validation->ApplyRule('LatestComment.Limit', array('Required', 'Integer')); //$ConfigurationModel->Validation->ApplyRule('LatestComment.Location.Show', 'Required'); if ($Sender->Form->Save() !== FALSE) { $Sender->StatusMessage = Gdn::Translate("Your settings have been saved."); } } $LatestCommentModule = new LatestCommentModule($Sender); $Sender->AllDiscussions = $LatestCommentModule->GetAllDiscussion(); $Sender->Render($this->GetView('latestcomment.php')); }