public function browse($data = null) { //require_once (JPATH_COMPONENT . '/libraries/template.php'); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_MEMBERS'), ''); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_GROUPS_MEMBERS')); $my = CFactory::getUser(); $view = CFactory::getView('search'); $searchModel = CFactory::getModel('search'); $userModel = CFactory::getModel('user'); $avatar = CFactory::getModel('avatar'); $friends = CFactory::getModel('friends'); $tmpl = new CTemplate(); $sorted = $jinput->get->get('sort', 'latest', 'STRING'); //JRequest::getVar( 'sort' , 'latest' , 'GET' ); $filter = JRequest::getWord('filter', 'all', 'GET'); $profiletype = $jinput->get('profiletype', 0, 'INT'); $rows = $searchModel->getPeople($sorted, $filter, $profiletype); $sortItems = array('online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL')); $filterItems = array(); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $filterItems = array('all' => JText::_('COM_COMMUNITY_JUMP_ALL'), 'abc' => JText::_('COM_COMMUNITY_JUMP_ABC'), 'def' => JText::_('COM_COMMUNITY_JUMP_DEF'), 'ghi' => JText::_('COM_COMMUNITY_JUMP_GHI'), 'jkl' => JText::_('COM_COMMUNITY_JUMP_JKL'), 'mno' => JText::_('COM_COMMUNITY_JUMP_MNO'), 'pqr' => JText::_('COM_COMMUNITY_JUMP_PQR'), 'stu' => JText::_('COM_COMMUNITY_JUMP_STU'), 'vwx' => JText::_('COM_COMMUNITY_JUMP_VWX'), 'yz' => JText::_('COM_COMMUNITY_JUMP_YZ'), 'others' => JText::_('COM_COMMUNITY_JUMP_OTHERS')); } $html = ''; $totalUser = $userModel->getMembersCount(); $resultRows = array(); $alreadyfriend = array(); // No need to pre-load multiple users at once since $searchModel->getPeople // already did for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; $obj = clone $row; $user = CFactory::getUser($row->id); $obj->friendsCount = $user->getFriendCount(); $obj->user = $user; $obj->profileLink = CUrl::build('profile', '', array('userid' => $row->id)); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $connection = $friends->getFriendConnection($my->id, $row->id); $obj->isMyFriend = false; if (!empty($connection)) { if ($connection[0]->connect_from == $my->id) { $obj->isMyFriend = true; } } $obj->addFriend = !$isFriend && $my->id != $row->id ? true : false; if ($obj->addFriend) { $alreadyfriend[$row->id] = $row->id; } $resultRows[] = $obj; } $featuredList = $this->_cachedCall('getFeaturedMember', array(), '', array(COMMUNITY_CACHE_TAG_FEATURED)); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'); $alphabetHTML = CFilterBar::getHTML(CRoute::getURI(), '', '', $filterItems, 'all'); } else { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'); } $multiprofileArr = array(); $hasMultiprofile = false; //let see if we have any multiprofile enabled if ($config->get('profile_multiprofile')) { $hasMultiprofile = true; //lets get the available profile $profileModel = CFactory::getModel('Profile'); $profiles = $profileModel->getProfileTypes(); if ($profiles) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=browse&filter=' . $filter . '&sort=' . $sorted), 'name' => JText::_('COM_COMMUNITY_ALL_PROFILE'), 'selected' => !$profiletype ? 1 : 0); foreach ($profiles as $profile) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=browse&filter=' . $filter . '&sort=' . $sorted . '&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profiletype ? 1 : 0); } } } echo $tmpl->set('featuredList', $featuredList)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('alreadyfriend', $alreadyfriend)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('data', $resultRows)->set('sortings', $sortingsHTML)->set('alphabet', $alphabetHTML)->set('my', $my)->set('submenu', $this->showSubmenu(false))->set('totalUser', $totalUser)->set('showFeaturedList', $config->get('show_featured'))->set('pagination', $searchModel->getPagination())->fetch('people.browse'); }
<span></span> <input type="submit" value="<?php echo JText::_('COM_COMMUNITY_SAVE_CHANGES_BUTTON'); ?> " class="joms-button--primary joms-button--full-small"> </div> </div> <div class="joms-js--tab-content joms-js--tab-content-ignorelist" style="display:none"> <div class="joms-gap"></div> <ul class="joms-list--friend"> <?php foreach ($blockedUsers as $row) { $user = CFactory::getUser($row->blocked_userid); $user->profileLink = CUrl::build('profile', '', array('userid' => $user->id)); ?> <li class="joms-list__item"> <div class="joms-list__avatar"> <a href="<?php echo $user->profileLink; ?> " class="joms-avatar"> <img src="<?php echo $user->getThumbAvatar(); ?> " alt="<?php echo $user->getDisplayName(); ?> " > </a>
/** * This function will prep user info so that it can display user mini header in privacy warning template. * Do not call this function outside this view.php */ function _prepUser($user) { if (!empty($user)) { $obj = new stdClass(); $my = CFactory::getUser(); $user = CFactory::getUser($user->id); $obj->friendsCount = $user->getFriendCount(); $obj->user = $user; $obj->profileLink = CUrl::build('profile', '', array('userid' => $user->id)); $isFriend = CFriendsHelper::isConnected($user->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false; return array($obj); } return false; }
/** * Return groups html block */ function _getGroupsHTML() { $tmpl = new CTemplate(); $model = CFactory::getModel('groups'); $my = CFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $groups = $model->getGroups($user->id); $total = count($groups); // Randomize groups if ($groups) { shuffle($groups); } CFactory::load('helpers', 'url'); // Load the groups as proper CTableGroup object foreach ($groups as &$gr) { $groupTable = JTable::getInstance('Group', 'CTable'); $groupTable->load($gr->id); $gr = $groupTable; } for ($i = 0; $i < count($groups); $i++) { $row =& $groups[$i]; $row->avatar = $row->getThumbAvatar(); $row->link = CUrl::build('groups', 'viewgroup', array('groupid' => $row->id), true); } $tmpl->set('user', $user); $tmpl->set('total', $total); $tmpl->set('groups', $groups); return $tmpl->fetch('profile.groups'); }
/** * Ajax function to approve a specific member when event admin or site admin tries to approve an invitation. * * @params string id The member's id that needs to be approved. * @params string groupid The group id that the user is in. **/ public function ajaxApproveInvite($memberId, $eventId) { $response = new JAXResponse(); $filter = JFilterInput::getInstance(); $memberId = $filter->clean($memberId, 'int'); $eventId = $filter->clean($eventId, 'int'); $my = CFactory::getUser(); $model = $this->getModel('events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($eventId); CFactory::load('helpers', 'event'); $handler = CEventHelper::getHandler($event); if (!$handler->manageable()) { $response->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION')); } else { // Load required tables $member =& JTable::getInstance('EventMembers', 'CTable'); $member->load($memberId, $eventId); $member->attend(); $member->store(); // Build the URL. $url = CUrl::build('events', 'viewevent', array('eventid' => $event->id), true); $user = CFactory::getUser($memberId); $tmplData = array(); $tmplData['url'] = CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false); $tmplData['event'] = $event->title; $tmplData['user'] = $user->getDisplayName(); $tmplData['approval'] = 1; // Send email to evnt member once their invitation is approved CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false)); $params->set('eventTitle', $event->title); CNotificationLibrary::add('etype_events_invitation_approved', $event->creator, $user->id, JText::sprintf('COM_COMMUNITY_EVENTS_EMAIL_SUBJECT', $event->title), '', 'events.invitation.approved', $params); $response->addScriptCall('joms.jQuery("#member_' . $memberId . '").css("border","3px solid blue");'); $response->addScriptCall('joms.jQuery("#notice").html("' . JText::_('COM_COMMUNITY_EVENTS_REQUEST_APPROVED') . '");'); $response->addScriptCall('joms.jQuery("#notice").attr("class","info");'); $response->addScriptCall('joms.jQuery("#events-approve-' . $memberId . '").remove();'); } $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS)); return $response->sendResponse(); }
public function deleteLink($controller, $method, $id) { $deleteLink = '<a class="remove" onClick="if(!confirm(\'' . JText::_('COM_COMMUNITY_CONFIRM_DELETE_FRIEND') . '\'))return false;" href="' . CUrl::build($controller, $method) . '&fid=' . $id . '"> </a>'; return $deleteLink; }
/** * Return groups html block * @since 2.4 */ public function modGetGroupsHTML($userid = null) { $html = ''; $my = CFactory::getUser($userid); $user = CFactory::getRequestUser(); $params = $user->getParams(); // site visitor $relation = 10; // site members if ($my->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($my->id, $user->id)) { $relation = 30; } // mine if (COwnerHelper::isMine($my->id, $user->id)) { $relation = 40; } // Respect privacy settings if ($relation < $params->get('privacyGroupsView')) { return ''; } $tmpl = new CTemplate(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $model = CFactory::getModel('groups'); $userid = $jinput->get('userid', $my->id, 'INT'); //JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $groups = $model->getGroups($user->id); $total = count($groups); // Randomize groups if ($groups) { shuffle($groups); } //CFactory::load( 'helpers' , 'url' ); // Load the groups as proper CTableGroup object foreach ($groups as &$gr) { $groupTable = JTable::getInstance('Group', 'CTable'); $groupTable->load($gr->id); $gr = $groupTable; } for ($i = 0; $i < count($groups); $i++) { $row = $groups[$i]; $row->avatar = $row->getThumbAvatar(); $row->link = CUrl::build('groups', 'viewgroup', array('groupid' => $row->id), true); } $html = $tmpl->set('user', $user)->set('total', $total)->set('groups', $groups)->fetch('profile.groups'); return $html; }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ public function ajaxSaveDiscussionWall($message, $uniqueId) { if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $response = new JAXResponse(); $my = CFactory::getUser(); CFactory::load('models', 'groups'); CFactory::load('models', 'discussions'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); CFactory::load('libraries', 'wall'); // Load models $group =& JTable::getInstance('Group', 'CTable'); $discussionModel = CFactory::getModel('Discussions'); $discussion =& JTable::getInstance('Discussion', 'CTable'); $message = strip_tags($message); $discussion->load($uniqueId); $group->load($discussion->groupid); // If the content is false, the message might be empty. if (empty($message)) { $response->addAlert(JText::_('CC EMPTY MESSAGE')); return $response->sendResponse(); } // Save the wall content $wall = CWallLibrary::saveWall($uniqueId, $message, 'discussions', $my, $my->id == $discussion->creator, 'groups,discussion'); $date =& JFactory::getDate(); $discussion->lastreplied = $date->toMySQL(); $discussion->store(); // @rule: only add the activities of the wall if the group is not private. if ($group->approvals == COMMUNITY_PUBLIC_GROUP) { // Build the URL $discussURL = CUrl::build('groups', 'viewdiscussion', array('groupid' => $discussion->groupid, 'topicid' => $discussion->id), true); $act = new stdClass(); $act->cmd = 'group.discussion.reply'; $act->actor = $my->id; $act->target = 0; $act->title = JText::sprintf('CC ACTIVITIES REPLY DISCUSSION', '{discuss_url}', $discussion->title); $act->content = $message; $act->app = 'groups'; $act->cid = $group->id; $params = new JParameter(''); $params->set('action', 'group.discussion.reply'); $params->set('wallid', $wall->id); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('group_name', $group->name); $params->set('discuss_url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id); // Add activity log CActivityStream::add($act, $params->toString()); } // Get repliers for this discussion and notify the discussion creator too $users = $discussionModel->getRepliers($discussion->id, $group->id); $users[] = $discussion->creator; $key = array_search($my->id, $users); if ($key !== false && isset($users[$key])) { unset($users[$key]); } // Add notification CFactory::load('libraries', 'notification'); $params = new JParameter(''); $params->set('url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id); $params->set('message', $message); $params->set('title', $discussion->title); CNotificationLibrary::add('groups.discussion.reply', $my->id, $users, JText::sprintf('CC GROUP NEW DISCUSSION REPLY SUBJECT', $my->getDisplayName(), $discussion->title), '', 'groups.discussion.reply', $params); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('group.discussion.reply'); $config = CFactory::getConfig(); $order = $config->get('group_discuss_order'); $order = $order == 'DESC' ? 'prepend' : 'append'; $response->addScriptCall('joms.walls.insertOrder = "' . $order . '";'); $response->addScriptCall('joms.walls.insert', $wall->content); return $response->sendResponse(); }
/** * Ajax function to save a new wall entry * * @param message A message that is submitted by the user * @param uniqueId The unique id for this group * **/ public function ajaxSaveDiscussionWall($message, $uniqueId) { $filter = JFilterInput::getInstance(); $message = $filter->clean($message, 'string'); $uniqueId = $filter->clean($uniqueId, 'int'); if (!COwnerHelper::isRegisteredUser()) { return $this->ajaxBlockUnregister(); } $response = new JAXResponse(); $my = CFactory::getUser(); CFactory::load('models', 'groups'); CFactory::load('models', 'discussions'); CFactory::load('helpers', 'url'); CFactory::load('libraries', 'activities'); CFactory::load('libraries', 'wall'); // Load models $group =& JTable::getInstance('Group', 'CTable'); $discussionModel = CFactory::getModel('Discussions'); $discussion =& JTable::getInstance('Discussion', 'CTable'); $message = strip_tags($message); $discussion->load($uniqueId); $group->load($discussion->groupid); // If the content is false, the message might be empty. if (empty($message)) { $response->addAlert(JText::_('COM_COMMUNITY_EMPTY_MESSAGE')); return $response->sendResponse(); } $config = CFactory::getConfig(); // @rule: Spam checks if ($config->get('antispam_akismet_walls')) { 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=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id)); $filter->setType('message'); $filter->setIP($_SERVER['REMOTE_ADDR']); if ($filter->isSpam()) { $response->addAlert(JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM')); return $response->sendResponse(); } } // Save the wall content $wall = CWallLibrary::saveWall($uniqueId, $message, 'discussions', $my, $my->id == $discussion->creator, 'groups,discussion'); $date =& JFactory::getDate(); $discussion->lastreplied = $date->toMySQL(); $discussion->store(); // Build the URL $discussURL = CUrl::build('groups', 'viewdiscussion', array('groupid' => $discussion->groupid, 'topicid' => $discussion->id), true); $act = new stdClass(); $act->cmd = 'group.discussion.reply'; $act->actor = $my->id; $act->target = 0; $act->title = JText::sprintf('COM_COMMUNITY_GROUPS_REPLY_DISCUSSION', '{discuss_url}', $discussion->title); $act->content = $message; $act->app = 'groups.discussion.reply'; $act->cid = $discussion->id; $act->groupid = $group->id; $act->group_access = $group->approvals; $act->like_id = $wall->id; $act->like_type = 'groups.discussion.reply'; $params = new CParameter(''); $params->set('action', 'group.discussion.reply'); $params->set('wallid', $wall->id); $params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id); $params->set('group_name', $group->name); $params->set('discuss_url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id); // Add activity log CActivityStream::add($act, $params->toString()); // Get repliers for this discussion and notify the discussion creator too $users = $discussionModel->getRepliers($discussion->id, $group->id); $users[] = $discussion->creator; // Make sure that each person gets only 1 email $users = array_unique($users); // The person who post this, should not be getting notification email $key = array_search($my->id, $users); if ($key !== false && isset($users[$key])) { unset($users[$key]); } // Add notification CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id); $params->set('message', $message); $params->set('title', $discussion->title); CNotificationLibrary::add('etype_groups_discussion_reply', $my->id, $users, JText::sprintf('COM_COMMUNITY_GROUP_NEW_DISCUSSION_REPLY_SUBJECT', $my->getDisplayName(), $discussion->title), '', 'groups.discussion.reply', $params); //add user points CFactory::load('libraries', 'userpoints'); CUserPoints::assignPoint('group.discussion.reply'); $config = CFactory::getConfig(); $order = $config->get('group_discuss_order'); $order = $order == 'DESC' ? 'prepend' : 'append'; $response->addScriptCall('joms.walls.insertOrder = "' . $order . '";'); $response->addScriptCall('joms.walls.insert', $wall->content); $this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES, COMMUNITY_CACHE_TAG_GROUPS_DETAIL)); return $response->sendResponse(); }
function browse($data = null) { require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'template.php'; $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); // Load required filterbar library that will be used to display the filtering and sorting. CFactory::load('libraries', 'filterbar'); $this->addPathway(JText::_('CC MEMBERS'), ''); $document->setTitle(JText::_('CC MEMBERS')); CFactory::load('helpers', 'friends'); CFactory::load('libraries', 'template'); CFactory::load('libraries', 'tooltip'); CFactory::load('helpers', 'owner'); CFactory::load('libraries', 'featured'); $my = CFactory::getUser(); $view = CFactory::getView('search'); $searchModel = CFactory::getModel('search'); $userModel = CFactory::getModel('user'); $avatar = CFactory::getModel('avatar'); $friends = CFactory::getModel('friends'); $tmpl = new CTemplate(); $sorted = JRequest::getVar('sort', 'latest', 'GET'); $filter = JRequest::getWord('filter', 'all', 'GET'); $rows = $searchModel->getPeople($sorted, $filter); $sortItems = array('latest' => JText::_('CC SORT LATEST'), 'online' => JText::_('CC SORT ONLINE'), 'alphabetical' => JText::_('CC SORT ALPHABETICAL')); $filterItems = array(); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $filterItems = array('all' => JText::_('CC ALL'), 'abc' => JText::_('CC ABC'), 'def' => JText::_('CC DEF'), 'ghi' => JText::_('CC GHI'), 'jkl' => JText::_('CC JKL'), 'mno' => JText::_('CC MNO'), 'pqr' => JText::_('CC PQR'), 'stu' => JText::_('CC STU'), 'vwx' => JText::_('CC VWX'), 'yz' => JText::_('CC YZ'), 'others' => JText::_('CC OTHERS')); } $html = ''; $totalUser = $userModel->getMembersCount(); $resultRows = array(); // No need to pre-load multiple users at once since $searchModel->getPeople // already did for ($i = 0; $i < count($rows); $i++) { $row =& $rows[$i]; $obj = clone $row; $user = CFactory::getUser($row->id); $obj->friendsCount = $user->getFriendCount(); $obj->user = $user; $obj->profileLink = CUrl::build('profile', '', array('userid' => $row->id)); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $obj->addFriend = !$isFriend && $my->id != $row->id ? true : false; $resultRows[] = $obj; } $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest', $filterItems, 'all'); } else { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'); } $tmpl->set('featuredList', $featuredList); $tmpl->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin()); $tmpl->set('featuredList', $featuredList); $tmpl->set('data', $resultRows); $tmpl->set('sortings', $sortingsHTML); $tmpl->set('my', $my); $tmpl->set('totalUser', $totalUser); $tmpl->set('showFeaturedList', true); $tmpl->set('pagination', $searchModel->getPagination()); echo $tmpl->fetch('people.browse'); }