Example #1
1
 /**
  * displayYouTubeVideoPage 
  * 
  * @param array $video 
  * 
  * @return void
  */
 function displayYouTubeVideoPage($video)
 {
     // Save video id for ajax call
     $_SESSION['source_id'] = $video['source_id'];
     $this->displayHeader();
     // Video not found in db
     if (!is_array($video)) {
         echo '
     <div class="info-alert">
         <h2>' . T_('Missing or Invalid Video.') . '</h2>
         <p>' . T_('This video cannot be found.  Are you sure you typed in URL correctly?') . '</p>
     </div>';
         $this->displayFooter();
         return;
     } elseif ($video['source_id'] == '0') {
         $this->displayVideoNotFound($video, 'YouTube');
         return;
     }
     $youTubeService = new Zend_Gdata_YouTube();
     $status = null;
     // Get video entry
     try {
         $videoEntry = $youTubeService->getVideoEntry($video['source_id']);
     } catch (Exception $e) {
         $response = $e->getRawResponseBody();
         $private = stripos($response, 'Private video');
         $notFound = stripos($response, 'Video not found');
         // Video not found at YouTube
         if ($notFound !== false) {
             $this->displayVideoNotFound($video, 'YouTube');
             return;
         } elseif ($private !== false) {
             echo '
         <div class="error-alert">
             <p>' . T_('Sorry, this video is private.') . '</p>
             <p>' . $e->getMessage() . '</p>
         </div>';
             $this->displayFooter();
             return;
         } else {
             echo '
         <div class="error-alert">
             <p>' . T_('Could not get video information.') . '</p>
             <p>' . $e->getMessage() . '</p>
         </div>';
             $this->displayFooter();
             return;
         }
     }
     // Video is public/unlisted
     if ($status == null) {
         $status = $this->getUploadStatus($video['source_id']);
     }
     $url = 'video.php?u=' . $video['created_id'] . '&amp;id=' . $video['id'];
     // Is youtube processing finished?
     if ($status !== 'Finished') {
         echo '
         <div class="ok-alert">
             <p><b>' . T_('Your video was uploaded to YouTube successfully.') . '</b></p>
             <p>' . T_('However it may take a few moments before you video is viewable. Please check back later.') . '</p>
             <p id="js_msg"></p><br/>
             <p>' . T_('Current status: ') . '<span id="current_status">' . $status . '</span></p>
             <p id="refresh"><a href="' . $url . '">' . T_('Refresh') . '</a></p>
         </div>';
         $this->displayFooter();
         return;
     }
     // Ajax is done at this point, we don't need the id anymore
     unset($_SESSION['source_id']);
     $videoUrl = 'http://www.youtube.com/e/' . $video['source_id'] . '?version=3&enablejsapi=1&rel=0&wmode=transparent';
     $this->displayVideoStartCode();
     echo '
     <div id="sections_menu">
         <ul>
             <li><a href="video.php">' . T_('Latest Videos') . '</a></li>
             <li><a href="video.php?u=' . $video['created_id'] . '">' . getUserDisplayName($video['created_id'], 2) . '</a></li>
         </ul>
     </div>';
     // Can you edit/delete this video?
     if ($video['created_id'] == $this->fcmsUser->id || $this->fcmsUser->access == 1) {
         echo '
     <div id="video_edit">
         <form action="' . $url . '" method="post">
             <div id="delete">
                 <input type="hidden" id="id" name="id" value="' . $video['id'] . '"/>
                 <input type="hidden" id="source_id" name="source_id" value="' . $video['source_id'] . '"/>
                 <input class="btn" type="submit" id="remove_video" name="remove_video" value="' . T_('Remove Video') . '"/>
                 <label for="delete_youtube">' . T_('Delete from YouTube?') . '</label>
                 <input type="checkbox" id="delete_youtube" name="delete_youtube"/>
             </div>
         </form>
     </div>';
     }
     echo '
     <div id="video_desc">
         <img src="' . getCurrentAvatar($video['created_id']) . '"/>
         <h2>' . cleanOutput($video['title']) . '</h2>
         <p>' . cleanOutput($video['description']) . '</p>
     </div>
     <div id="video_content">
         <iframe class="youtube-player" type="text/html" width="' . $video['width'] . '" height="' . $video['height'] . '" 
             src="http://www.youtube.com/embed/' . $video['source_id'] . '" allowfullscreen frameborder="0">
         </iframe>
     </div>';
     echo '<p>' . T_('Views') . ': ' . $videoEntry->getVideoViewCount() . '</p>';
     $params = array('id' => $video['id']);
     displayComments($url, 'video', $params);
     $this->displayFooter();
 }
Example #2
0
File: Form.php Project: lmcro/fcms
 /**
  * display 
  * 
  * @return void
  */
 public function display()
 {
     $id = (int) $_GET['avatar'];
     // Get user info
     $sql = "SELECT `id`, `fname`, `lname`, `maiden`, `avatar`, `gravatar`\n                FROM `fcms_users`\n                WHERE `id` = ?";
     $row = $this->fcmsDatabase->getRow($sql, $id);
     if ($row === false) {
         $this->fcmsError->displayError();
         return;
     }
     $name = cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']);
     echo '
             <form id="frm" name="frm" enctype="multipart/form-data" action="?avatar=' . $id . '" method="post">
                 <fieldset>
                     <legend><span>' . sprintf(T_pgettext('%s is a persons full name', 'Picture for %s'), $name) . '</span></legend>
                     <div class="field-row">
                         <div class="field-label"><b>' . T_('Current Picture') . '</b></div>
                         <div class="field-widget">
                             <img src="' . getCurrentAvatar($id) . '"/>
                         </div>
                     </div>';
     $this->displayUploadArea();
     echo '
                     <p>
                         <input type="hidden" name="avatar_orig" value="' . cleanOutput($row['avatar']) . '"/>
                         <input class="sub1" type="submit" name="submitUpload" id="submitUpload" value="' . T_('Submit') . '"/>
                         &nbsp; <a href="familytree.php">' . T_('Cancel') . '</a>
                     </p>
                 </fieldset>
             </form>';
 }
