public function put_index($id, $username, $email, $password = null, $id_group = null) { // Force to edit the current user if they don't have the proper permissions if (!$this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) { $id = $this->_currentUser->getId(); } $user = Model_Users::getById($id); $propsUpdate = ['username' => $username, 'email' => $email]; if ($id_group !== null && !empty($id_group) && $this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) { $group = Model_Groups::getById($id_group); $propsUpdate['usergroup'] = $group; } else { $user->load('usergroup'); } if ($password !== null && !empty($password)) { $propsUpdate['password'] = Library_String::hash(trim($password)); } $user->setProps($propsUpdate); Model_Users::update($user); // Disconnect the user if they changed their own profile if ($id === $this->_currentUser->getId()) { $this->response->redirect('../login/out', 200); } else { $this->response->redirect('../users', 200); } }
public function post_index($username, $email, $id_group) { $checkExisting = Model_Users::createRequest()->where('username = ? OR email = ?', [$username, $email])->exec(); if (!$checkExisting->isEmpty()) { $this->response->error('Un utilisateur avec ce pseudo ou cette adresse existe déjà.', 403); return; } $password = Library_String::generatePassword(); $group = Model_Groups::getById($id_group); Model_Users::add(new Model_Users($username, $email, $password, $group)); $email_content = \Eliya\Tpl::get('emails/register', ['username' => $username, 'email' => $email, 'password' => $password, 'login_url' => BASE_URL . 'admin/login']); Library_Email::send($email, 'Bienvenue sur Le Chomp Enchaîné !', $email_content); $this->get_index(); }
public function getUrl() { return BASE_URL . 'articles/' . $this->getId() . '-' . Library_String::makeUrlCompliant($this->title); }
public function getUrl() { return BASE_URL . 'authors/' . $this->getId() . '-' . Library_String::makeUrlCompliant($this->username); }
public function getUrl() { return BASE_URL . 'categories/' . $this->getId() . '-' . Library_String::makeUrlCompliant($this->name); }