+
+ public function createNewUser() {
+ if (isset($_GET['newuser'])){
+ if ($_POST['newusername'] != "" && $_POST['password4newuser'] != ""){
+ $newusername = filter_var($_POST['newusername'], FILTER_SANITIZE_STRING);
+ if (!$this->store->userExists($newusername)){
+ if ($this->store->install($newusername, Tools::encodeString($_POST['password4newuser'] . $newusername))) {
+ Tools::logm('The new user '.$newusername.' has been installed');
+ $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'),$newusername));
+ Tools::redirect();
+ }
+ else {
+ Tools::logm('error during adding new user');
+ Tools::redirect();
+ }
+ }
+ else {
+ $this->messages->add('e', sprintf(_('Error : An user with the name %s already exists !'),$newusername));
+ Tools::logm('An user with the name '.$newusername.' already exists !');
+ Tools::redirect();
+ }
+ }
+ }
+ }
+
+ public function deleteUser(){
+ if (isset($_GET['deluser'])){
+ if ($this->store->listUsers() > 1) {
+ if (Tools::encodeString($_POST['password4deletinguser'].$this->user->getUsername()) == $this->store->getUserPassword($this->user->getId())) {
+ $username = $this->user->getUsername();
+ $this->store->deleteUserConfig($this->user->getId());
+ Tools::logm('The configuration for user '. $username .' has been deleted !');
+ $this->store->deleteTagsEntriesAndEntries($this->user->getId());
+ Tools::logm('The entries for user '. $username .' has been deleted !');
+ $this->store->deleteUser($this->user->getId());
+ Tools::logm('User '. $username .' has been completely deleted !');
+ Session::logout();
+ Tools::logm('logout');
+ Tools::redirect();
+ $this->messages->add('s', sprintf(_('User %s has been successfully deleted !'),$newusername));
+ }
+ else {
+ Tools::logm('Bad password !');
+ $this->messages->add('e', _('Error : The password is wrong !'));
+ }
+ }
+ else {
+ Tools::logm('Only user !');
+ $this->messages->add('e', _('Error : You are the only user, you cannot delete your account !'));
+ }
+ }
+ }