Example #3
0
File: Form.php Project: lmcro/fcms
    /**
     * display 
     * 
     * @return void
     */
    public function display()
    {
        $this->setAvatarTypes();
        if (!$this->getAvatarData()) {
            $this->fcmsError->displayError();
            return;
        }
        $avatarOptions = buildHtmlSelectOptions($this->avatarTypes, $this->data['currentAvatarType']);
        echo '
                <form id="frm" name="frm" enctype="multipart/form-data" action="profile.php?view=picture" method="post">
                    <fieldset>
                        <legend><span>' . T_('Profile Picture') . '</span></legend>

                        <div class="field-row">
                            <div class="field-label">
                                <label for="avatar"><b>' . T_('Change Avatar') . '</b></label>
                            </div>
                            <div class="field-widget">
                                <select name="avatar_type" id="avatar_type">
                                    ' . $avatarOptions . '
                                </select><br/>
                            </div>
                        </div>

                        <div id="fcms" class="field-row">';
        $this->displayUploadArea();
        echo '
                        </div>

                        <div id="gravatar" class="field-row">
                            <div class="field-label">&nbsp;</div>
                            <div class="field-widget">
                                <b>' . T_('Gravatar Email') . '</b><br/>
                                <input type="text" name="gravatar_email" size="30" value="' . cleanOutput($this->data['gravatar']) . '"/><br/>
                            </div>
                        </div>

                        <div id="default" class="field-row">
                            <div class="field-label">&nbsp;</div>
                            <div class="field-widget">
                                <b>' . T_('Default') . '</b><br/>
                                <img id="current-avatar" src="' . getAvatarPath('no_avatar.jpg', '') . '" alt="' . T_('Default avatar.') . '"/>
                            </div>
                        </div>

                        <div class="field-row">
                            <div class="field-label">
                                <label for="avatar"><b>' . T_('Current Avatar') . '</b></label>
                            </div>
                            <div class="field-widget">
                                <img id="current-avatar" src="' . getCurrentAvatar($this->fcmsUser->id) . '" alt="' . T_('This is your current avatar.') . '"/>
                            </div>
                        </div>

                        <p><input class="sub1" type="submit" name="submit" id="submit-avatar" value="' . T_('Submit') . '"/></p>

                    </fieldset>
                </form>';
    }
Example #4
0
 /**
  * displayProfile 
  * 
  * @return void
  */
 function displayProfile()
 {
     $memberId = (int) $_GET['member'];
     $this->displayHeader($memberId);
     // handle unknown user
     if ($memberId == 0) {
         echo '
         <p class="error-alert">
             <b>' . T_('Unknown member.') . '</b><br/>
         </p>';
         $this->displayFooter();
         return;
     }
     $sql = "SELECT u.fname, u.lname, u.email, u.`bio`, u.`dob_year`, u.`dob_month`, u.`dob_day`, \n                    u.`dod_year`, u.`dod_month`, u.`dod_day`, u.avatar, u.username, u.joindate, \n                    u.`activity`, u.`sex`, a.`id` AS aid, a.`address`, a.`city`, a.`state`, a.`zip`, \n                    a.`home`, a.`cell`, a.`work`  \n                FROM fcms_users AS u, fcms_address AS a \n                WHERE u.id = ?\n                AND u.id = a.user";
     $row = $this->fcmsDatabase->getRow($sql, $memberId);
     if ($row === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     $tzOffset = getTimezone($memberId);
     $joinDate = fixDate(T_('F j, Y'), $tzOffset, $row['joindate']);
     $address = formatAddress($row);
     $contact = '';
     $activityDate = T_('Never visited');
     $points = getUserParticipationPoints($memberId);
     $level = getUserParticipationLevel($points);
     // Contacts - Email
     if (!empty($row['cell'])) {
         $contact .= '<p><span>' . T_('Email') . '</span> ' . $row['email'] . '</p>';
     }
     // Contacts - Phone
     if (!empty($row['cell'])) {
         $contact .= '<p><span>' . T_('Cell') . '</span> ' . formatPhone($row['cell']) . '</p>';
     }
     if (!empty($row['home'])) {
         $contact .= '<p><span>' . T_pgettext('The beginning or starting place.', 'Home') . '</span> ' . formatPhone($row['home']) . '</p>';
     }
     if (!empty($row['work'])) {
         $contact .= '<p><span>' . T_('Work') . '</span> ' . formatPhone($row['work']) . '</p>';
     }
     // Call
     $hasPhone = false;
     $call = '';
     $tel = '';
     if (!empty($row['cell'])) {
         $tel = $row['cell'];
         $hasPhone = true;
     } else {
         if (!empty($row['home'])) {
             $tel = $row['home'];
             $hasPhone = true;
         } else {
             if (!empty($row['work'])) {
                 $tel = $row['work'];
                 $hasPhone = true;
             }
         }
     }
     if ($hasPhone) {
         $call = '<li><a class="call" href="tel:' . $tel . '">' . sprintf(T_pgettext('%s is the name of a person. Call Bob. etc.', 'Call %s'), $row['fname']) . '</a></li>';
     }
     // Activity
     if ($row['activity'] != '0000-00-00 00:00:00') {
         $activityDate = fixDate(T_('F j, Y g:i a'), $tzOffset, $row['activity']);
     }
     $bday = formatDate('F j, Y', $row['dob_year'] . '-' . $row['dob_month'] . '-' . $row['dob_day']);
     $age = getAge($row['dob_year'], $row['dob_month'], $row['dob_day']);
     $gender = $row['sex'] == 'M' ? T_('Male') : T_('Female');
     echo '
             <div id="avatar">
                 <h1><img class="avatar" src="' . getCurrentAvatar($memberId) . '" alt="avatar"/></h1>
                 ' . $level . '
             </div>
             <div class="name-contacts">
                 <h1>' . cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']) . '</h1>
                 <h2>' . cleanOutput($row['username']) . '</h2>
                 <ul>
                     ' . $call . '
                     <li><a class="email" href="mailto:' . $row['email'] . '">' . T_('Send Email') . '</a></li>
                     <li><a class="pm" href="privatemsg.php?compose=new&amp;id=' . $memberId . '">' . T_('Send Private Message') . '</a></li>
                 </ul>
             </div>
             <ul>
                 <li>
                     <ul>
                         <li>
                             <b>' . T_('Birthday') . '</b>
                             <div>' . $bday . ' (' . sprintf(T_('%s years old'), $age) . ')</div>
                         </li>
                         <li>
                             <b>' . T_('Gender') . '</b>
                             <div>' . $gender . '</div>
                         </li>
                     </ul>
                 </li>
                 <li>
                     <ul>
                         <li>
                             <b>' . T_('Location') . '</b>
                             <div>' . $address . '</div>
                         </li>
                         <li>
                             <b>' . T_('Contact') . '</b>
                             <div>' . $contact . '</div>
                         </li>
                     </ul>
                 </li>
                 <li>
                     <b>' . T_('Bio') . '</b>
                     <div>' . cleanOutput($row['bio']) . '</div>
                 </li>
                 <li>
                     <ul>
                         <li>
                             <b>' . T_('Join Date') . '</b>
                             <div>' . $joinDate . '</div>
                         </li>
                         <li>
                             <b>' . T_('Last Visit') . '</b>
                             <div>' . $activityDate . '</div>
                         </li>
                     </ul>
                 </li>
             </ul>';
     $this->displayFooter($memberId);
 }
