Пример #1
0
 /**
  * Displays the viewing profile page.
  * 	 	
  * @access	public
  * @param	array  An associative array to display the fields
  */
 public function profile(&$data)
 {
     $mainframe = JFactory::getApplication();
     $friendsModel = CFactory::getModel('friends');
     $showfriends = JRequest::getVar('showfriends', false);
     $userid = JRequest::getVar('userid', '');
     $user = CFactory::getUser($userid);
     $linkUrl = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_USERS_FEED_TITLE', $user->getDisplayName()));
     $document->setDescription(JText::sprintf('COM_COMMUNITY_USERS_FEED_DESCRIPTION', $user->getDisplayName(), $user->lastvisitDate));
     $document->setLink($linkUrl);
     include_once JPATH_COMPONENT . '/libraries/activities.php';
     $act = new CActivityStream();
     $friendIds = $friendsModel->getFriendIds($user->id);
     $friendIds = $showfriends ? $friendIds : null;
     $rows = $act->getFEED($user->id, $friendIds, null, $mainframe->getCfg('feed_limit'));
     // add the avatar image
     $rssImage = new JFeedImage();
     $rssImage->url = $user->getThumbAvatar();
     $rssImage->link = $linkUrl;
     $rssImage->width = 64;
     $rssImage->height = 64;
     $document->image = $rssImage;
     //CFactory::load( 'helpers' , 'string' );
     //CFactory::load( 'helpers' , 'time' );
     foreach ($rows->data as $row) {
         if ($row->type != 'title') {
             // Get activities link
             $pattern = '/<a href=\\"(.*?)\\"/';
             preg_match_all($pattern, $row->title, $matches);
             // Use activity owner link when activity link is not available
             if (!empty($matches[1][1])) {
                 $linkUrl = $matches[1][1];
             } else {
                 if (!empty($matches[1][0])) {
                     $linkUrl = $matches[1][0];
                 }
             }
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = $row->title;
             $item->link = $linkUrl;
             $item->description = "<img src=\"{$row->favicon}\" alt=\"\" />&nbsp;" . $row->title;
             $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
             $item->category = '';
             //$row->category;
             $item->description = CString::str_ireplace('_QQQ_', '"', $item->description);
             // Make sure url is absolute
             $pattern = '/href="(.*?)index.php/';
             $replace = 'href="' . JURI::base() . 'index.php';
             $string = $item->description;
             $item->description = preg_replace($pattern, $replace, $string);
             // loads item info into rss array
             $document->addItem($item);
         }
     }
 }
Пример #2
0
 public function display($data = null)
 {
     $mainframe = JFactory::getApplication();
     $config = CFactory::getConfig();
     $document = JFactory::getDocument();
     $document->setTitle(JText::sprintf('COM_COMMUNITY_FRONTPAGE_TITLE', $config->get('sitename')));
     $document->setLink(CRoute::_('index.php?option=com_community'));
     $my = CFactory::getUser();
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'string');
     CFactory::load('helpers', 'time');
     $act = new CActivityStream();
     $rows = $act->getFEED('', '', null, $mainframe->getCfg('feed_limit'));
     if ($config->get('showactivitystream') == COMMUNITY_SHOW || $config->get('showactivitystream') == COMMUNITY_MEMBERS_ONLY && $my->id != 0) {
         foreach ($rows->data as $row) {
             if ($row->type != 'title') {
                 // load individual item creator class
                 $item = new JFeedItem();
                 // cannot escape the title. it's already formated. we should
                 // escape it during CActivityStream::add
                 //$item->title 		= CStringHelper::escape($row->title);
                 $item->title = $row->title;
                 $item->link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->actor);
                 $item->description = "<img src=\"{$row->favicon}\" alt=\"\"/>&nbsp;" . $row->title;
                 $item->date = CTimeHelper::getDate($row->createdDateRaw)->toRFC822();
                 $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);
             }
         }
     }
 }
Пример #3
0
<?php

/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <*****@*****.**>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
defined('_JEXEC') or die('Restricted access');
$usersModel = CFactory::getModel('user');
$now = new JDate();
$date = CTimeHelper::getDate();
$users = $usersModel->getLatestMember(10);
$totalRegistered = count($users);
$title = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $totalRegistered, $date->monthToString($now->format('%m')));
?>

<div class="joms-stream__body joms-stream-box">

    <h4><?php 
echo JText::_('COM_COMMUNITY_LAST_10_USERS_REGISTERED');
?>
</h4>

        <?php 
if ($totalRegistered > 0) {
    ?>

            <div class="joms-list--block">
Пример #4
0
 public function renderComment($cmtObj)
 {
     $my = CFactory::getUser();
     $user = CFactory::getUser($cmtObj->creator);
     // Process the text
     CFactory::load('helpers', 'string');
     $cmtObj->text = nl2br(CStringHelper::escape($cmtObj->text));
     //format the date
     $dateObject = CTimeHelper::getDate($cmtObj->date);
     $date = C_JOOMLA_15 == 1 ? $dateObject->toFormat(JText::_('DATE_FORMAT_LC2')) : $dateObject->Format(JText::_('DATE_FORMAT_LC2'));
     $html = '';
     $html .= '<div class="cComment">';
     CFactory::load('helpers', 'user');
     $html .= CUserHelper::getThumb($user->id, 'wall-coc-avatar');
     CFactory::load('helpers', 'string');
     $html = CStringHelper::replaceThumbnails($html);
     $html .= '<a class="wall-coc-author" href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id) . '">' . $user->getDisplayName() . '</a> ';
     $html .= JText::sprintf('COM_COMMUNITY_COMMENT_POSTED_ON', '<span class="wall-coc-date">' . $date . '</span>');
     CFactory::load('helpers', 'owner');
     if ($my->id == $user->id || COwnerHelper::isCommunityAdmin()) {
         $html .= ' | <a class="coc-remove coc-' . $cmtObj->creator . '" onclick="joms.comments.remove(this);" href="javascript:void(0)">' . JText::_('COM_COMMUNITY_REMOVE') . '</a>';
     }
     $html .= '<p>' . $cmtObj->text . '</p>';
     $html .= '</div>';
     return $html;
 }
Пример #5
0
 public function getTotalMessageSent($userId)
 {
     //CFactory::load( 'helpers' , 'time' );
     $date = CTimeHelper::getDate();
     $db = $this->getDBO();
     //Joomla 1.6 JDate::getOffset returns in second while in J1.5 it's in hours
     $query = 'SELECT COUNT(*) FROM ' . $db->quoteName('#__community_msg') . ' AS a ' . 'WHERE a.' . $db->quoteName('from') . '=' . $db->Quote($userId) . ' AND TO_DAYS(' . $db->Quote($date->toSql(true)) . ') - TO_DAYS( DATE_ADD( a.' . $db->quoteName('posted_on') . ' , INTERVAL ' . $date->getOffset() / 3600 . ' HOUR ) ) = ' . $db->Quote('0') . ' AND a.' . $db->quoteName('parent') . '=a.' . $db->quoteName('id');
     $db->setQuery($query);
     $count = $db->loadResult();
     return $count;
 }
Пример #6
0
 /**
  * Check if the given group name exist.
  * if id is specified, only search for those NOT within $id
  */
 public function isEventExist($title, $location, $startdate, $enddate, $id = 0, $parent = 0)
 {
     $db = $this->getDBO();
     $starttime = CTimeHelper::getDate($startdate);
     $endtime = CTimeHelper::getDate($enddate);
     $strSQL = 'SELECT count(*) FROM ' . $db->quoteName('#__community_events') . ' WHERE ' . $db->quoteName('title') . ' = ' . $db->Quote($title) . ' AND ' . $db->quoteName('location') . ' = ' . $db->Quote($location) . ' AND ' . $db->quoteName('startdate') . ' = ' . $db->Quote($starttime->toSql()) . ' AND ' . $db->quoteName('enddate') . ' = ' . $db->Quote($endtime->toSql()) . ' AND ' . $db->quoteName('id') . ' != ' . $db->Quote($id) . ' AND ' . $db->quoteName('id') . ' != ' . $db->Quote($parent) . ' AND ' . $db->quoteName('parent') . '=' . $db->Quote(0);
     $db->setQuery($strSQL);
     $result = $db->loadResult();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     return $result;
 }
Пример #7
0
        echo JText::_('COM_COMMUNITY_INBOX_REMOVE');
        ?>
</span>
                    </a>
                </div>
                <div class="joms-list--message__checkbox js-mail-checkbox">
                    <span>
                        <input type="checkbox" class="joms-checkbox" name="message[]" value="<?php 
        echo $message->id;
        ?>
" onclick="checkSelected();">
                    </span>
                </div>
                <small class="joms-list--message__time">
                    <?php 
        $postdate = CTimeHelper::timeLapse(CTimeHelper::getDate($message->posted_on));
        echo $postdate;
        ?>
                   <svg class="joms-icon" viewBox="0 0 16 16">
                        <use xlink:href="<?php 
        echo CRoute::getURI();
        ?>
#joms-icon-clock"/>
                    </svg>
                </small>
            </div>
        <?php 
    }
    ?>
    </div>
