/** * 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'; } }
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 (Phpfox::getService('friend')->isBirthdaySent(Phpfox::getUserId(), $aUser['user_id'])) { return false; } $this->template()->assign(array( 'sHeader' => 'Birthday Notification' ) ); return 'block'; } }
public function sendEmail($sType) { $this->database()->update($this->_sTable, array( 'send_email' => (int) $sType ), 'user_id = ' . Phpfox::getUserId() ); if ((int) $sType === 2) { $aUserInfo = Phpfox::getService('facebook.api')->getUserInfo(); if (Phpfox::getService('facebook')->checkEmail($aUserInfo['email']) !== false) { return false; } $this->database()->update(Phpfox::getT('user'), array( 'email' => $aUserInfo['email'] ), 'user_id = ' . Phpfox::getUserId() ); if ($aUserInfo['email'] == $aUserInfo['proxied_email']) { $this->database()->update($this->_sTable, array( 'is_proxy_email' => '1' ), 'user_id = ' . Phpfox::getUserId() ); } } return true; }
protected function getRandomLink($sType) { $sField = $sType . '_id'; $sTable = Phpfox::getT($sType); $sLink = $sType; switch ($sType) { case 'pages': $sField = 'page_id'; break; case 'music_song': $sField = 'song_id'; $sLink = 'music'; break; case 'mail': $this->database()->where('owner_user_id = ' . Phpfox::getUserId() . ' OR ' . 'viewer_user_id = ' . Phpfox::getUserId()); $sLink = 'mail.view'; break; case 'forum_thread': $sField = 'thread_id'; $sLink = 'forum.thread'; break; } $id = $this->database()->select($sField)->from($sTable)->order('RAND()')->execute('getField'); if (!$id) { return false; } $sUrl = Phpfox::getLib('url')->makeUrl($sLink, array($id)); return $sUrl; }
public function get() { /* @title @info Get all the messages of the user that is logged in. @method GET @extra @return id=#{Message ID#|int}&subject=#{Subject|string}&preview=#{Preview of the message|string}&from=#{From|string}&from_url=#{Profile link of the person who sent the message|string}&permalink=#{Link to the message|string}&new=#{Check to see if the message is read or not. <b>True</b> is a new message|bool} */ $iUserId = Phpfox::getUserId(); $aCond = array(); if (Phpfox::getParam('mail.threaded_mail_conversation')) { $aCond[] = 'AND m.viewer_user_id = ' . $iUserId . ' AND m.is_archive = 0'; } else { $aCond[] = 'AND m.viewer_folder_id = 0 AND m.viewer_user_id = ' . $iUserId . ' AND m.viewer_type_id = 0'; } $aMessages = array(); list($iTotal, $aMessageRows, $aTotals) = Phpfox::getService('mail')->get($aCond); foreach ($aMessageRows as $iKey => $aMessageRow) { $aMessages[$iKey] = array('id' => Phpfox::getParam('mail.threaded_mail_conversation') ? $aMessageRow['thread_id'] : $aMessageRow['mail_id'], 'subject' => Phpfox::getParam('mail.threaded_mail_conversation') ? '' : $aMessageRow['subject'], 'preview' => $aMessageRow['preview'], 'from' => $aMessageRow['full_name'], 'from_url' => Phpfox::getLib('url')->makeUrl($aMessageRow['user_name']), 'permalink' => Phpfox::getParam('mail.threaded_mail_conversation') ? Phpfox::getLib('url')->makeUrl('mail.thread', array('id' => $aMessageRow['thread_id'])) : Phpfox::getLib('url')->makeUrl('mail.view.' . $aMessageRow['mail_id']), 'new' => $aMessageRow['viewer_is_new'] ? true : false); if (Phpfox::getParam('mail.threaded_mail_conversation')) { unset($aMessages[$iKey]['subject']); } } return $aMessages; }
/** This function catches all the "actions" (Dislike, and in the future maybe others) * */ public function getNotificationAction($aNotification) { //d($aNotification);die(); // get the type of item that was marked ("blog", "photo"...) $aAction = $this->database()->select('*')->from(Phpfox::getT('action'))->where('action_id = ' . (int) $aNotification['item_id'])->limit(1)->execute('getSlaveRow'); if (empty($aAction) || !isset($aAction['item_type_id'])) { return false; throw new Exception('No type for this action (' . print_r($aAction, true) . ')'); } // Check if the module is a sub module if (preg_match('/(?P<module>[a-z]+)[_]?(?P<submodule>[a-z]{0,99})/i', $aAction['item_type_id'], $aMatch) < 1) { throw new Exception('Malformed item_type'); } // Call the module and get the title if (!Phpfox::isModule($aMatch['module'])) { return false; } $aRow = Phpfox::getService($aMatch['module'])->getInfoForAction($aAction); $sUsers = Phpfox::getService('notification')->getUsers($aNotification); $sTitle = Phpfox::getLib('parse.output')->shorten($aRow['title'], Phpfox::getParam('notification.total_notification_title_length'), '...'); $sPhrase = ''; if ($aNotification['user_id'] == $aRow['user_id']) { // {users} disliked {gender} own {item} "{title}" $sPhrase = Phpfox::getPhrase('like.users_disliked_gender_own_item_title', array('users' => $sUsers, 'gender' => Phpfox::getService('user')->gender($aRow['gender'], 1), 'title' => $sTitle, 'item' => $aAction['item_type_id'])); } elseif ($aRow['user_id'] == Phpfox::getUserId()) { // {users} liked your blog "{title}" $sPhrase = Phpfox::getPhrase('like.users_disliked_your_item_title', array('users' => $sUsers, 'title' => $sTitle, 'item' => $aAction['item_type_id'])); } else { $sPhrase = Phpfox::getPhrase('like.users_disliked_users_item', array('users' => $sUsers, 'row_full_name' => $aRow['full_name'], 'title' => $sTitle, 'item' => $aAction['item_type_id'])); } return array('link' => $aRow['link'], 'message' => $sPhrase, 'icon' => Phpfox_Template::instance()->getStyle('image', 'activity.png', 'blog')); }
/** * Controller */ public function process() { $this->url()->send('music'); Phpfox::isUser(true); if (Phpfox::getParam('music.music_user_group_id') == Phpfox::getUserBy('user_group_id')) { $this->url()->send('music'); } $aUser = array('full_name' => Phpfox::getUserBy('full_name')); $aSettings = Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), Phpfox::getUserId(), Phpfox::getParam('music.music_user_group_id')); $aParams = array('full_name' => Phpfox::getPhrase('music.provide_a_artist_band_name'), 'agree' => Phpfox::getPhrase('music.tick_the_box_to_agree_to_our_terms_and_privacy_policy')); foreach ($aSettings as $sKey => $aSetting) { if ($aSetting['is_required']) { $aParams['custom_field_' . $aSetting['field_id']] = array('title' => Phpfox::getPhrase('music.provide_a_value_for') . ': ' . Phpfox::getPhrase($aSetting['phrase_var_name']), 'def' => 'required', 'php_id' => 'custom[' . $aSetting['field_id'] . ']'); } } $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aParams)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if (Music_Service_Process::instance()->convertMember($aVals, $this->request()->getArray('custom'))) { $this->url()->send('music', null, Phpfox::getPhrase('music.you_have_successfully_converted_your_account')); } } } $this->template()->setTitle(Phpfox::getPhrase('music.musician_registration'))->setBreadcrumb(Phpfox::getPhrase('music.music'), $this->url()->makeUrl('music'))->setBreadcrumb(Phpfox::getPhrase('music.registration'), null, true)->setFullSite()->assign(array('aForms' => $aUser, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aSettings' => $aSettings)); }
public function check() { if (!Phpfox::getParam('user.check_promotion_system')) { return false; } if (!Phpfox::isUser()) { return false; } $sCacheId = $this->cache()->set('promotion_' . Phpfox::getUserBy('user_group_id')); $aPromotion = array(); if (!($aPromotion = $this->cache()->get($sCacheId))) { $aPromotion = $this->database()->select('*')->from($this->_sTable)->where('user_group_id = ' . Phpfox::getUserBy('user_group_id'))->execute('getSlaveRow'); $this->cache()->save($sCacheId, $aPromotion); } if (isset($aPromotion['promotion_id'])) { if ((int) Phpfox::getUserBy('activity_points') >= (int) $aPromotion['total_activity'] && (int) $aPromotion['total_activity']) { $this->database()->update(Phpfox::getT('user'), array('user_group_id' => $aPromotion['upgrade_user_group_id']), 'user_id = ' . Phpfox::getUserId()); Phpfox_Url::instance()->send('user.promotion'); } else { if ((int) $aPromotion['total_day'] > 0) { if (str_replace('-', '', Phpfox::getUserBy('joined') - PHPFOX_TIME) >= $aPromotion['total_day'] * 86400) { $this->database()->update(Phpfox::getT('user'), array('user_group_id' => $aPromotion['upgrade_user_group_id']), 'user_id = ' . Phpfox::getUserId()); Phpfox_Url::instance()->send('user.promotion'); } } } } }
public function render($name, array $params = array()) { $params['ActiveUser'] = (new \Api\User())->get(\Phpfox::getUserId()); $params['isPager'] = isset($_GET['page']) ? true : false; $params['Is'] = new \Core\Is(); return $this->loadTemplate($name)->render($params); }
public function get($iUserId = null) { if ($iUserId === null) { $iUserId = Phpfox::getUserId(); } return $this->database()->select('ub.block_user_id, ' . Phpfox::getUserField())->from($this->_sTable, 'ub')->join(Phpfox::getT('user'), 'u', 'u.user_id = ub.block_user_id')->where('ub.user_id = ' . (int) $iUserId)->execute('getSlaveRows'); }
public function update($sTable, $iId, $iUserId = null) { $this->database()->update(Phpfox::getT($sTable), array( 'time_stamp' => PHPFOX_TIME ), 'item_id = ' . (int) $iId . ' AND user_id = ' . Phpfox::getUserId() ); }
/** * 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'; }
/** * Controller */ public function process() { Phpfox::isUser(true); // http://www.phpfox.com/tracker/view/15093/ $bIsThickBox = $this->getParam('bIsThickBox'); $this->template()->assign(array('bIsThickBox' => $bIsThickBox)); if ($this->request()->getInt('purchase_id')) { if (!($aPackage = Phpfox::getService('subscribe.purchase')->getInvoice($this->request()->getInt('purchase_id'), true))) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.unable_to_find_the_purchase_you_are_looking_for')); } $iPurchaseId = $aPackage['purchase_id']; } else { if (!($aPackage = Phpfox::getService('subscribe')->getPackage($this->request()->getInt('id')))) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.unable_to_find_the_package_you_are_looking_for')); } if (Phpfox::getUserBy('user_group_id') == $aPackage['user_group_id']) { return Phpfox_Error::set(Phpfox::getPhrase('subscribe.attempting_to_upgrade_to_the_same_user_group_you_are_already_in')); } $aPackage['default_currency_id'] = isset($aPackage['default_currency_id']) ? $aPackage['default_currency_id'] : $aPackage['price'][0]['alternative_currency_id']; $aPackage['default_cost'] = isset($aPackage['default_cost']) ? $aPackage['default_cost'] : $aPackage['price'][0]['alternative_cost']; $iPurchaseId = Phpfox::getService('subscribe.purchase.process')->add(array('package_id' => $aPackage['package_id'], 'currency_id' => $aPackage['default_currency_id'], 'price' => $aPackage['default_cost'])); /* Make sure we mark it as free only if the default cost is free and its not a recurring charge */ if ($aPackage['default_cost'] == '0.00' && $aPackage['recurring_period'] == 0) { $this->template()->assign('bIsFree', true); $this->template()->assign('iPurchaseId', $iPurchaseId); Phpfox::getService('subscribe.purchase.process')->update($iPurchaseId, $aPackage['package_id'], 'completed', Phpfox::getUserId(), $aPackage['user_group_id'], $aPackage['fail_user_group']); return; } } /* Load the gateway only if its not free */ if (($aPackage['default_cost'] != '0.00' || $aPackage['recurring_period'] != 0) && $iPurchaseId) { $this->setParam('gateway_data', array('item_number' => 'subscribe|' . $iPurchaseId, 'currency_code' => $aPackage['default_currency_id'], 'amount' => $aPackage['default_cost'], 'item_name' => $aPackage['title'], 'return' => $this->url()->makeUrl('subscribe.complete'), 'recurring' => $aPackage['recurring_period'], 'recurring_cost' => isset($aPackage['default_recurring_cost']) ? $aPackage['default_recurring_cost'] : '', 'alternative_cost' => isset($aPackage['price'][0]) ? serialize($aPackage['price']) : '', 'alternative_recurring_cost' => isset($aPackage['recurring_price'][0]) ? serialize($aPackage['recurring_price']) : '')); } }
/** * Class process method wnich is used to execute this component. */ public function process() { $aCond = array(); $iPage = $this->request()->getInt('page'); $iPageSize = 10; $bIsSentbox = $this->request()->get('req2') == 'sent' ? true : false; $bIsSearch = false; if ($bIsSentbox) { $aCond[] = 'm.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 0'; } else { $aCond[] = 'm.viewer_folder_id = 0 AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0'; } 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 (m.subject LIKE '%" . Phpfox::getLib('database')->escape($sSearch) . "%' OR m.preview LIKE '%" . Phpfox::getLib('database')->escape($sSearch) . "%')"; $this->url()->setParam('search-query', 'true'); Phpfox::getLib('session')->set('mfsearch', $sSearch); } if ($bIsSearch == false) { Phpfox::getLib('session')->remove('mfsearch'); } list($iCnt, $aMessages, $aInputs) = Phpfox::getService('mail')->get($aCond, 'm.time_updated DESC', $iPage, $iPageSize, $bIsSentbox); Phpfox::getLib('pager')->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('bMobileInboxIsActive' => true, 'aMessages' => $aMessages, 'bIsSearch' => $bIsSearch, 'bIsSentbox' => $bIsSentbox, 'aMobileSubMenus' => array($this->url()->makeUrl('mail') => Phpfox::getPhrase('mail.mobile_messages'), $this->url()->makeUrl('mail', 'sent') => Phpfox::getPhrase('mail.sent'), $this->url()->makeUrl('mail', 'compose') => Phpfox::getPhrase('mail.compose')), 'sActiveMobileSubMenu' => $this->url()->makeUrl('mail', $this->request()->get('req2') == '' ? null : $this->request()->get('req2')))); }
public function getQueryJoins($bIsCount = false, $bNoQueryFriend = false) { if (Phpfox::isModule('friend') && Phpfox::getService('friend')->queryJoin($bNoQueryFriend)) { $this->database()->join(Phpfox::getT('friend'), 'friends', 'friends.user_id = q.user_id AND friends.friend_user_id = ' . Phpfox::getUserId()); } }
/** * Class process method wnich is used to execute this component. */ public function process() { Phpfox::isUser(true); $sView = $this->request()->get('view'); $aCond = array(); switch ($sView) { case 'pending': $aCond[] = 'AND s.is_custom = 2'; // pending approval break; case 'payment': $aCond[] = 'AND s.is_custom = 0'; break; case 'denied': $aCond[] = 'AND s.is_custom = 4'; break; default: $aCond[] = 'AND s.is_custom = 3'; break; } $aCond[] = 'AND s.user_id = ' . Phpfox::getUserId(); Phpfox::getService('ad')->getSectionMenu(); $aAds = Phpfox::getService('ad')->getSponsorForUser($aCond); $this->template()->setTitle(Phpfox::getPhrase('ad.ad_management'))->setFullSite()->setBreadcrumb(Phpfox::getPhrase('ad.advertise'), $this->url()->makeUrl('ad'))->setBreadcrumb(Phpfox::getPhrase('ad.sponsorships'), $this->url()->makeUrl('ad.manage-sponsor'), true)->setHeader(array('table.css' => 'style_css', 'manage.js' => 'module_ad'))->assign(array('aAds' => $aAds, 'sView' => $sView)); }
/** * Controller */ public function process() { $sCountryChildValue = $this->getParam('country_child_value'); $mCountryChildFilter = $this->getParam('country_child_filter', $this->request()->get('country_child_filter', null)); $sCountryChildType = $this->getParam('country_child_type', null); $sCountryChildId = null; if (empty($sCountryChildValue) && Phpfox::isUser() && $mCountryChildFilter === null && !$this->getParam('country_not_user')) { $sCountryChildValue = Phpfox::getUserBy('country_iso'); } $iSearchId = 0; if ($mCountryChildFilter !== null) { $iSearchId = $this->request()->get('search-id'); if (!empty($iSearchId) && isset($_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sCountryChildType][$iSearchId]['country'])) { $sCountryChildValue = $_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sCountryChildType][$iSearchId]['country']; } if (isset($_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sCountryChildType][$iSearchId]['country_child_id'])) { $sCountryChildId = $_SESSION[Phpfox::getParam('core.session_prefix')]['search'][$sCountryChildType][$iSearchId]['country_child_id']; } } /* Last resort, get is a little heavy but controller didnt provide a child country*/ if ($sCountryChildId == null && $this->getParam('country_child_id') == null) { $aUser = Phpfox::getService('user')->get(Phpfox::getUserId(), true); $sCountryChildId = $aUser['country_child_id']; } $this->template()->assign(array('aCountryChildren' => Phpfox::getService('core.country')->getChildren($sCountryChildValue), 'iCountryChildId' => (int) $this->getParam('country_child_id', $sCountryChildId), 'bForceDiv' => $this->getParam('country_force_div', false), 'mCountryChildFilter' => $mCountryChildFilter)); }
/** * Controller */ public function process() { Phpfox::isUser(true); if (!Phpfox::getUserParam('user.can_control_notification_privacy') && !Phpfox::getUserParam('user.can_control_profile_privacy')) { return Phpfox_Error::display(Phpfox::getPhrase('user.privacy_settings_have_been_disabled_for_your_user_group')); } if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('user.privacy.process')->update($aVals)) { $this->url()->send('user.privacy', null, Phpfox::getPhrase('user.privacy_settings_successfully_updated')); } } list($aUserPrivacy, $aNotifications, $aProfiles, $aItems) = Phpfox::getService('user.privacy')->get(); $aUserInfo = Phpfox::getService('user')->get(Phpfox::getUserId()); ($sPlugin = Phpfox_Plugin::get('user.component_controller_index_process')) ? eval($sPlugin) : false; $aMenus = array('profile' => Phpfox::getPhrase('user.profile'), 'items' => Phpfox::getPhrase('user.items'), 'notifications' => Phpfox::getPhrase('user.notifications'), 'blocked' => Phpfox::getPhrase('user.blocked_users')); if (!Phpfox::isModule('privacy')) { unset($aMenus['items']); } if (Phpfox::getUserParam('user.can_be_invisible')) { // $aMenus['invisible'] = Phpfox::getPhrase('user.invisible_mode'); } $this->template()->buildPageMenu('js_privacy_block', $aMenus, array('no_header_border' => true, 'link' => $this->url()->makeUrl(Phpfox::getUserBy('user_name')), 'phrase' => Phpfox::getPhrase('user.view_your_profile'))); if ($this->request()->get('view') == 'blocked') { $this->template()->assign(array('bGoToBlocked' => true)); } $this->template()->setTitle(Phpfox::getPhrase('user.privacy_settings'))->setBreadcrumb('Account', $this->url()->makeUrl('profile'))->setBreadcrumb(Phpfox::getPhrase('user.privacy_settings'), $this->url()->makeUrl('user.privacy'), true)->setFullSite()->setHeader(array('privacy.css' => 'module_user'))->assign(array('aForms' => $aUserPrivacy['privacy'], 'aPrivacyNotifications' => $aNotifications, 'aProfiles' => $aProfiles, 'aUserPrivacy' => $aUserPrivacy, 'aBlockedUsers' => Phpfox::getService('user.block')->get(), 'aUserInfo' => $aUserInfo, 'aItems' => $aItems)); }
public function update($sTable, $iId, $iUserId = null) { if (Phpfox::getParam('track.cache_allow_recurrent_visit') > 0) { // Get the cache! $sType = ''; switch ($sTable) { case 'user_track': // This type is defined in the service track->getLatestUsers. It is also used in track.callback->addTrack $sType = 'profile'; break; } $sCacheId = $this->cache()->set(array('track', $sType . '_' . $iId)); if (!($aTracks = $this->cache()->get($sCacheId))) { } else { // Check every track record in cache foreach ($aTracks as $aTrack) { // If its the user visiting this profile and it was added recently we dont add it anymore. if ($aTrack['user_id'] == Phpfox::getUserId() && $aTrack['time_stamp'] >= PHPFOX_TIME - Phpfox::getParam('track.cache_allow_recurrent_visit') * 60) { return true; } } } } $this->database()->update(Phpfox::getT($sTable), array('time_stamp' => PHPFOX_TIME), 'item_id = ' . (int) $iId . ' AND user_id = ' . Phpfox::getUserId()); }
public function getInvoice($iId, $bIsOrder = false, $sCacheUserId = null) { $aPurchase = $this->database()->select('sp.*, spack.*')->from($this->_sTable, 'sp')->join(Phpfox::getT('subscribe_package'), 'spack', 'spack.package_id = sp.package_id')->where('sp.purchase_id = ' . (int) $iId . ' AND sp.user_id = ' . ($sCacheUserId === null ? Phpfox::getUserId() : $sCacheUserId))->execute('getRow'); if (!isset($aPurchase['purchase_id'])) { return false; } if (!empty($aPurchase['cost']) && Phpfox::getLib('parse.format')->isSerialized($aPurchase['cost'])) { $aCosts = unserialize($aPurchase['cost']); foreach ($aCosts as $sKey => $iCost) { if (Phpfox::getService('core.currency')->getDefault() == $sKey) { $aPurchase['default_cost'] = $iCost; $aPurchase['default_currency_id'] = $sKey; } } } if ($aPurchase['recurring_period'] > 0 && Phpfox::getLib('parse.format')->isSerialized($aPurchase['recurring_cost'])) { $aRecurringCosts = unserialize($aPurchase['recurring_cost']); foreach ($aRecurringCosts as $sKey => $iCost) { if (Phpfox::getService('core.currency')->getDefault() == $sKey) { $aPurchase['default_recurring_cost'] = $bIsOrder ? $iCost : Phpfox::getService('api.gateway')->getPeriodPhrase($aPurchase['recurring_period'], $iCost, $aPurchase['default_cost']); $aPurchase['default_recurring_currency_id'] = $sKey; } } } return $aPurchase; }
public function process() { Phpfox::isUser(true); Phpfox::getUserParam('profiles.is_enabled', true); if ($sName = $this->request()->get('req3')) { $aExtraProfile = Phpfox::getService('profiles')->getProfile($sName); } if (count($aExtraProfile) == 0) { return Phpfox::getLib('module')->setController('error.404'); } if (Phpfox::getUserId() != $aExtraProfile['user_id']) { Phpfox::getUserParam('profiles.can_edit_others', true); if (($aUser = Phpfox::getService('user')->getUser($aExtraProfile['user_id'], 'u.user_group_id')) && isset($aUser['user_group_id'])) { $iUserGroupId = $aUser['user_group_id']; } } else { $iUserGroupId = Phpfox::getUserBy('user_group_id'); } $bIsEdit = false; if ($iId = $this->request()->getInt('id', false)) { $iUserGroupId = $iId; if ($aVals = $this->request()->getArray('custom') && !empty($aVals)) { $bIsEdit = true; if (Phpfox::getService('profiles.process')->updateFields($aExtraProfile['extra_id'], $aExtraProfile['user_id'], $aVals)) { $this->url()->send('profiles.' . $aExtraProfile['title_url'], null, Phpfox::getPhrase('profiles.successfully_updated_name_profile', array('extra_name' => $aExtraProfile['title']))); } } } $aCustomFields = Phpfox::getService('profiles')->getFields(array('extra_main', 'extra_panel', 'extra_side'), $aExtraProfile['extra_id'], $iUserGroupId); $this->template()->setTitle(Phpfox::getPhrase('profiles.edit_extra_profiles'))->setBreadcrumb($aExtraProfile['title']); $this->template()->setHeader(array('custom.js' => 'module_profiles'))->assign(array('aExtraProfile' => $aExtraProfile, 'aSettings' => $aCustomFields, 'bIsEdit' => $bIsEdit)); }
/** * Class process method wnich is used to execute this component. */ public function process() { $iUserId = $this->getParam('user_id') ? $this->getParam('user_id') : Phpfox::getUserId(); if ($iBlogId = $this->request()->get('blog_id')) { $aBlog = Phpfox::getService('blog')->getBlogForEdit($iBlogId); if (isset($aBlog['blog_id']) && ($aBlog['user_id'] == Phpfox::getUserId() && Phpfox::getUserParam('blog.can_delete_own_blog_category')) || Phpfox::getUserParam('blog.can_delete_other_blog_category')) { $iUserId = $aBlog['user_id']; } } if (Phpfox::getUserParam('blog.blog_add_categories')) { switch ($this->getParam('sType')) { case 'personal': $sCond = 'AND c.user_id IN(' . $iUserId . ')'; $sOrder = 'added DESC'; break; case 'used': $sCond = 'AND c.user_id IN(0,' . $iUserId . ')'; $sOrder = 'used DESC'; break; case 'public': $sCond = 'AND c.user_id IN(0)'; $sOrder = 'added DESC'; break; default: $sCond = 'AND c.user_id IN(0,' . $iUserId . ')'; $sOrder = 'added DESC'; } } else { $sCond = 'AND c.user_id IN(0)'; $sOrder = 'added DESC'; } $aItems = Phpfox::getService('blog.category')->getCategories(array($sCond), $sOrder); $this->template()->assign(array('aItems' => $aItems)); ($sPlugin = Phpfox_Plugin::get('blog.component_block_add_category_list_process')) ? eval($sPlugin) : false; }
/** * Class process method wnich is used to execute this component. */ public function process() { if ($aVals = $this->request()->getArray('val')) { Phpfox::isUser(true); Phpfox::getUserParam('comment.can_post_comments', true); if (($iFlood = Phpfox::getUserParam('comment.comment_post_flood_control')) !== 0) { $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('comment'), 'condition' => 'type_id = \'' . Phpfox::getLib('database')->escape($aVals['type']) . '\' AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60)); // actually check if flooding if (Phpfox::getLib('spam')->check($aFlood)) { Phpfox_Error::set(Phpfox::getPhrase('comment.posting_a_comment_a_little_too_soon_total_time', array('total_time' => Phpfox::getLib('spam')->getWaitTime()))); } } if (Phpfox::getLib('parse.format')->isEmpty($aVals['text'])) { Phpfox_Error::set(Phpfox::getPhrase('feed.add_some_text_to_your_comment')); } if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('comment.process')->add($aVals))) { $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), Phpfox::getPhrase('feed.successfully_added_your_comment')); } } if ($iLikeType = $this->request()->getInt('liketype')) { if (Phpfox::getService('feed.process')->like($this->request()->getInt('id'), $iLikeType)) { $this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), $iLikeType == '1' ? Phpfox::getPhrase('feed.successfully_liked_this_feed') : Phpfox::getPhrase('feed.successfully_unliked_this_feed')); } } list($iFeedCount, $aFeeds) = Phpfox::getService('feed')->get(null, $this->request()->getInt('id'), 1); $iCommentCnt = 0; $aComments = array(); if (Phpfox::getParam('feed.allow_comments_on_feeds')) { list($iCommentCnt, $aComments) = Phpfox::getService('comment')->get('cmt.*', array("AND cmt.type_id = 'feed'", 'AND cmt.item_id = ' . (int) $aFeeds[0]['feed_id'], 'AND cmt.view_id = 0'), 'cmt.time_stamp ASC'); } if (!count($aFeeds)) { return Phpfox_Error::display(Phpfox::getPhrase('feed.not_a_valid_feed')); } $this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('iFeedId' => $aFeeds[0]['feed_id'], 'aFeeds' => $aFeeds, 'aComments' => $aComments)); }
/** * Controller */ public function process() { Phpfox::isUser(true); $sView = $this->request()->get('view'); $aCond = array(); switch ($sView) { case 'pending': $aCond[] = 'AND a.is_custom = 2'; break; case 'payment': $aCond[] = 'AND a.is_custom = 1'; break; case 'denied': $aCond[] = 'AND a.is_custom = 4'; break; default: $aCond[] = 'AND a.is_custom = 3'; break; } $aCond[] = 'AND a.user_id = ' . Phpfox::getUserId(); if (Phpfox::getParam('ad.multi_ad')) { $aCond[] = ' AND a.location = 50'; } $aAds = Ad_Service_Ad::instance()->getForUser($aCond); Ad_Service_Ad::instance()->getSectionMenu(); $this->template()->setTitle(Phpfox::getPhrase('ad.ad_management'))->setFullSite()->setBreadcrumb(Phpfox::getPhrase('ad.advertise'), $this->url()->makeUrl('ad'))->setBreadcrumb(Phpfox::getPhrase('ad.advertise'), $this->url()->makeUrl('ad.manage'), true)->setHeader(array('table.css' => 'style_css', 'manage.js' => 'module_ad'))->assign(array('aAllAds' => $aAds, 'sView' => $sView, 'bNewPurchase' => $this->request()->get('payment'))); }
public function addCategory() { if (!Phpfox::getService('blog.category')->canAdd()) { return $this->alert(Phpfox::getPhrase('blog.you_have_reached_your_limit')); } $aVals = $this->get('val'); $oBlogCategoryProcess = Phpfox::getService('blog.category.process'); $sCleanUrl = Phpfox::getLib('parse.input')->clean($aVals['add']); if (Phpfox::getService('blog.category')->isPrivateCategory($sCleanUrl, Phpfox::getUserId())) { $this->call('alert("' . Phpfox::getPhrase('blog.already_a_category') . '"); $("#js_add_category").val(""); $("#js_add_category").focus();'); return false; } $aCategories = explode(',', $aVals['add']); $aRows = array(); foreach ($aCategories as $sCategory) { $sCategory = trim($sCategory); $iId = $oBlogCategoryProcess->add($sCategory); $aRows[] = array('category_id' => $iId, 'name' => Phpfox::getLib('parse.input')->clean($sCategory, 255)); } rsort($aRows); foreach ($aRows as $aRow) { Phpfox::getLib('template')->assign(array('aItem' => array('category_id' => $aRow['category_id'], 'name' => $aRow['name'], 'user_id' => Phpfox::getUserId()))); Phpfox::getLib('template')->getTemplate('blog.block.category-form'); } $this->call('$("#js_add_new_category").prepend("' . $this->getContent() . '").highlightFade(); $("#js_category_info").html("' . Phpfox::getPhrase('blog.added') . '").highlightFade().fadeOut(5000); $("#js_add_category").val(""); $Core.loadInit();'); }
/** * Class process method wnich is used to execute this component. */ public function process() { Phpfox::isUser(true); if (Phpfox::getUserBy('profile_page_id')) { Phpfox::getService('pages')->setIsInPage(); } if (!($aAlbum = Phpfox::getService('photo.album')->getForEdit($this->request()->getInt('id')))) { return Phpfox_Error::display(Phpfox::getPhrase('photo.photo_album_not_found')); } if ($aVals = $this->request()->getArray('val')) { if ($this->request()->get('req3') == 'photo') { if (Phpfox::getService('photo.process')->massProcess($aAlbum, $aVals)) { $this->url()->send('photo.edit-album.photo', array('id' => $aAlbum['album_id']), Phpfox::getPhrase('photo.photo_s_successfully_updated')); } } else { if (Phpfox::getService('photo.album.process')->update($aAlbum['album_id'], $aVals)) { $this->url()->permalink('photo.album', $aAlbum['album_id'], $aAlbum['name'], true, Phpfox::getPhrase('photo.album_successfully_updated')); } } } $aMenus = array('detail' => Phpfox::getPhrase('photo.album_info'), 'photo' => Phpfox::getPhrase('photo.photos')); $this->template()->buildPageMenu('js_photo_block', $aMenus, array('link' => $this->url()->permalink('photo.album', $aAlbum['album_id'], $aAlbum['name']), 'phrase' => Phpfox::getPhrase('photo.view_this_album_uppercase'))); list($iCnt, $aPhotos) = Phpfox::getService('photo')->get('p.album_id = ' . (int) $aAlbum['album_id']); list($iAlbumCnt, $aAlbums) = Phpfox::getService('photo.album')->get('pa.user_id = ' . Phpfox::getUserId()); $this->template()->setTitle(Phpfox::getPhrase('photo.editing_album') . ': ' . $aAlbum['name'])->setFullSite()->setBreadcrumb(Phpfox::getPhrase('photo.photo'), $this->url()->makeUrl('photo'))->setBreadcrumb(Phpfox::getPhrase('photo.editing_album') . ': ' . $aAlbum['name'], $this->url()->makeUrl('photo.edit-album', array('id' => $aAlbum['album_id'])), true)->setHeader(array('edit.css' => 'module_photo', 'photo.js' => 'module_photo'))->assign(array('aForms' => $aAlbum, 'aPhotos' => $aPhotos, 'aAlbums' => $aAlbums)); }
public function getJavascript($iPhotoId) { $aTags = $this->database()->select('p.user_id AS photo_owner_id, pt.tag_id, pt.user_id AS post_user_id, pt.content, pt.position_x, pt.position_y, pt.width, pt.height, ' . Phpfox::getUserField())->from($this->_sTable, 'pt')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = pt.tag_user_id')->join(Phpfox::getT('photo'), 'p', 'p.photo_id = pt.photo_id')->where('pt.photo_id = ' . (int) $iPhotoId)->execute('getSlaveRows'); if (!count($aTags)) { return false; } $sNotes = '['; foreach ($aTags as $aTag) { $sNotes .= '{'; $sNotes .= 'note_id: ' . $aTag['tag_id'] . ', '; $sNotes .= 'x1: ' . $aTag['position_x'] . ', '; $sNotes .= 'y1: ' . $aTag['position_y'] . ', '; $sNotes .= 'width: ' . $aTag['width'] . ', '; $sNotes .= 'height: ' . $aTag['height'] . ', '; $sRemove = $aTag['post_user_id'] == Phpfox::getUserId() || $aTag['photo_owner_id'] == Phpfox::getUserId() || $aTag['user_id'] == Phpfox::getUserId() ? ' <a href="#" onclick="if (confirm(\\\'' . Phpfox::getPhrase('photo.are_you_sure') . '\\\')) { $(\\\'#noteform\\\').hide(); $(\\\'#js_photo_view_image\\\').imgAreaSelect({ hide: true }); $(this).parent(\\\'span:first\\\').remove();$(\\\'.notep#notep_' . $aTag['tag_id'] . '\\\').remove();$.ajaxCall(\\\'photo.removePhotoTag\\\', \\\'tag_id=' . $aTag['tag_id'] . '\\\'); } return false;"><i class="fa fa-remove"></i></a>' : ''; if (!empty($aTag['user_id'])) { $sNotes .= 'note: \'<a href="' . Phpfox_Url::instance()->makeUrl($aTag['user_name']) . '" id="js_photo_tag_user_id_' . $aTag['user_id'] . '">' . $aTag['full_name'] . '</a>' . $sRemove . '\''; } else { $sNotes .= 'note: \'' . str_replace("'", "\\'", Phpfox::getLib('parse.output')->clean($aTag['content'])) . $sRemove . '\''; } $sNotes .= '},'; } $sNotes = rtrim($sNotes, ','); $sNotes .= ']'; return $sNotes; }
/** * Class process method wnich is used to execute this component. */ public function process() { if ($sPlugin = Phpfox_Plugin::get('core.component_controller_index_member_start')) { eval($sPlugin); } Phpfox::isUser(true); if ($this->request()->get('req3') == 'customize') { define('PHPFOX_IN_DESIGN_MODE', true); define('PHPFOX_CAN_MOVE_BLOCKS', true); if ($iTestStyle = $this->request()->get('test_style_id')) { if (Phpfox::getLib('template')->testStyle($iTestStyle)) { } } $aDesigner = array('current_style_id' => Phpfox::getUserBy('style_id'), 'design_header' => Phpfox::getPhrase('core.customize_dashboard'), 'current_page' => $this->url()->makeUrl(''), 'design_page' => $this->url()->makeUrl('core.index-member', 'customize'), 'block' => 'core.index-member', 'item_id' => Phpfox::getUserId(), 'type_id' => 'user'); $this->setParam('aDesigner', $aDesigner); $this->template()->setPhrase(array('theme.are_you_sure'))->setHeader('cache', array('style.css' => 'style_css', 'video.css' => 'module_video', 'design.js' => 'module_theme', 'select.js' => 'module_theme')); if (Phpfox::getParam('profile.can_drag_drop_blocks_on_profile')) { $this->template()->setHeader('cache', array('jquery/ui.js' => 'static_script', 'sort.js' => 'module_theme'))->setHeader(array('<script type="text/javascript">$Behavior.core_controller_member_designonupdate = function() { function designOnUpdate() { $Core.design.updateSorting(); } };</script>', '<script type="text/javascript">$Behavior.core_controller_init = function() { $Core.design.init({type_id: \'user\'}); };</script>')); } } else { // $this->template()->setHeader('jquery/ui.js', 'static_script'); $this->template()->setHeader('cache', array('sort.js' => 'module_theme', 'design.js' => 'module_theme', 'video.css' => 'module_video'))->setHeader(array()); } if (Phpfox::getParam('video.convert_servers_enable')) { $this->template()->setHeader('<script type="text/javascript">document.domain = "' . Phpfox::getParam('video.convert_js_parent') . '";</script>'); } Phpfox::getLib('module')->setCacheBlockData(array('table' => 'user_dashboard', 'field' => 'user_id', 'item_id' => Phpfox::getUserId(), 'controller' => 'core.index-member')); $this->template()->setHeader('cache', array('feed.js' => 'module_feed', 'welcome.css' => 'style_css', 'announcement.css' => 'style_css', 'comment.css' => 'style_css', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'player/flowplayer/flowplayer.js' => 'static_script'))->setEditor(array('load' => 'simple')); }
public function setHash($sCode) { if (Phpfox::getParam('core.store_only_users_in_session')) { $oRequest = Phpfox::getLib('request'); $oSession = Phpfox::getLib('session'); $sSessionHash = $oSession->get('sessionhash'); $bCreate = true; if (!empty($sSessionHash)) { $bCreate = false; $aRow = $this->database()->select('*')->from(Phpfox::getT('log_session'))->where('session_hash = \'' . $this->database()->escape($sSessionHash) . '\'')->execute('getSlaveRow'); if (isset($aRow['session_hash'])) { $this->database()->update(Phpfox::getT('log_session'), array('captcha_hash' => $this->_getHash($sCode, $sSessionHash)), "session_hash = '" . $sSessionHash . "'"); } else { $bCreate = true; } } if ($bCreate) { $sSessionHash = $oRequest->getSessionHash(); $this->database()->insert(Phpfox::getT('log_session'), array('session_hash' => $sSessionHash, 'id_hash' => $oRequest->getIdHash(), 'captcha_hash' => $this->_getHash($sCode, $sSessionHash), 'user_id' => Phpfox::getUserId(), 'last_activity' => PHPFOX_TIME, 'location' => '', 'is_forum' => '0', 'forum_id' => 0, 'im_hide' => 0, 'ip_address' => '', 'user_agent' => '')); $oSession->set('sessionhash', $sSessionHash); } } else { $iId = $this->_oSession->getSessionId(); $this->database()->update(Phpfox::getT('log_session'), array('captcha_hash' => $this->_getHash($sCode, $iId)), "session_hash = '" . $iId . "'"); } }
/** * Controller */ public function process() { Phpfox::isUser(true); if ($iInvite = $this->request()->getInt('del')) { $bDel = Phpfox::getService('invite.process')->delete($iInvite, Phpfox::getUserId()); if ($bDel) { $this->url()->send('invite.invitations', null, Phpfox::getPhrase('invite.invitation_deleted')); } $this->url()->send('invite.invitations', null, Phpfox::getPhrase('invite.invitation_not_found')); } elseif ($aInvite = $this->request()->get('val')) { $bDel = true; foreach ($aInvite as $iInvite) { $bDel = $bDel && Phpfox::getService('invite.process')->delete($iInvite, Phpfox::getUserId()); } if ($bDel) { $this->url()->send('invite.invitations', null, Phpfox::getPhrase('invite.invitation_deleted')); } $this->url()->send('invite.invitations', null, Phpfox::getPhrase('invite.invitation_not_found')); } $iPage = $this->request()->getInt('page'); $iPageSize = (int) Phpfox::getParam('invite.pendings_to_show_per_page'); list($iCnt, $aInvites) = Phpfox::getService('invite')->get(Phpfox::getUserId(), $iPage, $iPageSize); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->setParam('global_moderation', array('name' => 'invitations', 'ajax' => 'invite.moderation', 'menu' => array(array('phrase' => 'Delete', 'action' => 'delete')))); $this->template()->setTitle(Phpfox::getPhrase('invite.pending_invitations'))->setBreadcrumb(Phpfox::getPhrase('invite.pending_invitations'))->assign(array('aInvites' => $aInvites, 'iPage' => $iPage))->setHeader('cache', array('pager.css' => 'style_css', 'pending.js' => 'module_invite')); }