Example #5
0
    /**
     * showPhoto 
     * 
     * Displays the current photo, info, comments, next/prev butons etc.
     *
     * The following views use this function:
     *     Latest Comments - uid=0         cid=comments
     *     Top Rated       - uid=0         cid=toprated
     *     Most  Viewed    - uid=userid    cid=mostviewed
     *     Tagged Users    - uid=0         cid=tagged# (where # is the id of the tagged user)
     *     All for User    - uid=userid    cid=all
     *
     * @param string $uid the user's id or 0
     * @param string $cid the category id, 'tagged#', 'comments', 'toprated', 'mostviewed' or 'all'
     * @param string $pid the photo id 
     *
     * @return  void
     */
    function showPhoto($uid, $cid, $pid)
    {
        $uid = (int) $uid;
        $pid = (int) $pid;
        list($breadcrumbs, $cid, $urlcid, $sql) = $this->getShowPhotoParams($uid, $cid);
        $rows = $this->fcmsDatabase->getRows($sql);
        if ($rows === false) {
            $this->fcmsError->displayError();
            return;
        }
        // Save filenames in an array, so we can see next/prev, etc
        foreach ($rows as $row) {
            $photo_arr[] = $row['filename'];
            $photoIdLookup[] = $row['id'];
        }
        // No photos exist for the current view/category
        // Even though we are in photo view, bump them back to the category view
        // and let the user know that this category is now empty
        if (count($rows) <= 0) {
            $this->displayGalleryMenu($uid, $cid);
            echo '
            <div class="info-alert">
                <h2>' . T_('Oops!') . '</h2>
                <p>' . T_('The Category you are trying to view is Empty.') . '</p>
            </div>';
            return;
        }
        // Select Current Photo to view
        $sql = "SELECT p.`id`, p.`user` AS uid, `filename`, `caption`, `category` AS cid, p.`date`, \n                    `name` AS category_name, `views`, `votes`, `rating`, p.`external_id`, \n                    e.`thumbnail`, e.`medium`, e.`full`\n                FROM `fcms_gallery_photos` AS p\n                LEFT JOIN `fcms_category` AS c ON p.`category` = c.`id`\n                LEFT JOIN `fcms_gallery_external_photo` AS e ON p.`external_id` = e.`id`\n                WHERE p.`id` = ?";
        $r = $this->fcmsDatabase->getRow($sql, $pid);
        if ($r === false) {
            $this->fcmsError->displayError();
            return;
        }
        if (empty($r)) {
            echo '
            <p class="error-alert">' . T_('The Photo you are trying to view can not be found.') . '</p>';
            return;
        }
        // Save info about current photo
        $_SESSION['photo-path-data'][$r['id']] = array('id' => $r['id'], 'user' => $r['uid'], 'filename' => $r['filename'], 'external_id' => $r['external_id'], 'thumbnail' => $r['thumbnail'], 'medium' => $r['medium'], 'full' => $r['full']);
        $displayname = getUserDisplayName($r['uid']);
        // Update View count
        $sql = "UPDATE `fcms_gallery_photos` \n                SET `views` = `views`+1 \n                WHERE `id` = ?";
        if (!$this->fcmsDatabase->update($sql, $pid)) {
            // Just show error and continue
            $this->fcmsError->displayError();
        }
        // Get photo comments
        $comments = $this->getPhotoComments($pid);
        $total = count($photo_arr);
        $current = array_search($pid, $photoIdLookup);
        $prev = $this->getPrevId($photo_arr, $photoIdLookup, $current);
        $next = $this->getNextId($photo_arr, $photoIdLookup, $current);
        $photos_of = '<i>(' . sprintf(T_('%d of %d'), $current + 1, $total) . ')</i>';
        $prev_next = '';
        if ($total > 1) {
            $prev_next .= '
                <div class="prev_next">
                    <a class="previous" href="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $prev . '">' . T_('Previous') . '</a>
                    <a class="next" href="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $next . '">' . T_('Next') . '</a>
                </div>
                <script type="text/javascript">
                function keyHandler(e) {
                    if (!e) { e = window.event; }
                    arrowRight = 39;
                    arrowLeft = 37;
                    switch (e.keyCode) {
                        case arrowRight:
                        document.location.href = "index.php?uid=' . $uid . '&cid=' . $urlcid . '&pid=' . $next . '";
                        break;
                        case arrowLeft:
                        document.location.href = "index.php?uid=' . $uid . '&cid=' . $urlcid . '&pid=' . $prev . '";
                        break;
                    }
                }
                document.onkeydown = keyHandler;
                </script>';
        }
        // special view detail
        $special = '
                <div id="special">
                    ' . T_('From the Category:') . ' <a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '">' . cleanOutput($r['category_name']) . '</a> 
                    ' . T_('by') . ' 
                    <a class="u" href="../profile.php?member=' . $r['uid'] . '">' . $displayname . '</a>
                </div>';
        // if breadcrumbs haven't been defined, give the default
        if ($breadcrumbs == '') {
            $breadcrumbs = '
                <a href="?uid=0">' . T_('Members') . '</a> &gt; 
                <a href="?uid=' . $uid . '">' . $displayname . '</a> &gt; 
                <a href="?uid=' . $uid . '&amp;cid=' . $cid . '">' . cleanOutput($r['category_name']) . '</a>
                ' . $photos_of;
            $special = '';
        }
        // setup some vars to hold photo details
        if ($r['filename'] == 'noimage.gif' && $r['external_id'] != null) {
            $photo_path_middle = $r['medium'];
            $photo_path_full = $r['full'];
            $size = T_('Unknown');
        } else {
            $photo_path = $this->getPhotoPath($r['filename'], $r['uid']);
            $photo_path_middle = $photo_path[0];
            $photo_path_full = $photo_path[1];
            $size = filesize($photo_path_full);
            $size = formatSize($size);
        }
        $r['user'] = $r['uid'];
        // Figure out where we are currently saving photos, and create new destination object
        $photoDestinationType = getDestinationType() . 'PhotoGalleryDestination';
        $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
        $mediumSrc = $this->getPhotoSource($r, 'medium');
        $fullSrc = $this->getPhotoSource($r, 'full');
        $caption = cleanOutput($r['caption']);
        $dimensions = $photoDestination->getImageSize($photo_path_full);
        $date_added = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $r['date']);
        // Calculate rating
        if ($r['votes'] <= 0) {
            $rating = 0;
            $width = 0;
        } else {
            $rating = $r['rating'] / $r['votes'] * 100;
            $rating = round($rating, 0);
            $width = $rating / 5;
        }
        // Get Tagged Members
        $sql = "SELECT u.`id`, u.`fname`, u.`lname` \n                FROM `fcms_users` AS u, `fcms_gallery_photos_tags` AS t \n                WHERE t.`photo` = '{$pid}' \n                AND t.`user` = u.`id`\n                ORDER BY u.`lname`";
        $rows = $this->fcmsDatabase->getRows($sql, $pid);
        if ($rows === false) {
            $this->fcmsError->displayError();
            return;
        }
        $tagged_mem_list = '<li>' . T_('none') . '</li>';
        if (count($rows) > 0) {
            $tagged_mem_list = '';
            foreach ($rows as $t) {
                $taggedName = cleanOutput($t['fname']) . ' ' . cleanOutput($t['lname']);
                $tagged_mem_list .= '<li><a href="?uid=0&cid=' . $t['id'] . '" ';
                $tagged_mem_list .= 'title="' . sprintf(T_('Click to view more photos of %s.'), $taggedName) . '">' . $taggedName . '</a></li>';
            }
        }
        // Edit / Delete Photo options
        $edit_del_options = '';
        if ($this->fcmsUser->id == $r['uid'] || $this->fcmsUser->access < 2) {
            $edit_del_options = '
                            <li>
                                <input type="submit" name="editphoto" id="editphoto" value="' . T_('Edit') . '" class="editbtn"/>
                            </li>
                            <li>
                                <input type="submit" name="deletephoto" id="deletephoto" value="' . T_('Delete') . '" class="delbtn"/>
                            </li>';
        }
        // Display
        echo '
            <div class="breadcrumbs">
                ' . $breadcrumbs . '
                ' . $prev_next . '
            </div>
            <div id="photo">
                <a href="' . $fullSrc . '"><img class="photo" src="' . $mediumSrc . '" alt="' . $caption . '" title="' . $caption . '"/></a>
            </div>

            <div id="photo_details">

                <div id="caption">
                    ' . $caption . '
                    <ul class="star-rating small-star">
                        <li class="current-rating" style="width:' . $width . '%">' . sprintf(T_('Currently %s/5 Starts'), $r['rating']) . '</li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=1" title="' . sprintf(T_('%s out of 5 Stars', '1'), '1') . '" class="one-star">1</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=2" title="' . sprintf(T_('%s out of 5 Stars', '2'), '2') . '" class="two-stars">2</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=3" title="' . sprintf(T_('%s out of 5 Stars', '3'), '3') . '" class="three-stars">3</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=4" title="' . sprintf(T_('%s out of 5 Stars', '4'), '4') . '" class="four-stars">4</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=5" title="' . sprintf(T_('%s out of 5 Stars', '5'), '5') . '" class="five-stars">5</a></li>
                    </ul>
                </div>

                <div id="photo_stats">
                    <form action="index.php" method="post">
                        <ul>
                            <li class="photo_views">' . $r['views'] . '</li>
                            <li class="photo_comments">' . count($comments) . '</li> 
                            ' . $edit_del_options . '
                        </ul>
                        <div>
                            <input type="hidden" name="photo" id="photo" value="' . $pid . '"/>
                            <input type="hidden" name="url" id="url" value="uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '"/>
                        </div>
                    </form>
                </div>

                <div id="members_in_photo">
                    <b>' . T_('Members in Photo') . '</b>
                    <ul>
                        ' . $tagged_mem_list . '
                    </ul>
                </div>

                ' . $special . '

                <div id="more_details">
                    <div id="photo_details_sub">
                        <p><b>' . T_('Filename') . ':</b> ' . $r['filename'] . '</p>
                        <p><b>' . T_('Photo Size') . ':</b> ' . $size . '</p>
                        <p><b>' . T_('Dimensions') . ':</b> ' . $dimensions[0] . ' x ' . $dimensions[1] . '</p>
                        <p><b>' . T_('Date Added') . ':</b> ' . $date_added . '</p>
                    </div>
                </div>

            </div>';
        // Display Comments
        if ($this->fcmsUser->access <= 8 && $this->fcmsUser->access != 7 && $this->fcmsUser->access != 4) {
            echo '
            <h3 id="comments">' . T_('Comments') . '</h3>';
            if (count($comments) > 0) {
                foreach ($comments as $row) {
                    // Setup some vars for each comment block
                    $del_comment = '';
                    $date = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['date']);
                    $displayname = getUserDisplayName($row['user']);
                    $comment = $row['comment'];
                    if ($this->fcmsUser->id == $row['user'] || $this->fcmsUser->access < 2) {
                        $del_comment .= '<input type="submit" name="delcom" value="' . T_('Delete') . '" class="gal_delcombtn" title="' . T_('Delete this Comment') . '"/>';
                    }
                    echo '
            <div id="comment' . $row['id'] . '" class="comment_block">
                <form action="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '" method="post">
                    ' . $del_comment . '
                    <img class="avatar" alt="avatar" src="' . getCurrentAvatar($row['user'], true) . '"/>
                    <b>' . $displayname . '</b>
                    <span>' . $date . '</span>
                    <p>
                        ' . parse($comment, '../') . '
                    </p>
                    <input type="hidden" name="uid" value="' . $uid . '"/>
                    <input type="hidden" name="cid" value="' . $cid . '"/>
                    <input type="hidden" name="pid" value="' . $pid . '"/>
                    <input type="hidden" name="id" value="' . $row['id'] . '">
                </form>
            </div>';
                }
            }
            echo '
            <div class="add_comment_block">
                <form action="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '" method="post">
                    ' . T_('Add Comment') . '<br/>
                    <textarea class="frm_textarea" name="post" id="post" rows="3" cols="63"></textarea>
                    <input type="submit" name="addcom" id="addcom" value="' . T_('Add Comment') . '" title="' . T_('Add Comment') . '" class="gal_addcombtn"/>
                </form>
            </div>';
        }
    }
