コード例 #1
0
ファイル: UserSvc.php プロジェクト: berliozd/cherbouquin
 public function areUsersFriends(User $user, User $potentialFriend)
 {
     if ($user->getAcceptedFriends() && count($user->getAcceptedFriends()) > 0) {
         foreach ($user->getAcceptedFriends() as $userFriend) {
             if ($userFriend->getId() == $potentialFriend->getId()) {
                 return true;
             }
         }
     }
     return false;
 }
コード例 #2
0
ファイル: MailHelper.php プロジェクト: berliozd/cherbouquin
 public static function wishedUserBooksEmailBody(User $user, $userBooks)
 {
     $body = sprintf(__("Bonjour, <br/><br/>Voici les livres que souhaite %s : ", "s1b"), $user->getFriendlyName());
     $body .= "<ul>";
     foreach ($userBooks as $userbook) {
         $hasActiveGift = $userbook->getActiveGiftRelated() != null;
         $body .= "<li>" . "<a href=\"" . HTTPHelper::Link($userbook->getBook()->getLink()) . "\">" . $userbook->getBook()->getTitle() . "</a>" . "&nbsp;" . sprintf(__("de %s", "s1b"), $userbook->getBook()->getOrderableContributors()) . ($hasActiveGift ? "&nbsp;-&nbsp;" . __("ATTENTION ce livre a déjà été acheté par quelqu'un.", "s1b") : "") . "</li>";
     }
     $body .= "</ul>";
     $body .= sprintf(__("<br/><br/>Cette liste vous a été envoyée depuis le site <a href=\"%s\">%s</a>", "s1b"), HTTPHelper::Link(""), Constants::SITENAME);
     return $body;
 }
コード例 #3
0
ファイル: UserHelper.php プロジェクト: berliozd/cherbouquin
 public static function getGender(User $user)
 {
     if ($user->getGender() != "") {
         if ($user->getGender() == "male") {
             return __("masculin", "s1b");
         } else {
             return __("féminin", "s1b");
         }
         return "";
     }
     return "";
 }
コード例 #4
0
 /**
  * Tell if a user profile is accessible or not
  * IMPORTANT : a user profile can only be viewed by connected users.
  * @param \Sb\Db\Model\User $requestedUser
  * @param \Sb\Db\Model\User $requestingUser
  * @return boolean
  */
 public static function IsUserAccessible(\Sb\Db\Model\User $requestedUser, \Sb\Db\Model\User $requestingUser)
 {
     // Is the user account has been deleted the profile can not be viewed
     if ($requestedUser->getDeleted()) {
         return false;
     }
     // If a user has choosen to let his profile accessible by all members, then return true
     $requestedUserSettings = $requestedUser->getSetting();
     if ($requestedUserSettings) {
         if ($requestedUserSettings->getDisplayProfile() == \Sb\Entity\UserDataVisibility::MEMBERS_ONLY) {
             return true;
         }
     }
     // If the users are friend, return true
     $requestingUserFriendShips = $requestingUser->getFriendships_as_source();
     foreach ($requestingUserFriendShips as $friendShip) {
         if ($friendShip->getUser_target()->getId() == $requestedUser->getId() && $friendShip->getAccepted()) {
             return true;
         }
     }
     // Otherwise returns false
     return false;
 }
コード例 #5
0
 public function initAuthenticatedUser(User $activeUser)
 {
     $_SESSION['Auth'] = array('Email' => $activeUser->getEmail(), 'Password' => $activeUser->getPassword(), 'Id' => $activeUser->getId());
     if ($activeUser->getFacebookId()) {
         $_SESSION['Auth']['FacebookId'] = $activeUser->getFacebookId();
     }
     // If a return url is in session unset it and redirect to it
     $returnUrl = ArrayHelper::getSafeFromArray($_SESSION, SessionKeys::RETURN_URL_AFTER_LOGIN, null);
     if ($returnUrl) {
         unset($_SESSION[SessionKeys::RETURN_URL_AFTER_LOGIN]);
         HTTPHelper::redirectToUrl($returnUrl);
     }
 }
コード例 #6
0
ファイル: UserMapper.php プロジェクト: berliozd/cherbouquin
 public static function mapFromFacebookUser(\Sb\Db\Model\User &$user, \Sb\Facebook\Model\FacebookUser $faceBookUser)
 {
     $user->setFacebookId($faceBookUser->getUid());
     $user->setConnexionType(\Sb\Entity\ConnexionType::FACEBOOK);
     $user->setFirstName($faceBookUser->getFirst_name());
     $user->setLastName($faceBookUser->getLast_name());
     $user->setUserName($faceBookUser->getName());
     $user->setEmail($faceBookUser->getEmail());
     $user->setGender($faceBookUser->getSex());
     $user->setCity($faceBookUser->getHometown_location());
     $user->setBirthDay($faceBookUser->getBirthday());
     $user->setFacebookLanguage($faceBookUser->getLocale());
     $user->setTokenFacebook(sha1(uniqid(rand())));
     $user->setActivated(true);
     $user->setPicture($faceBookUser->getPic_small());
     $user->setPictureBig($faceBookUser->getPic());
 }
