Example #1
0
 public function friends($data = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $id = JRequest::getCmd('userid', 0);
     $sorted = $jinput->get->get('sort', 'latest', 'STRING');
     //JRequest::getVar( 'sort' , 'latest' , 'GET' );
     $filter = JRequest::getWord('filter', 'all', 'GET');
     $isMine = $id == $my->id && $my->id != 0;
     $my = CFactory::getUser();
     $id = $id == 0 ? $my->id : $id;
     $user = CFactory::getUser($id);
     $friends = CFactory::getModel('friends');
     $blockModel = CFactory::getModel('block');
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $rows = $friends->getFriends($id, $sorted, true, $filter);
     // Hide submenu if we are viewing other's friends
     if ($isMine) {
         $document->setTitle(JText::_('COM_COMMUNITY_FRIENDS_MY_FRIENDS'));
     } else {
         $document->setTitle(JText::sprintf('COM_COMMUNITY_FRIENDS_ALL_FRIENDS', $user->getDisplayName()));
     }
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_SORT_RECENT_FRIENDS'), 'online' => JText::_('COM_COMMUNITY_ONLINE'));
     $resultRows = array();
     // @todo: preload all friends
     foreach ($rows as $row) {
         $user = CFactory::getUser($row->id);
         $obj = clone $row;
         $obj->friendsCount = $user->getFriendCount();
         $obj->profileLink = CUrlHelper::userLink($row->id);
         $obj->isFriend = true;
         $obj->isBlocked = $blockModel->getBlockStatus($user->id, $my->id);
         $resultRows[] = $obj;
     }
     unset($rows);
     foreach ($resultRows as $row) {
         if (!$row->isBlocked) {
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = strip_tags($row->name);
             $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id);
             $item->description = '<img src="' . JURI::base() . $row->_thumb . '" alt="" />&nbsp;' . $row->_status;
             $item->date = $row->lastvisitDate;
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $item->description = CString::str_ireplace('href="/', 'href="' . JURI::base(), $item->description);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
 /**
  * Get large avatar use for cropping
  * @return string
  */
 public function getLargeAvatar()
 {
     $config = CFactory::getConfig();
     $largeAvatar = $config->getString('imagefolder') . '/avatar/profile-' . JFile::getName($this->avatar);
     if (JFile::exists(JPATH_ROOT . '/' . $largeAvatar)) {
         return CUrlHelper::avatarURI($largeAvatar) . '?' . md5(time());
         /* adding random param to prevent browser caching */
     } else {
         return $this->getAvatar();
     }
 }
Example #3
0
 public function getAvatar()
 {
     // Get the avatar path. Some maintance/cleaning work: We no longer store
     // the default avatar in db. If the default avatar is found, we reset it
     // to empty. In next release, we'll rewrite this portion accordingly.
     // We allow the default avatar to be template specific.
     if ($this->avatar == 'components/com_community/assets/user.png') {
         $this->avatar = '';
         $this->store();
     }
     CFactory::load('helpers', 'url');
     $avatar = CUrlHelper::avatarURI($this->avatar, 'user.png');
     return $avatar;
 }
Example #4
0
 public function getAvatar()
 {
     // Get the avatar path. Some maintance/cleaning work: We no longer store
     // the default avatar in db. If the default avatar is found, we reset it
     // to empty. In next release, we'll rewrite this portion accordingly.
     // We allow the default avatar to be template specific.
     $profileModel = CFactory::getModel('Profile');
     $gender = $profileModel->getGender($this->userid);
     if (empty($gender)) {
         $gender = 'Male';
     }
     if ($this->avatar == 'components/com_community/assets/user-' . JText::_($gender) . '.png') {
         $this->avatar = '';
         $this->store();
     }
     $avatar = CUrlHelper::avatarURI($this->avatar, 'user-' . JText::_($gender) . '.png');
     return $avatar;
 }
    <h3 class="app-box-header"><?php 
echo JText::sprintf('COM_COMMUNITY_EVENTS_CONFIRMED_GUESTS');
?>
</h3>
    <?php 
if ($eventMembersCount > 0) {
    ?>
        <div class="app-box-content">
            <ul class="cThumbsList cResetList clearfix">
                <?php 
    if ($eventMembers) {
        foreach ($eventMembers as $member) {
            ?>
                    <li>
                        <a href="<?php 
            echo CUrlHelper::userLink($member->id);
            ?>
">
                            <img class="cAvatar jomNameTips" src="<?php 
            echo $member->getThumbAvatar();
            ?>
" title="<?php 
            echo CTooltip::cAvatarTooltip($member);
            ?>
" alt="" />
                        </a>
                    </li>
                <?php 
        }
    }
    ?>
?>
    <div>

        <?php 
if ($bulletins) {
    for ($i = 0; $i < count($bulletins); $i++) {
        $row =& $bulletins[$i];
        ?>
                    <div class="joms-stream__container joms-stream--discussion">
                        <div class="joms-stream__header <?php 
        echo CUserHelper::onlineIndicator($row->creator);
        ?>
">
                            <div class="joms-avatar--stream">
                                <a href="<?php 
        echo CUrlHelper::userLink($row->creator->id);
        ?>
">
                                    <img data-author="<?php 
        echo $row->creator->id;
        ?>
"
                                         src="<?php 
        echo $row->creator->getThumbAvatar();
        ?>
"
                                         alt="<?php 
        echo $row->creator->getDisplayName();
        ?>
"/>
                                </a>
Example #7
0
            <div class="joms-avatar">
                <img src="<?php 
        echo $row->user->getThumbAvatar();
        ?>
" alt="<?php 
        echo $row->user->getDisplayName();
        ?>
" >
            </div>
        </div>
        <div class="joms-popover__content joms-js--frequest-msg-<?php 
        echo $row->connection_id;
        ?>
">
            <h5><a href="<?php 
        echo CUrlHelper::userLink($row->user->id);
        ?>
"><?php 
        echo $row->user->getDisplayName();
        ?>
</a></h5>
            <?php 
        echo $row->msg;
        ?>
        </div>
        <div class="joms-popover__actions joms-js--frequest-btn-<?php 
        echo $row->connection_id;
        ?>
">
            <button class="joms-button--neutral joms-button--small" onclick="joms.api.friendReject('<?php 
        echo $row->connection_id;
Example #8
0
 /**
  * Return formatted comment given the wall item
  */
 public static function formatComment($wall)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     $actModel = CFactory::getModel('activities');
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id);
     $user = CFactory::getUser($wall->post_by);
     // Censor if the user is banned
     if ($user->block) {
         $wall->comment = $origComment = JText::_('COM_COMMUNITY_CENSORED');
     } else {
         // strip out the comment data
         $CComment = new CComment();
         $wall->comment = $CComment->stripCommentData($wall->comment);
         // Need to perform basic formatting here
         // 1. support nl to br,
         // 2. auto-link text
         $CTemplate = new CTemplate();
         $wall->comment = $origComment = $CTemplate->escape($wall->comment);
         $wall->comment = CStringHelper::autoLink($wall->comment);
     }
     $commentsHTML = '';
     $commentsHTML .= '<div class="cComment wall-coc-item" id="wall-' . $wall->id . '"><a href="' . CUrlHelper::userLink($user->id) . '"><img src="' . $user->getThumbAvatar() . '" alt="" class="wall-coc-avatar" /></a>';
     $date = new JDate($wall->date);
     $commentsHTML .= '<a class="wall-coc-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ';
     $commentsHTML .= $wall->comment;
     $commentsHTML .= '<span class="wall-coc-time">' . CTimeHelper::timeLapse($date);
     $cid = isset($wall->contentid) ? $wall->contentid : null;
     $activity = $actModel->getActivity($cid);
     $ownPost = $my->id == $wall->post_by;
     $allowRemove = $my->authorise('community.delete', 'walls', $wall);
     $canEdit = $config->get('wallediting') && $my->id == $wall->post_by || COwnerHelper::isCommunityAdmin();
     // only poster can edit
     if ($allowRemove) {
         $commentsHTML .= ' <span class="wall-coc-remove-link">&#x2022; <a href="#removeComment">' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</a></span>';
     }
     $commentsHTML .= '</span>';
     $commentsHTML .= '</div>';
     $editHTML = '';
     if ($config->get('wallediting') && $ownPost || COwnerHelper::isCommunityAdmin()) {
         $editHTML .= '<a href="javascript:" class="joms-button--edit">';
         $editHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-pencil"></use></svg>';
         $editHTML .= '<span>' . JText::_('COM_COMMUNITY_EDIT') . '</span>';
         $editHTML .= '</a>';
     }
     $removeHTML = '';
     if ($allowRemove) {
         $removeHTML .= '<a href="javascript:" class="joms-button--remove">';
         $removeHTML .= '<svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="' . CRoute::getURI() . '#joms-icon-remove"></use></svg>';
         $removeHTML .= '<span>' . JText::_('COM_COMMUNITY_WALL_REMOVE') . '</span>';
         $removeHTML .= '</a>';
     }
     $removeTagHTML = '';
     if (CActivitiesHelper::hasTag($my->id, $wall->comment)) {
         $removeTagHTML = '<span><a data-action="remove-tag" data-id="' . $wall->id . '" href="javascript:">' . JText::_('COM_COMMUNITY_WALL_REMOVE_TAG') . '</a></span>';
     }
     /* user deleted */
     if ($user->guest == 1) {
         $userLink = '<span class="cStream-Author">' . $user->getDisplayName() . '</span> ';
     } else {
         $userLink = '<a class="cStream-Avatar cStream-Author cFloat-L" href="' . CUrlHelper::userLink($user->id) . '"> <img class="cAvatar" src="' . $user->getThumbAvatar() . '"> </a> ';
     }
     $params = $wall->params;
     $paramsHTML = '';
     $image = (array) $params->get('image');
     $photoThumbnail = false;
     if ($params->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($params->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
         $paramsHTML .= '<div style="padding: 5px 0"><img class="joms-stream-thumb" src="' . $photoThumbnail . '" /></div>';
     } else {
         if ($params->get('title')) {
             $video = self::detectVideo($params->get('url'));
             if (is_object($video)) {
                 $paramsHTML .= '<div class="joms-media--video joms-js--video"';
                 $paramsHTML .= ' data-type="' . $video->type . '"';
                 $paramsHTML .= ' data-id="' . $video->id . '"';
                 $paramsHTML .= ' data-path="' . ($video->type === 'file' ? JURI::root(true) . '/' : '') . $video->path . '"';
                 $paramsHTML .= ' style="margin-top:10px;">';
                 $paramsHTML .= '<div class="joms-media__thumbnail">';
                 $paramsHTML .= '<img src="' . $video->getThumbnail() . '">';
                 $paramsHTML .= '<a href="javascript:" class="mejs-overlay mejs-layer mejs-overlay-play joms-js--video-play joms-js--video-play-' . $wall->id . '">';
                 $paramsHTML .= '<div class="mejs-overlay-button"></div>';
                 $paramsHTML .= '</a>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . JHTML::_('string.truncate', $video->title, 50, true, false) . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . JHTML::_('string.truncate', $video->description, $config->getInt('streamcontentlength'), true, false) . '</p>';
                 $paramsHTML .= '</div>';
                 $paramsHTML .= '</div>';
             } else {
                 $paramsHTML .= '<div class="joms-gap"></div>';
                 $paramsHTML .= '<div class="joms-media--album joms-relative joms-js--comment-preview">';
                 if ($user->id == $my->id || COwnerHelper::isCommunityAdmin()) {
                     $paramsHTML .= '<span class="joms-media__remove" data-action="remove-preview" onClick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><svg viewBox="0 0 16 16" class="joms-icon"><use xlink:href="#joms-icon-remove"></use></svg></span>';
                 }
                 if ($params->get('image')) {
                     $paramsHTML .= $params->get('link');
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $params->get('link') ? $params->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $params->get('url') ? $params->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<a href="' . $url . '">';
                 $paramsHTML .= '<h4 class="joms-media__title">' . $params->get('title') . '</h4>';
                 $paramsHTML .= '<p class="joms-media__desc reset-gap">' . CStringHelper::trim_words($params->get('description')) . '</p>';
                 if ($params->get('link')) {
                     $paramsHTML .= '<span class="joms-text--light"><small>' . preg_replace('#^https?://#', '', $params->get('link')) . '</small></span>';
                 }
                 $paramsHTML .= '</a></div></div>';
             }
         }
     }
     if (!$params->get('title') && $params->get('url')) {
         $paramsHTML .= '<div class="joms-gap"></div>';
         $paramsHTML .= '<div class="joms-media--album">';
         $paramsHTML .= '<a href="' . $params->get('url') . '">';
         $paramsHTML .= '<img class="joms-stream-thumb" src="' . $params->get('url') . '" />';
         $paramsHTML .= '</a>';
         $paramsHTML .= '</div>';
     }
     $wall->comment = nl2br($wall->comment);
     $wall->comment = CUserHelper::replaceAliasURL($wall->comment);
     $wall->comment = CStringHelper::getEmoticon($wall->comment);
     $wall->comment = CStringHelper::converttagtolink($wall->comment);
     // convert to hashtag
     $template = new CTemplate();
     $template->set('wall', $wall)->set('originalComment', $origComment)->set('date', $date)->set('isLiked', $isLiked)->set('likeCount', $likeCount)->set('canRemove', $allowRemove)->set('canEdit', $canEdit)->set('canRemove', $allowRemove)->set('user', $user)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML);
     $commentsHTML = $template->fetch('stream/single-comment');
     return $commentsHTML;
 }
// Setup group table
$group = $this->group;
// Setup Discussion Table
$discussion = JTable::getInstance('Discussion', 'CTable');
$discussion->load($act->cid);
$discussionLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id);
if ($user->block) {
    $discussion->title = $discussion->message = JText::_('COM_COMMUNITY_CENSORED');
}
// Load params
$action = $act->params->get('action');
$actors = $act->params->get('actors');
$this->set('actors', $actors);
$stream = new stdClass();
$stream->actor = $user;
$stream->target = null;
$stream->datetime = $createdTime;
$stream->headline = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ' . JTEXT::_('COM_COMMUNITY_GROUPS_NEW_GROUP_DISCUSSION') . '<span class="joms-stream__time"><small>' . $stream->datetime . '</small></span>';
$stream->message = "";
$stream->group = $group;
$stream->groupid = $group->id;
$stream->attachments = array();
$stream->link = $discussionLink;
$stream->title = $discussion->title;
$stream->access = $act->access;
$attachment = new stdClass();
$attachment->type = 'create_discussion';
$attachment->message = $this->escape(JHTML::_('string.truncate', $discussion->message, $config->getInt('streamcontentlength'), true, false));
$stream->attachments[] = $attachment;
$this->set('stream', $stream);
$this->load('activities.stream');
$bulletin->load($act->cid);
// get created date time
$date = JFactory::getDate($act->created);
if ($config->get('activitydateformat') == "lapse") {
    $createdTime = CTimeHelper::timeLapse($date);
} else {
    $createdTime = $date->format($config->get('profileDateFormat'));
}
// Load params
$param = new JRegistry($this->act->params);
$action = $param->get('action');
$actors = $param->get('actors');
$this->set('actors', $actors);
$stream = new stdClass();
$stream->actor = $user;
$stream->target = null;
$stream->datetime = $createdTime;
$stream->headline = '<a class="joms-stream-author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a> ' . JTEXT::_('COM_COMMUNITY_GROUPS_NEW_GROUP_NEWS') . '<p class="joms-share-meta date">' . $stream->datetime . '</p>';
$stream->message = "";
$stream->group = $group;
$stream->groupid = $group->id;
$stream->attachments = array();
$stream->title = $bulletin->title;
$stream->link = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletin&groupid=' . $group->id . '&bulletinid=' . $bulletin->id);
$stream->access = $act->access;
$attachment = new stdClass();
$attachment->type = 'create_announcement';
$attachment->message = $this->escape(JHTML::_('string.truncate', $bulletin->message, $config->getInt('streamcontentlength'), true, false));
$stream->attachments[] = $attachment;
$this->set('stream', $stream);
$this->load('activities.stream');
Example #11
0
if ($my->id == $user1->id) {
    $you = $user1;
    $other = $user2;
}
if ($my->id == $user2->id) {
    $you = $user2;
    $other = $user1;
}
?>
<div class="joms-stream__body no-head">
    <p>
        <svg viewBox="0 0 16 16" class="joms-icon">
            <use xlink:href="<?php 
echo CRoute::getURI();
?>
#joms-icon-user"></use>
        </svg>
        <?php 
if (!is_null($you)) {
    // @todo: use sprintf with language code
    echo JText::sprintf('COM_COMMUNITY_STREAM_MY_FRIENDS', $other->getDisplayName(), CUrlHelper::userLink($other->id));
    ?>
        <?php 
} else {
    // @todo: use sprintf with language code
    echo JText::sprintf('COM_COMMUNITY_STREAM_OTHER_FRIENDS', $user1->getDisplayName(), $user2->getDisplayName(), CUrlHelper::userLink($user1->id), CUrlHelper::userLink($user2->id));
}
?>
    </p>
</div>
Example #12
0
 /**
  * Display the full list of people who likes this stream item
  *
  * @param <type> $objResponse
  * @param <type> $actid
  * @param <type> $like_type
  * @param <type> $like_id
  */
 private function _streamShowLikes($objResponse, $actid, $like_type, $like_id, $target = '')
 {
     $my = CFactory::getUser();
     $like = new CLike();
     $likes = $like->getWhoLikes($like_type, $like_id);
     $canUnlike = false;
     $likeHTML = '';
     $likeUsers = array();
     foreach ($likes as $user) {
         $likeUsers[] = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
         if ($my->id == $user->id) {
             $canUnlike = true;
         }
     }
     if (count($likeUsers) != 0) {
         if ($target === 'popup') {
             $tmpl = new CTemplate();
             $tmpl->set('users', $likes);
             $likeHTML = $tmpl->fetch('ajax.stream.showothers');
         } else {
             $likeHTML .= implode(", ", $likeUsers);
             $likeHTML = CStringHelper::isPlural(count($likeUsers)) ? JText::sprintf('COM_COMMUNITY_LIKE_THIS_MANY_LIST', $likeHTML) : JText::sprintf('COM_COMMUNITY_LIKE_THIS_LIST', $likeHTML);
         }
     }
     return $likeHTML;
 }
	    <!--NEWS FEED AVATAR-->

			<!--NEWS FEED CONTENT-->
	    <div class="newsfeed-content">
				<div class="newsfeed-content-top">

				<?php 
            // Put user header link if necessary
            if ($apptype == 'group' && $act->eventid) {
                // For group event, show the arrow indicator (using <span class="com_icons com_icons12 com_icons-inline com_icons-rarr">»</span>)
                echo '<div class="newsfeed-content-actor"><a href="' . CUrlHelper::userLink($act->actor) . '">' . $actor->getDisplayName() . '</a> <span class="com_icons com_icons12 com_icons-inline com_icons-rarr">»</span> <a href="' . CUrlHelper::eventLink($act->eventid) . '">' . $act->appTitle . '</a></div>';
            } else {
                ?>
						<div class="newsfeed-content-actor">
							<strong><a class="actor-link" href="<?php 
                echo CUrlHelper::userLink($act->actor);
                ?>
"><?php 
                echo $actor->getDisplayName();
                ?>
</a></strong>
						</div>
						<?php 
            }
            // Order of replacement
            $order = array("\r\n", "\n", "\r");
            $replace = '<br/>';
            // Processes \r\n's first so they aren't converted twice.
            $messageDisplay = str_replace($order, $replace, $act->title);
            echo $messageDisplay;
            ?>
Example #14
0
        if ($video->groupid) {
            $group = JTable::getInstance('Group', 'CTable');
            $group->load($video->groupid);
            echo JText::sprintf('COM_COMMUNITY_VIDEOS_FROM_GROUP', '<a href="' . CUrlHelper::groupLink($group->id) . '">' . $group->name . '</a>');
        } elseif ($video->eventid) {
            $event = JTable::getInstance('Event', 'CTable');
            $event->load($video->eventid);
            echo JText::sprintf('COM_COMMUNITY_VIDEOS_FROM_EVENT', '<a href="' . CUrlHelper::eventLink($event->id) . '">' . $event->title . '</a>');
        } elseif ($params->get('activity_id')) {
            $targetUser = CFactory::getUser($params->get('target_id'));
            ?>
                        ▶ <?php 
            echo CLinkGeneratorHelper::getUserURL($targetUser->id, $targetUser->getDisplayName());
            ?>
 <a href="<?php 
            echo CUrlHelper::streamURI($params->get('activity_id'), $targetUser->id);
            ?>
"><?php 
            echo JText::_('COM_COMMUNITY_SINGULAR_STREAM');
            ?>
</a>
                    <?php 
        }
        ?>
                </small>

            </li>
            <?php 
    }
    //end foreach
    ?>
Example #15
0
        <div class="clr"></div>
        <div class="group-discussion-author small">
            <?php 
        if (isset($row->lastreplier) && !empty($row->lastreplier)) {
            ?>
            <span class="groups-news-author">
                <?php 
            echo JText::sprintf('CC DISCUSSION LAST REPLIED', '<a href="' . CUrlHelper::userLink($row->lastreplier->post_by->id) . '">' . $row->lastreplier->post_by->getDisplayName() . '</a>', JHTML::_('date', $row->lastreplier->date, JText::_('DATE_FORMAT_LC')));
            ?>
            </span>
            <?php 
        } else {
            ?>
            <span class="groups-news-author">
				<?php 
            echo JText::sprintf('CC DISCUSS STARTED BY', '<a href="' . CUrlHelper::userLink($row->user->id) . '">' . $row->user->getDisplayName() . '</a>');
            ?>
			</span>
            <?php 
        }
        ?>
        </div>
	</div>
	<?php 
    }
} else {
    ?>
	<div class="empty"><?php 
    echo JText::_('CC NO DISCUSSIONS');
    ?>
</div>
Example #16
0
 /**
  * @deprecated Since 2.0
  */
 public function getThumbAvatar($id, $thumb)
 {
     $thumb = CUrlHelper::avatarURI($thumb, 'event_thumb.png');
     return $thumb;
 }
Example #17
0
 /**
  * Called when the user uploaded a new photo and process avatar upload & resize
  * @return type
  */
 public function changeAvatar()
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     /* get variables */
     $type = $jinput->get('type', null, 'NONE');
     $id = $jinput->get('id', null, 'INT');
     $saveAction = $jinput->get('repeattype', null, 'STRING');
     $filter = JFilterInput::getInstance();
     $type = $filter->clean($type, 'string');
     $id = $filter->clean($id, 'integer');
     $params = new JRegistry();
     $cTable = JTable::getInstance(ucfirst($type), 'CTable');
     $cTable->load($id);
     if ($type == "profile") {
         $my = CFactory::getUser($id);
     } else {
         $my = CFactory::getUser();
     }
     $config = CFactory::getConfig();
     $userid = $my->id;
     $fileFilter = new JInput($_FILES);
     $file = $fileFilter->get('filedata', '', 'array');
     if (!CImageHelper::checkImageSize(filesize($file['tmp_name']))) {
         $this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_VIDEOS_IMAGE_FILE_SIZE_EXCEEDED_MB', CFactory::getConfig()->get('maxuploadsize')));
         return;
     }
     //check if file is allwoed
     if (!CImageHelper::isValidType($file['type'])) {
         $this->_showUploadError(true, JText::_('COM_COMMUNITY_IMAGE_FILE_NOT_SUPPORTED'));
         return;
     }
     CImageHelper::autoRotate($file['tmp_name']);
     $album = JTable::getInstance('Album', 'CTable');
     //create the avatar default album if it does not exists
     if (!($albumId = $album->isAvatarAlbumExists($id, $type))) {
         $albumId = $album->addAvatarAlbum($id, $type);
     }
     //start image processing
     // Get a hash for the file name.
     $fileName = JApplication::getHash($file['tmp_name'] . time());
     $hashFileName = JString::substr($fileName, 0, 24);
     $avatarFolder = $type != 'profile' && $type != '' ? $type . '/' : '';
     //avatar store path
     $storage = JPATH_ROOT . '/' . $config->getString('imagefolder') . '/avatar' . '/' . $avatarFolder;
     if (!JFolder::exists($storage)) {
         JFolder::create($storage);
     }
     $storageImage = $storage . '/' . $hashFileName . CImageHelper::getExtension($file['type']);
     $image = $config->getString('imagefolder') . '/avatar/' . $avatarFolder . $hashFileName . CImageHelper::getExtension($file['type']);
     /**
      * reverse image use for cropping feature
      * @uses <type>-<hashFileName>.<ext>
      */
     $storageReserve = $storage . '/' . $type . '-' . $hashFileName . CImageHelper::getExtension($file['type']);
     // filename for stream attachment
     $imageAttachment = $config->getString('imagefolder') . '/avatar/' . $hashFileName . '_stream_' . CImageHelper::getExtension($file['type']);
     //avatar thumbnail path
     $storageThumbnail = $storage . '/thumb_' . $hashFileName . CImageHelper::getExtension($file['type']);
     $thumbnail = $config->getString('imagefolder') . '/avatar/' . $avatarFolder . 'thumb_' . $hashFileName . CImageHelper::getExtension($file['type']);
     //Minimum height/width checking for Avatar uploads
     list($currentWidth, $currentHeight) = getimagesize($file['tmp_name']);
     if ($currentWidth < COMMUNITY_AVATAR_PROFILE_WIDTH || $currentHeight < COMMUNITY_AVATAR_PROFILE_HEIGHT) {
         $this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MINIMUM_AVATAR_DIMENSION', COMMUNITY_AVATAR_PROFILE_WIDTH, COMMUNITY_AVATAR_PROFILE_HEIGHT));
         return;
     }
     /**
      * Generate square avatar
      */
     if (!CImageHelper::createThumb($file['tmp_name'], $storageImage, $file['type'], COMMUNITY_AVATAR_PROFILE_WIDTH, COMMUNITY_AVATAR_PROFILE_HEIGHT)) {
         $this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageImage));
         return;
     }
     // Generate thumbnail
     if (!CImageHelper::createThumb($file['tmp_name'], $storageThumbnail, $file['type'])) {
         $this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageImage));
         return;
     }
     /**
      * Generate large image use for avatar thumb cropping
      * It must be larget than profile avatar size because we'll use it for profile avatar recrop also
      */
     $newWidth = 0;
     $newHeight = 0;
     if ($currentWidth >= $currentHeight) {
         if ($this->testResize($currentWidth, $currentHeight, COMMUNITY_AVATAR_RESERVE_WIDTH, 0, COMMUNITY_AVATAR_PROFILE_WIDTH, COMMUNITY_AVATAR_RESERVE_WIDTH)) {
             $newWidth = COMMUNITY_AVATAR_RESERVE_WIDTH;
             $newHeight = 0;
         } else {
             $newWidth = 0;
             $newHeight = COMMUNITY_AVATAR_RESERVE_HEIGHT;
         }
     } else {
         if ($this->testResize($currentWidth, $currentHeight, 0, COMMUNITY_AVATAR_RESERVE_HEIGHT, COMMUNITY_AVATAR_PROFILE_HEIGHT, COMMUNITY_AVATAR_RESERVE_HEIGHT)) {
             $newWidth = 0;
             $newHeight = COMMUNITY_AVATAR_RESERVE_HEIGHT;
         } else {
             $newWidth = COMMUNITY_AVATAR_RESERVE_WIDTH;
             $newHeight = 0;
         }
     }
     if (!CImageHelper::resizeProportional($file['tmp_name'], $storageReserve, $file['type'], $newWidth, $newHeight)) {
         $this->_showUploadError(true, JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $storageReserve));
         return;
     }
     /*
      * Generate photo to be stored in default avatar album
      * notes: just in case this need to be used in registration, just get the code below.
      */
     $originalPath = $storage . 'original_' . md5($my->id . '_avatar' . time()) . CImageHelper::getExtension($file['type']);
     $fullImagePath = $storage . md5($my->id . '_avatar' . time()) . CImageHelper::getExtension($file['type']);
     $thumbPath = $storage . 'thumb_' . md5($my->id . '_avatar' . time()) . CImageHelper::getExtension($file['type']);
     // Generate full image
     if (!CImageHelper::resizeProportional($file['tmp_name'], $fullImagePath, $file['type'], 1024)) {
         $msg['error'] = JText::sprintf('COM_COMMUNITY_ERROR_MOVING_UPLOADED_FILE', $file['tmp_name']);
         echo json_encode($msg);
         exit;
     }
     CPhotos::generateThumbnail($file['tmp_name'], $thumbPath, $file['type']);
     if (!JFile::copy($file['tmp_name'], $originalPath)) {
         exit;
     }
     //store this picture into default avatar album
     $now = new JDate();
     $photo = JTable::getInstance('Photo', 'CTable');
     $photo->albumid = $albumId;
     $photo->image = str_replace(JPATH_ROOT . '/', '', $fullImagePath);
     $photo->caption = $file['name'];
     $photo->filesize = $file['size'];
     $photo->creator = $my->id;
     $photo->created = $now->toSql();
     $photo->published = 1;
     $photo->thumbnail = str_replace(JPATH_ROOT . '/', '', $thumbPath);
     $photo->original = str_replace(JPATH_ROOT . '/', '', $originalPath);
     if ($photo->store()) {
         $album->load($albumId);
         $album->photoid = $photo->id;
         $album->setParam('thumbnail', $photo->thumbnail);
         $album->store();
     }
     //end storing user avatar in avatar album
     if ($type == 'profile') {
         $profileType = $my->getProfileType();
         $multiprofile = JTable::getInstance('MultiProfile', 'CTable');
         $multiprofile->load($profileType);
         $useWatermark = $profileType != COMMUNITY_DEFAULT_PROFILE && $config->get('profile_multiprofile') && !empty($multiprofile->watermark) ? true : false;
         if ($useWatermark && $multiprofile->watermark) {
             JFile::copy($storageImage, JPATH_ROOT . '/images/watermarks/original' . '/' . md5($my->id . '_avatar') . CImageHelper::getExtension($file['type']));
             JFile::copy($storageThumbnail, JPATH_ROOT . '/images/watermarks/original' . '/' . md5($my->id . '_thumb') . CImageHelper::getExtension($file['type']));
             $watermarkPath = JPATH_ROOT . '/' . CString::str_ireplace('/', '/', $multiprofile->watermark);
             list($watermarkWidth, $watermarkHeight) = getimagesize($watermarkPath);
             list($avatarWidth, $avatarHeight) = getimagesize($storageImage);
             list($thumbWidth, $thumbHeight) = getimagesize($storageThumbnail);
             $watermarkImage = $storageImage;
             $watermarkThumbnail = $storageThumbnail;
             // Avatar Properties
             $avatarPosition = CImageHelper::getPositions($multiprofile->watermark_location, $avatarWidth, $avatarHeight, $watermarkWidth, $watermarkHeight);
             // The original image file will be removed from the system once it generates a new watermark image.
             CImageHelper::addWatermark($storageImage, $watermarkImage, $file['type'], $watermarkPath, $avatarPosition->x, $avatarPosition->y);
             //Thumbnail Properties
             $thumbPosition = CImageHelper::getPositions($multiprofile->watermark_location, $thumbWidth, $thumbHeight, $watermarkWidth, $watermarkHeight);
             // The original thumbnail file will be removed from the system once it generates a new watermark image.
             CImageHelper::addWatermark($storageThumbnail, $watermarkThumbnail, $file['type'], $watermarkPath, $thumbPosition->x, $thumbPosition->y);
             $my->set('_watermark_hash', $multiprofile->watermark_hash);
         }
         // We need to make a copy of current avatar and set it as stream 'attachement'
         // which will only gets deleted once teh stream is deleted
         $my->_cparams->set('avatar_photo_id', $photo->id);
         //we also set the id of the avatar photo
         $my->save();
         JFile::copy($image, $imageAttachment);
         $params->set('attachment', $imageAttachment);
     }
     //end of storing this picture into default avatar album
     if (empty($saveAction)) {
         $cTable->setImage($image, 'avatar');
         $cTable->setImage($thumbnail, 'thumb');
     } else {
         // This is for event recurring save option ( current / future event )
         $cTable->setImage($image, 'avatar', $saveAction);
         $cTable->setImage($thumbnail, 'thumb', $saveAction);
     }
     // add points & activity stream
     switch ($type) {
         case 'profile':
             /**
              * Generate activity stream
              * @todo Should we use CApiActivities::add
              */
             // do not have to generate a stream if the user is not the user itself (eg admin change user avatar)
             if (CUserPoints::assignPoint('profile.avatar.upload') && $my->id == CFactory::getUser()->id) {
                 $act = new stdClass();
                 $act->cmd = 'profile.avatar.upload';
                 $act->actor = $userid;
                 $act->target = 0;
                 $act->title = '';
                 $act->content = '';
                 $act->access = $my->_cparams->get("privacyPhotoView", 0);
                 $act->app = 'profile.avatar.upload';
                 /* Profile app */
                 $act->cid = isset($photo->id) && $photo->id ? $photo->id : 0;
                 $act->verb = 'upload';
                 /* We uploaded new avatar - NOT change avatar */
                 $act->params = $params;
                 $params->set('photo_id', $photo->id);
                 $params->set('album_id', $photo->albumid);
                 $act->comment_id = CActivities::COMMENT_SELF;
                 $act->comment_type = 'profile.avatar.upload';
                 $act->like_id = CActivities::LIKE_SELF;
                 $act->like_type = 'profile.avatar.upload';
             }
             break;
         case 'group':
             CUserPoints::assignPoint('group.avatar.upload');
             /**
              * Generate activity stream
              * @todo Should we use CApiActivities::add
              */
             $act = new stdClass();
             $act->cmd = 'groups.avatar.upload';
             $act->actor = $userid;
             $act->target = 0;
             $act->title = '';
             $act->content = '';
             $act->app = 'groups.avatar.upload';
             /* Groups app */
             $act->cid = $id;
             $act->groupid = $id;
             $act->verb = 'update';
             /* We do update */
             $params->set('photo_id', $photo->id);
             $params->set('album_id', $photo->albumid);
             $act->comment_id = CActivities::COMMENT_SELF;
             $act->comment_type = 'groups.avatar.upload';
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = 'groups.avatar.upload';
             break;
         case 'event':
             //CUserPoints::assignPoint('events.avatar.upload'); @disabled since 4.0
             /**
              * Generate activity stream
              * @todo Should we use CApiActivities::add
              */
             $act = new stdClass();
             $act->cmd = 'events.avatar.upload';
             $act->actor = $userid;
             $act->target = 0;
             $act->title = '';
             $act->content = '';
             $act->app = 'events.avatar.upload';
             /* Events app */
             $act->cid = $id;
             $act->eventid = $id;
             $act->verb = 'update';
             /* We do update */
             $act->comment_id = CActivities::COMMENT_SELF;
             $act->comment_type = 'events.avatar.upload';
             $act->like_id = CActivities::LIKE_SELF;
             $act->like_type = 'events.avatar.upload';
             break;
     }
     //we only generate stream if the uploader is the user himself, not admin or anyone else
     if (isset($act) && $my->id == $id || $type != 'profile') {
         // $return = CApiActivities::add($act);
         /**
          * use internal Stream instead use for 3rd part API
          */
         $return = CActivityStream::add($act, $params->toString());
         //add the reference to the activity so that we can do something when someone update the avatar
         if ($type == 'profile') {
             // overwrite the params because some of the param might be updated through $my object above
             $cTableParams = $my->_cparams;
         } else {
             $cTableParams = new JRegistry($cTable->params);
         }
         $cTableParams->set('avatar_activity_id', $return->id);
         $cTable->params = $cTableParams->toString();
         $cTable->store();
     }
     if (method_exists($cTable, 'getLargeAvatar')) {
         $this->_showUploadError(false, $cTable->getLargeAvatar(), CUrlHelper::avatarURI($thumbnail, 'user_thumb.png'));
     } else {
         $this->_showUploadError(false, $cTable->getAvatar(), CUrlHelper::avatarURI($thumbnail, 'user_thumb.png'));
     }
 }