Example #6
0
 /**
  * showPosts 
  * 
  * @param   int     $thread_id 
  * @param   int     $page 
  * @return  void
  */
 function showPosts($thread_id, $page = 1)
 {
     $thread_id = (int) $thread_id;
     $page = (int) $page;
     $from = $page * 15 - 15;
     $total = $this->getNumberOfPosts($thread_id);
     if ($total < 1) {
         echo '
         <p class="error-alert">' . T_('Thread does not exist.') . '</p>';
         return;
     }
     $sql = "UPDATE `fcms_board_threads` \n                SET `views` = (`views` + 1) \n                WHERE `id` = ?";
     if (!$this->fcmsDatabase->update($sql, $thread_id)) {
         $this->fcmsError->displayError();
         return;
     }
     $this->displayMessageBoardMenu($thread_id);
     $this->displayPages($page, $thread_id);
     $sort = $this->getSortOrder($this->fcmsUser->id);
     $sql = "SELECT p.`id`, `thread`, `post`, `subject`, p.`date`, `user`, `avatar` \n                FROM `fcms_board_posts` AS p, `fcms_board_threads` AS t, \n                    `fcms_users` AS u \n                WHERE `thread` = ?\n                AND t.`id` = `thread` \n                AND `user` = u.`id` \n                ORDER BY p.`id` {$sort}\n                LIMIT {$from}, 15";
     $rows = $this->fcmsDatabase->getRows($sql, $thread_id);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $alt = 0;
     $first = true;
     foreach ($rows as $row) {
         // display the table header
         if ($first) {
             echo '
         <table id="postlist" cellpadding="0" cellspacing="0">
             <tbody>';
             $first = false;
         }
         // Shrink long subjects
         $subject = $row['subject'];
         if (strlen($subject) > 40) {
             $subject = substr($subject, 0, 37) . "...";
         }
         // Remove #ANOUNCE#
         $isThreadAnnouncement = false;
         $pos = strpos($subject, '#ANOUNCE#');
         if ($pos !== false) {
             $isThreadAnnouncement = true;
             $subject = substr($subject, 9, strlen($subject) - 9);
         }
         // Add RE: to replies
         if ($sort == 'ASC') {
             if ($alt > 0) {
                 $subject = "RE: " . $subject;
             }
         } else {
             if ($alt !== $total - 1) {
                 $subject = "RE: " . $subject;
             }
         }
         $displayname = getUserDisplayName($row['user']);
         $date = fixDate(T_('n/d/y g:ia'), $this->fcmsUser->tzOffset, $row['date']);
         if ($alt % 2 == 0) {
             $tr_class = '';
         } else {
             $tr_class = 'alt';
         }
         // Participation Level
         $points = getUserParticipationPoints($row['user']);
         $level = getUserParticipationLevel($points);
         // Avatar
         $avatar = "<img src=\"" . getCurrentAvatar($row['user']) . "\" alt=\"{$displayname}\"/><br/><br/>";
         // Post Count
         $posts_count = $this->getUserPostCountById($row['user']);
         $actions = '';
         // quote
         if ($this->fcmsUser->access < 8 && $this->fcmsUser->access != 5) {
             $actions .= '<form method="post" action="messageboard.php?reply=' . $thread_id . '">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="submit" class="quotebtn" value="' . T_('Quote') . '" name="quotepost" title="' . T_('Quote this message') . '"/>
                                     </div>
                                 </form>';
         }
         // edit
         if ($this->fcmsUser->id == $row['user'] || $this->fcmsUser->access < 3) {
             $actions .= ' &nbsp;
                                 <form method="post" action="messageboard.php">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="submit" name="editpost" value="' . T_('Edit') . '" class="editbtn" title="' . T_('Edit this message') . '"/>
                                     </div>
                                 </form>';
         }
         // delete
         if ($this->fcmsUser->access < 2) {
             $actions .= ' &nbsp;
                                 <form class="delpost" method="post" action="messageboard.php">
                                     <div>
                                         <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                                         <input type="hidden" name="thread" value="' . $thread_id . '"/>
                                         <input type="submit" name="delpost" value="' . T_('Delete') . '" class="delbtn" title="' . T_('Delete this message') . '"/>
                                     </div>
                                 </form>';
         }
         // Display the posts rows
         echo '
                 <tr class="' . $tr_class . '">
                     <td class="side">
                         <b><a href="profile.php?member=' . $row['user'] . '">' . $displayname . '</a></b>
                         ' . $level . '
                         ' . $avatar . '
                         <b>' . T_('Posts') . '</b> ' . $posts_count . '
                     </td>
                     <td class="posts">
                         <div class="header">
                             <div class="subject"><b>' . cleanOutput($subject, 'html') . '</b> - ' . $date . '</div>
                             <div class="actions">
                                 ' . $actions . '
                             </div>
                         </div>
                         <div class="msg">
                             ' . parse($row['post']) . '
                         </div>
                     </td>
                 </tr>';
         $alt++;
     }
     if (!$first) {
         echo '
             </tbody>
         </table>';
     }
     $this->displayMessageBoardMenu($thread_id);
     $this->displayPages($page, $thread_id);
     $this->displayAdminMenu($thread_id, $isThreadAnnouncement);
     echo '
         <div class="top"><a href="#top">' . T_('Back to Top') . '</a></div>';
 }
