Exemplo n.º 1
0
/**
 * Send a notification to the poll admin to notify him about an update.
 *
 * @param $poll stdClass The poll
 * @param $mailService MailService The mail service
 * @param $name string The name user who triggered the notification
 * @param $type int cf: Constants on the top of this page
 */
function sendUpdateNotification($poll, $mailService, $name, $type)
{
    if (!isset($_SESSION['mail_sent'])) {
        $_SESSION['mail_sent'] = [];
    }
    if ($poll->receiveNewVotes) {
        $subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', 'Poll\'s participation: %s', $poll->title);
        $message = $name . ' ';
        switch ($type) {
            case UPDATE_VOTE:
                $message .= __('Mail', "updated a vote.\nYou can find your poll at the link") . " :\n\n";
                break;
            case ADD_VOTE:
                $message .= __('Mail', "filled a vote.\nYou can find your poll at the link") . " :\n\n";
                break;
            case ADD_COMMENT:
                $message .= __('Mail', "wrote a comment.\nYou can find your poll at the link") . " :\n\n";
                break;
        }
        $urlSondage = Utils::getUrlSondage($poll->admin_id, true);
        $message .= '<a href="' . $urlSondage . '">' . $urlSondage . '</a>' . "\n\n";
        $messageTypeKey = $type . '-' . $poll->id;
        $mailService->send($poll->admin_mail, $subject, $message, $messageTypeKey);
    }
}
Exemplo n.º 2
0
function smarty_function_poll_url($params, Smarty_Internal_Template $template)
{
    $poll_id = filter_var($params['id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
    $admin = isset($params['admin']) && $params['admin'] ? true : false;
    $action = isset($params['action']) && !empty($params['action']) ? Utils::htmlEscape($params['action']) : false;
    $action_value = isset($params['action_value']) && !empty($params['action_value']) ? Utils::htmlEscape($params['action_value']) : false;
    $vote_unique_id = isset($params['vote_id']) ? filter_var($params['vote_id'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]) : '';
    // If filter_var fails (i.e.: hack tentative), it will return false. At least no leak is possible from this.
    return Utils::getUrlSondage($poll_id, $admin, $vote_unique_id, $action, $action_value);
}
Exemplo n.º 3
0
/**
 * Send a notification to the poll admin to notify him about an update.
 *
 * @param stdClass $poll The poll
 * @param MailService $mailService The mail service
 * @param int $type cf: Constants on the top of this page
 */
function sendUpdateNotification($poll, $mailService, $type)
{
    if (!isset($_SESSION['mail_sent'])) {
        $_SESSION['mail_sent'] = [];
    }
    if ($poll->receiveNewVotes) {
        $subject = '[' . NOMAPPLICATION . '] ' . __f('Mail', 'Notification of poll: %s', $poll->title);
        $message = '';
        switch ($type) {
            case UPDATE_POLL:
                $message = __f('Mail', 'Someone just change your poll available at the following link %s.', Utils::getUrlSondage($poll->admin_id, true)) . "\n\n";
                break;
            case DELETED_POLL:
                $message = __f('Mail', 'Someone just delete your poll %s.', Utils::htmlEscape($poll->title)) . "\n\n";
                break;
        }
        $messageTypeKey = $type . '-' . $poll->id;
        $mailService->send($poll->admin_mail, $subject, $message, $messageTypeKey);
    }
}
Exemplo n.º 4
0
         $message .= __('Mail', 'Thanks for filling the poll at the link above') . ' :<br/><br/><a href="%1$s">%1$s</a>';
         $message_admin = __('Mail', "This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above");
         $message_admin .= ' :<br/><br/><a href="%1$s">%1$s</a>';
         $message = sprintf($message, Utils::getUrlSondage($poll_id));
         $message_admin = sprintf($message_admin, Utils::getUrlSondage($admin_poll_id, true));
         if ($mailService->isValidEmail($_SESSION['form']->admin_mail)) {
             $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'Author\'s message') . '] ' . __('Generic', 'Poll') . ': ' . Utils::htmlEscape($_SESSION['form']->title), $message_admin);
             $mailService->send($_SESSION['form']->admin_mail, '[' . NOMAPPLICATION . '][' . __('Mail', 'For sending to the polled users') . '] ' . __('Generic', 'Poll') . ': ' . Utils::htmlEscape($_SESSION['form']->title), $message);
         }
     }
     // Clean Form data in $_SESSION
     unset($_SESSION['form']);
     // Delete old polls
     $purgeService->purgeOldPolls();
     // Redirect to poll administration
     header('Location:' . Utils::getUrlSondage($admin_poll_id, true));
     exit;
 } else {
     if (isset($_POST['fin_sondage_autre'])) {
         Utils::print_header(__('Step 3', 'Removal date and confirmation (3 on 3)'));
         bandeau_titre(__('Step 3', 'Removal date and confirmation (3 on 3)'));
         // Store choices in $_SESSION
         if (isset($_POST['choices'])) {
             $_SESSION['form']->clearChoices();
             foreach ($_POST['choices'] as $c) {
                 if (!empty($c)) {
                     $c = strip_tags($c);
                     $choice = new Choice($c);
                     $_SESSION['form']->addChoice($choice);
                 }
             }