Пример #1
0
 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');
 }
Пример #2
0
 /**
  * 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();
 }
 /**
  * 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');
 }
Пример #4
0
 /**
  * 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_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'));
 }
Пример #6
0
 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_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 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'));
 }
 /**
  * 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_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');
   }
Пример #12
0
 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'));
 }
Пример #13
0
 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();
 }
Пример #14
0
 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'));
 }
Пример #15
0
 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'));
 }
Пример #16
0
 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();
 }
Пример #17
0
 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'));
 }
Пример #18
0
 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'));
 }
 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'));
 }
Пример #20
0
 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();
 }
Пример #21
0
 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'));
 }
Пример #22
0
 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'));
 }
Пример #23
0
 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'));
 }
Пример #24
0
 /**
  * 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"));
 }
Пример #25
0
 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'));
 }
 public function Advanced($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->Title('Advanced Embed Settings');
     $this->AddSideMenu('dashboard/embed/advanced');
     $this->Form = new Gdn_Form();
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.TrustedDomains', 'Garden.Embed.RemoteUrl', 'Garden.Embed.ForceDashboard', 'Garden.Embed.ForceForum', 'Garden.SignIn.Popup'));
     $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->Permission('Garden.Settings.Manage');
     $this->Render();
 }
Пример #27
0
 /**
  * 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);
     $Sender->Render($this->GetView('flagging.php'));
 }
 /**
  * Configuration of registration settings.
  */
 public function Registration($RedirectUrl = '')
 {
     $this->Permission('Garden.Registration.Manage');
     if (!C('Garden.Registration.Manage', TRUE)) {
         return Gdn::Dispatcher()->Dispatch('Default404');
     }
     $this->AddSideMenu('dashboard/settings/registration');
     $this->AddJsFile('registration.js');
     $this->Title(T('Registration'));
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.Registration.Method' => 'Captcha', 'Garden.Registration.CaptchaPrivateKey', 'Garden.Registration.CaptchaPublicKey', 'Garden.Registration.InviteExpiration'));
     // Set the model on the forms.
     $this->Form->SetModel($ConfigurationModel);
     // Load roles with sign-in permission
     $RoleModel = new RoleModel();
     $this->RoleData = $RoleModel->GetByPermission('Garden.SignIn.Allow');
     // Get the currently selected default roles
     // $this->ExistingRoleData = Gdn::Config('Garden.Registration.DefaultRoles');
     // if (is_array($this->ExistingRoleData) === FALSE)
     //    $this->ExistingRoleData = array();
     // Get currently selected InvitationOptions
     $this->ExistingRoleInvitations = Gdn::Config('Garden.Registration.InviteRoles');
     if (is_array($this->ExistingRoleInvitations) === FALSE) {
         $this->ExistingRoleInvitations = array();
     }
     // Get the currently selected Expiration Length
     $this->InviteExpiration = Gdn::Config('Garden.Registration.InviteExpiration', '');
     // Registration methods.
     $this->RegistrationMethods = array('Captcha' => "New users fill out a simple form and are granted access immediately.", 'Approval' => "New users are reviewed and approved by an administrator (that's you!).", 'Invitation' => "Existing members send invitations to new members.");
     // Options for how many invitations a role can send out per month.
     $this->InvitationOptions = array('0' => T('None'), '1' => '1', '2' => '2', '5' => '5', '-1' => T('Unlimited'));
     // Options for when invitations should expire.
     $this->InviteExpirationOptions = array('-1 week' => T('1 week after being sent'), '-2 weeks' => T('2 weeks after being sent'), '-1 month' => T('1 month after being sent'), 'FALSE' => T('never'));
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Garden.Registration.Method', 'Required');
         // if($this->Form->GetValue('Garden.Registration.Method') != 'Closed')
         //    $ConfigurationModel->Validation->ApplyRule('Garden.Registration.DefaultRoles', 'RequiredArray');
         // Define the Garden.Registration.RoleInvitations setting based on the postback values
         $InvitationRoleIDs = $this->Form->GetValue('InvitationRoleID');
         $InvitationCounts = $this->Form->GetValue('InvitationCount');
         $this->ExistingRoleInvitations = ArrayCombine($InvitationRoleIDs, $InvitationCounts);
         $ConfigurationModel->ForceSetting('Garden.Registration.InviteRoles', $this->ExistingRoleInvitations);
         // Save!
         if ($this->Form->Save() !== FALSE) {
             $this->StatusMessage = T("Your settings have been saved.");
             if ($RedirectUrl != '') {
                 $this->RedirectUrl = $RedirectUrl;
             }
         }
     }
     $this->Render();
 }
