/** * Add a new conversations. */ public function Add($Recipient = '') { $this->Form->SetModel($this->ConversationModel); if ($this->Form->AuthenticatedPostBack()) { $RecipientUserIDs = array(); $To = explode(',', $this->Form->GetFormValue('To', '')); $UserModel = new Gdn_UserModel(); foreach ($To as $Name) { if (trim($Name) != '') { $User = $UserModel->Get(trim($Name)); if (is_object($User)) { $RecipientUserIDs[] = $User->UserID; } } } $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs); $ConversationID = $this->Form->Save($this->ConversationMessageModel); if ($ConversationID !== FALSE) { $this->RedirectUrl = Url('messages/' . $ConversationID); } } else { if ($Recipient != '') { $this->Form->SetFormValue('To', $Recipient); } } $this->Render(); }
public function Edit($UserID) { $this->Permission('Garden.Users.Edit'); $this->AddJsFile('user.js'); $this->AddSideMenu('garden/user'); $RoleModel = new Gdn_Model('Role'); $this->RoleData = $RoleModel->Get(); $UserModel = new Gdn_UserModel(); $this->User = $UserModel->Get($UserID); // Set the model on the form. $this->Form->SetModel($UserModel); // Make sure the form knows which item we are editing. $this->Form->AddHidden('UserID', $UserID); if (!$this->Form->AuthenticatedPostBack()) { $this->Form->SetData($this->User); $this->UserRoleData = $UserModel->GetRoles($UserID); } else { // If a new password was specified, add it to the form's collection $ResetPassword = $this->Form->GetValue('ResetPassword', FALSE); $NewPassword = $this->Form->GetValue('NewPassword', ''); if ($ResetPassword !== FALSE) { $this->Form->SetFormValue('Password', $NewPassword); } if ($this->Form->Save(array('SaveRoles' => TRUE)) !== FALSE) { if ($this->Form->GetValue('Password', '') != '') { $UserModel->SendPasswordEmail($UserID, $NewPassword); } $this->StatusMessage = T('Your changes have been saved successfully.'); } $this->UserRoleData = $this->Form->GetFormValue('RoleID'); } $this->Render(); }