Exemple #1
0
 public function setStartDate($startDate)
 {
     $this->start_date = $startDate;
     // stocke une version string de la date pour utilisation lors des serialization/deserialization
     if ($startDate) {
         $this->start_date_s = \Sb\Helpers\DateHelper::getDateForDB($startDate);
     }
 }
 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);
 }
Exemple #3
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);
 }
 public static function map(&$facebookUser, array $properties, $prefix = "")
 {
     $facebookUser = new \Sb\Facebook\Model\FacebookUser();
     if (array_key_exists("Id", $properties)) {
         $facebookUser->setId($properties["Id"]);
     }
     if (array_key_exists("uid", $properties)) {
         $facebookUser->setUid($properties["uid"]);
     }
     if (array_key_exists("email", $properties)) {
         $facebookUser->setEmail($properties["email"]);
     }
     if (array_key_exists("first_name", $properties)) {
         $facebookUser->setFirst_name($properties["first_name"]);
     }
     if (array_key_exists("last_name", $properties)) {
         $facebookUser->setLast_name($properties["last_name"]);
     }
     if (array_key_exists("name", $properties)) {
         $facebookUser->setName($properties["name"]);
     }
     if (array_key_exists("sex", $properties)) {
         $facebookUser->setSex($properties["sex"]);
     }
     if (array_key_exists("hometown_location", $properties)) {
         $facebookUser->setHometown_location($properties["hometown_location"]);
     }
     if (array_key_exists("birthday", $properties)) {
         $facebookUser->setBirthday(\Sb\Helpers\DateHelper::createDateTime(date('Y-m-d H:i:s', strtotime($properties["birthday"]))));
     }
     if (array_key_exists("locale", $properties)) {
         $facebookUser->setLocale($properties["locale"]);
     }
     if (array_key_exists("pic_small", $properties)) {
         $facebookUser->setPic_small($properties["pic_small"]);
     }
     if (array_key_exists("pic", $properties)) {
         $facebookUser->setPic($properties["pic"]);
     }
 }
Exemple #5
0
 public static function map(\Sb\Db\Model\Model &$user, array $properties, $prefix = "")
 {
     //        var_dump($properties);
     if (array_key_exists('id', $properties)) {
         $user->setId($properties['id']);
     }
     //        if (array_key_exists('wp_id', $properties)) {
     //            $user->setWpId($properties['wp_id']);
     //        }
     if (array_key_exists('facebook_id', $properties)) {
         $user->setFacebookId($properties['facebook_id']);
     }
     if (array_key_exists('connexion_type', $properties)) {
         $user->setConnexionType($properties['connexion_type']);
     }
     if (array_key_exists('first_name', $properties)) {
         $user->setFirstName(stripslashes($properties['first_name']));
     }
     if (array_key_exists('last_name', $properties)) {
         $user->setLastName(stripslashes($properties['last_name']));
     }
     if (array_key_exists('user_name', $properties)) {
         $user->setUserName(stripslashes($properties['user_name']));
     }
     if (array_key_exists('email', $properties)) {
         $user->setEmail($properties['email']);
     }
     if (array_key_exists('password', $properties)) {
         if (!empty($properties['password'])) {
             $user->setPassword(sha1($properties['password']));
         }
     }
     if (array_key_exists('gender', $properties)) {
         $user->setGender($properties['gender']);
     }
     if (array_key_exists('address', $properties)) {
         $user->setAddress($properties['address']);
     }
     if (array_key_exists('city', $properties)) {
         $user->setCity($properties['city']);
     }
     if (array_key_exists('zipCode', $properties)) {
         $user->setZipCode($properties['zipCode']);
     }
     if (array_key_exists('country', $properties)) {
         $user->setCountry($properties['country']);
     }
     if (array_key_exists('birthday', $properties)) {
         $user->setBirthDay(\Sb\Helpers\DateHelper::createDate($properties['birthDay']));
     }
     if (array_key_exists('facebook_language', $properties)) {
         $user->setFacebookLanguage($properties['facebook_language']);
     }
     if (array_key_exists('language', $properties)) {
         $user->setLanguage($properties['language']);
     }
     if (array_key_exists('token', $properties)) {
         $user->setToken($properties['token']);
     }
     if (array_key_exists('token_facebook', $properties)) {
         $user->setTokenFacebook($properties['token_facebook']);
     }
     if (array_key_exists('TokenFacebook', $properties)) {
         $user->setTokenFacebook($properties['TokenFacebook']);
     }
     if (array_key_exists('activated', $properties)) {
         $user->setActivated($properties['activated']);
     }
     if (array_key_exists('deleted', $properties)) {
         $user->setDeleted($properties['deleted']);
     }
     if (array_key_exists('gravatar', $properties)) {
         $user->setGravatar($properties['gravatar']);
     }
     if (array_key_exists('picture', $properties)) {
         $user->setPicture($properties['picture']);
     }
     if (array_key_exists('picture_big', $properties)) {
         $user->setPictureBig($properties['picture_big']);
     }
     if (array_key_exists('created', $properties)) {
         $user->setCreated(\Sb\Helpers\DateHelper::createDate($properties['created']));
     }
     if (array_key_exists('last_login', $properties)) {
         $user->setLastLogin(\Sb\Helpers\DateHelper::createDate($properties['last_login']));
     }
 }
Exemple #6
0
 /**
  * Créé un tableau associatif à partir de l'objet Book
  * @param \Sb\Db\Model\Book $book
  * @param array $properties
  */
 public static function reverseMap(\Sb\Db\Model\Model $book, array &$properties)
 {
     $properties['author'] = $book->getAuthor();
     $properties['description'] = $book->getDescription();
     $properties['isbn10'] = $book->getISBN10();
     $properties['isbn13'] = $book->getISBN13();
     $properties['asin'] = $book->getASIN();
     $properties['id'] = $book->getId();
     $properties['image_binary'] = $book->getImageBinary();
     $properties['image_url'] = $book->getImageUrl();
     $properties['small_image_url'] = $book->getSmallImageUrl();
     $properties['large_image_url'] = $book->getLargeImageUrl();
     $properties['publisher'] = $book->getPublisher();
     $properties['publisher_id'] = $book->getPublisherId();
     $properties['title'] = $book->getTitle();
     if ($book->getCreationDate()) {
         $properties['creation_date'] = \Sb\Helpers\DateHelper::getDateForDB($book->getCreationDate());
     }
     if ($book->getLastModificationDate()) {
         $properties['last_modification_date'] = \Sb\Helpers\DateHelper::getDateForDB($book->getLastModificationDate());
     }
     if ($book->getPublishingDate()) {
         $properties['publishing_date'] = \Sb\Helpers\DateHelper::getDateForDB($book->getPublishingDate());
     }
     $properties['amazon_url'] = $book->getAmazonUrl();
 }
Exemple #7
0
 public function setReadingDate($readingDate)
 {
     $this->reading_date = $readingDate;
     // stocke une version string de la date pour utilisation lors des serialization/deserialization
     if ($this->reading_date) {
         $this->readingDateS = \Sb\Helpers\DateHelper::getDateForDB($this->reading_date);
     }
 }
Exemple #8
0
 public function setLastModificationDate($lastModificationDate)
 {
     $this->last_modification_date = $lastModificationDate;
     if ($this->last_modification_date) {
         $this->last_modification_date_s = \Sb\Helpers\DateHelper::getDateForDB($this->last_modification_date);
     }
 }