示例#1
0
 /**
  * getMembersOnline 
  * 
  * @return mixed - array on success, false on failure
  */
 function getMembersOnline()
 {
     $membersOnline = array('textLastSeen' => T_('Last Seen'), 'membersOnline' => array());
     $last24hours = time() - 60 * 60 * 24;
     $sql = "SELECT * \n                FROM fcms_users \n                WHERE UNIX_TIMESTAMP(`activity`) >= ?\n                ORDER BY `activity` DESC";
     $rows = $this->fcmsDatabase->getRows($sql, $last24hours);
     if ($rows === false) {
         $this->fcmsError->setMessage('Could not get members online.');
         return false;
     }
     foreach ($rows as $r) {
         $membersOnline['membersOnline'][] = array('id' => (int) $r['id'], 'avatar' => getCurrentAvatar($r['id']), 'displayname' => getUserDisplayName($r['id']), 'since' => getHumanTimeSince(strtotime($r['activity'])));
     }
     return $membersOnline;
 }
示例#2
0
 /**
  * displayAllNotifications 
  * 
  * @return void
  */
 function displayAllNotifications()
 {
     global $fcmsUser;
     $this->displayHeader();
     $sql = "SELECT `id`, `user`, `created_id`, `notification`, `data`, `created`, `updated`\n                FROM `fcms_notification`\n                WHERE `user` = ?\n                AND `created_id` != ?";
     $params = array($this->fcmsUser->id, $this->fcmsUser->id);
     $rows = $this->fcmsDatabase->getRows($sql, $params);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     if (count($rows) <= 0) {
         if (isset($_SESSION['notifications'])) {
             unset($_SESSION['notifications']);
         }
         echo '
         <p class="info-alert">' . T_('You do not have any notifications.') . '</p>';
         return;
     }
     echo '
     <div id="sections_menu">
         <ul>
             <li><a href="notifications.php">' . T_('Unread Notifications') . '</a></li>
         </ul>
     </div>
     <div id="notifications-list">';
     foreach ($rows as $r) {
         $date = getHumanTimeSince(strtotime($r['created']));
         $date = ' <span class="date">' . $date . '</span>';
         $info = '';
         if ($r['notification'] == 'tagged_photo') {
             $displayName = getUserDisplayName($r['created_id']);
             list($uid, $cid, $pid, $filename) = explode(':', $r['data']);
             $data = array('id' => $pid, 'external_id' => null, 'filename' => $filename, 'user' => $uid);
             $photoSrc = $this->fcmsPhotoGallery->getPhotoSource($data);
             $info = sprintf(T_('%s has added a photo of you.'), $displayName) . $date;
             $info .= '<br/><a href="gallery/index.php?uid=' . $uid . '&amp;cid=' . $cid . '&amp;pid=' . $pid . '">';
             $info .= '<img src="' . $photoSrc . '"/></a>';
         }
         echo '
             <p>
                 ' . $info . '
             </p>';
     }
     echo '
     </div>';
     $this->displayFooter();
 }
示例#3
0
 /**
  * showRecipeInCategory 
  *
  * Displays up to 5 recipes for the given category and page.
  * 
  * @param   int     $cat 
  * @param   int     $page 
  * @return  void
  */
 function showRecipeInCategory($cat, $page = 1)
 {
     $cat = (int) $cat;
     $page = (int) $page;
     $from = $page * 5 - 5;
     // Display Menu
     echo '
         <div id="sections_menu">
             <ul>
                 <li><a href="recipes.php">' . T_('Recipe Categories') . '</a></li>';
     if ($this->fcmsUser->access <= 5) {
         echo '
             </ul>
         </div>
         <div id="actions_menu">
             <ul>
                 <li><a href="?addrecipe=yes&amp;cat=' . $cat . '">' . T_('Add Recipe') . '</a></li>';
     }
     echo '
             </ul>
         </div>';
     // Show Category Side Menu
     $this->showCategoryMenu();
     echo '
         <div id="maincolumn">';
     // Get Recipes for this category
     $sql = "SELECT r.`id`, r.`name`, r.`category`, r.`thumbnail`, c.`name` AS category_name, r.`user`, r.`date`\n                FROM `fcms_recipes` AS r, `fcms_category` AS c\n                WHERE `category` = ?\n                AND r.`category` = c.`id` \n                ORDER BY `date` DESC \n                LIMIT {$from}, 5";
     $rows = $this->fcmsDatabase->getRows($sql, $cat);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $categoryName = '';
     // Display Recipes
     if (count($rows) > 0) {
         $displayed_category = false;
         $path = 'uploads/upimages/';
         if (defined('UPLOADS')) {
             $path = 'file.php?u=';
         }
         foreach ($rows as $r) {
             // Category
             if (!$displayed_category) {
                 $displayed_category = true;
                 $categoryName = cleanOutput($r['category_name']);
                 echo '
         <h2>' . $categoryName . '</h2>
         <ul id="recipe-list">';
             }
             $since = getHumanTimeSince(strtotime($r['date']));
             echo '
             <li>
                 <a href="?category=' . $cat . '&amp;id=' . (int) $r['id'] . '">
                     <span>' . T_('Click to view recipe') . '</span>
                     <img src="' . URL_PREFIX . $path . basename($r['thumbnail']) . '"/>
                     <b>' . cleanOutput($r['name']) . '</b>
                     <i>' . $since . '</i>
                 </a>
             </li>';
         }
         echo '
         </ul>';
         // Display Pagination
         $sql = "SELECT count(`id`) AS c \n                    FROM `fcms_recipes` \n                    WHERE `category` = ?";
         $r = $this->fcmsDatabase->getRow($sql, $cat);
         if ($r === false) {
             $this->fcmsError->displayError();
             return;
         }
         $recipecount = $r['c'];
         $total_pages = ceil($recipecount / 5);
         displayPagination('recipes.php?category=' . $cat, $page, $total_pages);
         // No recipes for this category
     } else {
         echo '
         <div class="info-alert">
             <h2>' . $categoryName . '</h2>
             <p><i>' . T_('Currently no one has added any recipes to this category.') . '</i></p>
             <p><a href="?addrecipe=yes&amp;cat=' . $cat . '">' . T_('Add a Recipe') . '</a></p>
         </div>';
     }
     echo '
         </div>';
 }