Example #18
0
 /**
  * Displays specific groups
  **/
 public function viewGroup($group)
 {
     $mainframe =& JFactory::getApplication();
     CFactory::load('libraries', 'tooltip');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'window');
     CFactory::load('libraries', 'videos');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'group');
     CWindow::load();
     $config = CFactory::getConfig();
     $document = JFactory::getDocument();
     $groupLib = new CGroups();
     // Load appropriate models
     $groupModel = CFactory::getModel('groups');
     $wallModel = CFactory::getModel('wall');
     $userModel = CFactory::getModel('user');
     $discussModel = CFactory::getModel('discussions');
     $bulletinModel = CFactory::getModel('bulletins');
     $photosModel = CFactory::getModel('photos');
     $activityModel = CFactory::getModel('activities');
     //$groupid		= JRequest::getInt( 'groupid' , '' );
     //CError::assert( $groupid , '' , '!empty' , __FILE__ , __LINE__ );
     $editGroup = JRequest::getVar('edit', false, 'GET');
     $editGroup = $editGroup == 1 ? true : false;
     $params = $group->getParams();
     CFactory::load('helpers', 'string');
     $document->setMetaData('title', CStringHelper::escape($group->name));
     $document->setMetaData('description', CStringHelper::escape(strip_tags($group->description)));
     $document->addCustomTag('<link rel="image_src" href="' . JURI::root() . $group->thumb . '" />');
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$group->published) {
         $this->_redirectUnpublishGroup();
         return;
     }
     // Show submenu
     $this->showSubmenu();
     // Set the group info to contain proper <br>
     $group->description = nl2br($group->description);
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
     $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_NAME_TITLE', $group->name), '');
     // Load the current browsers data
     $my = CFactory::getUser();
     // If user are invited
     $isInvited = $groupModel->isInvited($my->id, $group->id);
     // Get members list for display
     //$members	= $groupModel->getAllMember($group->id);
     //Set limit for member listing on view group page
     $limit = 12;
     $approvedMembers = $groupModel->getMembers($group->id, $limit, true, false, true);
     CError::assert($approvedMembers, 'array', 'istype', __FILE__, __LINE__);
     $membersCount = $groupModel->total;
     // Is there any my friend is the member of this group?
     $join = '';
     $friendsCount = 0;
     if ($isInvited) {
         // Get the invitors
         $invitors = $groupModel->getInvitors($my->id, $group->id);
         if (count($invitors) == 1) {
             $user = CFactory::getUser($invitors[0]->creator);
             $join = '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
         } else {
             for ($i = 0; $i < count($invitors); $i++) {
                 $user = CFactory::getUser($invitors[$i]->creator);
                 if ($i + 1 == count($invitors)) {
                     $join .= ' ' . JText::_('COM_COMMUNITY_AND') . ' ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
                 } else {
                     $join .= ', ' . '<a href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
                 }
             }
         }
         // Get users friends in this group
         $friendsCount = $groupModel->getFriendsCount($my->id, $group->id);
     }
     $admins = $groupModel->getAdmins($group->id, $limit, CC_RANDOMIZE);
     // Get list of unapproved members
     $groupModel->getMembers($group->id, null, false);
     $unapproved = $groupModel->total;
     //Get list of approved members
     // Test if the current user is admin
     $isAdmin = $groupModel->isAdmin($my->id, $group->id);
     // Test if the current browser is a member of the group
     $isMember = $groupModel->isMember($my->id, $group->id);
     $waitingApproval = false;
     // Test if the current user is banned from this group
     $isBanned = $group->isBanned($my->id);
     // Attach avatar of the member
     // Pre-load multiple users at once
     $userids = array();
     $limitloop = $limit;
     foreach ($approvedMembers as $uid) {
         $userids[] = $uid->id;
         if (--$limitloop < 1) {
             break;
         }
     }
     CFactory::loadUsers($userids);
     $limitloop = $limit;
     for ($i = 0; $i < count($approvedMembers); $i++) {
         $row =& $approvedMembers[$i];
         $approvedMembers[$i] = CFactory::getUser($row->id);
         if (--$limitloop < 1) {
             break;
         }
     }
     if ($isBanned) {
         $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_GROUPS_MEMBER_BANNED'), 'error');
     }
     // If I have tried to join this group, but not yet approved, display a notice
     if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
         $waitingApproval = true;
     }
     // Get the walls
     if (!$isBanned) {
         $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group');
     } else {
         $wallContent = CWallLibrary::getWallContents('groups', $group->id, $isAdmin, 10, 0, 'wall.content', 'groups,group', null, '1');
     }
     $wallCount = CWallLibrary::getWallCount('groups', $group->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=app&groupid=' . $group->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     CFactory::load('helpers', 'owner');
     if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && ($isMember && !$isBanned) && !$waitingApproval || COwnerHelper::isCommunityAdmin()) {
         $wallForm = CWallLibrary::getWallInputForm($group->id, 'groups,ajaxSaveWall', 'groups,ajaxRemoveWall');
     }
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $isMember && !$isBanned ? $likes->getHTML('groups', $group->id, $my->id) : $likes->getHtmlPublic('groups', $group->id);
     // Get discussions data
     $discussionData = $this->_cachedCall('_getDiscussionListHTML', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $discussionsHTML = $discussionData['HTML'];
     $totalDiscussion = $discussionData['total'];
     $discussions = $discussionData['data'];
     // Get bulletins data
     $bulletinData = $this->_cachedCall('_getBulletinListHTML', array($group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $totalBulletin = $bulletinData['total'];
     $bulletinsHTML = $bulletinData['HTML'];
     $bulletins = $bulletinData['data'];
     // Get album data
     $albumData = $this->_cachedCall('_getAlbums', array($params, $group->id), $group->id, array(COMMUNITY_CACHE_TAG_GROUPS_DETAIL));
     $albums = $albumData['data'];
     $totalAlbums = $albumData['total'];
     // Get video data
     $videoData = $this->_getVideos($params, $group->id);
     $videos = $videoData['data'];
     $totalVideos = $videoData['total'];
     $tmpl = new CTemplate();
     // Get categories list
     // We should really load this in saperate file
     // @todo: editing group should really open a new page
     if ($my->id == $group->ownerid || COwnerHelper::isCommunityAdmin()) {
         $categories = $groupModel->getCategories();
         CError::assert($categories, 'array', 'istype', __FILE__, __LINE__);
         $tmpl->set('categories', $categories);
     }
     $isMine = $my->id == $group->ownerid;
     // Get reporting html
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_REPORT_GROUP'), 'groups,reportGroup', array($group->id));
     $isSuperAdmin = COwnerHelper::isCommunityAdmin();
     if ($group->approvals == '1' && !$isMine && !$isMember && !$isSuperAdmin) {
         $this->addWarning(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
     }
     $videoThumbWidth = CVideoLibrary::thumbSize('width');
     $videoThumbHeight = CVideoLibrary::thumbSize('height');
     $eventsModel = CFactory::getModel('Events');
     $tmpEvents =& $eventsModel->getGroupEvents($group->id, $params->get('grouprecentevents', GROUP_EVENT_RECENT_LIMIT));
     $totalEvents = $eventsModel->getTotalGroupEvents($group->id);
     $events = array();
     foreach ($tmpEvents as $event) {
         $table =& JTable::getInstance('Event', 'CTable');
         $table->bind($event);
         $events[] = $table;
     }
     $allowManagePhotos = CGroupHelper::allowManagePhoto($group->id);
     $allowManageVideos = CGroupHelper::allowManageVideo($group->id);
     $allowCreateEvent = CGroupHelper::allowCreateEvent($my->id, $group->id);
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id));
     $bookmarksHTML = $bookmarks->getHTML();
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     if ($group->approvals == '0' || $isMine || $isMember && !$isBanned || $isCommunityAdmin) {
         // Set feed url
         $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewbulletins&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_BULLETIN_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_DISCUSSION_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=photos&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_PHOTOS_FEEDS') . '" href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=videos&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_VIDEOS_FEEDS') . '"  href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
         $feedLink = CRoute::_('index.php?option=com_community&view=events&groupid=' . $group->id . '&format=feed');
         $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_SUBSCRIBE_TO_GROUP_EVENTS_FEEDS') . '"  href="' . $feedLink . '"/>';
         $document->addCustomTag($feed);
     }
     $friendsModel = CFactory::getModel('Friends');
     $groupsModel = CFactory::getModel('Groups');
     CFactory::load('libraries', 'invitation');
     $inviteHTML = CInvitation::getHTML(null, 'groups,inviteUsers', $group->id);
     // Add tagging code
     /*
     $tagsHTML = '';
     if($config->get('tags_groups')){
     	CFactory::load('libraries', 'tags');
     	$tags = new CTags();
     	$tagsHTML = $tags->getHTML('groups', $group->id, $isAdmin );
     }
     */
     // Upgrade wall to stream @since 2.5
     if (!$params->get('stream', FALSE)) {
         $group->upgradeWallToStream();
     }
     // Add custom stream
     $activities = new CActivities();
     $streamHTML = $groupLib->getStreamHTML($group);
     $totalStream = $activityModel->getTotalActivities(array("`groupid` = '{$group->id}'"));
     CFactory::load('libraries', 'userstatus');
     $creators = array();
     $creators[] = CUserStatusCreator::getMessageInstance();
     if ($isAdmin && $params->get('photopermission') == 1 || $isMember && $params->get('photopermission') == 2) {
         $creators[] = CUserStatusCreator::getPhotoInstance();
     }
     if ($isAdmin && $params->get('videopermission') == 1 || $isMember && $params->get('videopermission') == 2) {
         $creators[] = CUserStatusCreator::getVideoInstance();
     }
     if ($allowCreateEvent && $config->get('group_events') && $config->get('enableevents') && ($config->get('createevents') || COwnerHelper::isCommunityAdmin())) {
         $creators[] = CUserStatusCreator::getEventInstance();
     }
     $status = new CUserStatus($group->id, 'groups', $creators);
     // Get Event Admins
     $groupAdmins = $group->getAdmins(12, CC_RANDOMIZE);
     $adminsInArray = array();
     // Attach avatar of the admin
     for ($i = 0; $i < count($groupAdmins); $i++) {
         $row =& $groupAdmins[$i];
         $admin = CFactory::getUser($row->id);
         array_push($adminsInArray, '<a href="' . CUrlHelper::userLink($admin->id) . '">' . $admin->getDisplayName() . '</a>');
     }
     $adminsList = ltrim(implode(', ', $adminsInArray), ',');
     echo $tmpl->setMetaTags('group', $group)->set('streamHTML', $streamHTML)->set('status', $status)->set('likesHTML', $likesHTML)->set('events', $events)->set('totalEvents', $totalEvents)->set('inviteHTML', $inviteHTML)->set('showEvents', $config->get('group_events') && $config->get('enableevents'))->set('showPhotos', $params->get('photopermission') != -1)->set('showVideos', $params->get('videopermission') != -1)->set('bookmarksHTML', $bookmarksHTML)->set('allowManagePhotos', $allowManagePhotos)->set('allowManageVideos', $allowManageVideos)->set('allowCreateEvent', $allowCreateEvent)->set('videos', $videos)->set('videoThumbWidth', $videoThumbWidth)->set('videoThumbHeight', $videoThumbHeight)->set('totalVideos', $totalVideos)->set('albums', $albums)->set('totalAlbums', $totalAlbums)->set('reportHTML', $reportHTML)->set('editGroup', $editGroup)->set('waitingApproval', $waitingApproval)->set('config', $config)->set('my', $my)->set('isMine', $isMine)->set('isAdmin', $isAdmin)->set('isSuperAdmin', $isSuperAdmin)->set('isMember', $isMember)->set('isInvited', $isInvited)->set('friendsCount', $friendsCount)->set('join', $join)->set('unapproved', $unapproved)->set('membersCount', $membersCount)->set('group', $group)->set('totalBulletin', $totalBulletin)->set('totalDiscussion', $totalDiscussion)->set('totalVideos', $totalVideos)->set('members', $approvedMembers)->set('bulletins', $bulletins)->set('wallForm', $wallForm)->set('wallContent', $wallContent)->set('discussions', $discussions)->set('discussionsHTML', $discussionsHTML)->set('bulletinsHTML', $bulletinsHTML)->set('isCommunityAdmin', $isCommunityAdmin)->set('isBanned', $isBanned)->set('isPrivate', $group->approvals)->set('limit', $limit)->set('adminsList', $adminsList)->set('alertNewDiscussion', $my->count('group_discussion_' . $group->id) != $totalDiscussion)->set('alertNewBulletin', $my->count('group_bulletin_' . $group->id) != $totalBulletin)->set('alertNewStream', $my->count('group_activity_' . $group->id) != $totalStream)->fetch('groups.viewgroup');
     // Update stream count cache, can only set this after we've set the alert aove
     $my->setCount('group_activity_' . $group->id, $totalStream);
 }
Example #19
0
                                <?php 
        } else {
            ?>
                                    <img src="<?php 
            echo $message->avatar;
            ?>
" alt="" >
                                <?php 
        }
        ?>
                            </a>
                        </div>

                        <div class="joms-comment__body">
                            <a href="<?php 
        echo $task == 'sent' && !empty($message->smallAvatar[0]) ? CUrlHelper::userLink($message->to[0]) : CUrlHelper::userLink($message->user->id);
        ?>
