当前位置: 首页>>代码示例>>PHP>>正文


PHP Articles::build_notification方法代码示例

本文整理汇总了PHP中Articles::build_notification方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::build_notification方法的具体用法?PHP Articles::build_notification怎么用?PHP Articles::build_notification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Articles的用法示例。


在下文中一共展示了Articles::build_notification方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: finalize_update

 /**
  * do whatever is necessary when a page has been updated
  *
  * This function:
  * - logs the update
  * - sends notification to watchers and to followers
  * - "touches" the container of the page,
  * - ping referred pages remotely (via the pingback protocol)
  * - ping selected servers, if any
  * - and triggers the hook 'update'.
  *
  * The first parameter provides the watching context to consider. If call is related
  * to the creation of a published page, the context is the section that hosts the new
  * page. If call is related to a draft page that has been published, then the context
  * is the page itself.
  *
  * This function is also able to notify followers of the surfer who has initiated the
  * action.
  *
  * @param object the watching context
  * @param array attributes of the published page
  * @param object page overlay, if any
  * @param boolean TRUE if dates should be left unchanged, FALSE otherwise
  * @param boolean TRUE if watchers should be notified, FALSE otherwise
  * @param boolean TRUE if followers should be notified, FALSE otherwise
  */
 public static function finalize_update($anchor, $item, $overlay = NULL, $silently = FALSE, $with_watchers = TRUE, $with_followers = FALSE)
 {
     global $context;
     // proceed only if the page has been published
     if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
         // notification to send by e-mail
         $mail = array();
         $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Update'), strip_tags($item['title']));
         $mail['notification'] = Articles::build_notification('update', $item);
         $mail['headers'] = Mailer::set_thread('article:' . $item['id']);
         // allow the overlay to prevent notifications of watcherss
         if (is_object($overlay) && !$overlay->should_notify_watchers($mail)) {
             $with_watchers = FALSE;
         }
         // send to watchers of this page, and to watchers upwards
         if ($with_watchers && ($handle = new Article())) {
             $handle->load_by_content($item, $anchor);
             $handle->alert_watchers($mail, 'article:update', $item['active'] == 'N');
         }
         // never notify followers on private pages
         if (isset($item['active']) && $item['active'] == 'N') {
             $with_followers = FALSE;
         }
         // allow the overlay to prevent notifications of followers
         if (is_object($overlay) && !$overlay->should_notify_followers()) {
             $with_followers = FALSE;
         }
         // send to followers of this user
         if ($with_followers && Surfer::get_id()) {
             $mail['message'] = Mailer::build_notification($mail['notification'], 2);
             Users::alert_watchers('user:' . Surfer::get_id(), $mail);
         }
         // update anchors
         $anchor->touch('article:update', $item['id'], $silently);
         // advertise public pages
         if (isset($item['active']) && $item['active'] == 'Y') {
             // expose links within the page
             $raw = '';
             if (isset($item['introduction'])) {
                 $raw .= $item['introduction'];
             }
             if (isset($item['source'])) {
                 $raw .= ' ' . $item['source'];
             }
             if (isset($item['description'])) {
                 $raw .= ' ' . $item['description'];
             }
             // pingback to referred links, if any
             include_once $context['path_to_root'] . 'links/links.php';
             Links::ping($raw, 'article:' . $item['id']);
             // ping servers, if any
             Servers::notify($anchor->get_url());
         }
     }
     // 'update' hook
     if (is_callable(array('Hooks', 'include_scripts'))) {
         Hooks::include_scripts('update', $item['id']);
     }
     // log page update
     $label = sprintf(i18n::c('Update: %s'), strip_tags($item['title']));
     $poster = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
     $description = sprintf(i18n::c('Updated by %s in %s'), $poster, $anchor->get_title());
     $description .= "\n\n" . '<a href="' . Articles::get_permalink($item) . '">' . $item['title'] . '</a>';
     Logger::notify('articles/articles.php: ' . $label, $description);
 }
开发者ID:rair,项目名称:yacs,代码行数:91,代码来源:articles.php

示例2: elseif

$context['page_link'] = Articles::get_permalink($item);
// not found -- help web crawlers
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    // make it clear to crawlers
    if (Surfer::is_crawler()) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    } elseif (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_permalink($item)));
    } elseif (isset($_REQUEST['requested']) && ($requested = Users::get($_REQUEST['requested'])) && $requested['email']) {
        // prepare the mail message
        $to = Mailer::encode_recipient($requested['email'], $requested['full_name']);
        $subject = sprintf(i18n::c('%s: %s'), i18n::c('Request'), strip_tags($item['title']));
        $message = Articles::build_notification('apply', $item, $overlay);
        $headers = Mailer::set_thread('article:' . $item['id']);
        // allow for skinnable template
        $message = Skin::build_mail_message($message);
        // build multiple parts, for HTML rendering
        $message = Mailer::build_multipart($message);
        // send the message to requested user
        if (Mailer::post(Surfer::from(), $to, $subject, $message, NULL, $headers)) {
            $text = sprintf(i18n::s('Your request has been transmitted to %s. Check your mailbox for feed-back.'), Skin::build_link(Users::get_permalink($requested), Codes::beautify_title($requested['full_name']), 'user'));
            $context['text'] .= Skin::build_block($text, 'note');
        }
        // follow-up navigation
        $context['text'] .= '<div>' . i18n::s('Where do you want to go now?') . '</div>';
        $menu = array();
        $menu[] = Skin::build_link($context['url_to_root'], i18n::s('Front page'), 'button');
        $menu[] = Skin::build_link(Surfer::get_permalink(), i18n::s('My profile'), 'span');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例3: foreach

         Members::assign('user:' . $item['id'], 'article:' . $article['id']);
     }
 }
 // add this page to watch lists
 Members::assign('article:' . $article['id'], 'user:' . Surfer::get_id());
 foreach ($items as $item) {
     if (isset($item['id'])) {
         Members::assign('article:' . $article['id'], 'user:' . $item['id']);
     }
 }
 // email has to be activated
 if (isset($context['with_email']) && $context['with_email'] == 'Y') {
     // contact target user by e-mail
     $mail = array();
     $mail['subject'] = sprintf(i18n::c('Private message: %s'), strip_tags($article['title']));
     $mail['message'] = Articles::build_notification('message', $article, $overlay);
     // enable threading
     $mail['headers'] = Mailer::set_thread('article:' . $article['id'], $anchor);
     // each recipient, one at a time
     foreach ($items as $item) {
         // you cannot write to yourself
         if (isset($item['id']) && Surfer::get_id() == $item['id']) {
             continue;
         }
         // target recipient does not accept messages
         if (isset($item['without_messages']) && $item['without_messages'] == 'Y') {
             continue;
         }
         // target is known here
         if (isset($item['id'])) {
             // suggest to change user preferences if applicable
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:contact.php


注:本文中的Articles::build_notification方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。