/** * Default Gdn_Model::Get() behavior. * * Prior to 2.0.18 it incorrectly behaved like GetID. * This method can be deleted entirely once it's been deprecated long enough. * * @since 2.0.0 * @return object DataSet */ public function Get($OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $Offset = FALSE) { if (is_numeric($OrderFields)) { // They're using the old version that was a misnamed GetID() Deprecated('UserModel->Get()', 'UserModel->GetID()'); $Result = $this->GetID($OrderFields); } else { $Result = parent::Get($OrderFields, $OrderDirection, $Limit, $Offset); } return $Result; }
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(); }
public function Edit($UserID) { $this->Permission('Garden.Users.Edit'); $this->AddJsFile('user.js'); $this->Title(T('Edit User')); $this->AddSideMenu('dashboard/user'); $this->CanEditUsername = TRUE; $this->CanEditUsername = $this->CanEditUsername & Gdn::Config("Garden.Profile.EditUsernames"); $this->CanEditUsername = $this->CanEditUsername | Gdn::Session()->CheckPermission('Garden.Users.Edit'); $RoleModel = new Gdn_Model('Role'); $this->RoleData = $RoleModel->Get(); $UserModel = new 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 (!$this->CanEditUsername) $this->Form->SetFormValue("Name", $this->User->Name); // 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->InformMessage(T('Your changes have been saved.')); } $this->UserRoleData = $this->Form->GetFormValue('RoleID'); } $this->Render(); }