/**
  * Return motions which are currently being voted
  * 
  * @param \Wonderland\Application\Model\Member
  * @return string
  */
 public function displayActiveMotions(Member $member)
 {
     $motions = $this->connection->query('SELECT motion_id, title_key, date_fin_vote ' . 'FROM motions ' . 'WHERE Date_fin_vote >  NOW() ' . 'ORDER BY date_fin_vote DESC ');
     $response = '';
     while ($motion = $motions->fetch(\PDO::FETCH_ASSOC)) {
         $response .= "<tr><td><a onclick=\"Clic('/Motion/displayMotion', 'motion_id={$motion['motion_id']}', 'milieu_milieu'); return false;\">{$motion['title_key']}</a></td>" . "<td><a onclick=\"Clic('/Motion/displayMotion', 'motion_id={$motion['motion_id']}', 'milieu_milieu'); return false;\">{$motion['date_fin_vote']}</a></td>";
         if ($this->hasAlreadyVoted($motion['motion_id'], $member->getId()) == 0) {
             $response .= "<td><div class='bouton'><a onclick=\"Clic('/Motion/displayVote', 'motion_id={$motion['motion_id']}', 'milieu_milieu'); return false;\">" . "<span style='color: #dfdfdf;'>{$this->translator->translate('btn_votemotion')}</span></a></div></td>";
         }
         $response .= '</tr>';
     }
     if (!empty($response)) {
         return $response;
     }
     return "<tr><td>{$this->translator->translate('no_result')}</td></tr>";
 }
 /**
  * @param \Wonderland\Application\Model\Member $author
  * @param string                               $recipientIdentity
  * @param string                               $title
  * @param string                               $content
  */
 public function createMessage(Member $author, $recipientIdentity, $title, $content)
 {
     $errors = [];
     if (($recipient = $this->memberManager->getMemberByIdentity($recipientIdentity)) === null) {
         $errors[] = ['message' => $this->translator->translate('messages.creation.recipient_not_found')];
     }
     if (trim($title) === '') {
         $errors[] = ['message' => $this->translator->translate('messages.creation.empty_content')];
     }
     if (trim($content) === '') {
         $errors[] = ['message' => $this->translator->translate('messages.creation.empty_content')];
     }
     if (count($errors) > 0) {
         return $errors;
     }
     $message = (new Message())->setTitle($title)->setContent($content)->setAuthor($author)->setRecipient($recipient)->setCreatedAt(new \DateTime());
     $this->repository->create($message);
     return true;
 }
 /**
  * @param string $login
  * @param string $password
  * @param string $confirmationPassword
  * @param string $email
  *
  * @return array
  */
 public function validate($login, $password, $confirmationPassword, $email)
 {
     $errors = [];
     $member = $this->repository->getExistingLoginOrEmail($login, $email);
     if ($member !== false) {
         if ($member['login'] === $login && $member['identity'] === $login) {
             $errors[] = $this->translator->translate('registration.existing_login');
         }
         if ($member['email'] === $email) {
             $errors[] = $this->translator->translate('registration.existing_mail');
         }
     }
     if ($password !== $confirmationPassword) {
         $errors[] = $this->translator->translate('registration.password_mismatch');
     }
     if (!$this->validateIdentity($login)) {
         $errors[] = $this->translator->translate('registration.invalid_login');
     }
     if (!$this->validateEmailAddress($email)) {
         $errors[] = $this->translator->translate('registration.invalid_mail');
     }
     return $errors;
 }
示例#4
0
 /**
  * @param string $key
  */
 public function translate($key)
 {
     echo $this->translator->translate($key);
 }
示例#5
0
 /**
  * @param string $key
  * @return string
  */
 public function getTranslation($key)
 {
     return $this->translator->translate($key);
 }