Пример #1
0
 public function Advanced()
 {
     $this->Permission('Vanilla.Settings.Manage');
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Vanilla.Archive.Date', 'Vanilla.Archive.Exclude'));
     // 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 {
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
         // Grab old config values to check for an update.
         $ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
         $ArchiveExcludeBak = (bool) Gdn::Config('Vanilla.Archive.Exclude');
         $Saved = $this->Form->Save();
         if ($Saved) {
             $ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
             $ArchiveExclude = (bool) Gdn::Config('Vanilla.Archive.Exclude');
             if ($ArchiveExclude != $ArchiveExcludeBak || $ArchiveExclude && $ArchiveDate != $ArchiveDateBak) {
                 $DiscussionModel = new Gdn_DiscussionModel();
                 $DiscussionModel->UpdateDiscussionCount('All');
             }
             $this->StatusMessage = Translate("Your changes have been saved.");
         }
     }
     $this->AddSideMenu('vanilla/settings/advanced');
     $this->AddJsFile('settings.js');
     $this->Title(Translate('Advanced Forum Settings'));
     $this->Render();
 }
 /**
  * Advanced settings.
  *
  * Allows setting configuration values via form elements.
  * 
  * @since 2.0.0
  * @access public
  */
 public function Advanced()
 {
     // Check permission
     $this->Permission('Vanilla.Settings.Manage');
     // Load up config options we'll be setting
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Vanilla.Discussions.PerPage', 'Vanilla.Comments.AutoRefresh', 'Vanilla.Comments.PerPage', 'Vanilla.Categories.Use', 'Vanilla.Archive.Date', 'Vanilla.Archive.Exclude', 'Garden.EditContentTimeout'));
     // 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.Discussions.PerPage', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.AutoRefresh', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Integer');
         $ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
         $ConfigurationModel->Validation->ApplyRule('Garden.EditContentTimeout', 'Integer');
         // Grab old config values to check for an update.
         $ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
         $ArchiveExcludeBak = (bool) Gdn::Config('Vanilla.Archive.Exclude');
         // Save new settings
         $Saved = $this->Form->Save();
         if ($Saved) {
             $ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
             $ArchiveExclude = (bool) Gdn::Config('Vanilla.Archive.Exclude');
             if ($ArchiveExclude != $ArchiveExcludeBak || $ArchiveExclude && $ArchiveDate != $ArchiveDateBak) {
                 $DiscussionModel = new Gdn_DiscussionModel();
                 $DiscussionModel->UpdateDiscussionCount('All');
             }
             $this->StatusMessage = T("Your changes have been saved.");
         }
     }
     $this->AddSideMenu('vanilla/settings/advanced');
     $this->AddJsFile('settings.js');
     $this->Title(T('Advanced Forum Settings'));
     // Render default view (settings/advanced.php)
     $this->Render();
 }