public function controller_index($Sender) { $Sender->Permission(array('Garden.Profiles.Edit')); $Args = $Sender->RequestArgs; if (sizeof($Args) < 2) { $Args = array_merge($Args, array(0, 0)); } elseif (sizeof($Args) > 2) { $Args = array_slice($Args, 0, 2); } list($UserReference, $Username) = $Args; $canEditSignatures = CheckPermission('Plugins.Signatures.Edit'); // Normalize no image config setting if (C('Plugins.Signatures.MaxNumberImages') === 0 || C('Plugins.Signatures.MaxNumberImages') === '0') { SaveToConfig('Plugins.Signatures.MaxNumberImages', 'None'); } $Sender->GetUserInfo($UserReference, $Username); $UserPrefs = Gdn_Format::Unserialize($Sender->User->Preferences); if (!is_array($UserPrefs)) { $UserPrefs = array(); } $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigArray = array('Plugin.Signatures.Sig' => NULL, 'Plugin.Signatures.HideAll' => NULL, 'Plugin.Signatures.HideImages' => NULL, 'Plugin.Signatures.HideMobile' => NULL, 'Plugin.Signatures.Format' => NULL); $SigUserID = $ViewingUserID = Gdn::Session()->UserID; if ($Sender->User->UserID != $ViewingUserID) { $Sender->Permission(array('Garden.Users.Edit', 'Moderation.Signatures.Edit'), FALSE); $SigUserID = $Sender->User->UserID; $canEditSignatures = true; } $Sender->SetData('CanEdit', $canEditSignatures); $Sender->SetData('Plugin-Signatures-ForceEditing', $SigUserID == Gdn::Session()->UserID ? FALSE : $Sender->User->Name); $UserMeta = $this->GetUserMeta($SigUserID, '%'); if ($Sender->Form->AuthenticatedPostBack() === FALSE && is_array($UserMeta)) { $ConfigArray = array_merge($ConfigArray, $UserMeta); } $ConfigurationModel->SetField($ConfigArray); // Set the model on the form. $Sender->Form->SetModel($ConfigurationModel); $Data = $ConfigurationModel->Data; $Sender->SetData('Signature', $Data); $this->SetSignatureRules($Sender); // Form submission handling. if ($Sender->Form->AuthenticatedPostBack()) { $Values = $Sender->Form->FormValues(); if ($canEditSignatures) { $Values['Plugin.Signatures.Sig'] = GetValue('Body', $Values, NULL); $Values['Plugin.Signatures.Format'] = GetValue('Format', $Values, NULL); } //$this->StripLineBreaks($Values['Plugin.Signatures.Sig']); $FrmValues = array_intersect_key($Values, $ConfigArray); if (sizeof($FrmValues)) { if (!GetValue($this->MakeMetaKey('Sig'), $FrmValues)) { // Delete the signature. $FrmValues[$this->MakeMetaKey('Sig')] = NULL; $FrmValues[$this->MakeMetaKey('Format')] = NULL; } $this->CrossCheckSignature($Values, $Sender); if ($Sender->Form->ErrorCount() == 0) { foreach ($FrmValues as $UserMetaKey => $UserMetaValue) { $Key = $this->TrimMetaKey($UserMetaKey); switch ($Key) { case 'Format': if (strcasecmp($UserMetaValue, 'Raw') == 0) { $UserMetaValue = NULL; } // don't allow raw signatures. break; } $this->SetUserMeta($SigUserID, $Key, $UserMetaValue); } $Sender->InformMessage(T("Your changes have been saved.")); } } } else { // Load form data. $Data['Body'] = GetValue('Plugin.Signatures.Sig', $Data); $Data['Format'] = GetValue('Plugin.Signatures.Format', $Data) ?: Gdn_Format::DefaultFormat(); // Apply the config settings to the form. $Sender->Form->SetData($Data); } $Sender->Render('signature', '', 'plugins/Signatures'); }
/** * A special text box for formattable text. * * Formatting plugins like ButtonBar will auto-attach to this element. * * @param string $Column * @param array $Attributes * @since 2.1 * @return string HTML element. */ public function BodyBox($Column = 'Body', $Attributes = array()) { TouchValue('MultiLine', $Attributes, TRUE); TouchValue('format', $Attributes, $this->GetValue('Format', Gdn_Format::DefaultFormat())); TouchValue('Wrap', $Attributes, TRUE); TouchValue('class', $Attributes, ''); $Attributes['class'] .= ' TextBox BodyBox'; $Attributes['format'] = htmlspecialchars($Attributes['format']); $this->SetValue('Format', $Attributes['format']); $this->EventArguments['Table'] = GetValue('Table', $Attributes); $this->EventArguments['Column'] = $Column; $this->EventArguments['Attributes'] = $Attributes; $Result = '<div class="bodybox-wrap">'; $this->EventArguments['BodyBox'] =& $Result; $this->FireEvent('BeforeBodyBox'); $Result .= $this->TextBox($Column, $Attributes) . $this->Hidden('Format') . '</div>'; return $Result; }