Example #7
0
    /**
     *  displayAddress
     *
     *  Displays the address details.
     *
     *  @param int    $aid Id of the address
     *  @param string $cat Category name
     *
     *  @return void
     */
    function displayAddress($aid, $cat)
    {
        $aid = (int) $aid;
        $cat = cleanOutput($cat);
        $sql = "SELECT a.`id`, a.`user`, `fname`, `lname`, `avatar`, `updated`, `country`, `address`, `city`, `state`, \n                    `zip`, `home`, `work`, `cell`, `email`, `phpass` \n                FROM `fcms_address` AS a, `fcms_users` AS u \n                WHERE a.`user` = u.`id` \n                AND a.`id` = ?";
        $r = $this->fcmsDatabase->getRow($sql, $aid);
        if ($r === false) {
            $this->fcmsError->displayError();
            return;
        }
        if (count($r) <= 0) {
            echo '
            <p class="error-alert">' . sprintf(T_('Could not find address (%s)'), $aid) . '</p>';
            return;
        }
        // Edit / Delete links
        $edit_del = '';
        if ($this->fcmsUser->id == $r['user'] || $this->fcmsUser->access < 2) {
            $edit_del = '<li id="edit"><a href="?cat=' . $cat . '&amp;edit=' . $r['id'] . '">' . T_('Edit') . '</a></li>';
            if ($r['phpass'] == 'NONMEMBER' || $r['phpass'] == 'PRIVATE') {
                $edit_del .= '
                        <li id="delete"><a id="del_address" href="?cat=' . $cat . '&amp;delete=' . $r['id'] . '">' . T_('Delete') . '</a></li>';
            }
        }
        // Address
        $address = formatAddress($r);
        $addressUrl = formatAddressUrl($address);
        if ($address == '') {
            $str = "<i>(" . T_('none') . ")</i>";
        }
        $map_link = !empty($addressUrl) ? '<br/><a href="http://maps.google.com/maps?q=' . $addressUrl . '"/>' . T_('Map') . '</a>' : '';
        // Email
        if (empty($r['email'])) {
            $email = "<i>(" . T_('none') . ")</i>";
        } else {
            $email = cleanOutput($r['email']) . ' <a class="email" href="mailto:' . cleanOutput($r['email']) . '" 
                title="' . T_('Email This Member') . '">&nbsp;</a>';
        }
        // Phone Number
        $home = empty($r['home']) ? '<i>(' . T_('none') . ')</i>' : formatPhone($r['home'], $r['country']);
        $work = empty($r['work']) ? '<i>(' . T_('none') . ')</i>' : formatPhone($r['work'], $r['country']);
        $cell = empty($r['cell']) ? '<i>(' . T_('none') . ')</i>' : formatPhone($r['cell'], $r['country']);
        // Display address
        echo '
            <div id="leftcolumn">';
        $this->displayCategories($cat);
        echo '
            </div>
            <div id="maincolumn">

                <div id="address-options">
                    <ul>
                        <li id="back"><a href="?cat=' . $cat . '">' . T_('Back to Addresses') . '</a></li>
                        <li id="email"><a href="mailto:' . cleanOutput($r['email']) . '">' . T_('Email') . '</a></li>
                        ' . $edit_del . '
                    </ul>
                </div>
                <div id="address-details">
                    <p>
                        <img alt="avatar" src="' . getCurrentAvatar($r['user']) . '"/>
                        <b class="name">' . cleanOutput($r['fname']) . ' ' . cleanOutput($r['lname']) . '</b>
                    </p>
                    <p>
                        <b class="label">' . T_('Address') . ':</b>
                        <span class="data">' . $address . ' ' . $map_link . '</span>
                    </p>
                    <p>
                        <b class="label">' . T_('Email') . ':</b>
                        <span class="data">' . $email . '</span>
                    </p>
                    <p>
                        <b class="label">' . T_pgettext('The dwelling where you live.', 'Home') . ':</b>
                        <span class="data">' . $home . '</span>
                    </p>
                    <p>
                        <b class="label">' . T_('Work') . ':</b>
                        <span class="data">' . $work . '</span>
                    </p>
                    <p>
                        <b class="label">' . T_('Mobile') . ':</b>
                        <span class="data">' . $cell . '</span>
                    </p>
                </div>

            </div>';
    }
Example #8
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;
 }