">
                                <strong>
                                    <?php 
        if ($task == 'sent' && !empty($message->smallAvatar[0])) {
            echo $message->to_name[0];
        } else {
            echo $message->from_name;
        }
        ?>
                                </strong>
                            </a>
                            <?php 
        $count = --$message->recipientCount;
        if ($count > 0) {
defined('_JEXEC') or die;
?>
<ul class ="cDetailList clrfix">
	<li class="avatarWrap">
		<a href="<?php 
echo $event->contentid ? CUrlHelper::groupeventLink($event->id, $event->contentid) : CUrlHelper::eventLink($event->id);
?>
"><img style="width: 64px; height: auto" class="cAvatar" src="<?php 
echo $event->getThumbAvatar();
?>
" /></a>
	</li>
	<li class="detailWrap">

		<strong><a href="<?php 
echo $event->contentid ? CUrlHelper::groupeventLink($event->id, $event->contentid) : CUrlHelper::eventLink($event->id);
?>
"><?php 
echo strip_tags($event->title);
?>
</a></strong>
		<small>
			<?php 
if (strlen(strip_tags($event->description))) {
    echo JHTML::_('string.truncate', strip_tags($event->description), $config->getInt('streamcontentlength')) . '<br />';
}
?>
			<?php 
echo $event->getStartDateHTML();
?>
<br />
*/
defined('_JEXEC') or die;
$user = CFactory::getUser($this->act->actor);
$users = explode(',', $this->actors);
// We want the last guy joining to be the first mentioned
$users = array_reverse($users);
$userCount = count($users);
$slice = 2;
if ($userCount > 2) {
    $slice = 1;
}
$users = array_slice($users, 0, $slice);
$actorsHTML = array();
?>

<div class="joms-stream-content">
	<i class="joms-icon-users"></i>
	<?php 
foreach ($users as $actor) {
    $user = CFactory::getUser($actor);
    $actorsHTML[] = '<a class="cStream-Author" href="' . CUrlHelper::userLink($user->id) . '">' . $user->getDisplayName() . '</a>';
}
$others = '';
if ($userCount > 2) {
    $others = JText::sprintf('COM_COMMUNITY_STREAM_OTHERS_JOIN_GROUP', $userCount - 1, 'onClick="joms.stream.showOthers(' . $act->id . ');return false;"');
}
echo implode(' ' . JText::_('COM_COMMUNITY_AND') . ' ', $actorsHTML) . $others;
echo JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_JOIN', $this->group->getLink(), $this->group->name);
?>

</div>
Example #22
0
                        echo '<strong><a class="actor-link" href="' . CUrlHelper::userLink($act->actor) . '">' . $actor->getDisplayName() . '</a></strong> <span class="com_icons com_icons12 com_icons-inline com_icons-rarr">»</span> <a href="' . CUrlHelper::groupLink($act->groupid) . '">' . $act->appTitle . '</a>';
                        if ($act->group_access == 1) {
                            echo ' <span title="' . JText::_('COM_COMMUNITY_GROUPS_PRIVATE') . '" class="com_icons com_icons12 com_icons-inline com_icons-private jomNameTips">' . JText::_('COM_COMMUNITY_GROUPS_PRIVATE') . '</span>';
                        }
                        echo '</div>';
                    } else {
                        if (!empty($act->target) && $act->target != $act->actor && $act->app == 'profile' && $act->target != $actorId) {
                            // Actor doing something to target
                            echo '<div class="newsfeed-content-actor">';
                            echo '<strong><a class="actor-link" href="' . CUrlHelper::userLink($act->actor) . '">' . $actor->getDisplayName() . '</a></strong> ';
                            echo '<span class="com_icons com_icons12 com_icons-inline com_icons-rarr">»</span> ';
                            echo '<a class="actor-link" href="' . CUrlHelper::userLink($act->target) . '">' . $target->getDisplayName() . '</a>';
                            echo '</div>';
                        } else {
                            // Everythings else should have the actor's title
                            $actorNeedle = '<a class="actor-link" href="' . CUrlHelper::userLink($act->actor) . '">' . $actor->getDisplayName() . '</a>';
                            // Will do a preg search for the actor's name and avoid a duplicated display
                            if (!preg_match('/^<a(.)+class="(.)?actor-link(.)?"(.)+>' . $actor->getDisplayName() . '<\\/a>/', $messageDisplay)) {
                                echo '<div class="newsfeed-content-actor">';
                                echo '<strong>' . $actorNeedle . '</strong>';
                                echo '</div>';
                            }
                        }
                    }
                }
                echo $messageDisplay;
                ?>
			</div>
			<?php 
                if (!empty($act->content) && $showMore) {
                    ?>
Example #23
0
"></div>
            </div>

            <div class="joms-list__footer joms-padding">
                <a class="joms-avatar" href="<?php 
        echo CUrlHelper::userLink($creator->id);
        ?>
"><img src="<?php 
        echo $creator->getAvatar();
        ?>
" alt="" ></a>
                <?php 
        echo JText::_('COM_COMMUNITY_GROUPS_CREATED_BY');
        ?>
 <a href="<?php 
        echo CUrlHelper::userLink($creator->id);
        ?>
"><?php 
        echo $creator->getDisplayName();
        ?>
</a>
            </div>

            <span class="joms-list__permission joms-js--invitation-buttons-group-<?php 
        echo $group->id;
        ?>
">
                <a class="joms-button--neutral joms-button--smallest" href="javascript:" onclick="joms.api.invitationReject('group', '<?php 
        echo $group->id;
        ?>
');"><?php 
Example #24
0
 function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile)
 {
     CFactory::load('helpers', 'url');
     CFactory::load('helpers', 'user');
     CFactory::load('helpers', 'videos');
     CFactory::load('libraries', 'comment');
     CFactory::load('helpers', 'owner');
     CFactory::load('helpers', 'time');
     $user = CFactory::getUser($wall->post_by);
     $date = CTimeHelper::getDate($wall->date);
     $config = CFactory::getConfig();
     // @rule: for site super administrators we want to allow them to view the remove link
     $isOwner = COwnerHelper::isCommunityAdmin() ? true : $isOwner;
     $isEditable = CWall::isEditable($processFunc, $wall->id);
     // Apply any post processing on the content
     $wall->comment = CWallLibrary::_processWallContent($wall->comment);
     $commentsHTML = '';
     $comment = new CComment();
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     //var_dump($avatarHTML);exit;
     // @rule: We only allow editing of wall in 15 minutes
     $now = JFactory::getDate();
     $interval = CTimeHelper::timeIntervalDifference($wall->date, $now->toMySQL());
     $interval = COMMUNITY_WALLS_EDIT_INTERVAL - abs($interval);
     $editInterval = round($interval / 60);
     // Create new instance of the template
     $tmpl = new CTemplate();
     $tmpl->set('id', $wall->id);
     $tmpl->set('author', $user->getDisplayName());
     $tmpl->set('avatarHTML', $avatarHTML);
     $tmpl->set('authorLink', CUrlHelper::userLink($user->id));
     $tmpl->set('created', $date->toFormat(JText::_('DATE_FORMAT_LC2')));
     $tmpl->set('content', $wall->comment);
     $tmpl->set('commentsHTML', $commentsHTML);
     $tmpl->set('avatar', $user->getThumbAvatar());
     $tmpl->set('isMine', $isOwner);
     $tmpl->set('isEditable', $isEditable);
     $tmpl->set('editInterval', $editInterval);
     $tmpl->set('processFunc', $processFunc);
     $tmpl->set('config', $config);
     return $tmpl->fetch($templateFile);
 }
