예제 #1
0
 /**
  * displayWhatsNewAll 
  * 
  * Displays the following types of new data from the site:
  *
  *  ADDRESSADD      Add address of non-member
  *  ADDRESSEDIT     Edit own address
  *  AVATAR          Change avatar
  *  BOARD           Message board post
  *  CALENDAR        Add date to calendar
  *  DOCS            Added document
  *  GALCATCOM       Commented on category of photos
  *  GALCOM          Commented on photo
  *  GALLERY         Added photo
  *  JOINED          Joined the site (became active)
  *  NEWS            Added family news
  *  NEWSCOM         Commented on family news
  *  POLL            Added poll
  *  POLLCOM         Commented on poll
  *  PRAYERS         Added prayer concern
  *  RECIPES         Added recipe
  *  RECIPECOM       Commented on recipe
  *  STATUS          Added status update
  *  VIDEO           Added video
  *  VIDEOCOM        Commented on video
  *  WHEREISEVERYONE Checked in on foursquare
  * 
  * @return void
  */
 function displayWhatsNewAll()
 {
     // Get data
     $whatsNewData = getWhatsNewData(30);
     if ($whatsNewData === false) {
         $this->fcmsError->displayError();
         return;
     }
     $template = array('textWhatsNew' => T_('What\'s New'), 'textRssFeed' => T_('RSS Feed'), 'new' => array());
     $position = 1;
     $cachedUserData = array();
     // Loop through data
     foreach ($whatsNewData as $groupType => $data) {
         $parent = array_shift($data);
         $data = array_reverse($data);
         // handle children (replies, etc)
         $children = array();
         foreach ($data as $d) {
             // Use cached data
             if (isset($cachedUserData[$d['userid']])) {
                 $displayname = $cachedUserData[$d['userid']]['displayname'];
                 $avatar = $cachedUserData[$d['userid']]['avatar'];
             } else {
                 $displayname = getUserDisplayName($d['userid']);
                 $avatar = getCurrentAvatar($d['userid']);
                 // Save this for later
                 $cachedUserData[$d['userid']]['avatar'] = $avatar;
                 $cachedUserData[$d['userid']]['displayname'] = $displayname;
             }
             $timeSince = $this->getWhatsNewDataTimeSince($d);
             $textInfo = $this->getWhatsNewDataTextInfo($d);
             $children[] = array('class' => 'new' . strtolower($d['type']), 'avatar' => $avatar, 'displayname' => $displayname, 'userId' => (int) $d['userid'], 'timeSince' => $timeSince, 'textInfo' => $textInfo);
         }
         $timeSince = $this->getWhatsNewDataTimeSince($parent);
         $textInfo = $this->getWhatsNewDataTextInfo($parent);
         $object = $this->getWhatsNewDataObject($parent);
         // Use cached data
         if (isset($cachedUserData[$parent['userid']])) {
             $displayname = $cachedUserData[$parent['userid']]['displayname'];
             $avatar = $cachedUserData[$parent['userid']]['avatar'];
         } else {
             $displayname = getUserDisplayName($parent['userid']);
             $avatar = getCurrentAvatar($parent['userid']);
             // Save this for later
             $cachedUserData[$parent['userid']]['avatar'] = $avatar;
             $cachedUserData[$parent['userid']]['displayname'] = $displayname;
         }
         $params = array('position' => $position, 'class' => 'new' . strtolower($parent['type']), 'avatar' => $avatar, 'displayname' => $displayname, 'userId' => (int) $parent['userid'], 'timeSince' => $timeSince, 'textInfo' => $textInfo, 'title' => $object['title'], 'details' => $object['details'], 'children' => $children);
         if (startsWith($groupType, 'status')) {
             $params['textReply'] = T_('Reply');
             $params['replyParentId'] = (int) $parent['id'];
         }
         $template['new'][] = $params;
         $position++;
     }
     loadTemplate('home', 'new', $template);
 }
