/**
  * register a user
  * @param \library\httpRequest $request
  * @return bool
  */
 public function register(\applications\modules\users\entities\usersEntity $user)
 {
     //check if user exists in db
     if ($register = $this->currentManager->register($user->getEmail(), $user->getPassword())) {
         $this->setUserSession($register[0]);
         return true;
     } else {
         \library\handleErrors::setErrors($this->errorNotExistingElement);
         return false;
     }
 }
 /**
  * add a user
  * @param usersEntity
  * @return true|errorInfo true if the user create successfully or the message error
  */
 public function save(\applications\modules\users\entities\usersEntity $users)
 {
     if ($users->getId() == "") {
         $sql = "INSERT INTO users ";
     } else {
         $sql = "UPDATE users ";
     }
     $sql .= "\n\t\tSET ";
     if ($users->getName() != "") {
         $sql .= "name \t\t\t= :name";
     }
     if ($users->getPassword() != "") {
         $sql .= ", password \t\t= :password";
     }
     if ($users->getEmail() != "") {
         $sql .= ", email\t\t\t= :email";
     }
     if ($users->getActive() != "") {
         $sql .= ", active\t\t\t= :active";
     }
     if ($users->getLevel() != "") {
         $sql .= ", level\t\t\t= :level";
     }
     if ($users->getCreationDate() != "") {
         $sql .= ", creationDate\t\t\t= :creationDate";
     }
     if ($users->getId() != "") {
         $sql .= " WHERE id = :id ";
     }
     $req = $this->db->prepare($sql);
     if ($users->getId() != "") {
         $req->bindValue(':id', $users->getId());
     }
     if ($users->getName() != "") {
         $req->bindValue(':name', $users->getName());
     }
     if ($users->getPassword() != "") {
         $req->bindValue(':password', $users->getPassword());
     }
     if ($users->getEmail() != "") {
         $req->bindValue(':email', $users->getEmail());
     }
     if ($users->getActive() != "") {
         $req->bindValue(':active', $users->getActive());
     }
     if ($users->getLevel() != "") {
         $req->bindValue(':level', $users->getLevel());
     }
     if ($users->getCreationDate() != "") {
         $req->bindValue(':creationDate', $users->getCreationDate());
     }
     if (!$req->execute()) {
         return false;
     } else {
         return true;
     }
 }