public function getIsConnected() { if ($_SESSION && ArrayHelper::getSafeFromArray($_SESSION, "Auth", null) && ArrayHelper::getSafeFromArray($_SESSION["Auth"], "Id", null)) { return true; } else { return false; } }
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); }
public function showAction() { $pageId = ArrayHelper::getSafeFromArray($_SESSION, SessionKeys::SEARCH_A_BOOK_PAGE_ID, 1); $bookSearch = $this->getBooks(false, null, $pageId); if (!$bookSearch->getHasResults()) { // Redirect to home $this->redirectToHome(); } else { // Set view $this->view->view = $this->getView($bookSearch->getList()); } }
public function get() { $tpl = new Template("components/searchForm"); $formAction = HTTPHelper::Link(Urls::BOOK_SEARCH_SUBMIT); $searchTermDef = "Titre, auteur, ISBN"; $searchTerm = ArrayHelper::getSafeFromArray($_REQUEST, "searchTerm", $searchTermDef); $isConnected = false; if ($this->getContext()->getConnectedUser()) { $isConnected = true; } $tpl->setVariables(array("formAction" => $formAction, "searchTerm" => $searchTerm, "searchTermDef" => $searchTermDef, "isConnected" => $isConnected, "showSearchTermDef" => $this->showSearchTermDef)); return $tpl->output(); }
private function load($data) { $pageId = ArrayHelper::getSafeFromArray($_GET, $this->paramName, $this->pageId); $params = array('itemData' => $data, 'perPage' => $this->itemPerPage, 'delta' => 8, 'append' => true, 'clearIfVoid' => false, 'urlVar' => $this->paramName, 'useSessions' => false, 'closeSession' => false, 'mode' => 'Jumping', 'httpMethod' => 'GET'); $pager = \Sb\Lists\Pager\Pager::factory($params); $pageData = $pager->getPageData($pageId); $this->items = $pageData; $links = $pager->getLinks($pageId); $this->navigationBar = $links['all']; $offSet = $pager->getOffsetByPageId($pageId); if ($offSet && count($offSet) >= 2) { $this->firstPage = $offSet[0]; $this->lastPage = $offSet[1]; } $this->totalPages = $pager->numItems(); }
public function getFailureMessages() { $errors = array(); // Walk through all errors to set the error flash messages foreach ($this->getErrors() as $errorKey => $errorValue) { if ($errorValue && count($errorValue) > 0) { foreach ($errorValue as $key => $value) { $fieldMessages = ArrayHelper::getSafeFromArray($this->getMessages(), $errorKey, null); if ($fieldMessages) { $errorMessage = ArrayHelper::getSafeFromArray($fieldMessages, $value, null); $errors[] = $errorMessage; } } } } return $errors; }
public static function getFullCityAndCountry(User $user) { $countryLabel = ""; if ($user->getCountry()) { $country = \Sb\Db\Dao\CountryDao::getInstance()->getCountryByCode($user->getCountry()); $countryLabel = ArrayHelper::getSafeFromArray($_SESSION, "WPLANG", "fr_FR") != "en_US" ? $country->getLabel_french() : $country->getLabel_english(); $countryLabel = ucfirst($countryLabel); } $res = ""; if ($countryLabel != '' && $user->getCity() != '') { $res = sprintf(__("%s, %s", "s1b"), ucfirst($user->getCity()), $countryLabel); } elseif ($countryLabel != '') { $res = $countryLabel; } elseif ($user->getCity() != '') { $res = ucfirst($user->getCity()); } return $res; }
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 function wishListAction() { try { $globalContext = new \Sb\Context\Model\Context(); $user = $globalContext->getConnectedUser(); if ($user) { // Get friend list for friend selection form $friends = $user->getAcceptedFriends(); // Order the friends list by firstname asc if ($friends && count($friends) > 0) { usort($friends, array($this, "compareFirstName")); } $this->view->friends = $friends; $this->view->user = $user; } $selectedFriendId = ArrayHelper::getSafeFromArray($_GET, "friendId", null); $selectedFriend = null; if ($selectedFriendId) { $selectedFriend = UserDao::getInstance()->get($selectedFriendId); $this->view->selectedFriend = $selectedFriend; $friendBooks = $selectedFriend->getNotDeletedUserBooks(); $friendWishedBooks = array_filter($friendBooks, array($this, "isWished")); $this->view->friendWishedBooks = $friendWishedBooks; } } catch (\Exception $e) { Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString())); $this->forward("error", "error", "default"); } }
private function validateRegistrationForm() { $ret = true; if (strlen($_POST['last_name']) < 3) { Flash::addItem(__("Votre nom doit comprendre au moins 3 caractères.", "s1b")); $ret = false; } if (strlen($_POST['first_name']) < 1) { Flash::addItem(__("Merci d'indiquer votre prénom.", "s1b")); $ret = false; } if (strlen($_POST['user_name']) < 1) { Flash::addItem(__("Merci d'indiquer un identifiant.", "s1b")); $ret = false; } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { Flash::addItem(__("Votre email n'est pas valide, merci de réessayer.", "s1b")); $ret = false; } if (strlen($_POST['password']) < 8) { Flash::addItem(__("Votre mot de passe doit faire au moins 8 caractères.", "s1b")); $ret = false; } if (!ArrayHelper::getSafeFromArray($_POST, 'cgu_validation', false)) { Flash::addItem(__("Vous devez accepter les CGU.", "s1b")); $ret = false; } return $ret; }
private function getTagLabelCol() { switch (ArrayHelper::getSafeFromArray($_SESSION, "WPLANG", "fr_FR")) { case "fr_FR": return "label"; break; case "en_US": return "label_en_us"; break; default: return "label"; break; } }
public function get() { $lineIdx = 0; $userBooks = $this->shownResults; $booksTemplates = array(); if ($userBooks) { $i = 0; foreach ($userBooks as $userBook) { $i++; $addSep = true; if ($i == 1) { $addSep = false; } //$book = new \Sb\Db\Model\Book; $book = $userBook->getBook(); // Get row template $rowTpl = new \Sb\Templates\Template("bookList/bookTableRow"); $pictos = \Sb\Helpers\UserBookHelper::getStatusPictos($userBook, $this->friendLibrary); $rowTpl->set("pictos", $pictos); $cssClass = $lineIdx % 2 ? "lineA" : "lineB"; $rowTpl->set("cssClass", $cssClass); $img = ""; if ($book->getSmallImageUrl()) { $img = sprintf("<img src = '%s' class = 'image-thumb-small'/>", $book->getSmallImageUrl()); } else { $img = sprintf("<img src = '%s' border = '0' class = 'image-thumb-small'/>", $this->defImg); } $rowTpl->set("img", $img); $rowTpl->set("title", $book->getTitle()); if ($book->getPublisher()) { $rowTpl->set("publicationInfo", $book->getPublicationInfo()); } else { $rowTpl->set("publicationInfo", ""); } $rowTpl->set("author", $book->getOrderableContributors()); $status = ""; if ($userBook->getReadingState()) { $status = $userBook->getReadingState()->getLabel(); } $readingStateSvc = \Sb\Db\Service\ReadingStateSvc::getInstance(); $readState = $readingStateSvc->getReadSate(); if ($userBook->getReadingState() && $userBook->getReadingState()->getId() == $readState->getId()) { if ($userBook->getReadingDate()) { $status = sprintf(__("%s le %s", "s1b"), $status, $userBook->getReadingDate()->format(__("d/m/Y", "s1b"))); } } $rowTpl->set("status", $status); $rating = $userBook->getRating(); if ($rating || $rating == 0) { $ratingCssClass = "rating-" . $rating; $rowTpl->set("ratingCssClass", "stars " . $ratingCssClass); } else { $rowTpl->set("ratingCssClass", ""); } if ($userBook->getIsBlowOfHeart()) { $rowTpl->set("bohCssClass", "boh"); } else { $rowTpl->set("bohCssClass", ""); } $editLink = HTTPHelper::Link(Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId())); $deleteLink = HTTPHelper::Link(Urls::USER_BOOK_DELETE, array("ubid" => $userBook->getId())); $viewLink = HTTPHelper::Link($book->getLink()); // Showing "Borrow this book" link only if: // - friend ownes the book // - book is not lent $borrowLink = null; if ($this->friendLibrary && $userBook->getIsOwned() && !$userBook->getActiveLending()) { $borrowLink = \Sb\Helpers\HTTPHelper::Link(Urls::USER_BOOK_BORROW, array("ubid" => $userBook->getId())); } $rowTpl->setVariables(array("addSep" => $addSep, "friendLibrary" => $this->friendLibrary, "editLink" => $editLink, "deleteLink" => $deleteLink, "viewLink" => $viewLink, "borrowLink" => $borrowLink, "bookId" => $book->getId())); $booksTemplates[] = $rowTpl; $lineIdx++; unset($addSep); unset($book); unset($rowTpl); unset($pictos); unset($cssClass); unset($img); unset($status); unset($rating); unset($ratingCssClass); unset($editLink); unset($deleteLink); unset($viewLink); unset($borrowLink); unset($userBook); } } $bookListTpl = new \Sb\Templates\Template("bookList/bookTable"); if ($booksTemplates) { // Get row header template $headerTpl = new \Sb\Templates\Template("bookList/bookTableHeader"); // Assignation des classe pour afficher le petit picto indiquant le sens de tri if ($this->listOptions) { if ($this->listOptions->getSorting()) { if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_AUTHOR) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_RATING) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_TITLE) { $headerTpl->set("titlesortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_STATE) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", $this->listOptions->getSorting()->getDirection()); } } } $headerTpl->setVariables(array("friendLibrary" => $this->friendLibrary)); $bookListTpl->set("tableHeader", $headerTpl->output()); $booksToShow = \Sb\Templates\Template::merge($booksTemplates); $bookListTpl->set("booksToShow", $booksToShow); $links = $this->pagerLinks; $bookListTpl->set("links", $links['all']); $bookListTpl->set("first", $this->firstItemIdx); $bookListTpl->set("last", $this->lastItemIdx); $bookListTpl->set("nbItemsTot", $this->nbItemsTot); $listSearchDefValue = __("Un titre, un auteur, ISBN dans ma bibliothèque", "s1b"); $bookListTpl->set("listSearchDefValue", $listSearchDefValue); if ($this->searchValue) { $bookListTpl->set("listSearchValue", $this->searchValue); } else { $bookListTpl->set("listSearchValue", $listSearchDefValue); } $key = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "key", null); $bookListTpl->set("key", $key); $selectedAuthorLetter = null; $selectedTitleLetter = null; $filtertype = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filtertype", null); if ($filtertype == \Sb\Lists\FilteringType::AUTHOR_FIRST_LETTER) { $selectedAuthorLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null); } elseif ($filtertype == \Sb\Lists\FilteringType::TITLE_FIRST_LETTER) { $selectedTitleLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null); } $bookListTpl->setVariables(array("authorsFirstLetters" => $this->authorsFirstLetters, "titlesFirstLetters" => $this->titlesFirstLetters, "selectedTitleLetter" => $selectedTitleLetter, "selectedAuthorLetter" => $selectedAuthorLetter, "emptyList" => false)); } else { $bookListTpl->setVariables(array("emptyList" => true)); } return $bookListTpl->output(); }
/** * Return the referer : when the referer is the library list page, we remove the "reset=1" parameters because we don't want the filtering, paging, sorting values to be reset when returning to the page * @return string */ public static function getReferer() { // When referer is the library list page, we remove the "reset=1" parameters because we don't want the filtering, paging, sorting // values to be reset when returning to the page $referer = ArrayHelper::getSafeFromArray($_SERVER, "HTTP_REFERER", null); if ($referer && strpos($referer, self::Link(Urls::USER_LIBRARY)) !== false) { $referer = str_replace("reset=1", "", $referer); } return $referer; }
public static function mapFromGoogleBookVolumeInfo(\Sb\Db\Model\Model &$book, $googleBookVolumeinfo) { $book->setDescription(\Sb\Helpers\ArrayHelper::getSafeFromArray($googleBookVolumeinfo, 'description', '')); $book->setTitle(\Sb\Helpers\ArrayHelper::getSafeFromArray($googleBookVolumeinfo, 'title', '')); $publishedDateStr = \Sb\Helpers\ArrayHelper::getSafeFromArray($googleBookVolumeinfo, 'publishedDate', ''); if ($publishedDateStr) { $book->setPublishingDate(\Sb\Helpers\DateHelper::createDate($publishedDateStr)); } $imageLinks = \Sb\Helpers\ArrayHelper::getSafeFromArray($googleBookVolumeinfo, 'imageLinks', null); if ($imageLinks) { $book->setImageUrl(\Sb\Helpers\ArrayHelper::getSafeFromArray($imageLinks, 'thumbnail', null)); $book->setSmallImageUrl(\Sb\Helpers\ArrayHelper::getSafeFromArray($imageLinks, 'smallThumbnail', null)); } }
private function validateUserInputForm() { $ret = true; if ($_POST) { if (strlen(ArrayHelper::getSafeFromArray($_POST, "guest_name", NULL)) < 3) { Flash::addItem(__("Le nom doit comprendre au moins 3 caractères.", "s1b")); $ret = false; } if (ArrayHelper::getSafeFromArray($_POST, "send_invitation", NULL) == 1) { $guestEmail = ArrayHelper::getSafeFromArray($_POST, "guest_email", NULL); if (!$guestEmail) { Flash::addItem(__("Vous devez renseigné un email si vous souhaitez envoyer une invitation.", "s1b")); $ret = false; } else { if (!StringHelper::isValidEmail($guestEmail)) { Flash::addItem(__("L'email que vous avez renseigné n'est pas valide. Merci de réessayer.", "s1b")); $ret = false; } } } } else { $ret = false; } return $ret; }
/** * Show pending friends request and allow to accepet or refuse it */ public function pendingRequestsAction() { try { $globalContext = new \Sb\Context\Model\Context(); $user = $globalContext->getConnectedUser(); $this->view->user = $user; // Show pending requests if (!$_POST) { $totalPendingRequests = $user->getPendingFriendShips(); if ($totalPendingRequests && count($totalPendingRequests) > 0) { // Preparing pagination $paginatedList = new PaginatedList($totalPendingRequests, 6); $this->view->firstItemIdx = $paginatedList->getFirstPage(); $this->view->lastItemIdx = $paginatedList->getLastPage(); $this->view->nbItemsTot = $paginatedList->getTotalPages(); $this->view->navigation = $paginatedList->getNavigationBar(); $this->view->pendingRequests = $paginatedList->getItems(); } } else { $friendShipId = ArrayHelper::getSafeFromArray($_POST, 'friendShipId', null); $Title = ArrayHelper::getSafeFromArray($_POST, 'Title', null); $Message = ArrayHelper::getSafeFromArray($_POST, 'Message', null); $Refused = ArrayHelper::getSafeFromArray($_POST, 'Refused', null); if ($friendShipId) { if ($Refused == 0) { // Update the requested friendship $friendShip = FriendShipDao::getInstance()->get($friendShipId); if ($friendShip) { $friendShip->setAccepted(true); $friendShip->setValidated(true); if (FriendShipDao::getInstance()->update($friendShip)) { // Add the userEvent try { $userEvent = new UserEvent(); $userEvent->setNew_value($user->getId()); $userEvent->setType_id(EventTypes::USER_ADD_FRIEND); $userEvent->setUser($friendShip->getUser_source()); UserEventDao::getInstance()->add($userEvent); } catch (\Exception $exc) { Trace::addItem("Erreur lors de l'ajout de l'événement : " . $exc->getMEssage()); } } } // Create a friendship on the other side $inverseFriendShip = new FriendShip(); $inverseFriendShip->setAccepted(true); $inverseFriendShip->setValidated(true); $inverseFriendShip->setCreationDate(new \DateTime()); $inverseFriendShip->setUser_source($user); $inverseFriendShip->setUser_target($friendShip->getUser_source()); if (FriendShipDao::getInstance()->add($inverseFriendShip)) { // Add the userEvent try { $userEvent = new UserEvent(); $userEvent->setNew_value($friendShip->getUser_source()->getId()); $userEvent->setType_id(EventTypes::USER_ADD_FRIEND); $userEvent->setUser($user); UserEventDao::getInstance()->add($userEvent); } catch (\Exception $exc) { Trace::addItem("Erreur lors de l'ajout de l'événement : " . $exc->getMEssage()); } } // Send email to the requesting user MailSvc::getInstance()->send($friendShip->getUser_source()->getEmail(), __("Demande d'ami", "s1b"), MailHelper::friendShipAcceptationEmailBody($user->getFirstName() . " " . $user->getLastName())); // add a message in requesting user internal mailbox $message = new \Sb\Db\Model\Message(); $message->setDate(new \DateTime()); $message->setMessage($Message); $message->setTitle($Title); $message->setRecipient($friendShip->getUser_source()); $message->setSender($user); MessageDao::getInstance()->add($message); // redirect to pending request page Flash::addItem("Demande acceptée."); HTTPHelper::redirect(Urls::USER_FRIENDS_PENDING_REQUEST); } elseif ($Refused == 1) { // update the requested friendship $friendShip = FriendShipDao::getInstance()->get($friendShipId); if ($friendShip) { $friendShip->setAccepted(false); $friendShip->setValidated(true); FriendShipDao::getInstance()->update($friendShip); } // send email to the requesting user MailSvc::getInstance()->send($friendShip->getUser_source()->getEmail(), __("Votre demande d'ami a été refusée", "s1b"), MailHelper::friendShipDenyEmailBody($user->getFirstName() . " " . $user->getLastName())); // add a message in requesting user internal mailbox $message = new Message(); $message->setDate(new \DateTime()); $message->setMessage($Message); $message->setTitle($Title); $message->setRecipient($friendShip->getUser_source()); $message->setSender($user); MessageDao::getInstance()->add($message); // redirect to pending request page Flash::addItem(__("Demande refusée.", "s1b")); HTTPHelper::redirect(Urls::USER_FRIENDS_PENDING_REQUEST); } } else { Flash::addItem(__("Vous devez sélectionner une demande d'ami.", "s1b")); HTTPHelper::redirect(Urls::USER_FRIENDS_PENDING_REQUEST); } } } catch (\Exception $e) { Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString())); $this->forward("error", "error", "default"); } }
public function replyAction() { return; try { $globalContext = new \Sb\Context\Model\Context(); $messageId = ArrayHelper::getSafeFromArray($_GET, 'mid', null); $redirect = false; if ($messageId) { $message = MessageDao::getInstance()->get($messageId); $this->view->message = $message; if ($message->getRecipient()->getId() != $globalContext->getConnectedUser()->getId()) { Flash::addItem(__("Vous ne pouvez pas répondre à ce message car il ne vous est pas destiné.", "s1b")); $redirect = true; } } else { Flash::addItem(__("Le message auquel vous tentez de répondre n'existe pas.", "s1b")); $redirect = true; } if ($_POST) { $title = htmlspecialchars($_POST['Title']); $messageContent = htmlspecialchars($_POST['Message']); /* test if form is not empty */ if (!empty($title) && !empty($messageContent)) { // create new message in db $reply = new Message(); $reply->setRecipient($message->getSender()); $replySender = $globalContext->getConnectedUser(); $reply->setSender($replySender); $reply->setDate(new \DateTime()); $reply->setTitle($title); $reply->setMessage($messageContent); $reply->setIs_read(false); MessageDao::getInstance()->add($reply); if ($message->getSender()->getSetting()->getEmailMe() == 'Yes') { // send a email to warn the origianl sender of the email $body = MailHelper::newMessageArrivedBody($replySender->getUserName()); MailSvc::getInstance()->send($message->getSender()->getEmail(), sprintf(__("Un message vous a été envoyé depuis le site %s", "s1b"), Constants::SITENAME), $body); } Flash::addItem(__("Message envoyé.", "s1b")); $redirect = true; } else { Flash::addItem(__("Vous devez renseigné le titre et le contenu du message.", "s1b")); } } if ($redirect) { HTTPHelper::redirect(Urls::USER_MAILBOX); } } catch (\Exception $e) { Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString())); $this->forward("error", "error", "default"); } }
private function setFilteringAndSearching($key) { if (array_key_exists("searchvalue", $_GET)) { // assignation du paramètre de recherche $searchValue = ArrayHelper::getSafeFromArray($_GET, "searchvalue", null); $this->setListOptionsForSearching($key, $searchValue); } else { if (array_key_exists("filter", $_GET) && array_key_exists("filtertype", $_GET)) { // assignation du paramètre de filtrage $filteringValue = ArrayHelper::getSafeFromArray($_GET, "filter", null); $filteringType = ArrayHelper::getSafeFromArray($_GET, "filtertype", null); $this->setListOptionsForFiltering($key, $filteringValue, $filteringType); } } // Rebase on first page $this->setListOptionsForNavigation($key, 1); }