Example #9
0
File: video.php Project: lmcro/fcms
 /**
  * displayYouTubeVideoPage 
  * 
  * @param array $video 
  * 
  * @return void
  */
 function displayYouTubeVideoPage($video)
 {
     $this->displayHeader();
     // Video not found in db
     if (!is_array($video)) {
         echo '
     <div class="info-alert">
         <h2>' . T_('Missing or Invalid Video.') . '</h2>
         <p>' . T_('This video cannot be found.  Are you sure you typed in URL correctly?') . '</p>
     </div>';
         $this->displayFooter();
         return;
     } elseif ($video['source_id'] == '0') {
         $this->displayVideoNotFound($video, 'YouTube');
         return;
     }
     // Save video id for ajax call
     $_SESSION['source_id'] = $video['source_id'];
     $url = 'video.php?u=' . $video['created_id'] . '&amp;id=' . $video['id'];
     $views = T_('Unknown');
     // Get authed google client
     $googleClient = getAuthedGoogleClient($this->fcmsUser->id);
     // If this user has a google account setup, we should get a google client in return
     // so go ahead and do googly/youtuby stuff
     if ($googleClient !== false) {
         // Get video entry
         try {
             $youtube = new Google_Service_YouTube($googleClient);
             $videoEntry = $youtube->videos->listVideos('id,snippet,status,contentDetails,processingDetails,statistics', array('id' => $video['source_id']));
         } catch (Exception $e) {
             $this->fcmsError->add(array('type' => 'operation', 'message' => 'Could not search YouTube.', 'error' => $e, 'file' => __FILE__, 'line' => __LINE__));
             $this->fcmsError->displayError();
             $this->displayFooter();
             return;
         }
         // Make sure we found the video first
         if (!isset($videoEntry['items'][0])) {
             $this->displayVideoNotFound($video, 'YouTube');
             $this->displayFooter();
             return;
         }
         $status = $videoEntry['items'][0]['status']['uploadStatus'];
         $views = $videoEntry['items'][0]['statistics']['viewCount'];
         // Let's handle all the upload statuses
         if ($status === 'deleted') {
             $this->displayVideoNotFound($video, 'YouTube');
             $this->displayFooter();
             return;
         } else {
             if ($status === 'failed') {
                 // TODO
                 echo '<h1>FAILED</h1>';
                 $this->displayFooter();
                 return;
             } else {
                 if ($status === 'rejected') {
                     $reason = $videoEntry['items'][0]['status']['rejectionReason'];
                     echo '
             <div class="info-alert">
                 <p><b>' . T_('This video was Rejected by YouTube') . '</b></p>
                 <p>' . T_('Rejection reason:') . ' ' . $reason . '</p>
                 <p>' . T_('Would you like to delete this video?') . '</p>
                 <form action="' . $url . '" method="post">
                     <input type="hidden" id="id" name="id" value="' . $video['id'] . '"/>
                     <input type="hidden" id="source_id" name="source_id" value="' . $video['source_id'] . '"/>
                     <input class="sub1" type="submit" id="delete_video" name="delete_video" value="' . T_('Yes') . '"/>
                     &nbsp; &nbsp; ' . T_('or') . ' &nbsp; &nbsp;
                     <a href="video.php">' . T_('No') . '</a>
                 </form>
             </div>';
                     $this->displayFooter();
                     return;
                 } else {
                     if ($status === 'uploaded') {
                         $percentComplete = 0;
                         $steps = array('fileDetailsAvailability', 'processingIssuesAvailability', 'tagSuggestionsAvailability', 'editorSuggestionsAvailability', 'thumbnailsAvailability');
                         foreach ($steps as $step) {
                             if ($videoEntry['items'][0]['processingDetails'][$step] === 'available') {
                                 $percentComplete += 20;
                             }
                         }
                         $message = $percentComplete;
                         echo '
             <div class="ok-alert">
                 <p><b>' . T_('This video was uploaded to YouTube successfully.') . '</b></p>
                 <p>' . T_('However it may take a few moments before you video is viewable. Please check back later.') . '</p>
                 <p>
                     ' . T_('Percentage complete:') . ' <span id="current_complete">' . $percentComplete . '%</span>
                 </p>
                 <p id="js_msg"></p>
                 <p id="refresh"><a href="' . $url . '">' . T_('Refresh') . '</a></p>
             </div>';
                         $this->displayFooter();
                         return;
                     }
                 }
             }
         }
     }
     $videoUrl = 'http://www.youtube.com/e/' . $video['source_id'] . '?version=3&enablejsapi=1&rel=0&wmode=transparent';
     $this->displayVideoStartCode();
     echo '
     <div id="sections_menu">
         <ul>
             <li><a href="video.php">' . T_('Latest Videos') . '</a></li>
             <li><a href="video.php?u=' . $video['created_id'] . '">' . getUserDisplayName($video['created_id'], 2) . '</a></li>
         </ul>
     </div>';
     // Can you edit/delete this video?
     if ($video['created_id'] == $this->fcmsUser->id || $this->fcmsUser->access == 1) {
         echo '
     <div id="video_edit">
         <form action="' . $url . '" method="post">
             <div id="delete">
                 <input type="hidden" id="id" name="id" value="' . $video['id'] . '"/>
                 <input type="hidden" id="source_id" name="source_id" value="' . $video['source_id'] . '"/>
                 <input class="btn" type="submit" id="remove_video" name="remove_video" value="' . T_('Remove Video') . '"/>
                 <label for="delete_youtube">' . T_('Delete from YouTube?') . '</label>
                 <input type="checkbox" id="delete_youtube" name="delete_youtube"/>
             </div>
         </form>
     </div>';
     }
     echo '
     <div id="video_desc">
         <img src="' . getCurrentAvatar($video['created_id']) . '"/>
         <h2>' . cleanOutput($video['title']) . '</h2>
         <p>' . cleanOutput($video['description']) . '</p>
     </div>
     <div id="video_content">
         <iframe class="youtube-player" type="text/html" width="854" height="480" 
             src="http://www.youtube.com/embed/' . $video['source_id'] . '" allowfullscreen frameborder="0">
         </iframe>
     </div>';
     echo '<p>' . T_('Views') . ': ' . cleanOutput($views) . '</p>';
     $params = array('id' => $video['id']);
     displayComments($url, 'video', $params);
     $this->displayFooter();
 }