Пример #29
0
 /**
  * Configuration of registration settings.
  */
 public function Registration($RedirectUrl = '')
 {
     $this->Permission('Garden.Registration.Manage');
     $this->AddSideMenu('garden/settings/registration');
     $this->AddJsFile('registration.js');
     $this->Title(Translate('Registration'));
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.Registration.Method', 'Garden.Registration.DefaultRoles', 'Garden.Registration.CaptchaPrivateKey', 'Garden.Registration.CaptchaPublicKey', 'Garden.Registration.InviteExpiration'));
     // Set the model on the forms.
     $this->Form->SetModel($ConfigurationModel);
     // Load roles with sign-in permission
     $RoleModel = new Gdn_RoleModel();
     $this->RoleData = $RoleModel->GetByPermission('Garden.SignIn.Allow');
     // Get the currently selected default roles
     $this->ExistingRoleData = Gdn::Config('Garden.Registration.DefaultRoles');
     if (is_array($this->ExistingRoleData) === FALSE) {
         $this->ExistingRoleData = array();
     }
     // Get currently selected InvitationOptions
     $this->ExistingRoleInvitations = Gdn::Config('Garden.Registration.InviteRoles');
     if (is_array($this->ExistingRoleInvitations) === FALSE) {
         $this->ExistingRoleInvitations = array();
     }
     // Get the currently selected Expiration Length
     $this->InviteExpiration = Gdn::Config('Garden.Registration.InviteExpiration', '');
     // Registration methods.
     $this->RegistrationMethods = array('Closed' => "Registration is closed.", 'Basic' => "The applicants are granted access immediately.", 'Captcha' => "The applicants must copy the text from a captcha image, proving that they are not a robot.", 'Approval' => "The applicants must be approved by an administrator before they are granted access.", 'Invitation' => "Existing members send out invitations to new members. Any person who receives an invitation is granted access immediately. Invitations are permission-based (defined below). Monthly invitations are NOT cumulative.");
     // Options for how many invitations a role can send out per month.
     $this->InvitationOptions = array('0' => Gdn::Translate('None'), '1' => '1', '2' => '2', '5' => '5', '-1' => Gdn::Translate('Unlimited'));
     // Options for when invitations should expire.
     $this->InviteExpirationOptions = array('-1 week' => Gdn::Translate('1 week after being sent'), '-2 weeks' => Gdn::Translate('2 weeks after being sent'), '-1 month' => Gdn::Translate('1 month after being sent'), 'FALSE' => Gdn::Translate('never'));
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Garden.Registration.Method', 'Required');
         if ($this->Form->GetValue('Garden.Registration.Method') != 'Closed') {
             $ConfigurationModel->Validation->ApplyRule('Garden.Registration.DefaultRoles', 'RequiredArray');
         }
         // Define the Garden.Registration.RoleInvitations setting based on the postback values
         $InvitationRoleIDs = $this->Form->GetValue('InvitationRoleID');
         $InvitationCounts = $this->Form->GetValue('InvitationCount');
         $this->ExistingRoleInvitations = ArrayCombine($InvitationRoleIDs, $InvitationCounts);
         $ConfigurationModel->ForceSetting('Garden.Registration.InviteRoles', $this->ExistingRoleInvitations);
         // Save!
         if ($this->Form->Save() !== FALSE) {
             $this->StatusMessage = Translate("Your settings have been saved.");
             if ($RedirectUrl != '') {
                 $this->RedirectUrl = $RedirectUrl;
             }
         }
     }
     $this->Render();
 }
