pushToAppleApp() public static method

Push a notification to Apple's notifications-server
Deprecation: : no more support for the Fork-app.
public static pushToAppleApp ( mixed $alert, integer $badge = null, string $sound = null, array $extraDictionaries = null )
$alert mixed The message/dictionary to send.
$badge integer The number for the badge.
$sound string The sound that should be played.
$extraDictionaries array Extra dictionaries.
Example #1
0
 /**
  * Notify the admin
  *
  * @param array $data
  */
 public static function notifyAdmin(array $data)
 {
     $alert = array('loc-key' => 'FORMBUILDER_SUBMISSION');
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'form_id' => $data['form_id'], 'id' => $data['entry_id']);
     // push it
     FrontendModel::pushToAppleApp($alert, 1, 'default', $data);
 }
Example #2
0
 /**
  * Notify the admin
  *
  * @param array $comment The comment that was submitted.
  */
 public static function notifyAdmin(array $comment)
 {
     // don't notify admin in case of spam
     if ($comment['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($comment['status'] == 'moderation') {
         $key = 'BLOG_COMMENT_MOD';
     } else {
         $key = 'BLOG_COMMENT';
     }
     $author = $comment['author'];
     if (mb_strlen($author) > 20) {
         $author = mb_substr($author, 0, 19) . '…';
     }
     $text = $comment['text'];
     if (mb_strlen($text) > 50) {
         $text = mb_substr($text, 0, 49) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($author, $text));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $comment['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnComment = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment', false);
     $notifyByMailOnCommentToModerate = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment_to_moderate', false);
     // create URLs
     $URL = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail') . '/' . $comment['post_url'] . '#comment-' . $comment['id'];
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('comments', 'Blog') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnComment) {
         // init var
         $variables = null;
         // comment to moderate
         if ($comment['status'] == 'moderation') {
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         } elseif ($comment['status'] == 'published') {
             // comment was published
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewComment'), array($comment['author'], $URL, $comment['post_title']));
         }
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     } elseif ($notifyByMailOnCommentToModerate && $comment['status'] == 'moderation') {
         // only notify on new comments to moderate and if the comment is one to moderate
         // set variables
         $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     }
 }
Example #3
0
 /**
  * Notify the admin
  *
  * @param array $subscription The subscription that was submitted.
  */
 public static function notifyAdmin(array $subscription)
 {
     // don't notify admin in case of spam
     if ($subscription['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($subscription['status'] == 'moderation') {
         $key = 'AGENDA_SUBSCRIPTION_MOD';
     } else {
         $key = 'AGENDA_SUBSCRIPTION';
     }
     $name = $subscription['name'];
     if (mb_strlen($name) > 20) {
         $name = mb_substr($name, 0, 19) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($name));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $subscription['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription', false);
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription_to_moderate', false);
     // create URLs
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('subscriptions', 'agenda') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnSubscription) {
         // init var
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         if ($subscription['status'] == 'moderation') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         } elseif ($subscription['status'] == 'published') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscription'), array($subscription['name'], $subscription['agenda_title']))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         }
         FrontendModel::get('mailer')->send($message);
         // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     } elseif ($notifyByMailOnSubscriptionToModerate && $subscription['status'] == 'moderation') {
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         FrontendModel::get('mailer')->send($message);
         // set variables
         //            $variables['message'] = vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'),
         //                array($subscription['name'], $subscription['agenda_title'], $backendURL));
         //
         //            // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     }
 }