Example #10
0
 /**
  * displayFamilyNews 
  * 
  * Displays a single family news entry.
  * 
  * @param int $user
  * @param int $id 
  * 
  * @return  void
  */
 function displayFamilyNews($user, $id)
 {
     $user = (int) $user;
     $id = (int) $id;
     $sql = "SELECT n.`id`, n.`title`, n.`news`, n.`updated`, n.`created`,\n                    n.`external_type`, n.`external_id`\n                FROM `fcms_news` AS n, `fcms_users` AS u \n                WHERE n.`id` = ? \n                    AND `user` = u.`id`";
     $row = $this->fcmsDatabase->getRow($sql, $id);
     if ($row === false) {
         return;
     }
     $updated = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['updated']);
     $created = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['created']);
     $displayname = getUserDisplayName($user);
     $edit = '';
     $del = '';
     if ($this->fcmsUser->id == $user || $this->fcmsUser->access < 2) {
         $edit = ' &nbsp;
             <form method="post" action="familynews.php">
                 <div>
                     <input type="hidden" name="user" value="' . $user . '"/>
                     <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                     <input type="hidden" name="title" value="' . cleanOutput($row['title']) . '"/>
                     <input type="hidden" name="news" value="' . cleanOutput($row['news']) . '"/>
                     <input type="submit" name="editnews" value="' . T_('Edit') . '" class="editbtn" title="' . T_('Edit this Family News') . '"/>
                 </div>
             </form>';
         $del = ' &nbsp;
             <form class="delnews" method="post" action="familynews.php?getnews=' . $user . '">
                 <div>
                     <input type="hidden" name="user" value="' . $user . '"/>
                     <input type="hidden" name="id" value="' . (int) $row['id'] . '"/>
                     <input type="submit" name="delnews" value="' . T_('Delete') . '" class="delbtn" title="' . T_('Delete this Family News') . '"/>
                 </div>
             </form>';
     }
     $newsSource = '';
     // FCMS news
     if (empty($row['external_type']) && empty($row['external_id'])) {
         $news = parse($row['news']);
     } else {
         $newsSource = '
                 <span style="background-color:#eee; color:#999; font-size:13px;">
                     ' . sprintf(T_('Originally from %s, %s.'), $row['external_type'], $created) . '
                 </span><br/>';
         $news = $row['news'];
         $edit = '';
         // can't edit external
     }
     $title = !empty($row['title']) ? cleanOutput($row['title']) : T_('untitled');
     echo '
         <div class="news-post">
             <h2>
                 <a href="?getnews=' . $user . '&amp;newsid=' . (int) $row['id'] . '">' . $title . '</a>
             </h2>
             <span class="date">
                 ' . $updated . ' - ' . $displayname . $edit . $del . '
             </span>
             <p>
                 ' . $newsSource . $news . '
             </p>
             <p class="news-comments">
                 <a href="?getnews=' . $user . '&amp;newsid=' . (int) $row['id'] . '#comments">' . T_('Comments') . '</a> - 
                 ' . getNewsComments($row['id']) . '
             </p>
         </div>
         <h3 id="comments">' . T_('Comments') . '</h3>
         <p class="center">
             <form action="?getnews=' . $user . '&amp;newsid=' . $id . '#footer" method="post">
                 ' . T_('Add Comment') . '<br/>
                 <input type="text" name="comment" id="comment" size="50" title="' . T_('Add a comment') . '"/> 
                 <input type="submit" name="addcom" id="addcom" value="' . T_('Add') . '" class="gal_addcombtn"/>
             </form>
         </p>
         <p>&nbsp;</p>';
     // Comments
     $sql = "SELECT c.id, comment, `date`, fname, lname, username, user, avatar  \n                FROM fcms_news_comments AS c, fcms_users AS u \n                WHERE news = ?\n                AND c.user = u.id \n                ORDER BY `date`";
     $rows = $this->fcmsDatabase->getRows($sql, $id);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     if (count($rows) <= 0) {
         echo '
         <p class="center">' . T_('no comments') . '</p>';
         return;
     }
     foreach ($rows as $row) {
         $displayname = getUserDisplayName($row['user']);
         $date = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['date']);
         if ($this->fcmsUser->id == $row['user'] || $this->fcmsUser->access < 2) {
             echo '
         <div class="comment_block">
             <form class="delcom" action="?getnews=' . $user . '&amp;newsid=' . $id . '" method="post">
                 <input type="submit" name="delcom" id="delcom" value="' . T_('Delete') . '" class="gal_delcombtn" title="' . T_('Delete this comment') . '"/>
                 <img class="avatar" alt="avatar" src="' . getCurrentAvatar($row['user']) . '"/>
                 <b>' . $displayname . '</b>
                 <span>' . $date . '</span>
                 <p>' . cleanOutput($row['comment']) . '</p>
                 <input type="hidden" name="id" value="' . (int) $row['id'] . '">
             </form>
         </div>';
         } else {
             echo '
         <div class="comment_block">
                 <img class="avatar" src="avatar/' . basename($row['avatar']) . '">
                 <b>' . $displayname . '</b>
                 <span>' . $date . '</span>
                 <p>' . cleanOutput($row['comment']) . '</p>
             </form>
         </div>';
         }
     }
 }
Example #11
0
 /**
  * displayNewUserHome 
  * 
  * @param  int  $userid 
  * 
  * @return boolean
  */
 function displayNewUserHome($userid)
 {
     include_once 'addressbook_class.php';
     $addressObj = new AddressBook($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser);
     $userid = (int) $userid;
     $sql = "SELECT `id`\n                FROM `fcms_alerts` \n                WHERE `alert` = 'alert_new_user_home'\n                AND `user` = ? \n                AND `hide` = 1";
     $row = $this->fcmsDatabase->getRow($sql, $userid);
     if ($row === false) {
         $this->fcmsError->displayError();
         return false;
     }
     if (count($row) >= 1) {
         return false;
     }
     $sitename = getSiteName();
     $sitename = cleanOutput($sitename);
     $complete = 0;
     // social media
     $social = '<a href="settings.php?view=socialmedia">' . T_('Connect social media sites') . '</a>';
     if (userConnectedSocialMedia($userid)) {
         $social = '<span>' . T_('Connect social media sites') . '</span>';
         $complete++;
     }
     // add profile pic
     $profilePicture = '<span>' . T_('Add a Profile Picture') . '</span>';
     $complete++;
     $avatar = getCurrentAvatar($userid);
     $checkUploadsPath = 'uploads/avatar/no_avatar.jpg';
     if (defined('UPLOADS')) {
         $checkUploadsPath = 'file.php?a=no_avatar.jpg';
     }
     if ($avatar == $checkUploadsPath) {
         $profilePicture = '<a href="profile.php?view=picture">' . T_('Add a Profile Picture') . '</a>';
         $complete--;
     }
     // update contact info
     $address = '<a href="addressbook.php?cat=all&edit=' . $userid . '">' . T_('Add your Address/Contact information') . '</a>';
     if ($addressObj->userhasAddress($userid)) {
         $address = '<span>' . T_('Add your Address/Contact information') . '</span>';
         $complete++;
     }
     // vote
     $sql = "SELECT MAX(`id`) AS 'max'\n                FROM `fcms_polls`";
     $r = $this->fcmsDatabase->getRow($sql);
     if ($r === false) {
         $this->fcmsError->displayError();
         return;
     }
     $currentPoll = $r['max'];
     $sql = "SELECT `id`\n                FROM `fcms_poll_votes`\n                WHERE `user` = ?\n                AND `poll_id` = ?";
     $rows = $this->fcmsDatabase->getRows($sql, array($userid, $currentPoll));
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $poll = '<a href="polls.php">' . T_('Vote on the Poll') . '</a>';
     if (count($rows) > 0) {
         $poll = '<span>' . T_('Vote on the Poll') . '</span>';
         $complete++;
     }
     $percent = $complete / 4 * 100;
     echo '
     <div id="alert_new_user_home" class="info-alert">
         <h2>' . T_('It looks like you\'re new here.') . '</h2>
         <p>' . T_('Complete the following list to get the most out of the site:') . '</p>
         <small>' . sprintf(T_('Your profile is %s complete.'), $percent) . '</small>
         <div id="progress"><div style="width: ' . $percent . '%"></div></div>
         <ol class="todo">
             <li>' . $social . '</a></li>
             <li>' . $profilePicture . '</a></li>
             <li>' . $address . '</li>
             <li>' . $poll . '</li>
         </ol>
         <p style="text-align:right"><a id="new_admin" href="?alert=alert_new_user_home">' . T_('Skip This and get right to the app.') . '</a></p>
     </div>';
     return true;
 }