Пример #30
0
 /**
  * Allows the configuration of basic setup information in Garden. This
  * should not be functional after the application has been set up.
  *
  * @since 2.0.0
  * @access public
  * @param string $RedirectUrl Where to send user afterward.
  */
 public function Configure($RedirectUrl = '')
 {
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password', 'Garden.Registration.ConfirmEmail', 'Garden.Email.SupportName'));
     // Set the models on the forms.
     $this->Form->SetModel($ConfigurationModel);
     // Load the locales for the locale dropdown
     // $Locale = Gdn::Locale();
     // $AvailableLocales = $Locale->GetAvailableLocaleSources();
     // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales);
     // If seeing the form for the first time...
     if (!$this->Form->IsPostback()) {
         // Force the webroot using our best guesstimates
         $ConfigurationModel->Data['Database.Host'] = 'localhost';
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Database.Name', 'Required', 'You must specify the name of the database in which you want to set up Vanilla.');
         // Let's make some user-friendly custom errors for database problems
         $DatabaseHost = $this->Form->GetFormValue('Database.Host', '~~Invalid~~');
         $DatabaseName = $this->Form->GetFormValue('Database.Name', '~~Invalid~~');
         $DatabaseUser = $this->Form->GetFormValue('Database.User', '~~Invalid~~');
         $DatabasePassword = $this->Form->GetFormValue('Database.Password', '~~Invalid~~');
         $ConnectionString = GetConnectionString($DatabaseName, $DatabaseHost);
         try {
             $Connection = new PDO($ConnectionString, $DatabaseUser, $DatabasePassword);
         } catch (PDOException $Exception) {
             switch ($Exception->getCode()) {
                 case 1044:
                     $this->Form->AddError(T('The database user you specified does not have permission to access the database. Have you created the database yet? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1045:
                     $this->Form->AddError(T('Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1049:
                     $this->Form->AddError(T('It appears as though the database you specified does not exist yet. Have you created it yet? Did you mistype the name? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 2005:
                     $this->Form->AddError(T("Are you sure you've entered the correct database host name? Maybe you mistyped it? The database reported: <code>%s</code>"), strip_tags($Exception->getMessage()));
                     break;
                 default:
                     $this->Form->AddError(sprintf(T('ValidateConnection'), strip_tags($Exception->getMessage())));
                     break;
             }
         }
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         $ConfigurationFormValues = $this->Form->FormValues();
         if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE || $this->Form->ErrorCount() > 0) {
             // Apply the validation results to the form(s)
             $this->Form->SetValidationResults($ConfigurationModel->ValidationResults());
         } else {
             $Host = array_shift(explode(':', Gdn::Request()->RequestHost()));
             $Domain = Gdn::Request()->Domain();
             // Set up cookies now so that the user can be signed in.
             $ExistingSalt = C('Garden.Cookie.Salt', FALSE);
             $ConfigurationFormValues['Garden.Cookie.Salt'] = $ExistingSalt ? $ExistingSalt : RandomString(10);
             $ConfigurationFormValues['Garden.Cookie.Domain'] = '';
             // Don't set this to anything by default. # Tim - 2010-06-23
             // Additional default setup values.
             $ConfigurationFormValues['Garden.Registration.ConfirmEmail'] = TRUE;
             $ConfigurationFormValues['Garden.Email.SupportName'] = $ConfigurationFormValues['Garden.Title'];
             $ConfigurationModel->Save($ConfigurationFormValues, TRUE);
             // If changing locale, redefine locale sources:
             $NewLocale = 'en-CA';
             // $this->Form->GetFormValue('Garden.Locale', FALSE);
             if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) {
                 $ApplicationManager = new Gdn_ApplicationManager();
                 $Locale = Gdn::Locale();
                 $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders(), TRUE);
             }
             // Install db structure & basic data.
             $Database = Gdn::Database();
             $Database->Init();
             $Drop = FALSE;
             // Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE;
             $Explicit = FALSE;
             try {
                 include PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'structure.php';
             } catch (Exception $ex) {
                 $this->Form->AddError($ex);
             }
             if ($this->Form->ErrorCount() > 0) {
                 return FALSE;
             }
             // Create the administrative user
             $UserModel = Gdn::UserModel();
             $UserModel->DefineSchema();
             $UsernameError = T('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.');
             $UserModel->Validation->ApplyRule('Name', 'Username', $UsernameError);
             $UserModel->Validation->ApplyRule('Name', 'Required', T('You must specify an admin username.'));
             $UserModel->Validation->ApplyRule('Password', 'Required', T('You must specify an admin password.'));
             $UserModel->Validation->ApplyRule('Password', 'Match');
             $UserModel->Validation->ApplyRule('Email', 'Email');
             if (!($AdminUserID = $UserModel->SaveAdminUser($ConfigurationFormValues))) {
                 $this->Form->SetValidationResults($UserModel->ValidationResults());
             } else {
                 // The user has been created successfully, so sign in now.
                 SaveToConfig('Garden.Installed', TRUE, array('Save' => FALSE));
                 Gdn::Session()->Start($AdminUserID, TRUE);
                 SaveToConfig('Garden.Installed', FALSE, array('Save' => FALSE));
             }
             if ($this->Form->ErrorCount() > 0) {
                 return FALSE;
             }
             // Assign some extra settings to the configuration file if everything succeeded.
             $ApplicationInfo = array();
             include CombinePaths(array(PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'about.php'));
             // Detect rewrite abilities
             try {
                 $Query = ConcatSep('/', Gdn::Request()->Domain(), Gdn::Request()->WebRoot(), 'dashboard/setup');
                 $Results = ProxyHead($Query, array(), 3);
                 $CanRewrite = FALSE;
                 if (in_array(ArrayValue('StatusCode', $Results, 404), array(200, 302)) && ArrayValue('X-Garden-Version', $Results, 'None') != 'None') {
                     $CanRewrite = TRUE;
                 }
             } catch (Exception $e) {
                 // cURL and fsockopen arent supported... guess?
                 $CanRewrite = function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) ? TRUE : FALSE;
             }
             SaveToConfig(array('Garden.Version' => ArrayValue('Version', GetValue('Dashboard', $ApplicationInfo, array()), 'Undefined'), 'Garden.RewriteUrls' => $CanRewrite, 'Garden.CanProcessImages' => function_exists('gd_info'), 'EnabledPlugins.GettingStarted' => 'GettingStarted', 'EnabledPlugins.HtmLawed' => 'HtmLawed'));
         }
     }
     return $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
 }