Пример #8
0
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $id = $jinput->get('listid', '', 'INT');
     //JRequest::getVar( 'listid' , '' );
     $list = JTable::getInstance('MemberList', 'CTable');
     $list->load($id);
     if (empty($list->id) || is_null($list->id)) {
         echo JText::_('COM_COMMUNITY_INVALID_ID');
         return;
     }
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', $list->getTitle());
     $tmpCriterias = $list->getCriterias();
     $criterias = array();
     foreach ($tmpCriterias as $criteria) {
         $obj = new stdClass();
         $obj->field = $criteria->field;
         $obj->condition = $criteria->condition;
         $obj->fieldType = $criteria->type;
         switch ($criteria->type) {
             case 'date':
             case 'birthdate':
                 if ($criteria->condition == 'between') {
                     $date = explode(',', $criteria->value);
                     if (isset($date[1])) {
                         $delimeter = '-';
                         if (strpos($date[0], '/')) {
                             $delimeter = '/';
                         }
                         $startDate = explode($delimeter, $date[0]);
                         $endDate = explode($delimeter, $date[1]);
                         if (isset($startDate[2]) && isset($endDate[2])) {
                             //date format
                             $obj->value = array($startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00', $endDate[2] . '-' . intval($endDate[1]) . '-' . $endDate[0] . ' 23:59:59');
                         } else {
                             //age format
                             $obj->value = array($date[0], $date[1]);
                         }
                     } else {
                         //wrong data, set to default
                         $obj->value = array(0, 0);
                     }
                 } else {
                     $delimeter = '-';
                     if (strpos($criteria->value, '/')) {
                         $delimeter = '/';
                     }
                     $startDate = explode($delimeter, $criteria->value);
                     if (isset($startDate[2])) {
                         //date format
                         $obj->value = $startDate[2] . '-' . intval($startDate[1]) . '-' . $startDate[0] . ' 00:00:00';
                     } else {
                         //age format
                         $obj->value = $criteria->value;
                     }
                 }
                 break;
             case 'checkbox':
             default:
                 $obj->value = $criteria->value;
                 break;
         }
         $criterias[] = $obj;
     }
     //CFactory::load( 'helpers' , 'time');
     $created = CTimeHelper::getDate($list->created);
     //CFactory::load( 'libraries' , 'advancesearch' );
     //CFactory::load( 'libraries' , 'filterbar' );
     $sortItems = array('latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL'));
     $sorting = $jinput->get->get('sort', 'latest', 'STRING');
     //JRequest::getVar( 'sort' , 'latest' , 'GET' );
     $data = CAdvanceSearch::getResult($criterias, $list->condition, $list->avataronly, $sorting);
     $tmpl = new CTemplate();
     $html = $tmpl->set('list', $list)->set('created', $created)->set('sorting', CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'))->fetch('memberlist.result');
     unset($tmpl);
     //CFactory::load( 'libraries' , 'tooltip' );
     //CFactory::load( 'helpers' , 'owner' );
     //CFactory::load( 'libraries' , 'featured' );
     $featured = new CFeatured(FEATURED_USERS);
     $featuredList = $featured->getItemIds();
     $my = CFactory::getUser();
     $resultRows = array();
     $friendsModel = CFactory::getModel('friends');
     $alreadyfriend = array();
     //CFactory::load( 'helpers' , 'friends' );
     foreach ($data->result as $user) {
         $obj = new stdClass();
         $obj->user = $user;
         $obj->friendsCount = $user->getFriendCount();
         $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id);
         $isFriend = CFriendsHelper::isConnected($user->id, $my->id);
         $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false;
         //record friends
         if ($obj->addFriend) {
             $alreadyfriend[$user->id] = $user->id;
         }
         $resultRows[] = $obj;
     }
     $tmpl = new CTemplate();
     echo $tmpl->set('data', $resultRows)->set('alreadyfriend', $alreadyfriend)->set('sortings', '')->set('pagination', $data->pagination)->set('filter', '')->set('featuredList', $featuredList)->set('my', $my)->set('showFeaturedList', false)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse');
 }
Пример #9
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);
 }
Пример #10
0
 /**
  * return array of notification items
  */
 public function getNotification($userid, $type = '0', $limit = 10, $since = '')
 {
     $db = $this->getDBO();
     $limit = $limit === 0 ? $this->getState('limit') : $limit;
     $limitstart = $this->getState('limitstart');
     $sinceWhere = '';
     if (empty($limitstart)) {
         $limitstart = 0;
     }
     if (!empty($since)) {
         $sinceWhere = ' AND ' . $db->quoteName('created') . ' >= ' . $db->Quote($since);
         //rule: if no new notification, load the first 5th latest notification
         $query = 'SELECT COUNT(*)  FROM ' . $db->quoteName('#__community_notifications') . ' AS a ' . 'WHERE a.' . $db->quoteName('target') . '=' . $db->Quote($userid) . $sinceWhere . ' AND a.' . $db->quoteName('type') . '=' . $db->Quote($type);
         $db->setQuery($query);
         $total = $db->loadResult();
         if ($total == 0) {
             $sinceWhere = '';
             //$limit = 5;
         }
     }
     if (!CFactory::getConfig()->get('enablepm')) {
         $sinceWhere .= ' AND a.' . $db->quoteName('cmd_type') . 'NOT LIKE ' . $db->quote('%inbox%');
     }
     $date = CTimeHelper::getDate();
     //we need to compare where both date with offset so that the day diff correctly.
     $query = 'SELECT *,' . ' TO_DAYS(' . $db->Quote($date->format('Y-m-d H:i:s', true, false)) . ') -  TO_DAYS( DATE_ADD(a.' . $db->quoteName('created') . ', INTERVAL ' . $date->getOffset() . ' HOUR ) ) as _daydiff' . ' FROM ' . $db->quoteName('#__community_notifications') . ' AS a ' . 'WHERE a.' . $db->quoteName('target') . '=' . $db->Quote($userid) . ' AND a.' . $db->quoteName('type') . '=' . $db->Quote($type) . $sinceWhere . ' ORDER BY a.' . $db->quoteName('created') . ' DESC';
     if (!is_null($limit)) {
         $query .= ' LIMIT ' . $limitstart . ',' . $limit;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     //Pagination
     $query = 'SELECT COUNT(*)  FROM ' . $db->quoteName('#__community_notifications') . ' AS a ' . 'WHERE a.' . $db->quoteName('target') . '=' . $db->Quote($userid) . $sinceWhere . ' AND a.' . $db->quoteName('type') . '=' . $db->Quote($type);
     $db->setQuery($query);
     $total = $db->loadResult();
     $this->total = $total;
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     if (empty($this->_pagination)) {
         jimport('joomla.html.pagination');
         $this->_pagination = new JPagination($total, $limitstart, $limit);
     }
     return $result;
 }
Пример #11
0
 /**
  * View method to display specific discussion from a group
  * @since 2.4
  * @access	public
  * @param	Object	Data object passed from controller
  */
 public function viewdiscussion()
 {
     $mainframe =& JFactory::getApplication();
     $document = JFactory::getDocument();
     $jconfig = JFactory::getConfig();
     $config = CFactory::getConfig();
     // Load window library
     CFactory::load('libraries', 'window');
     // Load necessary window css / javascript headers.
     CWindow::load();
     // Get necessary variables
     CFactory::load('models', 'groups');
     CFactory::load('models', 'discussions');
     $my = CFactory::getUser();
     $groupId = JRequest::getInt('groupid', '', 'GET');
     $topicId = JRequest::getInt('topicid', '', 'GET');
     // Load necessary library and objects
     $groupModel = CFactory::getModel('groups');
     $group =& JTable::getInstance('Group', 'CTable');
     $discussion =& JTable::getInstance('Discussion', 'CTable');
     $group->load($groupId);
     $discussion->load($topicId);
     $isBanned = $group->isBanned($my->id);
     $document->addCustomTag('<link rel="image_src" href="' . $group->getThumbAvatar() . '" />');
     // @rule: Test if the group is unpublished, don't display it at all.
     if (!$group->published) {
         $this->_redirectUnpublishGroup();
         return;
     }
     $feedLink = CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&topicid=' . $topicId . '&format=feed');
     $feed = '<link rel="alternate" type="application/rss+xml" title="' . JText::_('COM_COMMUNITY_GROUPS_LATEST_FEED') . '"  href="' . $feedLink . '"/>';
     $document->addCustomTag($feed);
     CFactory::load('helpers', 'owner');
     if ($group->approvals == 1 && !$group->isMember($my->id) && !COwnerHelper::isCommunityAdmin()) {
         $this->noAccess(JText::_('COM_COMMUNITY_GROUPS_PRIVATE_NOTICE'));
         return;
     }
     // Execute discussion onDisplay filter
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $args = array();
     $args[] =& $discussion;
     $appsLib->triggerEvent('onDiscussionDisplay', $args);
     // Get the discussion creator info
     $creator = CFactory::getUser($discussion->creator);
     // Format the date accordingly.
     //$discussion->created	= CTimeHelper::getDate( $discussion->created );
     $dayinterval = ACTIVITY_INTERVAL_DAY;
     $timeFormat = $config->get('activitiestimeformat');
     $dayFormat = $config->get('activitiesdayformat');
     if ($config->get('activitydateformat') == COMMUNITY_DATE_FIXED) {
         $discussion->created = CTimeHelper::getDate($discussion->created)->toFormat(JText::_('DATE_FORMAT_LC2'), true);
     } else {
         $discussion->created = CTimeHelper::timeLapse(CTimeHelper::getDate($discussion->created));
     }
     // Set page title
     $document->setTitle(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
     // Add pathways
     $this->_addGroupInPathway($group->id);
     $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION'), CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussions&groupid=' . $group->id));
     $this->addPathway(JText::sprintf('COM_COMMUNITY_GROUPS_DISCUSSION_TITTLE', $discussion->title));
     CFactory::load('helpers', 'owner');
     $isGroupAdmin = $groupModel->isAdmin($my->id, $group->id);
     if ($my->id == $creator->id || $isGroupAdmin || COwnerHelper::isCommunityAdmin()) {
         $title = JText::_('COM_COMMUNITY_DELETE_DISCUSSION');
         $titleLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK_DISCUSSION') : JText::_('COM_COMMUNITY_LOCK_DISCUSSION');
         $actionLock = $discussion->lock ? JText::_('COM_COMMUNITY_UNLOCK') : JText::_('COM_COMMUNITY_LOCK');
         $this->addSubmenuItem('', $actionLock, "joms.groups.lockTopic('" . $titleLock . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
         $this->addSubmenuItem('', JText::_('COM_COMMUNITY_DELETE'), "joms.groups.removeTopic('" . $title . "','" . $group->id . "','" . $discussion->id . "');", SUBMENU_RIGHT);
         $this->addSubmenuItem('index.php?option=com_community&view=groups&task=editdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id, JText::_('COM_COMMUNITY_EDIT'), '', SUBMENU_RIGHT);
     }
     $this->showSubmenu();
     CFactory::load('libraries', 'wall');
     $wallContent = CWallLibrary::getWallContents('discussions', $discussion->id, $isGroupAdmin, $jconfig->get('list_limit'), 0, 'wall.content', 'groups,discussion');
     $wallCount = CWallLibrary::getWallCount('discussions', $discussion->id);
     $viewAllLink = CRoute::_('index.php?option=com_community&view=groups&task=discussapp&topicid=' . $discussion->id . '&app=walls');
     $wallContent .= CWallLibrary::getViewAllLinkHTML($viewAllLink, $wallCount);
     // Test if the current browser is a member of the group
     $isMember = $group->isMember($my->id);
     $waitingApproval = false;
     // If I have tried to join this group, but not yet approved, display a notice
     if ($groupModel->isWaitingAuthorization($my->id, $group->id)) {
         $waitingApproval = true;
     }
     $wallForm = '';
     $config = CFactory::getConfig();
     // Only get the wall form if user is really allowed to see it.
     if (!$config->get('lockgroupwalls') || $config->get('lockgroupwalls') && $isMember && !$isBanned && !$waitingApproval || COwnerHelper::isCommunityAdmin()) {
         $outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
         $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
         $wallForm = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
         $wallForm .= $discussion->lock ? $outputLock : $outputUnLock;
     }
     if (empty($wallForm)) {
         //user must join in order to see this page
         $tmpl = new CTemplate();
         $wallForm = $tmpl->set('groupid', $groupId)->fetch('groups.joingroup');
         $outputLock = '<div class="warning">' . JText::_('COM_COMMUNITY_DISCUSSION_LOCKED_NOTICE') . '</div>';
         $outputUnLock = CWallLibrary::getWallInputForm($discussion->id, 'groups,ajaxSaveDiscussionWall', 'groups,ajaxRemoveReply');
         $wallForm2 = '<div class="wall-tittle">' . JText::_('COM_COMMUNITY_REPLIES') . '</div>';
         $wallForm2 .= $discussion->lock ? $outputLock : $outputUnLock;
         $wallForm = $wallForm . '<div style="display:none" class="reply-form">' . $wallForm2 . '</div>';
     }
     $config = CFactory::getConfig();
     // Get creator link
     $creatorLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $creator->id);
     // Get reporting html
     CFactory::load('libraries', 'reporting');
     $report = new CReportingLibrary();
     $reportHTML = $report->getReportingHTML(JText::_('COM_COMMUNITY_GROUPS_DISCUSSION_REPORT'), 'groups,reportDiscussion', array($discussion->id));
     CFactory::load('libraries', 'bookmarks');
     $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $group->id . '&topicid=' . $discussion->id));
     $bookmarksHTML = $bookmarks->getHTML();
     $tmpl = new CTemplate();
     echo $tmpl->set('bookmarksHTML', $bookmarksHTML)->set('discussion', $discussion)->set('creator', $creator)->set('wallContent', $wallContent)->set('wallForm', $wallForm)->set('creatorLink', $creatorLink)->set('reportHTML', $reportHTML)->set('groupid', $groupId)->fetch('groups.viewdiscussion');
 }