Example #25
0
                        </a>
                    </div>
                    <div class="joms-stream__meta">
                        <a class="joms-stream__user"
                           href="<?php 
        echo CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $groupId . '&topicid=' . $row->id);
        ?>
">
                            <?php 
        echo $row->title;
        ?>
                        </a>
                        <span class="joms-stream__time">
                            <small>
                                <?php 
        echo JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_CREATOR', '<a href="' . CUrlHelper::userLink($row->user->id) . '">' . $row->user->getDisplayName() . '</a>');
        ?>
                                <?php 
        echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC'));
        ?>
                            </small>
                        </span>
                    </div>
                    <div class="joms-stream__replies">
                        <a class="joms-button--neutral joms-button--small" href="<?php 
        echo CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $groupId . '&topicid=' . $row->id);
        ?>
">
                            <?php 
        echo JText::sprintf(CStringHelper::isPlural($row->count) ? 'COM_COMMUNITY_TOTAL_REPLIES_MANY' : 'COM_COMMUNITY_GROUPS_DISCUSSION_REPLY_COUNT', $row->count);
        ?>
Example #26
0
    <h4 class="joms-text--title"><?php 
    echo JText::_('COM_COMMUNITY_FILES_AVAILABLE');
    ?>
</h4>
    <ul class="joms-list--files">
        <?php 
    for ($i = 0; $i <= 4; $i++) {
        ?>
            <?php 
        if (!empty($data[$i])) {
            ?>
            <?php 
            $filename = $data[$i]->name;
            $filepath = $data[$i]->filepath;
            $fileext = strrpos($filepath, '.');
            $userlink = '<a href="' . CUrlHelper::userLink($data[$i]->user->id) . '">' . $data[$i]->user->getDisplayName() . '</a>';
            if ($fileext !== false) {
                $filename .= substr($filepath, $fileext);
            }
            ?>
            <li class="joms-list__item joms-js--file-<?php 
            echo $data[$i]->id;
            ?>
">
                <p>
                    <a href="<?php 
            echo $filepath;
            ?>
" target="_blank" title="<?php 
            echo $filename;
            ?>
Example #27
0
                ▶ <a href="<?php 
        echo CUrlHelper::groupLink($group->id);
        ?>
"><?php 
        echo $group->name;
        ?>
</a>
            </span>
            <!-- Target is user profile -->
        <?php 
    } else {
        if ($activity->get('app') == 'profile' && $activity->get('target') != 0 && $activity->get('target') != $user->id) {
            ?>
            <span class="joms-stream__reference">
                ▶ <a href="<?php 
            echo CUrlHelper::userLink($activity->target);
            ?>
"><?php 
            echo CFactory::getUser($activity->get('target'))->getDisplayName();
            ?>
</a>
            </span>
        <?php 
        }
    }
}
?>

        <a href="<?php 
echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $activity->actor . '&actid=' . $activity->id);
?>
Example #28
0
 /**
  * Responsible for displaying the event page.
  **/
 function viewevent()
 {
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     CFactory::load('libraries', 'tooltip');
     CFactory::load('libraries', 'wall');
     CFactory::load('libraries', 'window');
     CWindow::load();
     $eventid = JRequest::getInt('eventid', 0);
     $eventModel =& CFactory::getModel('events');
     $event =& JTable::getInstance('Event', 'CTable');
     CFactory::load('helpers', 'event');
     $handler = CEventHelper::getHandler($event);
     $event->load($eventid);
     if (!$handler->exists()) {
         $mainframe->enqueueMessage(JText::_('CC EVENTS NOT AVAILABLE'), 'error');
         return;
     }
     if (!$handler->browsable()) {
         echo JText::_('CC NOT ALLOWED TO ACCESS SECTION');
         return;
     }
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$event->published) {
         echo JText::_('CC EVENTS UNDER MODERATION');
         return;
     }
     $this->showSubmenu();
     $event->hit();
     // Basic page presentation
     if ($event->type == 'group') {
         $groupId = $event->contentid;
         $group =& JTable::getInstance('Group', 'CTable');
         $group->load($groupId);
         // Set pathway for group videos
         // Community > Groups > Group Name > Events
         $this->addPathway(JText::_('CC GROUPS'), CRoute::_('index.php?option=com_community&view=groups'));
         $this->addPathway($group->name, CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $groupId));
     }
     $this->addPathway(JText::_('CC EVENTS'), CRoute::_('index.php?option=com_community&view=events'));
     $this->addPathway(JText::sprintf('CC VIEW EVENTS TITLE', $event->title), '');
     // Permissions and privacies
     CFactory::load('helpers', 'owner');
     $isEventGuest = $event->isMember($my->id);
     $isMine = $my->id == $event->creator;
     $isAdmin = $event->isAdmin($my->id);
     $isCommunityAdmin = COwnerHelper::isCommunityAdmin();
     // Get Event Admins
     $eventAdmins = $event->getAdmins(12, CC_RANDOMIZE);
     $eventAdminsCount = $event->getAdminsCount();
     // Attach avatar of the admin
     for ($i = 0; $i < count($eventAdmins); $i++) {
         $row =& $eventAdmins[$i];
         $eventAdmins[$i] = CFactory::getUser($row->id);
     }
     // Get Attending Event Guests
     $eventMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_ATTEND, 12, CC_RANDOMIZE);
     $eventMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_ATTEND);
     // Get pending event guests
     $pendingMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_INVITED, 12, CC_RANDOMIZE);
     $pendingMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_INVITED);
     // Get blocked Event Guests
     $blockedMembers = $event->getMembers(COMMUNITY_EVENT_STATUS_BLOCKED, 12, CC_RANDOMIZE);
     $blockedMembersCount = $event->getMembersCount(COMMUNITY_EVENT_STATUS_BLOCKED);
     // Attach avatar of the admin
     // Pre-load multiple users at once
     $userids = array();
     foreach ($eventMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($eventMembers); $i++) {
         $row =& $eventMembers[$i];
         $eventMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($pendingMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($pendingMembers); $i++) {
         $row =& $pendingMembers[$i];
         $pendingMembers[$i] = CFactory::getUser($row->id);
     }
     // Pre-load multiple users at once
     $userids = array();
     foreach ($blockedMembers as $uid) {
         $userids[] = $uid->id;
     }
     CFactory::loadUsers($userids);
     for ($i = 0; $i < count($blockedMembers); $i++) {
         $row =& $blockedMembers[$i];
         $blockedMembers[$i] = CFactory::getUser($row->id);
     }
     $waitingApproval = $event->isPendingApproval($my->id);
     $waitingRespond = false;
     $myStatus = $event->getUserStatus($my->id);
     $hasResponded = $myStatus == COMMUNITY_EVENT_STATUS_ATTEND || $myStatus == COMMUNITY_EVENT_STATUS_WONTATTEND || $myStatus == COMMUNITY_EVENT_STATUS_MAYBE;
     // Get Bookmark HTML
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id));
     $bookmarksHTML = $bookmarks->getHTML();
     // Get Reporting HTML
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('CC REPORT EVENT'), 'events,reportEvent', array($event->id));
     // Get the Wall
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('events', $event->id, $isAdmin, 10, 0, 'wall.content', 'events,events');
     $wallCount = CWallLibrary::getWallCount('events', $event->id);
     $viewAllLink = false;
     if (JRequest::getVar('task', '', 'REQUEST') != 'app') {
         $viewAllLink = CRoute::_('index.php?option=com_community&view=events&task=app&eventid=' . $event->id . '&app=walls');
     }
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     $wallForm = '';
     if (!$config->get('lockeventwalls') || $config->get('lockeventwalls') && $isEventGuest && !$waitingApproval && $hasResponded || $isCommunityAdmin) {
         $wallForm = CWallLibrary::getWallInputForm($event->id, 'events,ajaxSaveWall', 'events,ajaxRemoveWall');
     }
     // Construct the RVSP radio list
     $arr = array(JHTML::_('select.option', COMMUNITY_EVENT_STATUS_ATTEND, JText::_('CC EVENT ACTION ATTEND')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_WONTATTEND, JText::_('CC EVENT ACTION DECLINE')), JHTML::_('select.option', COMMUNITY_EVENT_STATUS_MAYBE, JText::_('CC EVENT ACTION UNSURE')));
     $status = $event->getMemberStatus($my->id);
     $radioList = JHTML::_('select.radiolist', $arr, 'status', '', 'value', 'text', $status, false);
     $unapprovedCount = $event->inviteRequestCount();
     //...
     $editEvent = JRequest::getVar('edit', false, 'GET');
     $editEvent = $editEvent == 1 ? true : false;
     // Am I invited in this event?
     $isInvited = false;
     $join = '';
     $friendsCount = 0;
     $isInvited = $eventModel->isInvitedMe(0, $my->id, $event->id);
     // If I was invited, I want to know my invitation informations
     if ($isInvited) {
         $invitor = CFactory::getUser($isInvited[0]->invited_by);
         $join = '<a href="' . CUrlHelper::userLink($invitor->id) . '">' . $invitor->getDisplayName() . '</a>';
         // Get users friends in this group
         $friendsCount = $eventModel->getFriendsCount($my->id, $event->id);
     }
     $friendsModel = CFactory::getModel('Friends');
     $tmpFriends = $friendsModel->getFriends($my->id, 'name', false);
     $friends = array();
     for ($i = 0; $i < count($tmpFriends); $i++) {
         $friend =& $tmpFriends[$i];
         if (!$event->isMember($friend->id)) {
             $friends[] = $friend;
         }
     }
     unset($tmpFriends);
     // Get like
     CFactory::load('libraries', 'like');
     $likes = new CLike();
     $likesHTML = $likes->getHTML('events', $event->id, $my->id);
     // Is this event is a past event?
     $now = new JDate();
     $isPastEvent = $event->getEndDate(false)->toMySQL() < $now->toMySQL(true) ? true : false;
     // Output to template
     $tmpl = new CTemplate();
     CFactory::load('libraries', 'invitation');
     $inviteHTML = CInvitation::getHTML($friends, 'events,inviteUsers', $event->id, CInvitation::SHOW_FRIENDS, CInvitation::HIDE_EMAIL);
     $tmpl->setMetaTags('event', $event);
     $tmpl->set('timezone', CTimeHelper::getTimezone($event->offset));
     $tmpl->set('handler', $handler);
     $tmpl->set('likesHTML', $likesHTML);
     $tmpl->set('inviteHTML', $inviteHTML);
     $tmpl->set('guestStatus', $event->getUserStatus($my->id));
     $tmpl->set('event', $event);
     $tmpl->set('radioList', $radioList);
     $tmpl->set('bookmarksHTML', $bookmarksHTML);
     $tmpl->set('reportHTML', $reportHTML);
     $tmpl->set('isEventGuest', $isEventGuest);
     $tmpl->set('isMine', $isMine);
     $tmpl->set('isAdmin', $isAdmin);
     $tmpl->set('isCommunityAdmin', $isCommunityAdmin);
     $tmpl->set('unapproved', $unapprovedCount);
     $tmpl->set('waitingApproval', $waitingApproval);
     $tmpl->set('wallForm', $wallForm);
     $tmpl->set('wallContent', $wallContent);
     $tmpl->set('eventAdmins', $eventAdmins);
     $tmpl->set('eventAdminsCount', $eventAdminsCount);
     $tmpl->set('eventMembers', $eventMembers);
     $tmpl->set('eventMembersCount', $eventMembersCount);
     $tmpl->set('blockedMembers', $blockedMembers);
     $tmpl->set('blockedMembersCount', $blockedMembersCount);
     $tmpl->set('pendingMembers', $pendingMembers);
     $tmpl->set('pendingMembersCount', $pendingMembersCount);
     $tmpl->set('editEvent', $editEvent);
     $tmpl->set('my', $my);
     $tmpl->set('memberStatus', $myStatus);
     $tmpl->set('waitingRespond', $waitingRespond);
     $tmpl->set('isInvited', $isInvited);
     $tmpl->set('join', $join);
     $tmpl->set('friendsCount', $friendsCount);
     $tmpl->set('isPastEvent', $isPastEvent);
     echo $tmpl->fetch('events.viewevent');
 }
            ?>
    <?php 
        } else {
            if ($this->act->app == 'events.featured') {
                ?>
        <?php 
                $this->load('activities.events.featured');
            } else {
                ?>
	<?php 
                $table = JTable::getInstance('Activity', 'CTable');
                $table->load($this->act->id);
                if (!$table->delete()) {
                    ?>
	<a class="cStream-Avatar cFloat-L" href="<?php 
                    echo CUrlHelper::userLink($user->id);
                    ?>
">
		<img class="cAvatar" data-author="<?php 
                    echo $user->id;
                    ?>
" src="<?php 
                    echo $user->getThumbAvatar();
                    ?>
">
	</a>
	<div class="cStream-Content">
		<div class="cStream-Attachment">
			<?php 
                    $html = CGroups::getActivityContentHTML($act);
                    echo $html;
').remove(); jax.call('community','notification,ajaxGroupRejectRequest', '<?php 
    echo $row->id;
    ?>
' , '<?php 
    echo $row->groupId;
    ?>
');">

							    <?php 
    echo JText::_('COM_COMMUNITY_FRIENDS_PENDING_ACTION_REJECT');
    ?>

						    </a>
							
							<a class="jsIcon1 icon-go" style="text-indent: 0;" href="<?php 
    echo CUrlHelper::groupLink($row->groupId);
    ?>
" >

							    <?php 
    echo JText::_('COM_COMMUNITY_EVENTS_GO');
    ?>

						    </a>
						</span>
					    </span>

						<span id="error-request-<?php 
    echo $row->id;
    ?>
">