예제 #2
0
파일: rss.php 프로젝트: lmcro/fcms
/**
 * displayFeedAll 
 *
 * Displays RSS 2.0 feed for all updates to the site
 * 
 *  ADDRESSADD      Add address of non-member
 *  ADDRESSEDIT     Edit own address
 *  AVATAR          Change avatar
 *  BOARD           Message board post
 *  CALENDAR        Add date to calendar
 *  DOCS            Added document
 *  GALCATCOM       Commented on category of photos
 *  GALCOM          Commented on photo
 *  GALLERY         Added photo
 *  JOINED          Joined the site (became active)
 *  NEWS            Added family news
 *  NEWSCOM         Commented on family news
 *  POLL            Added poll
 *  POLLCOM         Commented on poll
 *  PRAYERS         Added prayer concern
 *  RECIPES         Added recipe
 *  RECIPECOM       Commented on recipe
 *  STATUS          Added status update
 *  VIDEO           Added video
 *  VIDEOCOM        Commented on video
 *  WHEREISEVERYONE Checked in on foursquare
 * 
 * @author: choc
 * @author: Ryan Haudenschilt <*****@*****.**>
 * 
 * @return  void
 */
function displayFeedAll()
{
    $fcmsError = FCMS_Error::getInstance();
    $fcmsDatabase = Database::getInstance($fcmsError);
    $url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $urlRoot = $url;
    $pos = strrpos($url, "/");
    if ($pos === false) {
        $pos = strrpos($url, "\\");
    }
    if (!($pos === false)) {
        $urlRoot = substr($url, 0, $pos);
    }
    // Get data
    $whatsNewData = getWhatsNewData(30);
    if ($whatsNewData === false) {
        return;
    }
    $output = "<?xml version=\"1.0\"?" . "> \n<rss version=\"2.0\"> \n<channel> \n<title>" . getSiteName() . " - " . T_('What\'s New') . "</title> \n<link>" . $url . "</link> \n<description>" . getSiteName() . " - " . T_('What\'s New') . " " . T_('RSS Feed') . "</description> \n<language>" . T_pgettext('Language Code for this translation', 'lang') . "</language> \n<managingEditor>" . getContactEmail() . "</managingEditor> \n";
    foreach ($whatsNewData as $line) {
        $title = "";
        $link = "";
        $guid = "";
        // Clean the data
        $cId = (int) $line['id'];
        $cId2 = (int) $line['id2'];
        $cUserid = (int) $line['userid'];
        $cTitle = html_convert_entities($line['title']);
        // Add Address
        if ($line['type'] == 'ADDRESSADD') {
            $displayname = getUserDisplayName($cId2);
            $for = getUserDisplayName($cUserid, 2, false);
            $link = 'addressbook.php?address=' . $cId;
            $title = sprintf(T_('%s has added address information for %s.'), $displayname, $for);
        } elseif ($line['type'] == 'ADDRESSEDIT') {
            $displayname = getUserDisplayName($cId2);
            $link = 'addressbook.php?address=' . $cId;
            $title = sprintf(T_('%s has updated his/her address.'), $displayname);
        } elseif ($line['type'] == 'AVATAR') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'profile.php?member=' . $cUserid;
            $title = sprintf(T_('%s has changed his/her picture.'), $displayname);
        } elseif ($line['type'] == 'BOARD') {
            $sql = "SELECT min(`id`) AS id \n                    FROM `fcms_board_posts` \n                    WHERE `thread` = ?";
            $minpost = $fcmsDatabase->getRow($sql, $cId2);
            if ($minpost === false) {
                // error will be logged, but not displayed
                continue;
            }
            $userName = getUserDisplayName($cUserid);
            $subject = $cTitle;
            $link = "messageboard.php?thread=" . $cId2;
            $pos = strpos($subject, '#ANOUNCE#');
            if ($pos !== false) {
                $subject = substr($subject, 9, strlen($subject) - 9);
            }
            if ($cId == $minpost['id']) {
                $title = sprintf(T_('%s started the new thread %s.'), $userName, $subject);
            } else {
                $title = sprintf(T_('%s replied to %s.'), $userName, $subject);
            }
        } elseif ($line['type'] == 'CALENDAR') {
            // TODO
            // copy from calendar_class
            $displayname = getUserDisplayName($cUserid);
            $date_date = gmdate(T_('m-d-y'), strtotime($cId2));
            $date_date2 = gmdate(T_('F j, Y'), strtotime($cId2));
            $link = 'calendar.php?year=' . gmdate('Y', strtotime($date_date2)) . '&amp;month=' . gmdate('m', strtotime($date_date2)) . '&amp;day=' . gmdate('d', strtotime($date_date2));
            $title = sprintf(T_('%s has added a new Calendar entry on %s for %s.'), $displayname, $date_date, $cTitle);
        } elseif ($line['type'] == 'DOCS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'documents.php';
            $title = sprintf(T_('%s has added a new document (%s).'), $displayname, $cTitle);
        } elseif ($line['type'] == 'GALCATCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid' . $cId2 . '&amp;cid=' . (int) $line['id3'];
            $title = sprintf(T_('%s commented on (%s).'), $displayname, $cTitle);
        } elseif ($line['type'] == 'GALCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid=0&amp;cid=comments&amp;pid=' . $cId;
            $title = sprintf(T_('%s commented on the following photo:'), $displayname);
        } elseif ($line['type'] == 'GALLERY') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'gallery/index.php?uid=' . $cUserid . '&amp;cid=' . $cId;
            $title = sprintf(T_('%s has added %d new photos to the %s category.'), $displayname, $cId2, $cTitle);
        } elseif ($line['type'] == 'JOINED') {
            $displayname = getUserDisplayName($cUserid);
            $link = "profile.php?member=" . $cUserid;
            $title = sprintf(T_('%s has joined the website.'), $displayname);
        } elseif ($line['type'] == 'NEWS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'familynews.php?getnews=' . $cUserid . '&amp;newsid=' . $cId;
            $title = sprintf(T_('%s has added %s to his/her Family News.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'NEWSCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'familynews.php?getnews=' . $cUserid . '&amp;newsid=' . $cId;
            $title = sprintf(T_('%s commented on Family News %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'POLL') {
            $link = 'polls.php?id=' . $cId;
            $title = sprintf(T_('A new Poll (%s) has been added.'), $cTitle);
        } elseif ($line['type'] == 'POLLCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'polls.php?id=' . $cId;
            $title = sprintf(T_('%s commented on Poll %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'PRAYERS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'prayers.php';
            $title = sprintf(T_('%s has added a Prayer Concern for %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'RECIPES') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'recipes.php?category=' . $cId2 . '&amp;id=' . $cId;
            $title = sprintf(T_('%s has added the recipe %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'RECIPECOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'recipes.php?category=' . $cId2 . '&amp;id=' . $cId;
            $title = sprintf(T_('%s commented on Recipe %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'STATUS') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'home.php';
            $title = $displayname . ': ' . $cTitle;
        } elseif ($line['type'] == 'VIDEO') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'video.php?u=' . $cUserid . '&amp;id=' . $cId;
            $title = sprintf(T_('%s has added a the video %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'VIDEOCOM') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'video.php?u=' . $cUserid . '&amp;id=' . $cId;
            $title = sprintf(T_('%s commented on the video %s.'), $displayname, $cTitle);
        } elseif ($line['type'] == 'WHEREISEVERYONE') {
            $displayname = getUserDisplayName($cUserid);
            $link = 'whereiseveryone.php';
            $title = sprintf(T_('%s visited %s.'), $displayname, $cTitle);
        }
        $output .= "\n<item>\n<title><![CDATA[{$title}]]></title> \n<pubDate>" . gmdate(T_('D, d M Y H:i:s'), strtotime($line['date'])) . " GMT</pubDate> \n<link>{$urlRoot}/{$link}</link> \n<guid isPermaLink=\"false\"><![CDATA[{$urlRoot} {$title} " . gmdate(T_('D, d M Y H:i:s'), strtotime($line['date'])) . "]]></guid> \n</item>";
    }
    $output .= "\n</channel>\n</rss>";
    echo $output;
}