/**
  * 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 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'));
 }
 /**
  *
  *
  * @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'));
 }
 /**
  * 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();
 }
Example #5
0
 /**
  * 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'));
 }
 /**
  * Options page.
  *
  * @param string $Toggle
  * @param string $TransientKey
  */
 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 = val('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("\n", $TrustedDomains);
         $TrustedDomains = array_unique(array_filter(array_map('trim', $TrustedDomains)));
         $TrustedDomains = implode("\n", $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', $TrustedDomains);
     }
     $this->permission('Garden.Settings.Manage');
     $this->render();
 }
 /**
  * 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.
  */
 private 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.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);
     // 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 : betterRandomString(16, 'Aa0');
             $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) {
                 $Locale = Gdn::locale();
                 $Locale->set($NewLocale);
             }
             // Install db structure & basic data.
             $Database = Gdn::database();
             $Database->init();
             $Drop = 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 Internet connection for CDNs
             $Disconnected = !(bool) @fsockopen('ajax.googleapis.com', 80);
             saveToConfig(array('Garden.Version' => val('Version', val('Dashboard', $ApplicationInfo, array()), 'Undefined'), 'Garden.Cdns.Disable' => $Disconnected, 'Garden.CanProcessImages' => function_exists('gd_info'), 'EnabledPlugins.GettingStarted' => 'GettingStarted', 'EnabledPlugins.HtmLawed' => 'HtmLawed'));
         }
     }
     return $this->Form->errorCount() == 0 ? true : false;
 }
 /**
  * Configuration of registration settings.
  *
  * Events: BeforeRegistrationUpdate
  *
  * @since 2.0.0
  * @access public
  * @param string $RedirectUrl Where to send user after registration.
  */
 public function registration($RedirectUrl = '')
 {
     $this->permission('Garden.Settings.Manage');
     $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);
     $registrationOptions = array('Garden.Registration.Method' => 'Captcha', 'Garden.Registration.InviteExpiration', 'Garden.Registration.ConfirmEmail');
     if ($manageCaptcha = c('Garden.Registration.ManageCaptcha', true)) {
         $registrationOptions[] = 'Garden.Registration.CaptchaPrivateKey';
         $registrationOptions[] = 'Garden.Registration.CaptchaPublicKey';
     }
     $this->setData('_ManageCaptcha', $manageCaptcha);
     $ConfigurationModel->setField($registrationOptions);
     // 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');
     $this->setData('_Roles', array_column($this->RoleData->resultArray(), 'Name', 'RoleID'));
     // 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.", 'Connect' => "New users are only registered through SSO plugins.");
     // 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');
         // 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);
         // Event hook
         $this->EventArguments['ConfigurationModel'] =& $ConfigurationModel;
         $this->fireEvent('BeforeRegistrationUpdate');
         // Save!
         if ($this->Form->save() !== false) {
             $this->informMessage(t("Your settings have been saved."));
             if ($RedirectUrl != '') {
                 $this->RedirectUrl = $RedirectUrl;
             }
         }
     }
     $this->render();
 }
 /**
  * Enabling and disabling categories from list.
  *
  * @since 2.0.0
  * @access public
  */
 public function manageCategories()
 {
     // Check permission
     $this->permission('Garden.Community.Manage');
     $this->addSideMenu('vanilla/settings/managecategories');
     $this->addJsFile('categories.js');
     $this->addJsFile('jquery.alphanumeric.js');
     // This now works on latest jQuery version 1.10.2
     //
     // Jan29, 2014, upgraded jQuery UI to 1.10.3 from 1.8.11
     $this->addJsFile('nestedSortable/jquery-ui.min.js');
     // Newer nestedSortable, but does not work.
     //$this->addJsFile('js/library/nestedSortable/jquery.mjs.nestedSortable.js');
     // old jquery-ui
     //$this->addJsFile('js/library/nestedSortable.1.3.4/jquery-ui-1.8.11.custom.min.js');
     $this->addJsFile('nestedSortable.1.3.4/jquery.ui.nestedSortable.js');
     $this->title(t('Categories'));
     // Get category data
     $CategoryData = $this->CategoryModel->getAll('TreeLeft');
     // Set CanDelete per-category so we can override later if we want.
     $canDelete = checkPermission('Garden.Settings.Manage');
     array_walk($CategoryData->result(), function (&$value) use($canDelete) {
         setvalr('CanDelete', $value, $canDelete);
     });
     $this->setData('CategoryData', $CategoryData, true);
     // Setup & save forms
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Vanilla.Categories.MaxDisplayDepth', 'Vanilla.Categories.DoHeadings', 'Vanilla.Categories.HideModule'));
     // Set the model on the form.
     $this->Form->setModel($ConfigurationModel);
     // Define MaxDepthOptions
     $DepthData = array();
     $DepthData['2'] = sprintf(t('more than %s deep'), plural(1, '%s level', '%s levels'));
     $DepthData['3'] = sprintf(t('more than %s deep'), plural(2, '%s level', '%s levels'));
     $DepthData['4'] = sprintf(t('more than %s deep'), plural(3, '%s level', '%s levels'));
     $DepthData['0'] = t('never');
     $this->setData('MaxDepthData', $DepthData);
     // 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 {
         if ($this->Form->save() !== false) {
             $this->informMessage(t("Your settings have been saved."));
         }
     }
     // Render default view
     $this->render();
 }
Example #10
0
 /**
  * Always document every method.
  *
  * @param $sender
  */
 public function controller_index($sender)
 {
     // Prevent non-admins from accessing this page
     $sender->permission('Garden.Settings.Manage');
     $sender->setData('PluginDescription', $this->getPluginKey('Description'));
     $validation = new Gdn_Validation();
     $configurationModel = new Gdn_ConfigurationModel($validation);
     $configurationModel->setField(array('Plugin.Example.RenderCondition' => 'all', 'Plugin.Example.TrimSize' => 100));
     // 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.Example.RenderCondition', 'Required');
         $configurationModel->Validation->applyRule('Plugin.Example.TrimSize', 'Required');
         $configurationModel->Validation->applyRule('Plugin.Example.TrimSize', 'Integer');
         $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('example.php'));
 }
Example #11
0
 /**
  *
  *
  * @param $Sender
  * @param $Args
  */
 protected function settings_index($Sender, $Args)
 {
     $validation = new Gdn_Validation();
     $configurationModel = new Gdn_ConfigurationModel($validation);
     $configurationModel->setField(['Garden.Registration.AutoConnect', 'Garden.SignIn.Popup']);
     $Sender->Form->setModel($configurationModel);
     if ($Sender->Form->authenticatedPostback()) {
         if ($Sender->Form->save() !== false) {
             $Sender->informMessage(t('Your settings have been saved.'));
         }
     } else {
         $Sender->Form->setData($configurationModel->Data);
     }
     $Providers = self::getProvider();
     $Sender->setData('Providers', $Providers);
     $Sender->render('Settings', '', 'plugins/jsconnect');
 }
Example #12
0
 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();
 }