public static function getAccessLevel($actorId, $targetId) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); //CFactory::load( 'helpers' , 'owner' ); //CFactory::load( 'helpers' , 'friends' ); // public guest $access = 0; // site members if ($actor->id > 0) { $access = 20; } // they are friends if ($target->id > 0 && CFriendsHelper::isConnected($actor->id, $target->id)) { $access = 30; } // mine, target and actor is the same person if ($target->id > 0 && COwnerHelper::isMine($actor->id, $target->id)) { $access = 40; } if (COwnerHelper::isCommunityAdmin()) { $access = 40; } return $access; }
function showMiniHeader($userId) { CMiniHeader::load(); CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'owner'); $option = JRequest::getVar('option', '', 'REQUEST'); $lang =& JFactory::getLanguage(); $lang->load('com_community'); $my = CFactory::getUser(); $config = CFactory::getConfig(); if (!empty($userId)) { $user = CFactory::getUser($userId); CFactory::load('libraries', 'messaging'); $sendMsg = CMessaging::getPopup($user->id); $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('user', $user); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('sendMsg', $sendMsg); $tmpl->set('config', $config); $tmpl->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>'; return $showMiniHeader; } }
/** * Return true if actor have access to target's item * @param type where the privacy setting should be extracted, {user, group, global, custom} * Site super admin waill always have access to all area */ static function isAccessAllowed($actorId, $targetId, $type, $userPrivacyParam) { $actor = CFactory::getUser($actorId); $target = CFactory::getUser($targetId); CFactory::load('helpers', 'owner'); CFactory::load('helpers', 'friends'); // Load User params $params =& $target->getParams(); // guest $relation = 10; // site members if ($actor->id != 0) { $relation = 20; } // friends if (CFriendsHelper::isConnected($actorId, $targetId)) { $relation = 30; } // mine, target and actor is the same person if (COwnerHelper::isMine($actor->id, $target->id)) { $relation = 40; } // @todo: respect privacy settings // If type is 'custom', then $userPrivacyParam will contain the exact // permission level $permissionLevel = $type == 'custom' ? $userPrivacyParam : $params->get($userPrivacyParam); if ($relation < $permissionLevel && !COwnerHelper::isCommunityAdmin($actorId)) { return false; } return true; }
public static function _getMutualFriendsHTML($userid = null) { $my = CFactory::getUser(); if ($my->id == $userid) { return; } $friendsModel = CFactory::getModel('Friends'); $friends = $friendsModel->getFriends($userid, 'latest', false, 'mutual'); $html = "<ul class='joms-list--friend single-column'>"; if (sizeof($friends)) { foreach ($friends as $friend) { $html .= "<li class='joms-list__item'>"; $html .= "<div class='joms-list__avatar'>"; $html .= '<div class="joms-avatar ' . CUserHelper::onlineIndicator($friend) . '"><a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $friend->id) . '">'; $html .= '<img src="' . $friend->getThumbAvatar() . '" data-author="' . $friend->id . '" />'; $html .= "</a></div></div>"; $html .= "<div class='joms-list__body'>"; $html .= CFriendsHelper::getUserCog($friend->id, null, null, true); $html .= CFriendsHelper::getUserFriendDropdown($friend->id); $html .= '<a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $friend->id) . '">'; $html .= '<h4 class="joms-text--username">' . $friend->getDisplayName() . '</h4></a>'; $html .= '<span class="joms-text--title">' . JText::sprintf('COM_COMMUNITY_TOTAL_MUTUAL_FRIENDS', CFriendsHelper::getTotalMutualFriends($friend->id)) . '</span>'; $html .= "</div></li>"; } $html .= "</ul>"; } else { $html .= JText::_('COM_COMMUNITY_NO_MUTUAL_FRIENDS'); } return $html; }
public static function showMiniHeader($userId) { CMiniHeader::load(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; JFactory::getLanguage()->load('com_community'); $option = $jinput->get('option', '', 'STRING'); //JRequest::getVar('option', '' , 'REQUEST'); $my = CFactory::getUser(); $config = CFactory::getConfig(); if (!empty($userId)) { $user = CFactory::getUser($userId); $params = $user->getParams(); //links information $photoEnabled = $config->get('enablephotos') ? true : false; $eventEnabled = $config->get('enableevents') ? true : false; $groupEnabled = $config->get('enablegroups') ? true : false; $videoEnabled = $config->get('enablevideos') ? true : false; //likes CFactory::load('libraries', 'like'); $like = new Clike(); $isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0; $isUserLiked = $like->userLiked('profile', $user->id, $my->id); /* likes count */ $likes = $like->getLikeCount('profile', $user->id); //profile $profileModel = CFactory::getModel('profile'); $profile = $profileModel->getViewableProfile($user->id, $user->getProfileType()); $profile = JArrayHelper::toObject($profile); $profile->largeAvatar = $user->getAvatar(); $profile->defaultAvatar = $user->isDefaultAvatar(); $profile->status = $user->getStatus(); $profile->defaultCover = $user->isDefaultCover(); $profile->cover = $user->getCover(); $profile->coverPostion = $params->get('coverPosition', ''); if (strpos($profile->coverPostion, '%') === false) { $profile->coverPostion = 0; } $groupmodel = CFactory::getModel('groups'); $profile->_groups = $groupmodel->getGroupsCount($profile->id); $eventmodel = CFactory::getModel('events'); $profile->_events = $eventmodel->getEventsCount($profile->id); $profile->_friends = $user->_friendcount; $videoModel = CFactory::getModel('Videos'); $profile->_videos = $videoModel->getVideosCount($profile->id); $photosModel = CFactory::getModel('photos'); $profile->_photos = $photosModel->getPhotosCount($profile->id); /* is featured */ $modelFeatured = CFactory::getModel('Featured'); $profile->featured = $modelFeatured->isExists(FEATURED_USERS, $profile->id); $sendMsg = CMessaging::getPopup($user->id); $tmpl = new CTemplate(); $tmpl->set('my', $my)->set('user', $user)->set('isBlocked', $user->isBlocked())->set('isMine', COwnerHelper::isMine($my->id, $user->id))->set('sendMsg', $sendMsg)->set('config', $config)->set('isWaitingApproval', CFriendsHelper::isWaitingApproval($my->id, $user->id))->set('isLikeEnabled', $isLikeEnabled)->set('photoEnabled', $photoEnabled)->set('eventEnabled', $eventEnabled)->set('groupEnabled', $groupEnabled)->set('videoEnabled', $videoEnabled)->set('profile', $profile)->set('isUserLiked', $isUserLiked)->set('likes', $likes)->set('isFriend', CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id); $showMiniHeader = $option == 'com_community' ? $tmpl->fetch('profile.miniheader') : '<div id="community-wrap" style="min-height:50px;">' . $tmpl->fetch('profile.miniheader') . '</div>'; return $showMiniHeader; } }
public static function activitiesCommentAdd($userId, $assetId, $obj = NULL) { //$obj = func_get_arg(2); $params = func_get_args(); $obj = !isset($params[2]) ? NULL : $params[2]; $model = CFactory::getModel('activities'); $result = false; $config = CFactory::getConfig(); // Guest can never leave a comment if ($userId == 0) { return false; } // If global config allow all members to comment, allow it if ($config->get('allmemberactivitycomment') == '1') { return true; } $allow_comment = false; // if all activity comment is allowed, return true $config = CFactory::getConfig(); if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) { $allow_comment = true; } if ($obj instanceof CTableEvent || $obj instanceof CTableGroup) { //event or group activities only if ($obj->isMember($userId)) { $allow_comment = true; } } else { if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) { // if all activity comment is allowed, return true $allow_comment = true; } } if (!isset($obj->params)) { $params = '{}'; } else { $params = $obj->params; } $params = new CParameter($params); $commentPermission = $params->get('commentPermission', NULL); if ($commentPermission == false && !is_null($commentPermission)) { $allow_comment = false; } if ($allow_comment || CFriendsHelper::isConnected($assetId, $userId) || COwnerHelper::isCommunityAdmin()) { $result = true; } return $result; }
/** * * @param type $userId * @param type $type * @param type $redirect */ public function block($userId, $type, $redirect = false) { $my = CFactory::getUser(); $result = false; /* both of ids must not empty */ if (empty($my->id) || empty($userId)) { $message = JText::_('COM_COMMUNITY_ERROR_BLOCK_USER'); } else { /* You can't block yourself */ if ($my->id != $userId) { /* Get model */ $model = CFactory::getModel('Block'); /* Do block */ if ($model->blockUser($my->id, $userId, $type)) { $result = true; /* check if current user is friend with requested user */ $isFriend = CFriendsHelper::isConnected($userId, $my->id); /* Remove user as friend if user is a friend */ if ($isFriend) { $this->removeFriend($userId); } $message = JText::_('COM_COMMUNITY_USER_BLOCKED'); } else { $message = JText::_('COM_COMMUNITY_ERROR_BLOCK_USER'); } } else { $message = JText::_('COM_COMMUNITY_ERROR_BLOCK_USER'); } } if ($redirect) { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; /* generate redirect url */ $viewName = $jinput->get->get('view', ''); $urlUserId = $viewName == 'friends' ? '' : "&userid=" . $userId; $url = CRoute::_("index.php?option=com_community&view=" . $viewName . $urlUserId, false); $mainframe->redirect($url, $message); } return $result; }
/** * Block user(Ban) */ public function block($userId) { $my = CFactory::getUser(); $mainframe =& JFactory::getApplication(); CFactory::load('helpers', 'friends'); $isFriend = CFriendsHelper::isConnected($userId, $my->id); $viewName = JRequest::getVar('view', '', 'GET'); $urlUserId = $viewName == 'friends' ? '' : "&userid=" . $userId; $url = CRoute::_("index.php?option=com_community&view=" . $viewName . $urlUserId, false); $message = empty($my->id) || empty($userId) ? JText::_('COM_COMMUNITY_ERROR_BLOCK_USER') : ''; if (!empty($my->id) && !empty($userId) && $my->id != $userId) { $model = CFactory::getModel('block'); if ($model->blockUser($my->id, $userId)) { // Remove user as friend if user is a friend if ($isFriend) { $this->removeFriend($userId); } $message = JText::_('COM_COMMUNITY_USER_BLOCKED'); } else { $message = JText::_('COM_COMMUNITY_ERROR_BLOCK_USER'); } } $mainframe->redirect($url, $message); }
public static function activitiesCommentAdd($userId, $assetId) { $obj = func_get_arg(0); $model =& CFactory::getModel('activities'); $result = false; $config = CFactory::getConfig(); // Guest can never leave a comment if ($userId == 0) { return false; } // If global config allow all members to comment, allow it if ($config->get('allmemberactivitycomment') == '1') { return true; } $allow_comment = false; // if all activity comment is allowed, return true $config = CFactory::getConfig(); if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) { $allow_comment = true; } if ($obj instanceof CTableEvent || $obj instanceof CTableGroup) { //event or group activities only if ($obj->isMember($userId)) { $allow_comment = true; } } else { if ($config->get('allmemberactivitycomment') == '1' && COwnerHelper::isRegisteredUser()) { // if all activity comment is allowed, return true $allow_comment = true; } } if ($allow_comment || CFriendsHelper::isConnected($assetId, $userId) || COwnerHelper::isCommunityAdmin()) { $result = true; } return $result; }
/** * @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; $params = $user->getParams(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $isMine = COwnerHelper::isMine($my->id, $user->id); $isFriend = CFriendsHelper::isConnected($user->id, $my->id) && $user->id != $my->id; $isWaitingApproval = CFriendsHelper::isWaitingApproval($my->id, $user->id); $isWaitingResponse = CFriendsHelper::isWaitingApproval($user->id, $my->id); $isBlocked = $user->isBlocked(); //links information $photoEnabled = $config->get('enablephotos') ? true : false; $eventEnabled = $config->get('enableevents') ? true : false; $groupEnabled = $config->get('enablegroups') ? true : false; $videoEnabled = $config->get('enablevideos') ? true : false; //likes CFactory::load('libraries', 'like'); $like = new Clike(); $isLikeEnabled = $like->enabled('profile') && $params->get('profileLikes', 1) ? 1 : 0; $isUserLiked = $like->userLiked('profile', $user->id, $my->id); /* likes count */ $likes = $like->getLikeCount('profile', $user->id); $profileFields = ''; $themeModel = CFactory::getModel('theme');
<div class="joms-list__body"> <a href="<?php echo $user->profileLink; ?> "><h4 class="joms-text--username"><?php echo $user->getDisplayName(); ?> </h4></a> <span class="joms-text--title"><?php echo JText::sprintf('COM_COMMUNITY_TOTAL_MUTUAL_FRIENDS', CFriendsHelper::getTotalMutualFriends($user->id)); ?> </span> </div> <div class="joms-list__actions"> <?php echo CFriendsHelper::getUserCog($user->id, null, null, true); ?> <?php echo CFriendsHelper::getUserFriendDropdown($user->id); ?> </div> </li> <?php } ?> </ul> </div> <?php }
<?php if ($enableReporting) { ?> <button class="joms-button--neutral joms-button--small" onclick="joms.api.photoReport('<?php echo $photo->id; ?> ');"><?php echo JText::_('COM_COMMUNITY_REPORT'); ?> </button> <?php } ?> <?php if (COwnerHelper::isMine($my->id, $album->creator) || CFriendsHelper::isConnected($my->id, $album->creator)) { ?> <button class="joms-button--neutral joms-button--small joms-js--btn-tag"><?php echo JText::_('COM_COMMUNITY_TAG_THIS_PHOTO'); ?> </button> <?php } ?> <div class="joms-js--photo-tag-ct"></div> <div class="joms-gap"></div> <div> <h5 class="joms-text--title"><?php echo JText::_('COM_COMMUNITY_PHOTOS_ALBUM_DESC');
/** * Check if permitted to play the video * * @param int $myid The current user's id * @param int $userid The active profile user's id * @param int $permission The video's permission * @return bool True if it's permitted * @since 1.2 */ public function isPermitted($myid = 0, $userid = 0, $permissions = 0) { if ($permissions == 0) { return true; } // public if (COwnerHelper::isCommunityAdmin()) { return true; } $relation = 0; if ($myid != 0) { $relation = 20; } // site members if (CFriendsHelper::isConnected($myid, $userid)) { $relation = 30; } // friends if (COwnerHelper::isMine($myid, $userid)) { $relation = 40; // mine } if ($relation >= $permissions) { return true; } return false; }
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'); }
?> </h4></a> <span class="joms-text--title"><?php echo JText::sprintf('COM_COMMUNITY_TOTAL_MUTUAL_FRIENDS', CFriendsHelper::getTotalMutualFriends($row->user->id)); ?> </span> </div> <div class="joms-list__actions joms-js--frequest-btn-<?php echo $connectionId; ?> "> <?php echo CFriendsHelper::getUserCog($row->user->id, null, null, true); ?> <?php $connectionId = CFriendsHelper::isWaitingApproval($row->user->id, $my->id); ?> <div class="joms-list__button--dropdown"> <button onclick="joms.api.friendReject('<?php echo $connectionId; ?> ');" class="joms-button--neutral joms-button--full-small joms-button--smallest"><?php echo JText::_('COM_COMMUNITY_FRIENDS_PENDING_ACTION_REJECT'); ?> </button> <button onclick="joms.api.friendApprove('<?php echo $connectionId; ?> ');" class="joms-button--primary joms-button--full-small joms-button--smallest"><?php echo JText::_('COM_COMMUNITY_PENDING_ACTION_APPROVE'); ?>
/** * Check if permitted to play the video * * @param int $myid The current user's id * @param int $userid The active profile user's id * @param int $permission The video's permission * @return bool True if it's permitted * @since 1.2 */ public function isPermitted($myid = 0, $userid = 0, $permissions = 0) { if ($permissions == 0) { return true; } // public // Load Libraries CFactory::load('helpers', 'friends'); CFactory::load('helpers', 'owner'); if (COwnerHelper::isCommunityAdmin()) { return true; } $relation = 0; if ($myid != 0) { $relation = 20; } // site members if (CFriendsHelper::isConnected($myid, $userid)) { $relation = 30; } // friends if (COwnerHelper::isMine($myid, $userid)) { $relation = 40; // mine } if ($relation >= $permissions) { return true; } return false; }
?> ');"> <button class="joms-button--neutral joms-button--smallest joms-button--full-small"><?php echo JText::_('COM_COMMUNITY_FRIENDS_PENDING_ACTION_REJECT'); ?> </button> </a> </div> <?php } ?> </div> <div class="joms-list__actions"> <?php echo CFriendsHelper::getUserCog($member->id, $groupid, null, true); ?> <?php //echo CFriendsHelper::getUserFriendDropdown($member->id); ?> </div> </li> <?php } ?> </ul> <?php } ?> <?php }
</b> <div class="small"> <a href="<?php echo CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id); ?> "> <?php echo JText::_('COM_COMMUNITY_GO_TO_PROFILE'); ?> </a> </div> </div> <div class="span8"> <ul class="cToolBox-Options unstyled"> <?php if (!$isFriend && !$isMine && !CFriendsHelper::isWaitingApproval($my->id, $user->id)) { ?> <li> <a href="javascript:void(0)" onclick="joms.api.friendAdd('<?php echo $user->id; ?> ')"> <i class="com-icon-user-plus"></i> <span><?php echo JText::_('COM_COMMUNITY_PROFILE_ADD_AS_FRIEND'); ?> </span> </a> </li> <?php }
public static function getUserFriendDropdown($targetId) { $my = CFactory::getUser(); //current user $user = CFactory::getUser($targetId); //if user is not logged in, nothing should be displayed at all if (!$my->id || $my->id == $targetId) { return false; } $display = new stdClass(); $display->canAddFriend = false; $display->canUnfriend = false; $display->canRemoveFriendRequest = false; $display->dropdown = false; $display->dropdownTrigger = false; $display->button = "COM_COMMUNITY_PROFILE_ADD_AS_FRIEND"; //by default $display->buttonTrigger = "joms.api.friendAdd('" . $user->id . "')"; //is friend if (CFriendsHelper::isConnected($my->id, $targetId)) { $display->button = "COM_COMMUNITY_FRIENDS_COUNT"; //friend $display->dropdown = 'COM_COMMUNITY_FRIENDS_REMOVE'; $display->dropdownTrigger = "joms.api.friendRemove('" . $user->id . "');"; $display->buttonTrigger = false; } else { if (CFriendsHelper::isWaitingApproval($my->id, $user->id)) { $display->button = "COM_COMMUNITY_PROFILE_CONNECT_REQUEST_SENT"; $display->buttonTrigger = false; $display->dropdown = "COM_COMMUNITY_CANCEL_FRIEND_REQUEST"; $display->dropdownTrigger = "joms.api.friendAddCancel('" . $user->id . "');"; } else { if ($connectionId = CFriendsHelper::isWaitingApproval($user->id, $my->id)) { $display->button = "COM_COMMUNITY_PENDING_APPROVAL"; $display->buttonTrigger = false; $display->dropdown[] = "COM_COMMUNITY_FRIEND_ACCEPT_REQUEST"; $display->dropdownTrigger[] = "joms.api.friendApprove('" . $connectionId . "');"; $display->dropdown[] = "COM_COMMUNITY_FRIEND_REJECT_REQUEST"; $display->dropdownTrigger[] = "joms.api.friendReject('" . $connectionId . "');"; } } } $tmpl = new CTemplate(); return $tmpl->set('options', $display)->fetch('general/friend-dropdown'); }
} else { $users = array($this->act->actor); $user = CFactory::getUser($this->act->actor); } $truncateVal = 60; $date = JFactory::getDate($act->created); if ($config->get('activitydateformat') == "lapse") { $createdTime = CTimeHelper::timeLapse($date); } else { $createdTime = $date->format($config->get('profileDateFormat')); } // Setup album table $album = JTable::getInstance('Album', 'CTable'); $album->load($act->cid); $this->set('album', $album); if ($album->permissions == 30 && !CFriendsHelper::isConnected($my->id, $album->creator)) { return false; } $albumUrl = CRoute::_($album->getURI()); $isPhotoModal = $config->get('album_mode') == 1; if ($isPhotoModal) { $albumUrl = 'javascript:" onclick="joms.api.photoOpen(\'' . $album->id . '\', \'\');'; } ?> <div class="joms-stream__header"> <div class= "joms-avatar--stream"> <a href="<?php echo CUrlHelper::userLink($user->id); ?> ">
/** * Deprecated since 1.8 */ function friendIsConnected($id1, $id2) { return CFriendsHelper::isConnected($id1, $id2); }
public function advanceSearch() { $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); //load calendar behavior JHtml::_('behavior.calendar'); JHtml::_('behavior.tooltip'); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH')); //$this->showSubMenu(); $this->addPathway(JText::_('COM_COMMUNITY_TITLE_CUSTOM_SEARCH')); $profileType = $jinput->get('profiletype', 0, 'INT'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $result = null; $fields = CAdvanceSearch::getFields($profileType); $data = new stdClass(); $post = JRequest::get('GET'); $keyList = isset($post['key-list']) ? $post['key-list'] : ''; $avatarOnly = $jinput->get('avatar', '', 'NONE'); if (JString::strlen($keyList) > 0) { //formatting the assoc array $filter = array(); $key = explode(',', $keyList); $joinOperator = isset($post['operator']) ? $post['operator'] : ''; foreach ($key as $idx) { $obj = new stdClass(); $obj->field = $post['field' . $idx]; $obj->condition = $post['condition' . $idx]; $obj->fieldType = $post['fieldType' . $idx]; if ($obj->fieldType == 'email') { $obj->condition = 'equal'; } // we need to check whether the value contain start and end kind of values. // if yes, make them an array. if (isset($post['value' . $idx . '_2'])) { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $endDate = empty($post['value' . $idx . '_2']) ? '01/01/1970' : $post['value' . $idx . '_2']; // Joomla 1.5 uses "/" // Joomla 1.6 uses "-" $delimeter = '-'; if (strpos($startDate, '/')) { $delimeter = '/'; } $sdate = explode($delimeter, $startDate); $edate = explode($delimeter, $endDate); if (isset($sdate[2]) && isset($edate[2])) { $obj->value = array($sdate[0] . '-' . $sdate[1] . '-' . $sdate[2] . ' 00:00:00', $edate[0] . '-' . $edate[1] . '-' . $edate[2] . ' 23:59:59'); } else { $obj->value = array(0, 0); } } else { $obj->value = array($post['value' . $idx], $post['value' . $idx . '_2']); } } else { if ($obj->fieldType == 'date') { $startDate = empty($post['value' . $idx]) ? '01/01/1970' : $post['value' . $idx]; $delimeter = '-'; if (strpos($startDate, '/')) { $delimeter = '/'; } $sdate = explode($delimeter, $startDate); if (isset($sdate[2])) { $obj->value = $sdate[2] . '-' . $sdate[1] . '-' . $sdate[0] . ' 00:00:00'; } else { $obj->value = 0; } } else { if ($obj->fieldType == 'checkbox') { if (empty($post['value' . $idx])) { //this mean user didnot check any of the option. $obj->value = ''; } else { $obj->value = isset($post['value' . $idx]) ? implode(',', $post['value' . $idx]) : ''; } } else { $obj->value = isset($post['value' . $idx]) ? $post['value' . $idx] : ''; } } } $filter[] = $obj; } $data->search = CAdvanceSearch::getResult($filter, $joinOperator, $avatarOnly, '', $profileType); $data->filter = $post; } $rows = !empty($data->search) ? $data->search->result : array(); $pagination = !empty($data->search) ? $data->search->pagination : ''; $filter = !empty($data->filter) ? $data->filter : array(); $resultRows = array(); $friendsModel = CFactory::getModel('friends'); for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; //filter the user profile type if ($profileType && $row->_profile_id != $profileType) { continue; } $obj = new stdClass(); $obj->user = $row; $obj->friendsCount = $row->getFriendCount(); $obj->profileLink = CRoute::_('index.php?option=com_community&view=profile&userid=' . $row->id); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $row->id ? true : false; $resultRows[] = $obj; } if (class_exists('Services_JSON')) { $json = new Services_JSON(); } else { require_once AZRUL_SYSTEM_PATH . '/pc_includes/JSON.php'; $json = new Services_JSON(); } $tmpl = new CTemplate(); $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=advancesearch'), '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=advancesearch&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profileType ? 1 : 0); } } } $searchForm = $tmpl->set('fields', $fields)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('keyList', $keyList)->set('profileType', $profileType)->set('avatarOnly', $avatarOnly)->set('filterJson', $json->encode($filter))->set('postresult', isset($post['key-list']))->set('submenu', $this->showSubmenu(false))->fetch('search.advancesearch'); if (isset($post['key-list'])) { //result template $tmplResult = new CTemplate(); $featured = new CFeatured(FEATURED_USERS); $featuredList = $featured->getItemIds(); $tmpl->set('featuredList', $featuredList); $searchForm .= $tmplResult->set('my', $my)->set('showFeaturedList', false)->set('multiprofileArr', $multiprofileArr)->set('featuredList', $featuredList)->set('data', $resultRows)->set('isAdvanceSearch', true)->set('hasMultiprofile', $hasMultiprofile)->set('sortings', '')->set('pagination', $pagination)->set('filter', $filter)->set('featuredList', $featuredList)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->fetch('people.browse'); } echo $searchForm; }
/** * 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; }
public function getVideos($userid, $limitstart, $limit) { $photoType = PHOTOS_USER_TYPE; //privacy settings //CFactory::load('libraries', 'privacy'); $permission = CPrivacy::getAccessLevel($this->_my->id, $userid); //get videos from the user //CFactory::load('models', 'videos'); $model = CFactory::getModel('Videos'); if ($this->_my->id == $userid || COwnerHelper::isCommunityAdmin()) { $permission = 40; } elseif (CFriendsHelper::isConnected($this->_my->id, $userid)) { $permission = 30; } elseif ($this->_my->id != 0) { $permission = 20; } else { $permission = 10; } $videos = $model->getUserTotalVideos($userid, $permission); return $videos; }
public function isWallsAllowed($photoId) { $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($photoId); $config = CFactory::getConfig(); $isConnected = CFriendsHelper::isConnected($this->my->id, $photo->creator); $isMe = COwnerHelper::isMine($this->my->id, $photo->creator); // Check if user is really allowed to post walls on this photo. if ($isMe || !$config->get('lockphotoswalls') || $config->get('lockphotoswalls') && $isConnected || COwnerHelper::isCommunityAdmin()) { return true; } return false; }
</div> <div class="joms-list__actions"> <?php echo CFriendsHelper::getUserCog($row->user->id, null, null, true); ?> <?php echo CFriendsHelper::getUserFriendDropdown($row->user->id); ?> <!-- <?php $blockedByMe = $blockModel->getBlockStatus($my->id, $row->user->id); if ($row->addFriend && !$blockedByMe) { $isWaitingApproval = CFriendsHelper::isWaitingApproval($my->id, $row->user->id); ?> <?php if (isset($row->isMyFriend) && $row->isMyFriend == 1) { ?> <a class="joms-button--neutral joms-button--small" href="javascript:void(0)" onclick="joms.api.friendAdd('<?php echo $row->user->id; ?> ')"><?php echo JText::_('COM_COMMUNITY_PROFILE_PENDING_FRIEND_REQUEST'); ?> </a> <?php } else { ?>
public function checkAlbumsPermissions($row, $myId) { switch ($row->permissions) { case 0: $result = true; break; case 20: $result = !empty($myId) ? true : false; break; case 30: $result = CFriendsHelper::isConnected($row->creator, $myId) ? true : false; break; case 40: $result = $row->creator == $myId ? true : false; break; default: $result = false; break; } return $result; }
function _userPhoto() { $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); // Get necessary properties and load the libraries CFactory::load('models', 'photos'); CFactory::load('helpers', 'friends'); $my = CFactory::getUser(); $model = CFactory::getModel('photos'); $albumId = JRequest::getVar('albumid', '', 'GET'); $defaultId = JRequest::getVar('photoid', '', 'GET'); if (empty($albumId)) { echo JText::_('CC NO PROPER ALBUM ID'); return; } // Load the album table $album =& JTable::getInstance('Album', 'CTable'); $album->load($albumId); // Since the URL might not contain userid, we need to get the user object from the creator $user = CFactory::getUser($album->creator); if (!$user->block || COwnerHelper::isCommunityAdmin($my->id)) { // Set the current user's active profile CFactory::setActiveProfile($album->creator); // Get list of photos and set some limit to be displayed. // @todo: make limit configurable? set to 1000, unlimited? $photos = $model->getPhotos($albumId, 1000); $pagination = $model->getPagination(); CFactory::load('helpers', 'pagination'); // @todo: make limit configurable? $paging = CPaginationLibrary::getLinks($pagination, 'photos,ajaxPagination', $albumId, 10); // Set document title CFactory::load('helpers', 'string'); $document->setTitle($album->name); // @checks: Test if album doesnt have any default photo id. We need to get the first row // of the photos to be the default if ($album->photoid == '0') { $album->photoid = count($photos) >= 1 ? $photos[0]->id : '0'; } // Try to see if there is any photo id in the query $defaultId = !empty($defaultId) ? $defaultId : $album->photoid; // Load the default photo $photo =& JTable::getInstance('Photo', 'CTable'); $photo->load($defaultId); // If default has an id of 0, we need to tell the template to dont process anything $default = $photo->id == 0 ? false : $photo; // Load User params $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; } if ($my->id != $user->id) { $this->attachMiniHeaderUser($user->id); } CFactory::load('helpers', 'owner'); // @todo: respect privacy settings if ($relation < $params->get('privacyPhotoView') && !COwnerHelper::isCommunityAdmin()) { echo JText::_('CC ACCESS FORBIDDEN'); return; } CFactory::load('helpers', 'owner'); //friend list for photo tag CFactory::load('libraries', 'phototagging'); $tagging = new CPhotoTagging(); for ($i = 0; $i < count($photos); $i++) { $item = JTable::getInstance('Photo', 'CTable'); $item->bind($photos[$i]); $photos[$i] = $item; $row =& $photos[$i]; $taggedList = $tagging->getTaggedList($row->id); for ($t = 0; $t < count($taggedList); $t++) { $tagItem =& $taggedList[$t]; $tagUser = CFactory::getUser($tagItem->userid); $canRemoveTag = 0; // 1st we check the tagged user is the photo owner. // If yes, canRemoveTag == true. // If no, then check on user is the tag creator or not. // If yes, canRemoveTag == true // If no, then check on user whether user is being tagged if (COwnerHelper::isMine($my->id, $row->creator) || COwnerHelper::isMine($my->id, $tagItem->created_by) || COwnerHelper::isMine($my->id, $tagItem->userid)) { $canRemoveTag = 1; } $tagItem->user = $tagUser; $tagItem->canRemoveTag = $canRemoveTag; } $row->tagged = $taggedList; } $friendModel = CFactory::getModel('friends'); $friends = $friendModel->getFriends($my->id, '', false); array_unshift($friends, $my); // Show wall contents CFactory::load('helpers', 'friends'); // Load up required objects. $user = CFactory::getUser($photo->creator); $config = CFactory::getConfig(); $isConnected = CFriendsHelper::isConnected($my->id, $user->id); $isMe = COwnerHelper::isMine($my->id, $user->id); $showWall = false; $allowTag = false; // Check if user is really allowed to post walls on this photo. if ($isMe || !$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && $isConnected) { $showWall = true; } //check if we can allow the current viewing user to tag the photos if ($isMe || $isConnected) { $allowTag = true; } $tmpl = new CTemplate(); CFactory::load('libraries', 'bookmarks'); $bookmarks = new CBookmarks(CRoute::getExternalURL('index.php?option=com_community&view=photos&task=album&albumid=' . $album->id . '&userid=' . $user->id)); $bookmarksHTML = $bookmarks->getHTML(); $tmpl->set('showWall', $showWall); $tmpl->set('allowTag', $allowTag); $tmpl->set('isOwner', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('photos', $photos); $tmpl->set('pagination', $paging); $tmpl->set('default', $default); $tmpl->set('album', $album); $tmpl->set('config', $config); //echo $tmpl->fetch('photos.photo'); } else { CFactory::load('helpers', 'owner'); $tmpl = new CTemplate(); echo $tmpl->fetch('profile.blocked'); return; } }
public function isTaggable() { if (COwnerHelper::isMine($this->my->id, $this->user->id) || CFriendsHelper::isConnected($this->my->id, $this->user->id)) { return true; } return false; }
function onProfileDisplay() { $mainframe =& JFactory::getApplication(); JPlugin::loadLanguage('plg_walls', JPATH_ADMINISTRATOR); $document =& JFactory::getDocument(); $my = CFactory::getUser(); $config = CFactory::getConfig(); // Load libraries CFactory::load('libraries', 'wall'); CFactory::load('helpers', 'friends'); $user = CFactory::getRequestUser(); $friendModel = CFactory::getModel('friends'); $avatarModel = CFactory::getModel('avatar'); $isMe = $my->id == $user->id && $my->id != 0; $isGuest = $my->id == 0 ? true : false; $isConnected = CFriendsHelper::isConnected($my->id, $user->id); CFactory::load('helpers', 'owner'); $isSuperAdmin = isCommunityAdmin(); // @rule: Limit should follow Joomla's list limit $jConfig =& JFactory::getConfig(); $limit = JRequest::getVar('limit', $jConfig->getValue('list_limit'), 'REQUEST'); $limitstart = JRequest::getVar('limitstart', 0, 'REQUEST'); if (JRequest::getVar('task', '', 'REQUEST') == 'app') { $cache =& JFactory::getCache('plgCommunityWalls_fullview'); } else { $cache =& JFactory::getCache('plgCommunityWalls'); } $caching = $this->params->get('cache', 1); if ($caching) { $caching = $mainframe->getCfg('caching'); } $cache->setCaching($caching); $callback = array('plgCommunityWalls', '_getWallHTML'); $allowPosting = ($isMe || !$config->get('lockprofilewalls') || $config->get('lockprofilewalls') && $isConnected || $isSuperAdmin) && !$isGuest; $allowRemoval = $isMe || $isSuperAdmin; $maxchar = $this->params->get('charlimit', 0); if (!empty($maxchar)) { $this->characterLimitScript($maxchar); } //$cache_id = JCacheCallback::_makeId(array('plgCommunityWalls', '_getWallHTML'), array($user->id, $limit, $limitstart , $allowPosting , $allowRemoval)); //get cache id $callback_args = array($user->id, $limit, $limitstart, $allowPosting, $allowRemoval); $cache_id = md5(serialize(array($callback, $callback_args))); $javascript = <<<SHOWJS \t\t\t\t\t\t\tfunction getCacheId() \t\t\t\t\t\t \t{ \t\t\t\t\t\t\t\tvar cache_id = "'.{$cache_id}.'"; \t\t\t\t\t\t\t\treturn cache_id; \t\t\t\t\t\t\t} SHOWJS; $document->addScriptDeclaration($javascript); $content = $cache->call($callback, $user->id, $limit, $limitstart, $allowPosting, $allowRemoval); return $content; }