Пример #12
0
				<td>
					<a class="subject" href="<?php 
    echo CRoute::_('index.php?option=com_community&view=inbox&task=read&msgid=' . $message->parent);
    ?>
">
						<img src="<?php 
    echo JURI::root();
    ?>
components/com_community/templates/default/images/new.gif"  style="vertical-align:middle" />						
						<?php 
    echo $message->subject;
    ?>
					</a>
					<div class="small">
					    <?php 
    echo $this->escape($message->from_name);
    ?>
, 
						<?php 
    $postdate = CTimeHelper::getDate($message->posted_on);
    echo $postdate->toFormat('%d %b %Y, %I:%M %p');
    ?>
					</div>
				</td>
		    </tr>
		</table>
	</div>
	<?php 
}
?>
</div>
Пример #13
0
?>
" />
                </a>
            </div>
        
            <div class="message-body">
                <div class="bubble-arrow">
                    <div class="bubble-content">
                        <?php 
echo $msg->body;
?>
                        
                        <div class="message-info" style="margin: 10px 0 0;">
                            <span  class="icon-calendar">						
                                <?php 
$postdate = CTimeHelper::getDate($msg->posted_on);
echo $postdate->toFormat('%d %b %Y, %I:%M %p');
?>
                            </span>
                            <span class="icon-user">
                                <a href="<?php 
echo $authorLink;
?>
">
                                <?php 
echo $user->getDisplayName();
?>
                                </a>
                            </span>
                            <span class="icon-remove">
                                <a href="javascript:jax.call('community', 'inbox,ajaxRemoveMessage', <?php 
Пример #14
0
 function getTotalMessageSent($userId)
 {
     CFactory::load('helpers', 'time');
     $date = CTimeHelper::getDate();
     $db =& $this->getDBO();
     $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote('#__community_msg') . ' AS a ' . 'WHERE a.from=' . $db->Quote($userId) . ' ' . 'AND TO_DAYS(' . $db->Quote($date->toMySQL(true)) . ') - TO_DAYS( DATE_ADD( a.posted_on , INTERVAL ' . $date->getOffset() . ' HOUR ) ) = 0 ' . 'AND a.parent=a.id';
     $db->setQuery($query);
     $count = $db->loadResult();
     return $count;
 }
