public function get($iPage = 0, $iLimit = 5, $iRequestId = 0) { $aCond = array(); ($sPlugin = Phpfox_Plugin::get('friend.service_request_request_get')) ? eval($sPlugin) : false; $aCond[] = 'fr.user_id = ' . Phpfox::getUserId() . ' AND fr.is_ignore = 0'; if ($iRequestId > 0) { $aCond[] = 'AND fr.request_id = ' . (int) $iRequestId; } $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'fr')->where($aCond)->execute('getSlaveField'); $aRows = $this->database()->select('fr.request_id, fr.is_seen, fr.message, fr.friend_user_id, fr.time_stamp, fr.relation_data_id , ' . Phpfox::getUserField())->from($this->_sTable, 'fr')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = fr.friend_user_id')->where($aCond)->limit($iPage, $iLimit, $iCnt)->order('fr.is_seen ASC, fr.time_stamp DESC')->group('fr.request_id')->execute('getSlaveRows'); $sIds = ''; foreach ($aRows as $iKey => $aRow) { $sIds .= $aRow['request_id'] . ','; list($iTotal, $aMutual) = Friend_Service_Friend::instance()->getMutualFriends($aRow['friend_user_id'], 5); $aRows[$iKey]['mutual_friends'] = array('total' => $iTotal, 'friends' => $aMutual); if ($sPlugin = Phpfox_Plugin::get('friend.service_request_get__2')) { eval($sPlugin); } } $sIds = rtrim($sIds, ','); if (!empty($sIds)) { $this->database()->update(Phpfox::getT('friend_request'), array('is_seen' => '1'), 'request_id IN(' . $sIds . ')'); } if ($sPlugin = Phpfox_Plugin::get('friend.service_request_get__3')) { eval($sPlugin); } return array($iCnt, $aRows); }
public function doPoke() { if (!Phpfox::getUserParam('poke.can_poke')) { return Phpfox_Error::display(Phpfox::getPhrase('poke.you_are_not_allowed_to_send_pokes')); } if (Phpfox::getUserParam('poke.can_only_poke_friends') && !Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $this->get('user_id'))) { return Phpfox_Error::display(Phpfox::getPhrase('poke.you_can_only_poke_your_own_friends')); } if (Phpfox::getService('poke.process')->sendPoke($this->get('user_id'))) { /* Type 1 is when poking back from the display block*/ if ($this->get('type') == '1') { $this->call('$("#poke_' . $this->get('user_id') . '").hide().remove();'); } else { $this->call('$("#liPoke").hide().remove();'); $this->alert(Phpfox::getPhrase('poke.poke_sent')); } } else { $this->alert(Phpfox::getPhrase('poke.poke_could_not_be_sent')); } list($iTotalPokes, $aPokes) = Phpfox::getService('poke')->getPokesForUser(Phpfox::getUserId()); if (!$iTotalPokes) { $this->call('$("#js_block_border_poke_display").remove();'); } else { $this->call('$("#poke_' . $this->get('user_id') . '").hide().remove();'); } }
/** * Controller */ public function process() { ($sPlugin = Phpfox_Plugin::get('friend.component_block_mini_process')) ? eval($sPlugin) : false; if (isset($bHideThisBlock)) { return false; } if (Phpfox::getUserBy('profile_page_id')) { return false; } if (!Phpfox::isUser()) { return false; } $iTotal = 20; if (Phpfox::getParam('friend.load_friends_online_ajax') && !PHPFOX_IS_AJAX) { $aRows = array(); $iCnt = 0; } else { list($iCnt, $aRows) = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . Phpfox::getUserId(), 'ls.last_activity DESC', 0, $iTotal, true, false, true); } if (!$iCnt) { return false; } $this->template()->assign(array('sHeader' => '' . Phpfox::getPhrase('friend.friends_online') . ' (<span id="js_total_block_friends_onlin">' . $iCnt . '</span>)', 'aFriends' => $aRows, 'iTotalFriendsOnline' => $iCnt)); return 'block'; }
/** * Controller */ public function process() { if (!defined('PHPFOX_IS_USER_PROFILE') && !Phpfox::isUser()) { return false; } $aUser = $this->getParam('aUser'); $iTotal = (int) Phpfox::getComponentSetting(defined('PHPFOX_IS_USER_PROFILE') ? $aUser['user_id'] : Phpfox::getUserId(), 'friend.friend_display_limit_profile', Phpfox::getParam('friend.friend_display_limit')); $aTopFriends = Friend_Service_Friend::instance()->getTop(defined('PHPFOX_IS_USER_PROFILE') ? $aUser['user_id'] : Phpfox::getUserId(), $iTotal); $iCount = count($aTopFriends); if (defined('PHPFOX_IS_USER_PROFILE') && !$iCount) { return false; } $this->template()->assign(array('aTopFriends' => $aTopFriends)); if (defined('PHPFOX_IS_USER_PROFILE')) { $this->template()->assign(array('bMoveCursor' => false)); } else { $this->template()->assign(array('bMoveCursor' => true)); } if (!$this->getParam('bIsAjax')) { $this->template()->assign(array('sHeader' => Phpfox::getPhrase('friend.top_friends'), 'sBlockJsId' => 'top_friends')); $bCanEditSettings = false; if (defined('PHPFOX_IS_USER_PROFILE')) { if ($aUser['user_id'] == Phpfox::getUserId()) { // $bCanEditSettings = true; } $bCanEditSettings = false; } else { $bCanEditSettings = true; } if ($bCanEditSettings) { $this->template()->assign(array('aEditBar' => array('ajax_call' => 'friend.getEditBar', 'params' => '&type_id=profile&no_delete_link=true&is_edit_top=true'))); } return 'block'; } }
/** * Controller */ public function process() { $aUser = PHPFOX_IS_AJAX ? Phpfox::getService('user')->get(Phpfox::getUserId(), true) : $this->getParam('aUser'); if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'friend.view_friend')) { return false; } $iTotal = (int) Phpfox::getComponentSetting($aUser['user_id'], 'friend.friend_display_limit_profile', Phpfox::getParam('friend.friend_display_limit')); $aRows = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . $aUser['user_id'], 'friend.is_top_friend DESC, friend.ordering ASC, RAND()', 0, $iTotal, false); $iCount = count($aRows); if (!$iCount) { return false; } $sFriendsLink = Phpfox::getService('user')->getLink($aUser['user_id'], $aUser['user_name'], 'friend'); $this->template()->assign(array('sHeader' => '<a href="' . $this->url()->makeUrl($aUser['user_name'], 'friend') . '">' . Phpfox::getPhrase('friend.friends') . '<span>' . $aUser['total_friend'] . '</span></a>', 'aFriends' => $aRows, 'sFriendsLink' => $sFriendsLink, 'sBlockJsId' => 'profile_friend')); /* if (Phpfox::getUserParam('friend.can_remove_friends_from_profile') && $aUser['user_id'] == Phpfox::getUserId()) { $this->template()->assign(array( 'aEditBar' => array( 'ajax_call' => 'friend.getEditBar', 'params' => '&type_id=profile' ) ) ); $this->template()->assign('sDeleteBlock', 'profile'); } */ return 'block'; }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Friend_Service_Friend::instance()->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = m.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } if ($this->_sCategory !== null) { $this->database()->innerJoin(Phpfox::getT('event_category_data'), 'mcd', 'mcd.event_id = m.event_id'); if (!$bIsCount) { $this->database()->group('m.event_id'); } } if ($this->_iAttending !== null) { $this->database()->innerJoin(Phpfox::getT('event_invite'), 'ei', 'ei.event_id = m.event_id AND ei.rsvp_id = ' . (int) $this->_iAttending . ' AND ei.invited_user_id = ' . Phpfox::getUserId()); if (!$bIsCount) { $this->database()->select('ei.rsvp_id, '); $this->database()->group('m.event_id'); } } else { if (Phpfox::isUser()) { $this->database()->leftJoin(Phpfox::getT('event_invite'), 'ei', 'ei.event_id = m.event_id AND ei.invited_user_id = ' . Phpfox::getUserId()); if (!$bIsCount) { $this->database()->select('ei.rsvp_id, '); $this->database()->group('m.event_id'); } } } }
public function process() { Phpfox::isUser(true); // get the request for just one message $iId = (int) $this->request()->get('id'); $aMessages = Friend_Service_Friend::instance()->getBirthdayMessages(Phpfox::getUserId(), $iId); $this->template()->assign(array('aMessages' => $aMessages))->setBreadcrumb(Phpfox::getPhrase('friend.my_friends'), $this->url()->makeUrl('friend'))->setBreadCrumb(Phpfox::getPhrase('friend.birthday_e_cards'), $this->url()->makeUrl('friend.mybirthday'), true)->setTitle(Phpfox::getPhrase('friend.birthday_e_cards')); Phpfox::isModule('notification') ? Phpfox::getService('notification.process')->delete('friend_birthday', $iId, Phpfox::getUserId()) : null; }
public function process() { if (!Phpfox::getParam('friend.enable_birthday_notices')) { return false; } if (!Phpfox::isUser()) { return false; } $aBirthdays = Friend_Service_Friend::instance()->getBirthdays(Phpfox::getuserId()); $bIsEventSection = true; /* $bIsEventSection = (Phpfox_Module::instance()->getFullControllerName() == 'event.index' ? true : false); if (!Phpfox::isModule('event')) { $bIsEventSection = true; } */ if ($bIsEventSection && empty($aBirthdays) && Phpfox::getParam('friend.show_empty_birthdays') == false) { return false; } $aUpcomingEvents = array(); if (!$bIsEventSection) { if (Phpfox::isUser()) { $sEventCacheId = Phpfox::getLib('cache')->set(array('events', Phpfox::getUserId())); if (!($aUpcomingEvents = Phpfox::getLib('cache')->get($sEventCacheId, Phpfox::getParam('event.cache_upcoming_events_info') * 60))) { $this->search()->set(array('type' => 'event', 'field' => 'm.event_id', 'search_tool' => array('default_when' => 'upcoming', 'when_field' => 'start_time', 'when_upcoming' => true, 'table_alias' => 'm', 'sort' => array('latest' => array('m.start_time', 'Latest', 'ASC')), 'show' => array(5)))); $aBrowseParams = array('module_id' => 'event', 'alias' => 'm', 'field' => 'event_id', 'table' => Phpfox::getT('event'), 'hide_view' => array('pending', 'my')); $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%)'); $this->search()->browse()->params($aBrowseParams)->execute(); $aUpcomingEvents = $this->search()->browse()->getRows(); // http://www.phpfox.com/tracker/view/14796/ // iterate among dates foreach ($aUpcomingEvents as $sUpcomingDate => $aEvents) { // iterate among events foreach ($aEvents as $iKey => $aUpcomingEvent) { // if the event is in a page if (Phpfox::isModule('pages') && $aUpcomingEvent['module_id'] == 'pages') { // if current user is not member or admin, remove the event from the upcoming block if (!Phpfox::getService('pages')->isMember($aUpcomingEvent['profile_page_id']) && !Phpfox::getService('pages')->isAdmin($aUpcomingEvent['profile_page_id'])) { // if only one event in the date, erase the date if (count($aUpcomingEvents[$sUpcomingDate]) == 1) { unset($aUpcomingEvents[$sUpcomingDate]); } else { unset($aUpcomingEvents[$sUpcomingDate][$iKey]); } } } } } Phpfox::getLib('cache')->save($sEventCacheId, $aUpcomingEvents); } } } $this->template()->assign(array('aSearchTool' => '', 'aUpcomingEvents' => is_bool($aUpcomingEvents) ? array() : $aUpcomingEvents, 'aBirthdays' => $aBirthdays, 'bIsEventSection' => $bIsEventSection, 'sHeader' => $bIsEventSection ? Phpfox::getPhrase('friend.birthdays') : Phpfox::getPhrase('event.upcoming_events'))); return 'block'; }
/** * Controller */ public function process() { $iPage = $this->request()->getInt('page'); $iPageSize = 5; $aCond = array(); $aCond[] = 'AND friend.user_id = ' . Phpfox::getUserId(); list($iCnt, $aFriends) = Friend_Service_Friend::instance()->get($aCond, 'friend.time_stamp DESC', $iPage, $iPageSize, true, false, false, $this->request()->getInt('user_id')); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'ajax' => 'friend.getMutualFriends')); $this->template()->assign(array('aFriends' => $aFriends, 'iPage' => $iPage)); }
/** * Controller */ public function process() { define('PHPFOX_PROFILE_PRIVACY', true); $aUser = $this->getParam('aUser'); $bCanFrRequest = true; if (Phpfox::getService('user.block')->isBlocked($aUser['user_id'], Phpfox::getUserId()) && (Phpfox::isModule('friend') && Phpfox::getParam('friend.allow_blocked_user_to_friend_request') == false)) { $bCanFrRequest = false; } $this->template()->setTitle($aUser['full_name'])->assign(array('aUser' => $aUser, 'bIsFriend' => Phpfox::getUserId() && Phpfox::isModule('friend') ? Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $aUser['user_id']) : false, 'bIsBlocked' => Phpfox::isUser() ? Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aUser['user_id']) : false, 'bCanFrRequest' => $bCanFrRequest)); }
/** * Controller */ public function process() { $oUser = User_Service_User::instance(); $aUser = $oUser->getByUserName($this->request()->get('user_name')); $bIsPage = $aUser['profile_page_id'] > 0 ? true : false; if ($bIsPage) { $aUser['page'] = Phpfox::getService('pages')->getPage($aUser['profile_page_id']); // list($iTotalMembers, $aMembers) = Phpfox::getService('pages')->getMembers($aUser['page']['page_id']); // $aUser['page_members'] = $aMembers; } $aUser['birthday_time_stamp'] = $aUser['birthday']; $aUser['birthday'] = $oUser->age($aUser['birthday']); $aUser['gender_name'] = $oUser->gender($aUser['gender']); $aUser['birthdate_display'] = $oUser->getProfileBirthDate($aUser); $aUser['location'] = Phpfox::getPhraseT(Phpfox::getService('core.country')->getCountry($aUser['country_iso']), 'country'); if (isset($aUser['country_child_id']) && $aUser['country_child_id'] > 0) { $aUser['location_child'] = Phpfox::getService('core.country')->getChild($aUser['country_child_id']); } $aUser['is_friend'] = false; $iTotal = 0; $aMutual = array(); if ($aUser['user_id'] != Phpfox::getUserId() && !$bIsPage) { if (Phpfox::isUser() && Phpfox::isModule('friend')) { $aUser['is_friend'] = Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $aUser['user_id']); if (!$aUser['is_friend']) { $aUser['is_friend'] = Phpfox::getService('friend.request')->isRequested(Phpfox::getUserId(), $aUser['user_id']) ? 2 : false; } } list($iTotal, $aMutual) = Friend_Service_Friend::instance()->getMutualFriends($aUser['user_id'], 4); } $bShowBDayInput = false; if (!empty($aUser['birthday'])) { $iDays = Phpfox::getLib('date')->daysToDate($aUser['birthday'], null, false); } else { $iDays = 999; } if ($iDays < 1 && $iDays > 0) { $bShowBDayInput = true; } if (empty($aUser['dob_setting'])) { switch (Phpfox::getParam('user.default_privacy_brithdate')) { case 'month_day': $aUser['dob_setting'] = '1'; break; case 'show_age': $aUser['dob_setting'] = '2'; break; case 'hide': $aUser['dob_setting'] = '3'; break; } } ($sPlugin = Phpfox_Plugin::get('user.component_block_tooltip_1')) ? eval($sPlugin) : false; $this->template()->assign(array('bIsPage' => $bIsPage, 'aUser' => $aUser, 'iMutualTotal' => $iTotal, 'aMutualFriends' => $aMutual, 'bShowBDay' => $bShowBDayInput)); }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Friend_Service_Friend::instance()->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = pa.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } // http://www.phpfox.com/tracker/view/14733/ if (Phpfox::isModule('like')) { $this->database()->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = "photo_album" AND l.item_id = pa.album_id AND l.user_id = ' . Phpfox::getUserId() . ''); } // END }
/** * Controller */ public function process() { Phpfox::isUser(true); $aUser = Phpfox::getService('user')->getUser($this->request()->get('id')); if (empty($aUser)) { return Phpfox_Error::display(Phpfox::getPhrase('friend.not_a_valid_user_to_be_friends_with')); } if (Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $aUser['user_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('friend.you_are_already_friends_with_this_user')); } $this->template()->setBreadcrumb(Phpfox::getPhrase('friend.friends_request'))->setTitle(Phpfox::getPhrase('friend.friends_request'))->assign(array('aUser' => $aUser)); }
public function add($sType, $iItemId, $iUserId = null) { $bIsNotNull = false; if ($iUserId === null) { $iUserId = Phpfox::getUserId(); $bIsNotNull = true; } if ($sType == 'pages') { $bIsNotNull = false; } // check if iUserId can Like this item $aFeed = $this->database()->select('privacy, user_id')->from(Phpfox::getT('feed'))->where('item_id = ' . (int) $iItemId . ' AND type_id = "' . Phpfox::getLib('parse.input')->clean($sType) . '"')->execute('getSlaveRow'); /* if (($sType != 'pages') && $sType != 'event' && empty($aFeed)) { return Phpfox_Error::display('Item does not exist.'); } */ if (!empty($aFeed) && isset($aFeed['privacy']) && !empty($aFeed['privacy']) && !empty($aFeed['user_id']) && $aFeed['user_id'] != $iUserId) { if ($aFeed['privacy'] == 1 && Friend_Service_Friend::instance()->isFriend($iUserId, $aFeed['user_id']) != true) { return Phpfox_Error::display('Not allowed to like this item.'); } else { if ($aFeed['privacy'] == 2 && Friend_Service_Friend::instance()->isFriendOfFriend($iUserId) != true) { return Phpfox_Error::display('Not allowed to like this item.'); } else { if ($aFeed['privacy'] == 3 && $aFeed['user_id'] != Phpfox::getUserId()) { return Phpfox_Error::display('Not allowed to like this item.'); } else { if ($aFeed['privacy'] == 4 && ($bCheck = Privacy_Service_Privacy::instance()->check($sType, $iItemId, $aFeed['user_id'], $aFeed['privacy'], null, true)) != true) { return Phpfox_Error::display('Not allowed to like this item.'); } } } } } $iCheck = $this->database()->select('COUNT(*)')->from(Phpfox::getT('like'))->where('type_id = \'' . $this->database()->escape($sType) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . $iUserId)->execute('getField'); if ($iCheck) { return Phpfox_Error::set(Phpfox::getPhrase('feed.you_have_already_liked_this_feed')); } $iCnt = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('like_cache'))->where('type_id = \'' . $this->database()->escape($sType) . '\' AND item_id = ' . (int) $iItemId . ' AND user_id = ' . (int) $iUserId)->execute('getSlaveField'); $this->database()->insert($this->_sTable, array('type_id' => $sType, 'item_id' => (int) $iItemId, 'user_id' => $iUserId, 'time_stamp' => PHPFOX_TIME)); $iCnt = 0; if (!$iCnt) { $this->database()->insert(Phpfox::getT('like_cache'), array('type_id' => $sType, 'item_id' => (int) $iItemId, 'user_id' => $iUserId)); } Phpfox::getService('feed.process')->clearCache($sType, $iItemId); if ($sPlugin = Phpfox_Plugin::get('like.service_process_add__1')) { eval($sPlugin); } Phpfox::callback($sType . '.addLike', $iItemId, $iCnt ? true : false, $bIsNotNull ? null : $iUserId); return true; }
/** * Controller */ public function process() { if (defined('PHPFOX_IS_AJAX_CONTROLLER')) { $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id')); $this->setParam('aUser', $aUser); } $iPageSize = 12; $iPage = $this->request()->getInt('page'); $aUser = $this->getParam('aUser'); $bMutual = $this->request()->get('req3') == 'mutual' ? true : false; if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'friend.view_friend')) { return Phpfox_Error::display('<div class="extra_info">' . Phpfox::getService('user')->getFirstName($aUser['full_name']) . ' has closed ' . Phpfox::getService('user')->gender($aUser['gender'], true) . ' friends section.</div>'); } $aFilters = array('sort' => array('type' => 'select', 'options' => array(), 'default' => 'full_name', 'alias' => 'u'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'ASC'), 'search' => array('type' => 'input:text', 'search' => '(u.full_name LIKE \'%[VALUE]%\' OR u.email LIKE \'%[VALUE]%\') AND', 'size' => '15', 'onclick' => 'Search')); $oFilter = Phpfox_Search::instance()->set(array('type' => 'friend', 'filters' => $aFilters, 'search' => 'search')); if ($bMutual === true) { $oFilter->setCondition('friend.is_page = 0 AND friend.user_id = ' . Phpfox::getUserId()); $this->template()->setBreadcrumb(Phpfox::getPhrase('friend.mutual_friends'), null, true); } else { $oFilter->setCondition('friend.is_page = 0 AND friend.user_id = ' . (int) $aUser['user_id']); if ($this->request()->get('view')) { $this->template()->setBreadcrumb(Phpfox::getPhrase('friend.friends_online'), null, true); } } if (($iListId = $this->request()->getInt('list')) && ($aList = Phpfox::getService('friend.list')->getList($iListId, Phpfox::getUserId())) && isset($aList['list_id'])) { $this->search()->setCondition('AND fld.list_id = ' . (int) $aList['list_id'] . ' AND friend.user_id = ' . $aUser['user_id']); // $this->template()->setTitle($aList['name'])->setBreadcrumb($aList['name'], $this->url()->makeUrl('friend', array('view' => 'list', 'id' => $iListId)), true); } list($iCnt, $aFriends) = Friend_Service_Friend::instance()->get($oFilter->getConditions(), $oFilter->getSort(), $oFilter->getPage(), $iPageSize, true, true, $this->request()->get('view') ? true : false, $bMutual === true ? $aUser['user_id'] : null); $iCnt = $oFilter->getSearchTotal($iCnt); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->setParam('aTotalFriends', $iCnt); $this->template()->setMeta('keywords', Phpfox::getPhrase('friend.full_name_s_friends', array('full_name' => $aUser['full_name']))); $this->template()->setMeta('keywords', Phpfox::getParam('friend.friend_meta_keywords')); $this->template()->setMeta('description', Phpfox::getPhrase('friend.full_name_is_on_site_title_and_has_total_friends', array('full_name' => $aUser['full_name'], 'site_title' => Phpfox::getParam('core.site_title'), 'total' => $iCnt))); if ($iCnt) { $sCustomFriends = ''; foreach ($aFriends as $aFriend) { $sCustomFriends .= $aFriend['full_name'] . ', '; } $sCustomFriends = rtrim($sCustomFriends, ', '); $this->template()->setMeta('description', Phpfox::getPhrase('friend.full_name_is_connected_with_friends', array('full_name' => $aUser['full_name'], 'friends' => $sCustomFriends))); } $this->template()->setMeta('description', Phpfox::getPhrase('friend.sign_up_on_site_title_and_connect_with_full_name_message_full_name_or_add_full_name_as_you', array('site_title' => Phpfox::getParam('core.site_title'), 'full_name' => $aUser['full_name']))); if (Phpfox::getUserId() == $aUser['user_id']) { // $this->template()->assign('lists', Friend_Service_List_List::instance()->get()); $this->template()->menu('Manage Friends', $this->url()->makeUrl('friend')); } $this->template()->setTitle(Phpfox::getPhrase('friend.full_name_s_friends', array('full_name' => $aUser['full_name'])))->setBreadcrumb(Phpfox::getPhrase('friend.friends'))->setHeader('cache', array('pager.css' => 'style_css', 'friend.css' => 'style_css'))->assign(array('aFriends' => $aFriends, 'sFriendView' => $this->request()->get('view'), 'activeList' => $this->request()->get('list'))); }
/** * Controller */ public function process() { Phpfox::isUser(true); if (($iDeleteList = $this->request()->getInt('dlist')) && Phpfox::getService('friend.list.process')->delete($iDeleteList)) { $this->url()->send('friend', true, Phpfox::getPhrase('friend.list_successfully_deleted')); } $sView = $this->request()->get('view'); $iPage = $this->request()->getInt('page'); $this->template()->setTitle(Phpfox::getPhrase('friend.friends'))->setBreadcrumb(Phpfox::getPhrase('friend.friends'), $this->url()->makeUrl('friend')); $aSort = array(); if ($sView == 'list') { $aSort['custom'] = array('fld.ordering', Phpfox::getPhrase('friend.custom_order')); } $aSort['latest'] = array('friend.time_stamp', Phpfox::getPhrase('friend.newest_friends')); $aSort['first-name'] = array('u.full_name', Phpfox::getPhrase('friend.by_first_name'), 'ASC'); $aParams = array('type' => 'friend', 'field' => 'friend.friend_id', 'search_tool' => array('table_alias' => 'friend', 'search' => array('action' => $this->url()->makeUrl('friend', array('view' => $this->request()->get('view'))), 'default_value' => Phpfox::getPhrase('friend.search_friends_dot_dot_dot'), 'name' => 'search', 'field' => 'u.full_name'), 'sort' => $aSort, 'show' => array(10, 15, 20))); $this->search()->set($aParams); $iPageSize = $this->search()->getDisplay(); $bIsOnline = false; $iListId = 0; $aSend = null; $aList = array(); switch ($sView) { case 'list': if (($iListId = $this->request()->getInt('id')) && ($aList = Phpfox::getService('friend.list')->getList($iListId, Phpfox::getUserId())) && isset($aList['list_id'])) { $this->search()->setCondition('AND fld.list_id = ' . (int) $aList['list_id']); $aSend = array('list' => $iListId); $this->template()->setTitle($aList['name'])->setBreadcrumb($aList['name'], $this->url()->makeUrl('friend', array('view' => 'list', 'id' => $iListId)), true); } else { return Phpfox_Error::display(Phpfox::getPhrase('friend.invalid_friend_list')); } break; default: $this->search()->setCondition('AND friend.is_page = 0 AND friend.user_id = ' . Phpfox::getUserId()); break; } if (($aVals = $this->request()->getArray('val')) && isset($aVals['id']) && is_array($aVals['id'])) { $oServiceFriendProcess = Phpfox::getService('friend.process'); foreach ($aVals['id'] as $iId) { $oServiceFriendProcess->delete($iId); } $this->url()->send('friend', $aSend, Phpfox::getPhrase('friend.successfully_deleted')); } list($iCnt, $aRows) = Friend_Service_Friend::instance()->get($this->search()->getConditions(), $this->search()->getSort(), $this->search()->getPage(), $iPageSize, true, true, $bIsOnline, null, true); Phpfox::getLib('pager')->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'ajax' => 'friend.viewMoreFriends')); Friend_Service_Friend::instance()->buildMenu(); $this->template()->setHeader('jquery/ui.js', 'static_script'); $this->template()->setHeader('cache', array('friend.js' => 'module_friend'))->assign(array('aFriends' => $aRows, 'aList' => $aList, 'iList' => $iListId, 'sView' => $sView, 'iTotalFriendRequests' => Phpfox::getService('friend.request')->getUnseenTotal())); }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Friend_Service_Friend::instance()->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = photo.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } if ($this->request()->get('req2') == 'tag') { $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = photo.photo_id AND tag.category_id = \'photo\''); } if ($this->_sCategory !== null || isset($_SESSION['photo_category']) && $_SESSION['photo_category'] != '') { $this->database()->innerJoin(Phpfox::getT('photo_category_data'), 'pcd', 'pcd.photo_id = photo.photo_id'); if (!$bIsCount) { $this->database()->group('photo.photo_id'); } } }
/** * Controller */ public function process() { $sError = false; $iUserId = $this->getParam('user_id'); $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField()); if (Phpfox::getUserId() === $aUser['user_id']) { $sError = 'same_user'; } elseif (Phpfox::getService('friend.request')->isRequested(Phpfox::getUserId(), $aUser['user_id'])) { $sError = 'already_asked'; } elseif (Phpfox::getService('friend.request')->isRequested($aUser['user_id'], Phpfox::getUserId())) { $sError = 'user_asked_already'; } elseif (Friend_Service_Friend::instance()->isFriend($aUser['user_id'], Phpfox::getUserId())) { $sError = 'already_friends'; } $this->template()->setPhrase(array('core.you_cannot_write_more_then_limit_characters', 'core.you_have_limit_character_s_left'))->setHeader(array())->assign(array('aUser' => $aUser, 'sError' => $sError, 'aOptions' => Phpfox::getService('friend.list')->get(), 'bSuggestion' => $this->request()->get('suggestion') ? true : false, 'bPageSuggestion' => $this->request()->get('suggestion_page') ? true : false, 'bInvite' => $this->request()->get('invite') ? true : false)); }
/** * Controller */ public function process() { Phpfox::isUser(true); $aCheckParams = array('url' => $this->url()->makeUrl('friend'), 'start' => 3, 'reqs' => array('2' => array('accept', 'pending'))); if (Phpfox::getParam('core.force_404_check') && !Phpfox::getService('core.redirect')->check404($aCheckParams)) { return Phpfox_Module::instance()->setController('error.404'); } $iPage = $this->request()->getInt('page'); $iLimit = Phpfox::getParam('friend.total_requests_display'); $iRequestId = $this->request()->getInt('id'); list($iCnt, $aFriends) = Phpfox::getService('friend.request')->get($iPage, $iLimit, $iRequestId); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iLimit, 'count' => $iCnt)); Friend_Service_Friend::instance()->buildMenu(); $this->setParam('global_moderation', array('name' => 'friend', 'ajax' => 'friend.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('friend.accept'), 'action' => 'accept'), array('phrase' => Phpfox::getPhrase('friend.deny'), 'action' => 'deny')))); $this->template()->setTitle(Phpfox::getPhrase('friend.friend_requests'))->setBreadcrumb(Phpfox::getPhrase('friend.friends'), $this->url()->makeUrl('friend'))->assign(array('aFriends' => $aFriends, 'iRequestId' => $iRequestId, 'bIsFriendController' => true)); }
/** * Controller */ public function process() { Phpfox::isUser(true); if ($iDeleteId = $this->request()->get('id')) { if (Phpfox::getService('friend.request.process')->delete($iDeleteId, Phpfox::getUserId())) { $this->url()->send('friend.pending', null, Phpfox::getPhrase('friend.friends_request_successfully_deleted')); } } $iPage = $this->request()->getInt('page'); $iPageSize = 12; list($iCnt, $aPendingRequests) = Phpfox::getService('friend.request')->getPending($iPage, $iPageSize); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); Friend_Service_Friend::instance()->buildMenu(); $this->template()->setTitle('Friends')->setBreadcrumb(Phpfox::getPhrase('friend.my_friends'), $this->url()->makeUrl('friend')); $this->template()->setTitle(Phpfox::getPhrase('friend.pending_friend_requests'))->setHeader('cache', array('pager.css' => 'style_css', 'friend.css' => 'style_css'))->assign(array('aPendingRequests' => $aPendingRequests)); }
public function process() { $aUser = $this->getParam('aUser'); if (empty($aUser)) { $aUser = $this->request()->get('iUser'); } //$iUser = (PHPFOX_IS_AJAX ? $this->request()->get('iUser') : $this->getParam('iUser')); $this->template()->assign(array('iUser' => $aUser['user_id'])); if (!PHPFOX_IS_AJAX) { if (Friend_Service_Friend::instance()->isBirthdaySent(Phpfox::getUserId(), $aUser['user_id'])) { return false; } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('friend.birthday_notification'))); return 'block'; } }
/** * This function does the normal permissions checks and also checks the database * if the user has a pending poke it should not allow the current user to send * a new poke */ public function canSendPoke($iUser) { /* If user cannot send pokes or can only send pokes to friends but $iUser is not a friend */ if (!Phpfox::getUserParam('poke.can_poke') || Phpfox::getUserParam('poke.can_only_poke_friends') && !Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $iUser)) { return false; } /* if (Phpfox::getParam('core.super_cache_system')) { $sCacheId = $this->cache()->set(array('pokes', $iUser)); if ( !($aCache = $this->cache()->get($sCacheId)) ) { $aCache = $this->database()->select('p.*, u.user_name, u.full_name') ->from($this->_sTable, 'p') ->join(Phpfox::getT('user'), 'u', 'u.user_id = p.to_user_id') ->where('p.user_id = ' . (int)$iUser) ->execute('getSlaveRows'); $iCnt = count($aCache); $aCache = array('cnt' => $iCnt, 'pokes' => $aCache); $this->cache()->save($sCacheId, $aCache); } if (!is_array($aCache)) { return false; } if ($aCache['cnt'] < 1) { return true; } foreach ($aCache['pokes'] as $aPoke) { if ($aPoke['user_id'] == Phpfox::getUserId() && $aPoke['status_id'] == 1) { return true; } } return false; } */ /* if $iUser has a pending poke */ $iExists = $this->database()->select('poke_id')->from($this->_sTable)->where('user_id = ' . Phpfox::getUserId() . ' AND to_user_id = ' . (int) $iUser . ' AND status_id = 1')->execute('getSlaveField'); return empty($iExists); }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Friend_Service_Friend::instance()->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = blog.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } if (Phpfox::getParam('core.section_privacy_item_browsing')) { if ($this->search()->isSearch()) { $this->database()->join(Phpfox::getT('blog_text'), 'blog_text', 'blog_text.blog_id = blog.blog_id'); } } else { if ($bIsCount && $this->search()->isSearch()) { $this->database()->join(Phpfox::getT('blog_text'), 'blog_text', 'blog_text.blog_id = blog.blog_id'); } } if ($this->request()->get(defined('PHPFOX_IS_PAGES_VIEW') ? 'req4' : 'req2') == 'tag') { $this->database()->innerJoin(Phpfox::getT('tag'), 'tag', 'tag.item_id = blog.blog_id AND tag.category_id = \'blog\''); } if ($this->request()->get(defined('PHPFOX_IS_USER_PROFILE') ? 'req3' : 'req2') == 'category') { $this->database()->innerJoin(Phpfox::getT('blog_category_data'), 'blog_category_data', 'blog_category_data.blog_id = blog.blog_id')->innerJoin(Phpfox::getT('blog_category'), 'blog_category', 'blog_category.category_id = blog_category_data.category_id'); } }
/** * This function validates the permission to send a PM to another user, it * takes into account the user group setting: mail.can_compose_message * the privacy setting by the receiving user: mail.send_message * and if the receiving user is blocked by the sender user or viceversa * Also checks on other user group based restrictions * @param int $iUser The user id of the member trying to send a message * @return boolean true if its ok to send the message, false otherwise */ public function canMessageUser($iUser) { ($sPlugin = Phpfox_Plugin::get('mail.service_mail_canmessageuser_1')) ? eval($sPlugin) : false; if (isset($bCanOverrideChecks)) { return true; } // 1. user group setting: if (!Phpfox::getUserParam('mail.can_compose_message')) { return false; } // 2. Privacy setting check $iPrivacy = $this->database()->select('user_value')->from(Phpfox::getT('user_privacy'))->where('user_id = ' . (int) $iUser . ' AND user_privacy = "mail.send_message"')->execute('getSlaveField'); if (!empty($iPrivacy) && !Phpfox::isAdmin()) { if ($iPrivacy == 4) { return false; } else { if ($iPrivacy == 1 && !Phpfox::isUser()) { return false; } else { if ($iPrivacy == 2 && !Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $iUser, false)) { return false; } } } } // 3. Blocked users if (!Phpfox::isAdmin() && (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iUser) > 0 || Phpfox::getService('user.block')->isBlocked($iUser, Phpfox::getUserId()) > 0)) { return false; } // 4. Sending message to oneself vs the setting mail.can_message_self if ($iUser == Phpfox::getUserId() && !Phpfox::getUserParam('mail.can_message_self')) { return false; } // 5. User group setting (different from check 2 since that is user specific) if (Phpfox::getUserParam('mail.restrict_message_to_friends') == true && Friend_Service_Friend::instance()->isFriend(Phpfox::getUserId(), $iUser, false) == false && Phpfox::getUserParam('mail.override_restrict_message_to_friends') == false) { return false; } // then its ok return true; }
public function process() { if ($this->request()->get('resettimeline')) { $aUser = PHPFOX_IS_AJAX ? Phpfox::getService('user')->get($this->request()->get('profile_user_id'), true) : $this->getParam('aUser'); } else { $aUser = PHPFOX_IS_AJAX ? Phpfox::getService('user')->get(Phpfox::getUserId(), true) : $this->getParam('aUser'); } if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'friend.view_friend')) { return false; } if (defined('PAGE_TIME_LINE') && PAGE_TIME_LINE) { return false; } $iTotal = 6; $aRows = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . $aUser['user_id'], 'friend.is_top_friend DESC, friend.ordering ASC, RAND()', 0, $iTotal, false); $iCount = count($aRows); if (!$iCount) { return false; } $sFriendsLink = Phpfox::getService('user')->getLink($aUser['user_id'], $aUser['user_name'], 'friend'); $this->template()->assign(array('aFriends' => $aRows, 'sFriendsLink' => $sFriendsLink)); }
/** * Controller */ public function process() { Phpfox::isUser(true); if (!Phpfox::getUserParam('user.can_delete_own_account')) { Phpfox_Url::instance()->send(''); } if (Phpfox::isModule('friend')) { list($iCnt, $aShowFriends) = Friend_Service_Friend::instance()->get('friend.is_page = 0 AND friend.user_id = ' . Phpfox::getUserId() . ' AND ' . Phpfox_Database::instance()->isNotNull('user_image'), 'RAND()', 0, 3); $this->template()->assign(array('aFriends' => $aShowFriends, 'aReasons' => Phpfox::getService('user')->getReasons())); } // is not confirming if ($this->request()->get('req3') == 'confirm') { if ($aVals = $this->request()->getArray('val')) { // user inputted password, no turning back now... if (User_Service_Cancellations_Process::instance()->cancelAccount($aVals)) { // redirect is in the cancelAccoutn because of the logout } else { // an error occured (??) } } } $this->template()->setTitle(Phpfox::getPhrase('user.cancel_account'))->setBreadcrumb(Phpfox::getPhrase('user.cancel_account')); }
/** * Controller */ public function process() { $aUser = $this->getParam('aUser'); if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'friend.view_friend')) { return false; } if (Phpfox::getUserId() == $aUser['user_id'] && !defined('PHPFOX_IN_DESIGN_MODE')) { return false; } if (Phpfox::getUserId() == $aUser['user_id']) { $this->template()->assign(array('sHeader' => Phpfox::getPhrase('friend.mutual_friends'), 'sDeleteBlock' => 'profile')); return 'block'; } list($iTotal, $aRows) = Friend_Service_Friend::instance()->getMutualFriends($aUser['user_id']); if (!$iTotal) { return false; } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('friend.mutual_friends'), 'sDeleteBlock' => 'profile', 'aMutualFriends' => $aRows, 'iTotalMutualFriends' => $iTotal)); if ($iTotal > 3) { $this->template()->assign(array('aFooter' => array(Phpfox::getPhrase('friend.view_all') => $this->url()->makeUrl($aUser['user_name'], array('friend', 'mutual'))))); } return 'block'; }
/** * Controller */ public function process() { Phpfox::isUser(true); $iPageSize = 10; $iPage = $this->request()->getInt('page'); $bIsSearch = false; $aCond = array(); $aCond[] = 'AND friend.user_id = ' . Phpfox::getUserId(); if (($sSearch = $this->request()->get('search')) || $this->request()->get('search-query')) { if ($this->request()->get('search-query')) { $sSearch = Phpfox::getLib('session')->get('mfsearch'); } $bIsSearch = true; $aCond[] = "AND (u.full_name LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR u.email LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR u.user_name LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%')"; $this->url()->setParam('search-query', 'true'); Phpfox::getLib('session')->set('mfsearch', $sSearch); } if ($bIsSearch == false) { Phpfox::getLib('session')->remove('mfsearch'); } list($iCnt, $aFriends) = Friend_Service_Friend::instance()->get($aCond, 'u.full_name ASC', $iPage, $iPageSize); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('aFriends' => $aFriends, 'bMobileFriendIsActive' => true, 'bIsSearch' => $bIsSearch, 'bIsFriendSelect' => $this->request()->get('req2') == 'select' ? true : false)); }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Friend_Service_Friend::instance()->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = m.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } }
public function check($sModule, $iItemId, $iUserId, $iPrivacy, $iIsFriend = null, $bReturn = false) { $bCanViewItem = true; if ($iUserId != Phpfox::getUserId() && !Phpfox::getUserParam('privacy.can_view_all_items')) { switch ($iPrivacy) { case 1: if ((int) $iIsFriend <= 0) { $bCanViewItem = false; } break; case 2: if ((int) $iIsFriend > 0) { $bCanViewItem = true; } else { if (!Friend_Service_Friend::instance()->isFriendOfFriend($iUserId)) { $bCanViewItem = false; } } break; case 3: $bCanViewItem = false; break; case 4: if (Phpfox::isUser()) { $iCheck = (int) $this->database()->select('COUNT(privacy_id)')->from($this->_sTable, 'p')->join(Phpfox::getT('friend_list_data'), 'fld', 'fld.list_id = p.friend_list_id AND fld.friend_user_id = ' . Phpfox::getUserId())->where('p.module_id = \'' . $this->database()->escape($sModule) . '\' AND p.item_id = ' . (int) $iItemId . '')->execute('getSlaveField'); if ($iCheck === 0) { $bCanViewItem = false; } } else { $bCanViewItem = false; } break; } } if ($bReturn === true) { return $bCanViewItem; } if ($bCanViewItem === false) { Phpfox_Url::instance()->send('privacy.invalid'); } }