Example #12
0
 /**
  * displayMembers 
  * 
  * @return void
  */
 function displayMembers()
 {
     $this->displayHeader();
     $order = isset($_GET['order']) ? $_GET['order'] : 'alphabetical';
     $tzOffset = getTimezone($this->fcmsUser->id);
     $validOrderTypes = array('alphabetical' => 'ORDER BY u.`fname`', 'age' => 'ORDER BY u.`dob_year`, u.`dob_month`, u.`dob_day`', 'participation' => '', 'activity' => 'ORDER BY u.`activity` DESC', 'joined' => 'ORDER BY u.`joindate` DESC');
     if (!array_key_exists($order, $validOrderTypes)) {
         echo '
     <div class="error-alert">' . T_('Invalid Order.') . '</div>';
         $this->displayFooter();
         return;
     }
     $sql = "SELECT u.`id`, u.`activity`, u.`joindate`, u.`fname`, u.`lname`, u.`sex`, \n                    u.`dob_year`, u.`dob_month`, u.`dob_day`, u.`username`, u.`avatar`, u.`gravatar`\n                FROM `fcms_users` AS u\n                WHERE u.`phpass` != 'NONMEMBER'\n                AND u.`phpass` != 'PRIVATE'\n                OR (\n                    u.`phpass` IS NULL\n                    AND u.`password` != 'NONMEMBER'\n                    AND u.`password` != 'PRIVATE'\n                )\n                " . $validOrderTypes[$order];
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     foreach ($rows as $row) {
         $row['points'] = getUserParticipationPoints($row['id']);
         $memberData[] = $row;
     }
     // Sort by participation
     if ($order == 'participation') {
         foreach ($memberData as $k => $v) {
             $b[$k] = strtolower($v['points']);
         }
         asort($b);
         foreach ($b as $key => $val) {
             $c[] = $memberData[$key];
         }
         $memberData = array_reverse($c);
     }
     // Get Additional header columns
     $header = '';
     $colspan = 4;
     if ($order == 'age') {
         $header = '<td>' . T_('Age') . '</td><td>' . T_('Birthday') . '</td>';
         $colspan++;
     } elseif ($order == 'participation') {
         $header = '<td>' . T_('Participation Points') . '</td>';
     } elseif ($order == 'activity') {
         $header = '<td>' . T_('Last Seen') . '</td>';
     } elseif ($order == 'joined') {
         $header = '<td>' . T_('Joined') . '</td>';
     }
     echo '
     <table cellspacing="0" cellpadding="0">
         <thead>
             <th colspan="' . $colspan . '"></th>
         </thead>
         <tbody>
             <tr class="header">
                 <td></td>
                 <td>' . T_('Name') . '</td>
                 <td>' . T_('Username') . '</td>
                 ' . $header . '
             </tr>';
     foreach ($memberData as $row) {
         $display = '';
         // Age
         if ($order == 'age') {
             $age = getAge($row['dob_year'], $row['dob_month'], $row['dob_day']);
             // Don't show users with an unknown age
             if ($age === '...') {
                 continue;
             }
             $display = '<td>' . sprintf(T_('%s years old'), $age) . '</td>';
             $display .= '<td>' . $row['dob_year'] . '-' . $row['dob_month'] . '-' . $row['dob_day'] . '</td>';
         } elseif ($order == 'participation') {
             $display = '<td>' . $row['points'] . '</td>';
         } elseif ($order == 'activity') {
             $display = '<td></td>';
             if ($row['activity'] != '0000-00-00 00:00:00') {
                 $display = '<td>' . fixDate(T_('M. j, Y (g:i a)'), $tzOffset, $row['activity']) . '</td>';
             }
         } elseif ($order == 'joined') {
             $display = '<td>' . fixDate(T_('M. j, Y'), $tzOffset, $row['joindate']) . '</td>';
         }
         // Display members
         echo '
             <tr>
                 <td>
                     <a class="avatar" href="profile.php?member=' . (int) $row['id'] . '">
                         <img alt="avatar" src="' . getCurrentAvatar($row['id']) . '"/>
                     </a>
                 </td>
                 <td>
                     <a class="avatar" href="profile.php?member=' . (int) $row['id'] . '">
                         ' . cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']) . '
                     </a>
                 </td>
                 <td>' . cleanOutput($row['username']) . '</td>
                 ' . $display . '
             </tr>';
     }
     echo '
         </tbody>
     </table>';
     $this->displayFooter();
 }
Example #13
0
 /**
  * showComments 
  * 
  * Show the comments for the given recipe.
  * 
  * @param   int     $id 
  * @param   int     $category 
  * @return  void
  */
 function showComments($id, $category)
 {
     $id = (int) $id;
     $category = (int) $category;
     $sql = "SELECT rc.`id`, rc.`recipe`, rc.`comment`, rc.`date`, rc.`user`, u.`avatar` \n                FROM `fcms_recipe_comment` AS rc, `fcms_users` AS u \n                WHERE `recipe` = '{$id}' \n                AND rc.`user` = u.`id` \n                ORDER BY `date`";
     $rows = $this->fcmsDatabase->getRows($sql, $id);
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     // Display current comments
     if (count($rows) >= 0) {
         foreach ($rows as $r) {
             $del_comment = '';
             $date = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $r['date']);
             $displayname = getUserDisplayName($r['user']);
             $comment = $r['comment'];
             if ($this->fcmsUser->id == $r['user'] || $this->fcmsUser->access < 2) {
                 $del_comment .= '<input type="submit" name="delcom" id="delcom" ' . 'value="' . T_('Delete') . '" class="gal_delcombtn" title="' . T_('Delete this Comment') . '"/>';
             }
             echo '
         <div id="comment' . $id . '" class="comment_block">
             <form class="delcom" action="?category=' . $category . '&amp;id=' . $id . '" method="post">
                 ' . $del_comment . '
                 <img class="avatar" alt="avatar" src="' . getCurrentAvatar($r['user']) . '"/>
                 <b>' . $displayname . '</b>
                 <span>' . $date . '</span>
                 <p>
                     ' . parse($comment) . '
                 </p>
                 <input type="hidden" name="id" value="' . $r['id'] . '">
                 <input type="hidden" name="user" value="' . $r['user'] . '">
             </form>
         </div>';
         }
     }
     // Display add comment form
     echo '
         <p>&nbsp;</p>
         <div class="add_comment_block">
             <form action="?category=' . $category . '&amp;id=' . $id . '" method="post">
                 ' . T_('Add Comment') . '<br/>
                 <textarea class="frm_textarea" name="comment" id="comment" rows="3" cols="63"></textarea>
                 <input type="hidden" name="recipe" value="' . $id . '">
                 <input type="submit" name="addcom" id="addcom" value="' . T_('Add Comment') . '" title="' . T_('Add Comment') . '" class="gal_addcombtn"/>
             </form>
         </div>
         <p>&nbsp;</p>';
 }