Пример #15
0
 /**
  * Update the status of current user
  */
 public function ajaxUpdate($message = '')
 {
     $filter = JFilterInput::getInstance();
     $message = $filter->clean($message, 'string');
     $cache = CFactory::getFastCache();
     $cache->clean(array('activities'));
     if (!COwnerHelper::isRegisteredUser()) {
         return $this->ajaxBlockUnregister();
     }
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $objResponse = new JAXResponse();
     //@rule: In case someone bypasses the status in the html, we enforce the character limit.
     $config = CFactory::getConfig();
     if (JString::strlen($message) > $config->get('statusmaxchar')) {
         $message = JHTML::_('string.truncate', $message, $config->get('statusmaxchar'));
     }
     //trim it here so that it wun go into activities stream.
     $message = JString::trim($message);
     $my = CFactory::getUser();
     $status = $this->getModel('status');
     // @rule: Spam checks
     if ($config->get('antispam_akismet_status')) {
         //CFactory::load( 'libraries' , 'spamfilter' );
         $filter = CSpamFilter::getFilter();
         $filter->setAuthor($my->getDisplayName());
         $filter->setMessage($message);
         $filter->setEmail($my->email);
         $filter->setURL(CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
         $filter->setType('message');
         $filter->setIP($_SERVER['REMOTE_ADDR']);
         if ($filter->isSpam()) {
             $objResponse->addAlert(JText::_('COM_COMMUNITY_STATUS_MARKED_SPAM'));
             return $objResponse->sendResponse();
         }
     }
     $status->update($my->id, $message);
     //set user status for current session.
     $today = JFactory::getDate();
     $message2 = empty($message) ? ' ' : $message;
     $my->set('_status', $message2);
     $my->set('_posted_on', $today->toSql());
     $profileid = $jinput->get->get('userid', 0, 'INT');
     //JRequest::getVar('userid' , 0 , 'GET');
     if (COwnerHelper::isMine($my->id, $profileid)) {
         $objResponse->addScriptCall("joms.jQuery('#profile-status span#profile-status-message').html('" . addslashes($message) . "');");
     }
     //CFactory::load( 'helpers' , 'string' );
     // $message		= CStringHelper::escape( $message );
     if (!empty($message)) {
         $act = new stdClass();
         $act->cmd = 'profile.status.update';
         $act->actor = $my->id;
         $act->target = $my->id;
         //CFactory::load( 'helpers' , 'linkgenerator' );
         // @rule: Autolink hyperlinks
         $message = CLinkGeneratorHelper::replaceURL($message);
         // @rule: Autolink to users profile when message contains @username
         $message = CUserHelper::replaceAliasURL($message);
         $privacyParams = $my->getParams();
         $act->title = $message;
         $act->content = '';
         $act->app = 'profile';
         $act->cid = $my->id;
         $act->access = $privacyParams->get('privacyProfileView');
         $act->comment_id = CActivities::COMMENT_SELF;
         $act->comment_type = 'profile.status';
         $act->like_id = CActivities::LIKE_SELF;
         $act->like_type = 'profile.status';
         //add user points
         //CFactory::load( 'libraries' , 'userpoints' );
         if (CUserPoints::assignPoint('profile.status.update')) {
             //only assign act if user points is set to true
             CActivityStream::add($act);
         }
         //now we need to reload the activities streams (since some report regarding update status from hello me we disabled update the stream, cuz hellome usually called  out from jomsocial page)
         $friendsModel = CFactory::getModel('friends');
         $memberSince = CTimeHelper::getDate($my->registerDate);
         $friendIds = $friendsModel->getFriendIds($my->id);
         //include_once(JPATH_COMPONENT .'/libraries/activities.php');
         $act = new CActivityStream();
         $params = $my->getParams();
         $limit = !empty($params) ? $params->get('activityLimit', '') : '';
         //$html	= $act->getHTML($my->id, $friendIds, $memberSince, $limit );
         $status = $my->getStatus();
         $status = str_replace(array("\r\n", "\n", "\r"), "", $status);
         $status = addslashes($status);
         // also update hellome module if available
         $script = "joms.jQuery('.joms-js--mod-hellome-label').html('" . $status . "');";
         $script .= "joms.jQuery('.joms-js--mod-hellome-loading').hide();";
         $objResponse->addScriptCall($script);
     }
     return $objResponse->sendResponse();
 }
Пример #16
0
        protected function _getTwitterHTML($userId)
        {
            $this->loadUserParams();
            $my = CFactory::getUser($userId);
            $this->userparams = $my->getAppParams($this->_name);
            $showFriends = $this->userparams->get('showFriends', false);
            $oauth = JTable::getInstance('Oauth', 'CTable');
            $loaded = $oauth->load($my->id, 'twitter');
            $accesstoken = unserialize($oauth->accesstoken);
            ob_start();
            if ($loaded && !is_null($accesstoken) && !empty($accesstoken)) {
                $client = new tmhOAuth(self::getConfiguration());
                $timeline = $showFriends ? 'home' : 'user';
                $count = $this->userparams->get('count', 5);
                //echo $timeline;die();
                // get user info/
                $code = $client->request('GET', $client->url($this->users['show']), array('screen_name' => $accesstoken['screen_name']));
                if ($code == 200) {
                    $userinfo = json_decode($client->response['response']);
                    // get tweets
                    $code = $client->request('GET', $client->url($this->timelines[$timeline]), array('count' => $count, 'screen_name' => $userinfo->screen_name));
                    if ($code == 200) {
                        $data = json_decode($client->response['response']);
                    } else {
                        $data = null;
                    }
                } else {
                    $userinfo = null;
                }
                if (!$userinfo) {
                    ?>
                    <div><?php 
                    echo JText::_('PLG_TWITTER_UNABLE_TO_CONTACT_SERVER');
                    ?>
</div>
                    <?php 
                } else {
                    ?>
                    <div id="application-twitter">

                            <div class="joms-stream__header">
                                <div class="joms-avatar--stream">
                                    <a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank" class="joms-avatar">
                                    <img src="<?php 
                    echo $userinfo->profile_image_url;
                    ?>
" alt="<?php 
                    echo $userinfo->screen_name;
                    ?>
"/>
                                    </a>
                                </div>
                                <!--start twitter post-->
                                <div class="joms-stream__meta ">
                                    <a href="http://twitter.com/<?php 
                    echo $userinfo->screen_name;
                    ?>
" target="blank" class="cThumb-Title"><?php 
                    echo $userinfo->name;
                    ?>
</a>
                                    <span class="joms-block"><?php 
                    echo $userinfo->statuses_count;
                    ?>
 tweets, <?php 
                    echo $userinfo->followers_count;
                    ?>
 followers</span>
                                    <small><?php 
                    echo $userinfo->description;
                    ?>
</small>
                                </div>
                                <!--end twitter post-->
                            </div>
                            <div class="joms-gap"></div>
                            <?php 
                    if (is_object($data)) {
                        if (isset($data->error)) {
                            echo $data->error;
                        }
                    } else {
                        //CFactory::load( 'helpers' , 'linkgenerator' );
                        for ($i = 0; $i < count($data); $i++) {
                            $tweet = $data[$i];
                            //$date   = cGetDate($tweet->created_at); //JFactory::getDate( $tweet->created_at );
                            $date = CTimeHelper::getDate($tweet->created_at);
                            $text = CLinkGeneratorHelper::replaceURL($tweet->text, true, true);
                            $text = $this->replaceAliasURL($text);
                            ?>
                                    <div class="joms-stream__header">
                                        <?php 
                            if ($i == 0 && $showFriends || $showFriends) {
                                ?>
                                            <div class="joms-avatar--stream">
                                                <a href="http://twitter.com/<?php 
                                echo $tweet->user->screen_name;
                                ?>
" target="blank" ><img src="<?php 
                                echo $tweet->user->profile_image_url;
                                ?>
" alt="<?php 
                                echo $tweet->user->screen_name;
                                ?>
"></a>
                                            </div>
                                        <?php 
                            }
                            ?>
                                        <div class="joms-stream__meta">
                                            <?php 
                            echo CStringHelper::formatLinks($text);
                            ?>
                                            <div class="small joms-text--light"><?php 
                            echo $date->format(JText::_('DATE_FORMAT_LC2'));
                            ?>
</div>
                                        </div>
                                        <!--twitter avatar-->
                                    </div>
                                    <div class="joms-gap"></div>
                                    <?php 
                        }
                    }
                    ?>

                    </div>

                    <?php 
                }
            } else {
                ?>
                <!-- <div class="icon-nopost">
                        <img src="<?php 
                echo JURI::base();
                ?>
components/com_community/assets/error.gif" alt="" />
                </div> -->
                <div class="content-nopost">
                    <?php 
                echo JText::_('PLG_TWITTER_NOT_UPDATES');
                ?>
                </div>
                <?php 
            }
            $html = ob_get_contents();
            ob_end_clean();
            return $html;
        }
Пример #17
0
 /**
  * Return newsfeed html block
  */
 function _getNewsfeedHTML()
 {
     jimport('joomla.utilities.date');
     $mainframe =& JFactory::getApplication();
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     //$user 			= CFactory::getActiveProfile();
     $userid = JRequest::getVar('userid', $my->id);
     $user = CFactory::getUser($userid);
     $params =& $user->getParams();
     $activities = CFactory::getModel('activities');
     $appModel = CFactory::getModel('apps');
     $friendsModel = CFactory::getModel('friends');
     $html = '';
     $activityLimit = !empty($params) ? $params->get('activityLimit', '') : '';
     if (empty($activityLimit)) {
         $activityLimit = $config->get('maxactivities');
     }
     $memberSince = CTimeHelper::getDate($user->registerDate);
     $friendIds = $friendsModel->getFriendIds($user->id);
     include_once JPATH_COMPONENT . DS . 'libraries' . DS . 'activities.php';
     $act = new CActivityStream();
     return $act->getHTML($user->id, $friendIds, $memberSince, $activityLimit, '', '');
 }
Пример #18
0
						<img src="<?php 
        echo $user->getThumbAvatar();
        ?>
" alt="<?php 
        echo $user->getDisplayName();
        ?>
" data-author="<?php 
        echo $user->id;
        ?>
" />
					</a>
				</div>
				<div class="joms-stream__meta">
					<div class="joms-stream__time">
						<small><?php 
        echo CTimeHelper::timeLapse(CTimeHelper::getDate($row->created));
        ?>
</small>
					</div>
				</div>
			</div>
			<div class="joms-stream__body">
				<div class="cStream-Headline"><?php 
        $content = CContentHelper::injectTags($row->content, $row->params, true);
        if ($isPhotoModal && $row->cmd_type == 'notif_photos_like') {
            preg_match_all('/(albumid|photoid)=(\\d+)/', $content, $matches);
            // Get albumid and photoid.
            $albumid = false;
            $photoid = false;
            foreach ($matches[1] as $index => $varname) {
                if ($varname == 'albumid') {
Пример #19
0
/**
 * Deprecated since 1.8
 * Use CTimeHelper::getDate instead. 
 */
function cGetDate($str = '')
{
    return CTimeHelper::getDate($str);
}
Пример #20
0
 /**
  * Returns an object of events which the user has registered.
  *
  * @access	public
  * @param	string 	User's id.
  * @param	string 	sorting criteria.
  * @returns array  An objects of event fields.
  */
 function getEvents($categoryId = null, $userId = null, $sorting = null, $search = null, $hideOldEvent = true, $showOnlyOldEvent = false, $pending = null, $advance = null, $type = CEventHelper::ALL_TYPES, $contentid = 0, $limit = null)
 {
     $db =& $this->getDBO();
     $join = '';
     $extraSQL = '';
     if (!empty($userId)) {
         $join = 'LEFT JOIN ' . $db->nameQuote('#__community_events_members') . ' AS b ON a.id=b.eventid ';
         $extraSQL .= ' AND b.memberid=' . $db->Quote($userId);
     }
     if (!empty($search)) {
         $extraSQL .= ' AND a.title LIKE ' . $db->Quote('%' . $search . '%');
     }
     if (!empty($categoryId) && $categoryId != 0) {
         $extraSQL .= ' AND a.catid=' . $db->Quote($categoryId);
     }
     if (!is_null($pending) && !empty($userId)) {
         $extraSQL .= ' AND b.status=' . $db->Quote($pending);
     }
     /* Begin : ADVANCE SEARCH */
     if (!empty($advance)) {
         if (!empty($advance['startdate'])) {
             $startDate = CTimeHelper::getDate(strtotime($advance['startdate']));
             $extraSQL .= ' AND a.startdate >= ' . $db->Quote($startDate->toMySQL());
         } else {
             $now = CTimeHelper::getDate();
             $extraSQL .= ' AND a.startdate >= ' . $db->Quote($now->toMySQL());
         }
         if (!empty($advance['enddate'])) {
             $endDate = CTimeHelper::getDate(strtotime($advance['enddate']));
             $extraSQL .= ' AND a.startdate <= ' . $db->Quote($endDate->toMySQL());
         }
         /* Begin : SEARCH WITHIN */
         if (!empty($advance['radius']) && !empty($advance['fromlocation'])) {
             $longitude = null;
             $latitude = null;
             CFactory::load('libraries', 'mapping');
             $data = CMapping::getAddressData($advance['fromlocation']);
             if ($data) {
                 if ($data->status == 'OK') {
                     $latitude = (double) $data->results[0]->geometry->location->lat;
                     $longitude = (double) $data->results[0]->geometry->location->lng;
                 }
             }
             $now = new JDate();
             $lng_min = $longitude - $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
             $lng_max = $longitude + $advance['radius'] / abs(cos(deg2rad($latitude)) * 69);
             $lat_min = $latitude - $advance['radius'] / 69;
             $lat_max = $latitude + $advance['radius'] / 69;
             $extraSQL .= ' AND a.longitude > ' . $db->quote($lng_min) . ' AND a.longitude < ' . $db->quote($lng_max) . ' AND a.latitude > ' . $db->quote($lat_min) . ' AND a.latitude < ' . $db->quote($lat_max);
         }
         /* End : SEARCH WITHIN */
     }
     /* End : ADVANCE SEARCH */
     $limitstart = $this->getState('limitstart');
     $limit = $limit === null ? $this->getState('limit') : $limit;
     if ($type != CEventHelper::ALL_TYPES) {
         $extraSQL .= ' AND a.type=' . $db->Quote($type);
         $extraSQL .= ' AND a.contentid=' . $contentid;
     }
     if ($type == CEventHelper::GROUP_TYPE || $type == CEventHelper::ALL_TYPES) {
         // @rule: Respect group privacy
         $join .= ' LEFT JOIN ' . $db->nameQuote('#__community_groups') . ' AS g';
         $join .= ' ON g.id = a.contentid ';
         if ($type != CEventHelper::GROUP_TYPE) {
             $extraSQL .= ' AND (g.approvals = 0 OR g.approvals IS NULL';
             if (!empty($userId)) {
                 $extraSQL .= ' OR b.memberid=' . $db->Quote($userId);
             }
             $extraSQL .= ')';
         }
     }
     $orderBy = '';
     $total = 0;
     switch ($sorting) {
         case 'latest':
             if (empty($orderBy)) {
                 $orderBy = ' ORDER BY a.created DESC';
             }
             break;
         case 'alphabetical':
             if (empty($orderBy)) {
                 $orderBy = ' ORDER BY a.title ASC';
             }
             break;
         case 'startdate':
         default:
             $orderBy = ' ORDER BY a.startdate ASC';
             break;
     }
     $now = new JDate();
     if ($hideOldEvent && $type != CEventHelper::GROUP_TYPE) {
         $extraSQL .= ' AND a.enddate > ' . $db->Quote($now->toMySQL());
     }
     if ($showOnlyOldEvent) {
         $extraSQL .= ' AND a.enddate < ' . $db->Quote($now->toMySQL());
     }
     $limit = empty($limit) ? 0 : $limit;
     $query = 'SELECT DISTINCT a.* FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.published=' . $db->Quote('1') . $extraSQL . $orderBy . ' LIMIT ' . $limitstart . ', ' . $limit;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $query = 'SELECT COUNT(DISTINCT(a.`id`)) FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.published=' . $db->Quote('1') . $extraSQL;
     $db->setQuery($query);
     $this->total = $db->loadResult();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $query = 'SELECT COUNT(DISTINCT(a.`id`)) FROM ' . $db->nameQuote('#__community_events') . ' AS a ' . $join . 'WHERE a.published=' . $db->Quote('1') . ' ' . $extraSQL;
     $db->setQuery($query);
     $total = $db->loadResult();
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     if (empty($this->_pagination)) {
         jimport('joomla.html.pagination');
         $this->_pagination = new JPagination($total, $limitstart, $limit);
     }
     return $result;
 }
Пример #21
0
<?php

/**
 * @package		JomSocial
 * @subpackage 	Template 
 * @copyright (C) 2008 by Slashes & Dots Sdn Bhd - All rights reserved!
 * @license		GNU/GPL, see LICENSE.php
 * 
 * @param	friends		array or CUser (all user)
 * @param	total		integer total number of friends  
 */
defined('_JEXEC') or die;
$jnow = CTimeHelper::getDate();
?>

<div id="writeMessageContainer">
	<form name="jsform-inbox-ajaxcompose" method="post" action="" name="writeMessageForm" id="writeMessageForm">
		<table class="cWindowForm">
			<tr>
				<td class="cWindowFormKey"><label class="label"><?php 
echo JText::_('CC COMPOSE TO');
?>
</td>
				<td class="cWindowFormVal">
				    <table cellpadding="0" cellspacing="0" border="0" width="100%" class="receiverContainer">
						<tr>
						    <td style="padding: 0; width: 40px;">
						    	<div>
									<img src="<?php 
echo $user->getThumbAvatar();
?>
Пример #22
0
 /**
  *
  * @param type $filter
  * @param type $userId
  * @param type $view
  * @param type $showMore
  * @return type 
  */
 public function getActivitiesByFilter($filter = 'all', $userId = 0, $view = '', $showMore = true)
 {
     $config = CFactory::getConfig();
     $act = new CActivityStream();
     if ($userId == 0) {
         // Legacy code, some module might still use the old code
         $user = CFactory::getRequestUser();
     } else {
         $user = CFactory::getUser($userId);
     }
     jimport('joomla.utilities.date');
     $friendsModel = CFactory::getModel('friends');
     $memberSince = CTimeHelper::getDate($user->registerDate);
     //$friendIds = $friendsModel->getFriendIds($user->id);
     $friendIds = $user->getFriendIds();
     switch ($filter) {
         case "active-profile":
             $target = array($user->id);
             $params =& $user->getParams();
             $actLimit = $view == 'profile' ? $params->get('activityLimit', $config->get('maxactivities')) : $config->get('maxactivities');
             $html = $act->getHTML($user->id, $target, '', $actLimit, $view, '', true, $showMore, null, false, 'active-profile');
             break;
         case "me-and-friends":
             $user =& JFactory::getUser();
             $html = $act->getHTML($user->id, $friendIds, $memberSince, 0, $view, '', true, $showMore, null, false, 'me-and-friends');
             break;
         case "active-user-and-friends":
         case "active-profile-and-friends":
             $params =& $user->getParams();
             $actLimit = $view == 'profile' ? $params->get('activityLimit', $config->get('maxactivities')) : $config->get('maxactivities');
             $html = $act->getHTML($user->id, $friendIds, $memberSince, $actLimit, $view, '', true, $showMore, null, false, 'active-profile-and-friends');
             break;
         case "all":
         default:
             $html = $act->getHTML('', '', null, 0, $view, '', true, $showMore);
             break;
     }
     return $html;
 }
Пример #23
0
 /**
  * AJAX method to add predefined activity
  **/
 public function ajaxAddPredefined($key, $message = '')
 {
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     $filter = JFilterInput::getInstance();
     $key = $filter->clean($key, 'string');
     $message = $filter->clean($message, 'string');
     CFactory::load('libraries', 'activities');
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isCommunityAdmin()) {
         return;
     }
     // Predefined system custom activity.
     $system = array('system.registered', 'system.populargroup', 'system.totalphotos', 'system.popularprofiles', 'system.popularphotos', 'system.popularvideos');
     $act = new stdClass();
     $act->actor = $my->id;
     $act->target = 0;
     $act->app = 'system';
     $act->access = PRIVACY_FORCE_PUBLIC;
     $params = new CParameter('');
     if (in_array($key, $system)) {
         switch ($key) {
             case 'system.registered':
                 CFactory::load('helpers', 'time');
                 $usersModel = CFactory::getModel('user');
                 $now = new JDate();
                 $date = CTimeHelper::getDate();
                 $title = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $usersModel->getTotalRegisteredByMonth($now->toFormat('%Y-%m')), $date->_monthToString($now->toFormat('%m')));
                 $act->cmd = 'system.registered';
                 $act->title = $title;
                 $act->content = '';
                 break;
             case 'system.populargroup':
                 $groupsModel = CFactory::getModel('groups');
                 $activeGroup = $groupsModel->getMostActiveGroup();
                 $title = JText::sprintf('COM_COMMUNITY_MOST_POPULAR_GROUP_ACTIVITY_TITLE', $activeGroup->name);
                 $params->set('action', 'groups.join');
                 $params->set('group_url', CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $activeGroup->id));
                 $act->cmd = 'groups.popular';
                 $act->cid = $activeGroup->id;
                 $act->title = $title;
                 break;
             case 'system.totalphotos':
                 $photosModel = CFactory::getModel('photos');
                 $total = $photosModel->getTotalSitePhotos();
                 $params->set('photos_url', CRoute::_('index.php?option=com_community&view=photos'));
                 $act->cmd = 'photos.total';
                 $act->title = JText::sprintf('COM_COMMUNITY_TOTAL_PHOTOS_ACTIVITY_TITLE', $total);
                 break;
             case 'system.popularprofiles':
                 CFactory::load('libraries', 'tooltip');
                 $act->cmd = 'members.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PROFILES', 5);
                 $params->set('action', 'top_users');
                 $params->set('count', 5);
                 break;
             case 'system.popularphotos':
                 $act->cmd = 'photos.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_PHOTOS', 5);
                 $params->set('action', 'top_photos');
                 $params->set('count', 5);
                 break;
             case 'system.popularvideos':
                 $act->cmd = 'videos.popular';
                 $act->title = JText::sprintf('COM_COMMUNITY_ACTIVITIES_TOP_VIDEOS', 5);
                 $params->set('action', 'top_videos');
                 $params->set('count', 5);
                 break;
         }
     } else {
         // For additional custom activities, we only take the content passed by them.
         if (!empty($message)) {
             CFactory::load('helpers', 'string');
             $message = CStringHelper::escape($message);
             $app = explode('.', $key);
             $app = isset($app[0]) ? $app[0] : 'system';
             $act->title = JText::_($message);
             $act->app = $app;
         }
     }
     $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
     // Allow comments on all these
     $act->comment_id = CActivities::COMMENT_SELF;
     $act->comment_type = $key;
     // Allow like for all admin activities
     $act->like_id = CActivities::LIKE_SELF;
     $act->like_type = $key;
     // Add activity logging
     CActivityStream::add($act, $params->toString());
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $this->_getActivityStream());
     $objResponse->addScriptCall("joms.jQuery('.jomTipsJax').addClass('jomTips');");
     $objResponse->addScriptCall('joms.tooltip.setup();');
     return $objResponse->sendResponse();
 }