コード例 #7
0
ファイル: UserBookSvc.php プロジェクト: berliozd/cherbouquin
 private function addUserBook(\Sb\Db\Model\Book $book, \Sb\Db\Model\User $user, \Sb\Config\Model\Config $config)
 {
     $userBookDao = UserBookDao::getInstance();
     $userBook = $userBookDao->getByBookIdAndUserId($user->getId(), $book->getId());
     // Testing if the user :
     // - doesn't already have that book or
     // - have it but is deleted : in this case we will undelete the book
     if ($userBook && !$userBook->getIs_deleted()) {
         $returnMsg = __("Vous avez déjà ce livre dans votre bibliothèque.", "s1b");
     } else {
         // Getting current user current nb userbooks in libary
         $userNbUserBooks = count($user->getNotDeletedUserBooks());
         if ($userNbUserBooks >= $config->getMaximumNbUserBooksForPublic()) {
             $returnMsg = sprintf(__("Vous ne pouvez pas avoir plus de %s livres dans votre bibliothèque.", "s1b"), $config->getMaximumNbUserBooksForPublic());
         } else {
             // Ajout du UserBook
             $existingUserBook = false;
             $userBook = UserBookDao::getInstance()->getByBookIdAndUserId($user->getId(), $book->getId());
             // testing if the user already had the book but deleted it :
             // if yes, then the userbook is undeleted
             if ($userBook && $userBook->getIs_deleted()) {
                 $userBook->setIs_deleted(false);
                 $existingUserBook = true;
             } else {
                 // Création du UserBoook
                 $userBook = new \Sb\Db\Model\UserBook();
                 $userBook->setCreationDate(new \DateTime());
             }
             // Updating userbook data
             $userBook->setLastModificationDate(new \DateTime());
             $userBook->setUser($user);
             $userBook->setBook($book);
             $bookLink = \Sb\Helpers\HTTPHelper::Link($book->getLink());
             // Persisting userbook in DB
             $addOk = false;
             if ($existingUserBook) {
                 if (UserBookDao::getInstance()->update($userBook)) {
                     $editUserBookLink = \Sb\Helpers\HTTPHelper::Link(\Sb\Entity\Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId()));
                     $returnMsg = sprintf(__("Vous aviez déjà le livre \"%s\" dans votre bibliothèque mais l'aviez supprimé. Il a été rajouté.<br/><a class=\"link\" href=\"%s\">Remplir votre fiche de lecture</a> ou <a class=\"link\" href=\"%s\">Voir ce livre</a>", "s1b"), $book->getTitle(), $editUserBookLink, $bookLink);
                     $addOk = true;
                 }
             } else {
                 if (UserBookDao::getInstance()->add($userBook)) {
                     $editUserBookLink = \Sb\Helpers\HTTPHelper::Link(\Sb\Entity\Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId()));
                     $returnMsg = sprintf(__("Le livre \"%s\" a été ajouté à votre bibliothèque.<br/><a class=\"link\" href=\"%s\">Remplir votre fiche de lecture</a> ou <a class=\"link\" href=\"%s\">Voir ce livre</a>", "s1b"), $book->getTitle(), $editUserBookLink, $bookLink);
                     $addOk = true;
                 }
             }
             if ($addOk) {
                 try {
                     $userEvent = new \Sb\Db\Model\UserEvent();
                     $userEvent->setItem_id($userBook->getId());
                     $userEvent->setType_id(\Sb\Entity\EventTypes::USERBOOK_ADD);
                     $userEvent->setUser($user);
                     \Sb\Db\Dao\UserEventDao::getInstance()->add($userEvent);
                 } catch (\Exception $exc) {
                     Trace::addItem("Une erreur s'est produite lors de l'ajout de l'événement suite à l'ajout d'un livre " . $exc->getMessage());
                 }
             }
         }
     }
     return $returnMsg;
 }
コード例 #8
0
 private function isNotAdmin(User $foundUser)
 {
     return $foundUser->getId() != 1;
 }
コード例 #9
0
 public function setIs_partner($is_partner)
 {
     $this->__load();
     return parent::setIs_partner($is_partner);
 }
コード例 #10
0
ファイル: UserBook.php プロジェクト: berliozd/cherbouquin
 public function setUser(\Sb\Db\Model\User $user)
 {
     $this->user = $user;
     $user->addUserBook($this);
 }
コード例 #11
0
ファイル: Message.php プロジェクト: berliozd/cherbouquin
 public function setRecipient(\Sb\Db\Model\User $recipient)
 {
     $this->recipient = $recipient;
     $recipient->addMessagesReceived($this);
 }
コード例 #12
0
ファイル: User.php プロジェクト: berliozd/cherbouquin
 private function userAcceptEmail(\Sb\Db\Model\User $user)
 {
     $setting = $user->getSetting();
     if ($setting) {
         if ($setting->getEmailMe() == "Yes") {
             return true;
         }
     }
 }