Пример #1
0
 public function submitAction()
 {
     $globalContext = new \Sb\Context\Model\Context();
     $user = $globalContext->getConnectedUser();
     $userSettings = $user->getSetting();
     $newFirstName = trim($this->getParam("FirstName_modif", null));
     $newLastName = trim($this->getParam("LastName_modif", null));
     $newUserName = trim($this->getParam("UserName_modif", null));
     $newGender = trim($this->getParam("Gender_modif", null));
     $newBirthDay = trim($this->getParam("BirthDay_pre_modif", null));
     $newAddress = trim($this->getParam("Address_modif", null));
     $newCity = trim($this->getParam("City_modif", null));
     $newZipCode = trim($this->getParam("ZipCode_modif", null));
     $newCountry = trim($this->getParam("Country_modif", null));
     $newLanguage = trim($this->getParam("Language_modif", null));
     $lang = ArrayHelper::getSafeFromArray($_SESSION, "WPLANG", "fr_FR");
     // on vérifie que tous les champs soient complétés
     if (strlen($newLastName) > 3 && strlen($newFirstName) > 1 && strlen($newUserName) > 1) {
         $userNameExist = false;
         // Check new username is not already existing in database
         if ($newUserName != $user->getUserName()) {
             $existingUserWithUserName = UserDao::getInstance()->getByUserName($newUserName);
             if ($existingUserWithUserName) {
                 Flash::addItem(__("Un membre utilise déjà l'identifiant que vous avez entré, merci d'en choisir un autre", "s1b"));
                 $userNameExist = true;
             }
         }
         if (!$userNameExist) {
             $user->setFirstName($newFirstName);
             $user->setLastName($newLastName);
             $user->setUserName($newUserName);
             $user->setGender($newGender);
             $user->setBirthDay(DateHelper::createDateBis($newBirthDay));
             $user->setAddress($newAddress);
             $user->setCity($newCity);
             $user->setZipCode($newZipCode);
             $user->setCountry($newCountry);
             $user->setLanguage($newLanguage);
             UserDao::getInstance()->update($user);
             Flash::addItem(__("Vos modifications ont bien été enregistrées", "s1b"));
         }
     } else {
         if (strlen($newLastName) < 3) {
             Flash::addItem(__("votre nom doit comprendre au moins 3 caractères", "s1b"));
         }
         if (strlen($newFirstName) < 1) {
             Flash::addItem(__("merci d'indiquer votre prénom", "s1b"));
         }
         if (strlen($newUserName) < 1) {
             Flash::addItem(__("merci d'indiquer un identifiant", "s1b"));
         }
     }
     $this->redirect(Urls::USER_PROFILE_EDIT);
 }
Пример #2
0
 function __construct($post)
 {
     $this->id = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "Id", null);
     $this->review = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "Review", null);
     if (array_key_exists('Rating', $post)) {
         if ($post['Rating'] != "") {
             $this->rating = $post['Rating'];
         }
     }
     $this->isBlowOfHeart = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "IsBlowOfHeart", 0);
     if (array_key_exists('WishedOrOwned', $post)) {
         if ($post['WishedOrOwned'] == "1") {
             // le livre est possédé par le user
             $this->isOwned = true;
             $this->isWished = false;
         } else {
             // le livre est souhaité par le user
             $this->isOwned = false;
             $this->isWished = true;
         }
     } else {
         if (array_key_exists('IsOwned', $post)) {
             $this->isOwned = $post['IsOwned'];
         }
         if (array_key_exists('IsWished', $post)) {
             $this->isWished = $post['IsWished'];
         }
     }
     $this->readingStateId = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "ReadingStateId", null);
     if (array_key_exists('tag', $post)) {
         $this->tags = array_keys($_POST["tag"]);
     }
     if (array_key_exists('ReadingDate', $post)) {
         $this->readingDate = \Sb\Helpers\DateHelper::createDateBis($post['ReadingDate']);
     }
     if (array_key_exists('HyperLink', $post)) {
         $this->hyperLink = $post['HyperLink'];
     }
     $this->nb_of_pages = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "nb_of_pages", null);
     $this->nb_of_pages_read = \Sb\Helpers\ArrayHelper::getSafeFromArray($post, "nb_of_pages_read", null);
 }