Пример #24
0
 /**
  * Popup message notification
  */
 public function ajaxGetInbox()
 {
     $inboxModel = CFactory::getModel('inbox');
     //$messages = $inboxModel->getInbox(false);
     $messages = $inboxModel->getUnReadInbox();
     // format for template
     $data = array();
     foreach ($messages as $row) {
         $user = CFactory::getUser($row->from);
         $obj = new stdClass();
         $obj->user = $user;
         $obj->subject = $row->subject;
         $obj->link = CRoute::_('index.php?option=com_community&view=inbox&task=read&msgid=' . $row->parent);
         $obj->created = CTimeHelper::timeLapse(CTimeHelper::getDate($row->posted_on));
         $data[] = $obj;
     }
     $template = new CTemplate();
     $html = $template->set('rows', $data)->fetch('notification/inbox');
     $json = array('title' => JText::_('COM_COMMUNITY_MESSAGE'), 'html' => $html);
     die(json_encode($json));
 }
Пример #25
0
 /**
  * The default method that will display the output of this view which is called by
  * Joomla
  *
  * @param	string template	Template file name
  **/
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $model = $this->getModel('Activities');
     $activities = $model->getActivities();
     foreach ($activities as $key => $activity) {
         $param = new CParameter($activity->params);
         switch ($activity->app) {
             case 'users.featured':
                 $user = CFactory::getUser($param->get('userid'));
                 $activities[$key]->title = JText::sprintf('COM_COMMUNITY_MEMBER_IS_FEATURED', '<a href="' . CRoute::_(JUri::root() . $param->get('owner_url')) . '" class="cStream-Author">' . $user->getDisplayName() . '</a>');
                 break;
             case 'events.wall':
             case 'groups.wall':
             case 'profile':
                 $user = CFactory::getUser($activity->actor);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ';
                 if ($activity->eventid) {
                     $event = JTable::getInstance('Event', 'cTable');
                     $event->load($activity->eventid);
                     $html .= '➜ <a class="cStream-Reference" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id . '">' . $event->title . '</a>';
                 } elseif ($activity->groupid) {
                     $group = JTable::getInstance('Group', 'cTable');
                     $group->load($activity->groupid);
                     $html .= '➜ <a class="cStream-Reference" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id . '">' . $group->name . '</a>';
                 } elseif (!empty($activity->target) && $activity->target != $activity->actor) {
                     $target = CFactory::getUser($activity->target);
                     $html .= '➜ <a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $target->id . '">' . $target->getDisplayName() . '</a> ';
                     $html .= CActivities::format($activity->title);
                 } else {
                     $html .= ' posted: "' . CActivities::format($activity->title) . '"';
                 }
                 $activities[$key]->title = $html;
                 break;
             case 'groups.avatar.upload':
                 $user = CFactory::getUser($activity->actor);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ';
                 $html .= JText::_('COM_COMMUNITY_ACTIVITIES_NEW_GROUP_AVATAR');
                 $activities[$key]->title = $html;
                 break;
             case 'profile.avatar.upload':
                 $user = CFactory::getUser($activity->actor);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ';
                 $html .= JText::_('COM_COMMUNITY_ACTIVITIES_NEW_AVATAR');
                 $activities[$key]->title = $html;
                 break;
             case 'albums.comment':
             case 'albums':
                 $album = JTable::getInstance('Album', 'CTable');
                 $album->load($activity->cid);
                 $user = CFactory::getUser($activity->actor);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ';
                 $html .= JText::sprintf('COM_COMMUNITY_ACTIVITIES_WALL_POST_ALBUM', CRoute::_($album->getURI()), $this->escape($album->name));
                 $activities[$key]->title = $html;
                 break;
             case 'profile.like':
             case 'groups.like':
             case 'events.like':
             case 'photo.like':
             case 'videos.like':
             case 'album.like':
                 $actors = $param->get('actors');
                 $user = CFactory::getUser($activity->actor);
                 $users = explode(',', $actors);
                 $userCount = count($users);
                 switch ($activity->app) {
                     case 'profile.like':
                         $cid = CFactory::getUser($activity->cid);
                         $urlLink = JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $cid->id;
                         $name = $cid->getDisplayName();
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_PROFILE';
                         break;
                     case 'groups.like':
                         $cid = JTable::getInstance('Group', 'CTable');
                         $cid->load($activity->groupid);
                         $urlLink = JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $cid->id;
                         $name = $cid->name;
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_GROUP';
                         break;
                     case 'events.like':
                         $cid = JTable::getInstance('Event', 'CTable');
                         $cid->load($activity->eventid);
                         $urlLink = JUri::root() . 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $cid->id;
                         $name = $cid->title;
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_EVENT';
                         break;
                     case 'photo.like':
                         $cid = JTable::getInstance('Photo', 'CTable');
                         $cid->load($activity->cid);
                         $urlLink = JUri::root() . 'index.php?option=com_community&view=photos&task=photo&albumid=' . $cid->albumid . '&userid=' . $cid->creator . '&photoid=' . $cid->id;
                         $name = $cid->caption;
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_PHOTO';
                         break;
                     case 'videos.like':
                         $cid = JTable::getInstance('Video', 'CTable');
                         $cid->load($activity->cid);
                         $urlLink = JURI::root() . 'index.php?option=com_community&view=videos&task=video&userid=' . $cid->creator . '&videoid=' . $cid->id;
                         $name = $cid->getTitle();
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_VIDEO';
                         break;
                     case 'album.like':
                         $cid = JTable::getInstance('Album', 'CTable');
                         $cid->load($activity->cid);
                         $urlLink = Juri::root() . 'index.php?option=com_community&view=photos&task=album&albumid=' . $cid->id . '&userid=' . $cid->creator;
                         $name = $cid->name;
                         $element = 'COM_COMMUNITY_STREAM_LIKES_ELEMENT_ALBUM';
                         break;
                 }
                 $slice = 2;
                 if ($userCount > 2) {
                     $slice = 1;
                 }
                 $users = array_slice($users, 0, $slice);
                 $actorsHTML = array();
                 foreach ($users as $actor) {
                     $user = CFactory::getUser($actor);
                     $actorsHTML[] = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>';
                 }
                 $others = '';
                 if ($userCount > 2) {
                     $others = JText::sprintf('COM_COMMUNITY_STREAM_OTHERS_JOIN_GROUP', $userCount - 1);
                 }
                 $jtext = $userCount > 1 ? 'COM_COMMUNITY_STREAM_LIKES_PLURAL' : 'COM_COMMUNITY_STREAM_LIKES_SINGULAR';
                 $activities[$key]->title = implode(' ' . JText::_('COM_COMMUNITY_AND') . ' ', $actorsHTML) . $others . JText::sprintf($jtext, $urlLink, $name, JText::_($element));
                 break;
             case 'cover.upload':
                 $user = CFactory::getUser($activity->actor);
                 $type = $param->get('type');
                 $extraMessage = '';
                 if (strtolower($type) !== 'profile') {
                     $id = strtolower($type . 'id');
                     $cTable = JTable::getInstance(ucfirst($type), 'CTable');
                     $cTable->load($activity->{$id});
                     if ($type == 'group') {
                         $extraMessage = ', <a target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $cTable->id . '">' . $cTable->name . '</a>';
                     }
                     if ($type == 'event') {
                         $extraMessage = ', <a target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $cTable->id . '">' . $cTable->title . '</a>';
                     }
                 }
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ';
                 if ($type == 'profile') {
                     $html .= JText::_('COM_COMMUNITY_PHOTOS_COVER_UPLOAD_PROFILE');
                 } else {
                     $html .= JText::sprintf('COM_COMMUNITY_PHOTOS_COVER_UPLOAD', strtolower(Jtext::_('COM_COMMUNITY_COVER_' . strtoupper($type)))) . $extraMessage;
                 }
                 $activities[$key]->title = $html;
                 break;
             case 'events.attend':
             case 'events':
                 $user = CFactory::getUser($activity->actor);
                 $action = $param->get('action');
                 $event = JTable::getInstance('Event', 'CTable');
                 $event->load($activity->eventid);
                 switch ($action) {
                     case 'events.create':
                         $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> -';
                         $html .= JText::sprintf('COM_COMMUNITY_EVENTS_ACTIVITIES_NEW_EVENT', JUri::root() . 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, $event->title);
                         $activities[$key]->title = $html;
                         break;
                     case 'events.attendence.attend':
                         $users = explode(',', $param->get('actors'));
                         $actorsHTML = array();
                         foreach ($users as $actor) {
                             if (!$actor) {
                                 $actor = $activity->actor;
                             }
                             $user = CFactory::getUser($actor);
                             $actorsHTML[] = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>';
                         }
                         $activities[$key]->title = implode(', ', $actorsHTML) . ' - ' . JText::sprintf('COM_COMMUNITY_ACTIVITIES_EVENT_ATTEND', JUri::root() . 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, $event->title);
                         break;
                 }
                 break;
             case 'friends.connect':
                 $user1 = CFactory::getUser($activity->actor);
                 $user2 = CFactory::getUser($activity->target);
                 $html = JText::sprintf('COM_COMMUNITY_STREAM_OTHER_FRIENDS', $user1->getDisplayName(), $user2->getDisplayName(), JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user1->id, JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user2->id);
                 $activities[$key]->title = $html;
                 break;
             case 'groups.bulletin':
                 $user = CFactory::getUser($activity->actor);
                 $bulletin = JTable::getInstance('Bulletin', 'CTable');
                 $bulletin->load($activity->cid);
                 $group = JTable::getInstance('Group', 'CTable');
                 $group->load($bulletin->groupid);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>' . JText::sprintf('COM_COMMUNITY_GROUPS_NEW_GROUP_NEWS', CRoute::_(JUri::root() . 'index.php?option=com_community&view=groups&task=viewbulletin&groupid=' . $group->id . '&bulletinid=' . $bulletin->id), $bulletin->title);
                 $activities[$key]->title = $html;
                 break;
             case 'groups.discussion':
                 $user = CFactory::getUser($activity->actor);
                 $discussion = JTable::getInstance('Discussion', 'CTable');
                 $discussion->load($activity->cid);
                 $discussionLink = CRoute::_(JUri::root() . 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>' . JText::sprintf('COM_COMMUNITY_GROUPS_NEW_GROUP_DISCUSSION', $discussionLink, $discussion->title);
                 $activities[$key]->title = $html;
                 break;
             case 'groups.discussion.reply':
                 $user = CFactory::getUser($activity->actor);
                 $discussion = JTable::getInstance('Discussion', 'CTable');
                 $discussion->load($activity->cid);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>' . JText::sprintf('COM_COMMUNITY_GROUPS_REPLY_DISCUSSION', CRoute::_(JUri::root() . 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id), $discussion->title);
                 $activities[$key]->title = $html;
                 break;
             case 'groups.join':
                 $user = CFactory::getUser($activity->actor);
                 $users = explode(',', $param->get('actors'));
                 $userCount = count($users);
                 $group = JTable::getInstance('Group', 'CTable');
                 $group->load($activity->cid);
                 $slice = 2;
                 if ($userCount > 2) {
                     $slice = 1;
                 }
                 $users = array_slice($users, 0, $slice);
                 $actorsHTML = array();
                 foreach ($users as $actor) {
                     $user = CFactory::getUser($actor);
                     $actorsHTML[] = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>';
                 }
                 $others = '';
                 if ($userCount > 2) {
                     $others = JText::sprintf('COM_COMMUNITY_STREAM_OTHERS_JOIN_GROUP', $userCount - 1);
                 }
                 $html = implode(' ' . JText::_('COM_COMMUNITY_AND') . ' ', $actorsHTML) . $others . JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_JOIN', JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, $group->name);
                 $activities[$key]->title = $html;
                 break;
             case 'groups.update':
                 $user = CFactory::getUser($activity->actor);
                 $group = JTable::getInstance('Group', 'CTable');
                 $group->load($activity->cid);
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> - ' . JText::sprintf('COM_COMMUNITY_GROUPS_GROUP_UPDATED', JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id, $group->name);
                 $activities[$key]->title = $html;
                 break;
             case 'photos':
                 $user = CFactory::getUser($activity->actor);
                 $album = JTable::getInstance('Album', 'CTable');
                 $album->load($activity->cid);
                 $html = '';
                 if ($activity->groupid) {
                     $group = JTable::getInstance('Group', 'CTable');
                     $group->load($activity->groupid);
                     $html .= '<a class="cStream-Reference" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id . '">' . $group->name . '</a> -';
                 }
                 $html .= ' <a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a>';
                 $count = $param->get('count', 1);
                 $url = Juri::root() . 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $user->id;
                 if (CStringHelper::isPlural($count)) {
                     $html .= JText::sprintf('COM_COMMUNITY_ACTIVITY_PHOTO_UPLOAD_TITLE_MANY', $count, $url, CStringHelper::escape($album->name));
                 } else {
                     $html .= JText::sprintf('COM_COMMUNITY_ACTIVITY_PHOTO_UPLOAD_TITLE', $url, CStringHelper::escape($album->name));
                 }
                 $activities[$key]->title = $html;
                 break;
             case 'photos.comment':
                 $user = CFactory::getUser($activity->actor);
                 $wall = JTable::getInstance('Wall', 'CTable');
                 $wall->load($param->get('wallid'));
                 $photo = JTable::getInstance('Photo', 'CTable');
                 $photo->load($activity->cid);
                 $url = JUri::root() . 'index.php?option=com_community&view=photos&task=photo&albumid=' . $photo->albumid . '&userid=' . $photo->creator . '&photoid=' . $photo->id;
                 $html = '<a class="cStream-Author" target="_blank" href="' . JUri::root() . 'index.php?option=com_community&view=profile&userid=' . $user->id . '">' . $user->getDisplayName() . '</a> ' . JText::sprintf('COM_COMMUNITY_ACTIVITIES_WALL_POST_PHOTO', $url, $this->escape($photo->caption));
                 $activities[$key]->title = $html;
                 break;
             case 'system.message':
             case 'system.videos.popular':
             case 'system.photos.popular':
             case 'system.members.popular':
             case 'system.photos.total':
             case 'system.groups.popular':
             case 'system.members.registered':
                 $action = $param->get('action');
                 switch ($action) {
                     case 'registered_users':
                         $usersModel = CFactory::getModel('user');
                         $now = new JDate();
                         $date = CTimeHelper::getDate();
                         $users = $usersModel->getLatestMember(10);
                         $totalRegistered = count($users);
                         $title = JText::sprintf('COM_COMMUNITY_TOTAL_USERS_REGISTERED_THIS_MONTH_ACTIVITY_TITLE', $totalRegistered, $date->monthToString($now->format('%m')));
                         $activities[$key]->title = $title;
                         break;
                     case 'total_photos':
                         $photosModel = CFactory::getModel('photos');
                         $total = $photosModel->getTotalSitePhotos();
                         $activities[$key]->title = JText::sprintf('COM_COMMUNITY_TOTAL_PHOTOS_ACTIVITY_TITLE', CRoute::_(JURI::root() . 'index.php?option=com_community&view=photos'), $total);
                         break;
                     case 'top_videos':
                         $activities[$key]->title = JText::_('COM_COMMUNITY_ACTIVITIES_TOP_VIDEOS');
                         break;
                     case 'top_photos':
                         $activities[$key]->title = JText::_('COM_COMMUNITY_ACTIVITIES_TOP_PHOTOS');
                         break;
                     case 'top_users':
                         $activities[$key]->title = JText::_('COM_COMMUNITY_ACTIVITIES_TOP_MEMBERS');
                         break;
                     case 'top_groups':
                         $groupsModel = $this->getModel('groups');
                         $activeGroup = $groupsModel->getMostActiveGroup();
                         if (is_null($activeGroup)) {
                             $title = JText::_('COM_COMMUNITY_GROUPS_NONE_CREATED');
                         } else {
                             $title = JText::sprintf('COM_COMMUNITY_MOST_POPULAR_GROUP_ACTIVITY_TITLE', CRoute::_(JUri::root() . 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $activeGroup->id), $activeGroup->name);
                         }
                         $activities[$key]->title = $title;
                         break;
                     case 'message':
                         break;
                 }
                 break;
             case 'videos.linking':
             case 'videos':
                 $video = JTable::getInstance('Video', 'CTable');
                 $video->load($activity->cid);
                 $actor = CFactory::getUser($activity->actor);
                 $html = $this->_getUserLink($activity->actor);
                 $html .= JText::sprintf('COM_COMMUNITY_ACTIVITY_VIDEO_SHARE_TITLE', JUri::root() . $video->getViewURI(false), $this->escape($video->title));
                 $activities[$key]->title = $html;
                 break;
             case 'videos.featured':
                 $video = JTable::getInstance('Video', 'CTable');
                 $video->load($activity->cid);
                 $activities[$key]->title = JText::sprintf('COM_COMMUNITY_VIDEOS_IS_FEATURED', '<a href="' . CRoute::_(JUri::root() . 'index.php?option=com_community&view=videos&task=video&userid=' . $video->creator . '&videoid=' . $video->id) . '" class="cStream-Title">' . $this->escape($video->title) . '</a>');
                 break;
             case 'albums.featured':
                 $album = JTable::getInstance('Album', 'CTable');
                 $album->load($activity->cid);
                 $activities[$key]->title = JText::sprintf('COM_COMMUNITY_ALBUM_IS_FEATURED', '<a href="' . CRoute::_(JUri::root() . 'index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $album->creator) . '" class="cStream-Title">' . $this->escape($album->name) . '</a>');
                 break;
         }
     }
     //exit;
     $userModel = $this->getModel('Users', false);
     $currentUser = $jinput->request->get('actor', JText::_('COM_COMMUNITY_ACTIVITIES_ENTER_NAME_VALUE'), 'NONE');
     $currentArchived = $jinput->request->get('archived', 0, 'NONE');
     $currentApp = $jinput->request->get('app', 'none', 'NONE');
     $filterApps = $model->getFilterApps();
     $this->assignRef('filterApps', $filterApps);
     $this->assignRef('currentApp', $currentApp);
     $this->assignRef('currentUser', $currentUser);
     $this->assignRef('currentArchive', $currentArchived);
     $this->assignRef('pagination', $model->getPagination());
     $this->assignRef('activities', $activities);
     parent::display($tpl);
 }
Пример #26
0
 private function groupActivitiesMigrate()
 {
     $db = JFactory::getDBO();
     /* To check what is the version of jomsocial for current db */
     $query = 'SELECT * FROM ' . $db->quoteName('#__community_activities') . ' WHERE ' . $db->quoteName('params') . ' LIKE ' . $db->Quote('%group.wall.create%') . ' AND ' . $db->quoteName('params') . ' LIKE ' . $db->Quote('%groupid=' . $this->id . '%');
     $db->setQuery($query);
     $results = $db->loadobjectList();
     if (!empty($results)) {
         // format : wall_activity_match['activity id'] = wall id
         $wall_activity_match = array();
         // this is used to match id from activities with wall id
         foreach ($results as &$result) {
             // update the info
             $result = (array) $result;
             //change content to title
             $result['title'] = $result['content'];
             $result['content'] = '';
             //empty content after assigned to title
             $wall_activity_match[$result['id']] = $result['comment_id'];
             //getting the group id out from the param
             $decoded_params = (array) json_decode($result['params']);
             //explode('=',$result['params']);
             if (isset($decoded_params['group_url'])) {
                 $group_url = $decoded_params['group_url'];
                 $group_url_arr = explode('=', $group_url);
             } else {
                 $group_url_arr = explode('=', $result['params']);
             }
             $group_id = $group_url_arr[count($group_url_arr) - 1];
             $result['groupid'] = $group_id;
             // set group id
             $result['target'] = $group_id;
             // set target as group id
             $result['cid'] = $group_id;
             // set cid as group id
             $result['params'] = '';
             //empty params
             $result['like_id'] = $result['id'];
             // set like_id as id
             $result['comment_id'] = $result['id'];
             // set comment id to the current row id
             $result['eventid'] = 0;
             $result['like_type'] = 'groups.wall';
             $result['comment_type'] = 'groups.wall';
         }
         //echo '> Start to convert 2.2.x activities table<br/>';
         //echo '2.2.x has '.count($results).' activities to be converted.<br/>';
         // Lets update the converted row into the 2.4 format!
         foreach ($results as $res) {
             $tmp_res = $res;
             unset($tmp_res['created']);
             //created no need to update
             //echo 'Converting activity #'.$res['id'].' -- ';
             $tmp_result = (object) $tmp_res;
             $db->updateObject('#__community_activities', $tmp_result, 'id');
             if ($db->getErrorNum()) {
                 //echo 'Failed <br/>';
             } else {
                 //echo 'Succeed <br/>';
             }
         }
         //echo '> 2.2.x activities table conversion ends<br/><br/><br/>';
         /* lets update the wall content */
         if (!empty($wall_activity_match)) {
             //echo '> Start to convert 2.2.x wall table<br/> ';
             // narrow down the search with array
             $in = implode(',', $wall_activity_match);
             $query = 'SELECT * FROM ' . $db->quoteName('#__community_wall') . ' WHERE ' . $db->quoteName('id') . ' IN (' . $in . ' ) ';
             $db->setQuery($query);
             $results = $db->loadobjectList();
             foreach ($results as $result) {
                 //extract the comments if there is any
                 $pos = strpos($result->comment, '<comment>');
                 if (!$pos) {
                     continue;
                 }
                 list($str, $comments) = explode('<comment>', $result->comment);
                 $comments_arr = json_decode(strip_tags(trim($comments), '</comment>'));
                 //delete this record... optional
                 $activity_id = array_search($result->id, $wall_activity_match);
                 foreach ($comments_arr as $comment) {
                     $dateObject = CTimeHelper::getDate($comment->date);
                     $date = $dateObject->Format('Y-m-d H:i:s');
                     //echo 'Inserting new wall base on wall #'.$result->id.' -- date: '.$date.' == ';
                     $data = array('contentid' => $activity_id, 'post_by' => $comment->creator, 'ip' => '', 'comment' => $comment->text, 'date' => $date, 'published' => 1, 'type' => 'groups.wall');
                     $tmp_data = (object) $data;
                     $db->insertObject('#__community_wall', $tmp_data);
                     if ($db->getErrorNum()) {
                         //echo 'Failed <br/>';
                     } else {
                         //echo 'Succeed <br/>';
                     }
                 }
             }
             //echo '> 2.2.x wall table conversion ends<br/><br/><br/>';
         }
     }
 }
Пример #27
0
 private function getPhotoInfoHeader($photo)
 {
     $date = CTimeHelper::getDate($photo->created);
     $config = CFactory::getConfig();
     $creator = CFactory::getUser($photo->creator);
     if ($config->get('activitydateformat') == 'lapse') {
         $created = CTimeHelper::timeLapse($date);
     } else {
         $created = $date->Format(JText::_('DATE_FORMAT_LC2'));
     }
     $userThumb = CUserHelper::getThumb($creator->id, 'avatar');
     $caption = $photo->caption;
     $template = new CTemplate();
     return $template->set('creator', $creator)->set('permission', $photo->permissions)->set('created', $created)->set('userThumb', $userThumb)->set('caption', $caption)->fetch('wall/info');
 }
Пример #28
0
 public function getGroupUpcomingEvents($userId, $limit = 3)
 {
     $userGroups = $this->getGroupIds($userId);
     $eventsDetails = array();
     $extraSQL = '';
     if ($limit > 0) {
         $extraSQL = ' LIMIT ' . $limit;
     }
     if (count($userGroups) > 0) {
         $groups_id = implode(',', $userGroups);
         $db = $this->getDBO();
         $now = CTimeHelper::getDate();
         $query = "SELECT * FROM " . $db->quoteName('#__community_events') . " WHERE " . $db->quoteName('contentid') . " IN (" . $groups_id . " ) AND\n\t\t\t\t\t((parent = 0 AND  (" . $db->quoteName('repeat') . " IS NULL OR  " . $db->quoteName('repeat') . " =  ''))\n\t\t\t\t\tOR (parent > 0 AND  " . $db->quoteName('repeat') . " IS NOT NULL)) AND " . $db->quoteName('published') . " = 1 AND\n\t\t\t\t\t" . $db->quoteName('type') . " =  'group' AND " . $db->quoteName('enddate') . " >= " . $db->Quote($now->toSql()) . " ORDER by startdate ASC " . $extraSQL;
         $db->setQuery($query);
         $result = $db->loadObjectList();
         if (!empty($result)) {
             foreach ($result as $row) {
                 $event = JTable::getInstance('Event', 'CTable');
                 $event->bind($row);
                 $eventsDetails[] = $event;
             }
         }
     }
     return $eventsDetails;
 }
Пример #29
0
 public static function _getWallHTML($wall, $wallComments, $appType, $isOwner, $processFunc, $templateFile, $banned = 0)
 {
     $my = CFactory::getUser();
     $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);
     $commentsHTML = '';
     $comment = new CComment();
     /*
      * @todo 3.3 revise what is this code about
      */
     // If the wall post is a user wall post (in profile pages), we
     // add wall comment feature
     if ($appType == 'user' || $appType == 'groups' || $appType == 'events') {
         if ($banned == 1) {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, false);
         } else {
             $commentsHTML = $comment->getHTML($wallComments, 'wall-cmt-' . $wall->id, CWall::canComment($wall->type, $wall->contentid));
         }
     }
     $avatarHTML = CUserHelper::getThumb($wall->post_by, 'avatar');
     // Change '->created to lapse format if stream uses lapse format'
     if ($config->get('activitydateformat') == 'lapse') {
         $wall->created = CTimeHelper::timeLapse($date);
     } else {
         $wall->created = $date->Format(JText::_('DATE_FORMAT_LC2'), true);
     }
     $wallParam = new CParameter($wall->params);
     $photoThumbnail = '';
     $paramsHTML = '';
     $image = (array) $wallParam->get('image');
     if ($wallParam->get('attached_photo_id') > 0) {
         $photo = JTable::getInstance('Photo', 'CTable');
         $photo->load($wallParam->get('attached_photo_id'));
         $photoThumbnail = $photo->getThumbURI();
     } else {
         if ($wallParam->get('title')) {
             $video = self::detectVideo($wallParam->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-js--comment-preview">';
                 if ($isOwner) {
                     $paramsHTML .= '<span data-action="remove-preview" class="joms-fetched-close" style="top:0;right:0;left:auto" onclick="joms.api.commentRemovePreview(\'' . $wall->id . '\');"><i class="joms-icon-remove"></i></span>';
                 }
                 if ($wallParam->get('image')) {
                     $paramsHTML .= '<div class="joms-media__thumbnail">';
                     $paramsHTML .= '<a href="' . $wallParam->get('link') ? $wallParam->get('link') : '#' . '">';
                     $paramsHTML .= '<img src="' . array_shift($image) . '" />';
                     $paramsHTML .= '</a>';
                     $paramsHTML .= '</div>';
                 }
                 $url = $wallParam->get('url') ? $wallParam->get('url') : '#';
                 $paramsHTML .= '<div class="joms-media__body">';
                 $paramsHTML .= '<h4 class="joms-media__title"><a href="' . $url . '">' . $wallParam->get('title') . '</a></h4>';
                 $paramsHTML .= '<p class="joms-media__desc">' . CStringHelper::trim_words($wallParam->get('description')) . '</p>';
                 if ($wallParam->get('link')) {
                     $paramsHTML .= '<cite>' . preg_replace('#^https?://#', '', $wallParam->get('link')) . '</cite>';
                 }
                 $paramsHTML .= '</div></div>';
             }
         }
     }
     $CComment = new CComment();
     $wall->originalComment = $wall->comment;
     $wall->comment = $CComment->stripCommentData($wall->comment);
     $CTemplate = new CTemplate();
     $wall->comment = CStringHelper::autoLink($wall->comment);
     $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
     $canDelete = $my->authorise('community.delete', 'walls', $wall);
     $like = new CLike();
     $likeCount = $like->getLikeCount('comment', $wall->id);
     $isLiked = $like->userLiked('comment', $wall->id, $my->id) == COMMUNITY_LIKE;
     // Create new instance of the template
     $tmpl = new CTemplate();
     return $tmpl->set('id', $wall->id)->set('author', $user->getDisplayName())->set('avatarHTML', $avatarHTML)->set('authorLink', CUrlHelper::userLink($user->id))->set('created', $wall->created)->set('content', $wall->comment)->set('commentsHTML', $commentsHTML)->set('avatar', $user->getThumbAvatar())->set('isMine', $isOwner)->set('canDelete', $canDelete)->set('isEditable', $isEditable)->set('processFunc', $processFunc)->set('config', $config)->set('photoThumbnail', $photoThumbnail)->set('paramsHTML', $paramsHTML)->set('wall', $wall)->set('likeCount', $likeCount)->set('isLiked', $isLiked)->fetch($templateFile);
 }
Пример #30
0
 /**
  * AJAX method to add predefined activity
  **/
 function ajaxAddPredefined($key, $message = '')
 {
     $objResponse = new JAXResponse();
     $my = CFactory::getUser();
     CFactory::load('helpers', 'owner');
     if (!COwnerHelper::isCommunityAdmin()) {
         return;
     }
     // Predefined system custom activity.
     $system = array('system.registered', 'system.populargroup', 'system.totalphotos', 'system.popularprofiles', 'system.popularphotos', 'system.popularvideos');
     $act = new stdClass();
     $act->actor = $my->id;
     $act->target = 0;
     $act->app = 'system';
     $act->access = PRIVACY_FORCE_PUBLIC;
     $params = '';
     if (in_array($key, $system)) {
         switch ($key) {
             case 'system.registered':
                 CFactory::load('helpers', 'time');
                 $usersModel = CFactory::getModel('user');
                 $date = CTimeHelper::getDate();
                 $title = JText::sprintf('CC TOTAL USERS REGISTERED THIS MONTH ACTIVITY TITLE', $usersModel->getTotalRegisteredByMonth($date->toFormat('%Y-%m')), $date->_monthToString($date->toFormat('%m')));
                 $act->cmd = 'system.registered';
                 $act->title = $title;
                 $act->content = '';
                 break;
             case 'system.populargroup':
                 $groupsModel = CFactory::getModel('groups');
                 $activeGroup = $groupsModel->getMostActiveGroup();
                 $title = JText::sprintf('CC MOST POPULAR GROUP ACTIVITY TITLE', $activeGroup->name);
                 $params = new JParameter('');
                 $params->set('action', 'groups.join');
                 $params->set('group_url', CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $activeGroup->id));
                 $act->cmd = 'groups.popular';
                 $act->cid = $activeGroup->id;
                 $act->title = $title;
                 break;
             case 'system.totalphotos':
                 $photosModel = CFactory::getModel('photos');
                 $total = $photosModel->getTotalSitePhotos();
                 $params = new JParameter('');
                 $params->set('photos_url', CRoute::_('index.php?option=com_community&view=photos'));
                 $act->cmd = 'photos.total';
                 $act->title = JText::sprintf('CC TOTAL PHOTOS ACTIVITY TITLE', $total);
                 break;
             case 'system.popularprofiles':
                 CFactory::load('libraries', 'tooltip');
                 $model = CFactory::getModel('user');
                 $members = $model->getPopularMember(5);
                 $total = count($members);
                 $content = '';
                 $tmpl = new CTemplate();
                 $tmpl->set('members', $members);
                 $content = $tmpl->fetch('activity.members.popular');
                 $act->cmd = 'members.popular';
                 $act->content = $content;
                 $act->title = JText::sprintf('CC ACTIVITIES TOP PROFILES', 5);
                 break;
             case 'system.popularphotos':
                 $model = CFactory::getModel('photos');
                 $photos = $model->getPopularPhotos(5, 0);
                 $tmpl = new CTemplate();
                 $tmpl->set('photos', $photos);
                 $content = $tmpl->fetch('activity.photos.popular');
                 $act->cmd = 'photos.popular';
                 $act->title = JText::sprintf('CC ACTIVITIES TOP PHOTOS', 5);
                 $act->content = $content;
                 break;
             case 'system.popularvideos':
                 $model = CFactory::getModel('videos');
                 $videos = $model->getPopularVideos(5);
                 $tmpl = new CTemplate();
                 $tmpl->set('videos', $videos);
                 $content = $tmpl->fetch('activity.videos.popular');
                 $act->cmd = 'videos.popular';
                 $act->title = JText::sprintf('CC ACTIVITIES TOP VIDEOS', 5);
                 $act->content = $content;
                 break;
         }
     } else {
         // For additional custom activities, we only take the content passed by them.
         if (!empty($message)) {
             $app = explode('.', $key);
             $app = isset($app[0]) ? $app[0] : 'system';
             $act->title = JText::_($message);
             $act->app = $app;
         }
     }
     $this->_addActivity($act, $params);
     $objResponse->addAssign('activity-stream-container', 'innerHTML', $this->_getActivityStream());
     $objResponse->addScriptCall("joms.jQuery('.jomTipsJax').addClass('jomTips');");
     $objResponse->addScriptCall('joms.tooltip.setup();');
     return $objResponse->sendResponse();
 }