public function add($iBlockedUserId) { Phpfox::isUser(true); Phpfox::getUserParam('user.can_block_other_members', true); if ($iBlockedUserId == Phpfox::getUserId()) { return Phpfox_Error::set(Phpfox::getPhrase('user.not_able_to_block_yourself')); } if (Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $iBlockedUserId)) { return Phpfox_Error::set(Phpfox::getPhrase('user.you_have_already_blocked_this_user')); } $aUser = Phpfox::getService('user')->getUser($iBlockedUserId, 'u.user_id, u.user_group_id'); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others')) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user')); } $this->database()->insert($this->_sTable, array( 'user_id' => Phpfox::getUserId(), 'block_user_id' => (int) $iBlockedUserId, 'time_stamp' => PHPFOX_TIME, 'ip_address' => Phpfox::getIp() ) ); Phpfox::getService('friend.process')->deleteFromConnection(Phpfox::getUserId(), $iBlockedUserId); Phpfox::getService('friend.process')->deleteFromConnection($iBlockedUserId, Phpfox::getUserId()); return true; }
/** * Class process method wnich is used to execute this component. */ public function process() { $aUser = $this->getParam('aUser'); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public')) { return false; } $aAlbums = Phpfox::getService('music.album')->getForProfile($aUser['user_id']); if (!count($aAlbums) && !defined('PHPFOX_IN_DESIGN_MODE')) { return false; } $this->template()->assign(array( 'sHeader' => Phpfox::getPhrase('music.albums'), 'sBlockJsId' => 'profile_music_album', 'aAlbums' => $aAlbums ) ); if (count($aAlbums) >= 4) { $this->template()->assign(array( 'aFooter' => array( Phpfox::getPhrase('music.view_more') => $this->url()->makeUrl('music.browse.album', array('userid' => $aUser['user_id'])) ) ) ); } return 'block'; }
public function getProfileTitle($aRow) { $sTitleReplace = Phpfox::getParam('profile.profile_seo_for_meta_title'); if (!empty($sTitleReplace) && Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'profile.basic_info')) { preg_match_all('/\\{(.*?)\\}/i', $sTitleReplace, $aMatches); if (isset($aMatches[1]) && is_array($aMatches[1])) { foreach ($aMatches[1] as $sFind) { if ($sFind == 'gender_name' && !Phpfox::getUserGroupParam($aRow['user_group_id'], 'user.can_edit_gender_setting')) { unset($aRow[$sFind]); } if (!empty($aRow[$sFind])) { if ($sFind == 'location' && !empty($aRow[$sFind])) { if (isset($aRow['location_child'])) { $aRow[$sFind] = $aRow[$sFind] . ' - ' . $aRow['location_child']; } } $sTitleReplace = str_replace('{' . $sFind . '}', $aRow[$sFind], $sTitleReplace); } else { $sTitleReplace = str_replace('{' . $sFind . '} -', '', $sTitleReplace); $sTitleReplace = str_replace('{' . $sFind . '}', '', $sTitleReplace); } } } $sPageTitle = rtrim(trim($sTitleReplace), '-'); } if (empty($sPageTitle)) { $sPageTitle = $aRow['full_name']; } return $sPageTitle; }
/** * Changes a user's email addres, checks if user is allowed and if he should be made verify their email address * afterwards and if it should be logged out immediately after changing it. * @param <type> $aUser * @param <type> $sMail * @return <type> */ public function changeEmail($aUser, $sMail) { // check if user has enough permissions and the mails dont match if they have to verify the new email upon signup it if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_change_email')) { Phpfox::getService('user.validate')->email($sMail); if (!Phpfox_Error::isPassed()) { return false; } // check that the new email is not in use. $sEmail = Phpfox::getLib('parse.input')->prepare($sMail); $inUse = $this->database()->select('email')->where('email = \'' . $sEmail . '\'')->from(Phpfox::getT('user'))->execute('getSlaveField'); if ($inUse != '') { return 'Email address already in use'; } //die(d(Phpfox::getParam('user.verify_email_at_signup'), true)); // set the status to need to be verified only if they are required at signup if (Phpfox::getParam('user.verify_email_at_signup')) { $mUser = array('user_id' => $aUser['user_id'], 'email' => Phpfox::getLib('parse.input')->prepare($sMail), 'password' => $aUser['password']); $this->database()->update(Phpfox::getT('user'), array('status_id' => 1), 'user_id = ' . (int) $aUser['user_id']); $this->sendMail($mUser); } else { // just change the email $this->database()->update(Phpfox::getT('user'), array('email' => Phpfox::getLib('parse.input')->prepare($sMail)), 'user_id = ' . (int) $aUser['user_id']); } //Phpfox::getParam('user.logout_after_change_email_if_verify') && Phpfox::getParam('user.verify_email_at_signup') // check if they should be logged out immediately after changing it. Only then should their status_id be changed if (Phpfox::getParam('user.verify_email_at_signup') && Phpfox::getParam('user.logout_after_change_email_if_verify') == true) { Phpfox::getService('user.auth')->logout(); } return true; } return false; }
/** * Class process method wnich is used to execute this component. */ public function process() { $aUser = PHPFOX_IS_AJAX ? array('user_group_id' => Phpfox::getUserBy('user_group_id'), 'user_id' => Phpfox::getUserId()) : $this->getParam('aUser'); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public')) { return false; } $aUserGenres = Phpfox::getService('music.genre')->getUserGenre($aUser['user_id']); if (!count($aUserGenres)) { return false; } $this->template()->assign(array('aUserGenres' => $aUserGenres)); }
public function getGroups($sType, $iUserGroup) { $iGroup = 0; $aWhere = array('type_id = \'' . $this->database()->escape($sType) . '\' AND is_active = 1'); if (Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) { $iGroup = $iUserGroup; $iInherit = $this->database()->select('inherit_id')->from(Phpfox::getT('user_group'))->where('user_group_id = ' . (int) $iUserGroup)->execute('getSlaveField'); $aWhere[] = 'AND (user_group_id = 0 OR user_group_id = ' . $iInherit . ' OR user_group_id = ' . (int) $iGroup . ')'; } else { $aWhere[] = 'AND (user_group_id = 0 OR user_group_id = ' . (int) $iGroup . ')'; } return $this->database()->select('*')->from($this->_sTable)->where($aWhere)->order('ordering ASC')->execute('getSlaveRows'); }
public function getGroups($sType, $iUserGroup) { $iGroup = 0; if (Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) { $iGroup = $iUserGroup; } return $this->database()->select('*') ->from($this->_sTable) ->where('user_group_id = ' . (int) $iGroup . ' AND type_id = \'' . $this->database()->escape($sType) . '\' AND is_active = 1') ->order('ordering ASC') ->execute('getSlaveRows'); }
/** * Controller */ public function process() { $aUser = $this->getParam('aUser'); if (!Phpfox::getUserGroupParam(isset($aUser['user_group_id']) ? $aUser['user_group_id'] : Phpfox::getUserBy('user_group_id'), 'music.can_upload_music_public')) { return false; } $aUserGenres = array(); $aGetUserGenres = Phpfox::getService('music.genre')->getUserGenre(isset($aUser['user_id']) ? $aUser['user_id'] : Phpfox::getUserId()); if (count($aGetUserGenres)) { foreach ($aGetUserGenres as $aUserGenre) { $aUserGenres[$aUserGenre['order_id']] = $aUserGenre; } } $this->template()->assign(array('iCustomGroupId' => Phpfox::getService('custom.group')->getId('music.custom_group_basics'), 'aGenres' => Phpfox::getService('music.genre')->getList(), 'aUserGenres' => $aUserGenres, 'iGenerCount' => 3, 'bIsGlobalEdit' => isset($aUser['user_id']) ? true : false)); }
/** * Controller */ public function process() { $aUser = Phpfox::getService('user')->getUser($this->request()->getInt('user_id')); if (!isset($aUser['user_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_find_this_member')); } $bIsBlocked = Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aUser['user_id']); if (!$bIsBlocked) { Phpfox::getUserParam('user.can_block_other_members', true); if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_be_blocked_by_others')) { return Phpfox_Error::set(Phpfox::getPhrase('user.unable_to_block_this_user')); } } $this->template()->assign(array('aUser' => $aUser, 'bIsBlocked' => $bIsBlocked)); }
/** * Controller */ public function process() { $aUser = $this->getParam('aUser'); $bIsMusician = false; if (!Phpfox::getUserGroupParam($aUser['user_group_id'], 'music.can_upload_music_public')) { return false; } $aSongs = Phpfox::getService('music')->getSongs($aUser['user_id'], null, 10); if (!count($aSongs) && !defined('PHPFOX_IN_DESIGN_MODE')) { return false; } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('music.latest_tracks'), 'sBlockJsId' => 'profile_music_song', 'aSongs' => $aSongs, 'bIsMusician' => true, 'sCustomPlayId' => 'js_my_block_track_player')); if (Phpfox::getUserId() == $aUser['user_id']) { $this->template()->assign('sDeleteBlock', 'profile'); } return 'block'; }
/** * Controller */ public function process() { $bIsEdit = false; if ($iEditId = $this->request()->getInt('id')) { Phpfox::getUserParam('custom.can_manage_custom_fields', true); if (($aGroup = Phpfox::getService('custom.group')->getForEdit($iEditId)) && isset($aGroup['group_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aGroup)); } } else { Phpfox::getUserParam('custom.can_add_custom_fields_group', true); } $aGroupValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'module_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_where_this_custom_field_should_be_located')); $oGroupValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_group_field', 'aParams' => $aGroupValidation, 'bParent' => true)); $aGroupTypes = array(); foreach (Phpfox::massCallback('getCustomGroups') as $sModule => $aCustomGroups) { foreach ($aCustomGroups as $sKey => $sPhrase) { $aGroupTypes[$sKey] = $sPhrase; } } if ($aVals = $this->request()->getArray('val')) { if ($oGroupValidator->isValid($aVals)) { if ($bIsEdit === true) { if (Phpfox::getService('custom.group.process')->update($aGroup['group_id'], $aVals)) { $this->url()->send('admincp.custom.group.add', array('id' => $aGroup['group_id']), Phpfox::getPhrase('custom.group_successfully_updated')); } } else { if (Phpfox::getService('custom.group.process')->add($aVals)) { $this->url()->send('admincp.custom.group.add', null, Phpfox::getPhrase('custom.group_successfully_added')); } } } } $aUserGroups = Phpfox::getService('user.group')->get(); foreach ($aUserGroups as $iKey => $aUserGroup) { if (!Phpfox::getUserGroupParam($aUserGroup['user_group_id'], 'custom.has_special_custom_fields')) { unset($aUserGroups[$iKey]); } } $this->template()->setTitle(Phpfox::getPhrase('custom.add_a_new_custom_group'))->setBreadcrumb(Phpfox::getPhrase('custom.add_a_new_custom_group'))->assign(array('sGroupCreateJs' => $oGroupValidator->createJS(), 'sGroupGetJsForm' => $oGroupValidator->getJsForm(), 'aGroupTypes' => $aGroupTypes, 'bIsEdit' => $bIsEdit, 'aUserGroups' => $aUserGroups)); }
/** * Sends newsletters according to the round set in `newsletter`.`round` * Updates `newsletter`.`state` if needed. * user_field.newsletter_state = * 0 = no newsletter * 1 = received newsletter * * Steps: * 1. get the newsletter info * 2. get users to send with filtering by total * 3. send the message/email * 4. update the users so they dont receive it again * 5. update the round of the job. * 6. return the job id and the percentage completed * @param int | null $iId if null it fetches the first newsletter in progress and processes it. */ public function processJob($iId = null) { // Step 1. Need to check the newsletter state is in progress if ($iId === null) { $this->database()->where('n.newsletter_state = 1') // in progress ->limit(1); } else { $this->database()->where('n.newsletter_id = ' . (int)$iId); } $aNewsletterInfo = $this->database()->select('*') ->join(Phpfox::getT('newsletter_text'), 'nt', 'nt.newsletter_id = n.newsletter_id') ->from($this->_sTable, 'n') ->execute('getSlaveRow'); if (!isset($aNewsletterInfo['text_plain'])) { $aNewsletterInfo['text_plain'] = null; } // check if we have completed this job if (empty($aNewsletterInfo) || (isset($aNewsletterInfo['state']) && $aNewsletterInfo['state'] == 2)) { $this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 0), 'newsletter_state != 0'); return array(true, 100); } // Step 2: Get the pending members [the round field is unnecessary now] $sSelect = Phpfox::getUserField() . ', un.user_id as notification, u.email, u.language_id'; $sWhere = 'uf.newsletter_state = 0'; // 0 = no newsletter ever sent, 1 last newsletter sent // filter the audience if (isset($aNewsletterInfo['age_from']) && $aNewsletterInfo['age_from'] > 0) { $iFromDate = PHPFOX_TIME - (31556926 * $aNewsletterInfo['age_from']); $sWhere .= ' AND u.birthday_search < ' . $iFromDate; } if (isset($aNewsletterInfo['age_to']) && $aNewsletterInfo['age_to'] > 0) { $iToDate = PHPFOX_TIME - (31556926 * $aNewsletterInfo['age_to']); $sWhere .= ' AND u.birthday_search > ' . $iToDate; } if (isset($aNewsletterInfo['country_iso']) && $aNewsletterInfo['country_iso'] != '') { $sWhere .= ' AND country_iso = \'' . $aNewsletterInfo['country_iso'] . '\''; // no extra checks here since it either comes directly from DB } if (isset($aNewsletterInfo['gender']) && $aNewsletterInfo['gender'] > 0) { $sWhere .= ' AND gender = ' . (int)$aNewsletterInfo['gender']; } if (!empty($aNewsletterInfo['user_group_id'])) { $aUserGroups = unserialize($aNewsletterInfo['user_group_id']); $sWhere .= ' AND u.user_group_id IN(' . implode(',', $aUserGroups) . ')'; } $aUsers = $this->database()->select($sSelect) ->from(Phpfox::getT('user'), 'u') ->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = u.user_id') ->limit((int)$aNewsletterInfo['total']) ->leftjoin(Phpfox::getT('user_notification'), 'un', 'un.user_id = u.user_id') ->group('u.user_id') ->where($sWhere) ->execute('getSlaveRows'); if (count($aUsers) == 0) { if ($aNewsletterInfo['archive'] != 1) { $this->database()->delete($this->_sTable, 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']); $this->database()->delete(Phpfox::getT('newsletter_text'), 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']); } else { $this->database()->update($this->_sTable, array('state' => 2), 'newsletter_id = ' . (int)$aNewsletterInfo['newsletter_id']); } $this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 0), 'newsletter_state != 0'); return array(true, 100); // newsletter sent to everyone. finished successfully. } $sOriginalHtmlText = $aNewsletterInfo['text_html']; $sOriginalPlainText = $aNewsletterInfo['text_plain']; // store these users ID into a string to update them $sUpdate = '1=2 '; // Step 3: Send the message if ($aNewsletterInfo['type_id'] == 2) // External -> send email { $aValsT = $aNewsletterInfo; foreach ($aUsers as $aUser) { $aNewsletterInfo = $aValsT; $sUpdate .= ' OR user_id = ' . $aUser['user_id']; if (isset($aUser['user_group_id']) && Phpfox::getUserGroupParam($aUser['user_group_id'], 'newsletter.can_receive_notification') == false) { } elseif (isset($aUser['notification']) && $aUser['notification'] != '' && $aNewsletterInfo['privacy'] != 1) { // user does not want to receive mails and admin set this newsletter to NOT override this continue; } // keyword substitution $aSearch = array('{FULL_NAME}', '{USER_NAME}', '{SITE_NAME}'); $aReplace = array($aUser['full_name'], $aUser['user_name'], Phpfox::getParam('core.site_title')); $aNewsletterInfo['text_html'] = str_ireplace($aSearch, $aReplace, $sOriginalHtmlText); $aNewsletterInfo['subject'] = str_ireplace($aSearch, $aReplace, $aNewsletterInfo['subject']); if ($aNewsletterInfo['text_plain'] !== null) { $aNewsletterInfo['text_plain'] = str_ireplace($aSearch, $aReplace, $sOriginalPlainText); } unset($aSearch); unset($aReplace); $this->_sendExternal($aNewsletterInfo, $aUser); } } elseif($aNewsletterInfo['type_id'] == 1) // internal message { foreach ($aUsers as $aUser) { // keyword substitution $aSearch = array('{FULL_NAME}', '{USER_NAME}', '{SITE_NAME}'); $aReplace = array($aUser['full_name'], $aUser['user_name'], Phpfox::getParam('core.site_title')); $aNewsletterInfo['text_html'] = str_ireplace($aSearch, $aReplace, $sOriginalHtmlText); $aNewsletterInfo['subject'] = str_ireplace($aSearch, $aReplace, $aNewsletterInfo['subject']); $aNewsletterInfo['user_id'] = $aUser['user_id']; unset($aSearch); unset($aReplace); $this->_sendInternal($aNewsletterInfo); $aNewsletterInfo['full_name'] = $aUser['full_name']; $aNewsletterInfo['user_id'] = $aUser['user_id']; $aNewsletterInfo['email'] = $aUser['email']; $sUpdate .= ' OR user_id = ' . $aUser['user_id']; if (isset($aUser['notification']) && $aUser['notification'] != '' && $aNewsletterInfo['privacy'] != 1) { // user does not want to receive mails and admin set this newsletter to NOT override this continue; } } } // Step 4: Update these users so they dont get the newsletter again $this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 1), $sUpdate); //Step 5: Update the round ++$aNewsletterInfo['round']; $this->database()->update($this->_sTable, array( 'round' => $aNewsletterInfo['round'], 'state' => 1, // its in progress ), 'newsletter_id = ' . (int)$aNewsletterInfo['newsletter_id']); // Step 6: return the id so it keeps sending in the next batch and calculate the percentage. // how many users do we have left? // check if we have a where $sSelect = 'COUNT(user_id)'; if (str_replace('uf.newsletter_state = 0', '', $sWhere) != '') { $sSelect = 'COUNT(uf.user_id)'; $this->database()->where($sWhere) ->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = u.user_id'); } $iTotalUsers = $this->database() ->select($sSelect) ->from(Phpfox::getT('user'), 'u') ->execute('getSlaveField'); $iSentTotal = $this->database() ->select('count(user_id)') ->from(Phpfox::getT('user_field')) ->where('newsletter_state = 1') ->execute('getSlaveField'); if ($iTotalUsers > 0 && $iTotalUsers != $iSentTotal) { $iPerc = ceil( ($iSentTotal / $iTotalUsers) * 100 ); } else { $iPerc = 100; } if($iPerc >= 100) { if ($aNewsletterInfo['archive'] != 1) { $this->database()->delete($this->_sTable, 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']); $this->database()->delete(Phpfox::getT('newsletter_text'), 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']); } else { $this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 0), 'newsletter_state != 0'); $this->database()->update($this->_sTable, array('state' => 2), 'newsletter_id = ' . $aNewsletterInfo['newsletter_id']); } $this->database()->update(Phpfox::getT('user_field'), array('newsletter_state' => 0), 'newsletter_state != 0'); } return array((int)$aNewsletterInfo['newsletter_id'], $iPerc); }
/** * Class process method wnich is used to execute this component. */ public function process() { // $aUser = (PHPFOX_IS_AJAX ? Phpfox::getService('user')->get(Phpfox::getUserId(), true) : $this->getParam('aUser')); $aUser = $this->getParam('aUser'); /* if (PHPFOX_IS_AJAX) { $aUser['gender_name'] = Phpfox::getService('user')->gender($aUser['gender']); $aUser['birthday_time_stamp'] = $aUser['birthday']; $aUser['birthday'] = Phpfox::getService('user')->age($aUser['birthday']); $aUser['location'] = Phpfox::getService('core.country')->getCountry($aUser['country_iso']); $this->template()->assign('aUser', $aUser); } */ if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'profile.basic_info')) { return false; } $aUser['bRelationshipHeader'] = true; $sRelationship = Phpfox::getService('custom')->getRelationshipPhrase($aUser); $aUserDetails = array(); if (!empty($aUser['gender'])) { $aUserDetails[Phpfox::getPhrase('profile.gender')] = '<a href="' . $this->url()->makeUrl('user.browse', array('gender' => $aUser['gender'])) . '">' . $aUser['gender_name'] . '</a>'; } $aUserDetails = array_merge($aUserDetails, $aUser['birthdate_display']); $sExtraLocation = ''; if (!empty($aUser['city_location'])) { $sExtraLocation .= '<div class="p_2"><a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'], 'state' => $aUser['country_child_id'], 'city-name' => $aUser['city_location'])) . '">' . Phpfox::getLib('parse.output')->clean($aUser['city_location']) . '</a> »</div>'; } if ($aUser['country_child_id'] > 0) { $sExtraLocation .= '<div class="p_2"><a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'], 'state' => $aUser['country_child_id'])) . '">' . Phpfox::getService('core.country')->getChild($aUser['country_child_id']) . '</a> »</div>'; } if (!empty($aUser['country_iso'])) { $aUserDetails[Phpfox::getPhrase('profile.location')] = $sExtraLocation . '<a href="' . $this->url()->makeUrl('user.browse', array('location' => $aUser['country_iso'])) . '">' . Phpfox::getPhraseT($aUser['location'], 'country') . '</a>'; } if ((int) $aUser['last_login'] > 0 && (!$aUser['is_invisible'] || Phpfox::getUserParam('user.can_view_if_a_user_is_invisible') && $aUser['is_invisible'])) { $aUserDetails[Phpfox::getPhrase('profile.last_login')] = Phpfox::getLib('date')->convertTime($aUser['last_login'], 'core.profile_time_stamps'); } if ((int) $aUser['joined'] > 0) { $aUserDetails[Phpfox::getPhrase('profile.member_since')] = Phpfox::getLib('date')->convertTime($aUser['joined'], 'core.profile_time_stamps'); } if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'profile.display_membership_info')) { $aUserDetails[Phpfox::getPhrase('profile.membership')] = (empty($aUser['icon_ext']) ? '' : '<img src="' . Phpfox::getParam('core.url_icon') . $aUser['icon_ext'] . '" class="v_middle" alt="' . Phpfox::getLib('locale')->convert($aUser['title']) . '" title="' . Phpfox::getLib('locale')->convert($aUser['title']) . '" /> ') . $aUser['prefix'] . Phpfox::getLib('locale')->convert($aUser['title']) . $aUser['suffix']; } $aUserDetails[Phpfox::getPhrase('profile.profile_views')] = $aUser['total_view']; if (Phpfox::isModule('rss') && Phpfox::getParam('rss.display_rss_count_on_profile') && Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'rss.display_on_profile')) { $aUserDetails[Phpfox::getPhrase('profile.rss_subscribers')] = $aUser['rss_count']; } $sEditLink = ''; if ($aUser['user_id'] == Phpfox::getUserId()) { $sEditLink = '<div class="js_edit_header_bar">'; $sEditLink .= '<span id="js_user_basic_info" style="display:none;"><img src="' . $this->template()->getStyle('image', 'ajax/small.gif') . '" alt="" class="v_middle" /></span>'; $sEditLink .= '<a href="' . Phpfox::getLib('url')->makeUrl('user.profile') . '" id="js_user_basic_edit_link">'; $sEditLink .= '<img src="' . $this->template()->getStyle('image', 'misc/page_white_edit.png') . '" alt="" class="v_middle" />'; $sEditLink .= '</a>'; $sEditLink .= '</div>'; } // Get the Smoker and Drinker details $aUserPanel = Phpfox::getService('custom')->getUserPanelForUser($aUser['user_id']); foreach ($aUserPanel as $sName => $aField) { //$aUserDetails[Phpfox::getPhrase($aField['phrase_var_name'])] = Phpfox::getPhrase($aField['phrase_chosen']); } $this->template()->assign(array('aUserDetails' => $aUserDetails, 'sBlockJsId' => 'profile_basic_info', 'sRelationship' => $sRelationship)); $this->setParam('aRatingCallback', array('type' => 'user', 'total_rating' => Phpfox::getPhrase('profile.total_rating_ratings', array('total_rating' => $aUser['total_rating'])), 'default_rating' => $aUser['total_score'], 'item_id' => $aUser['user_id'], 'stars' => range(1, 10))); ($sPlugin = Phpfox_Plugin::get('profile.component_block_info')) ? eval($sPlugin) : false; if (!Phpfox::isMobile()) { $this->template()->assign(array('sHeader' => $sEditLink . Phpfox::getPhrase('profile.basic_info'), 'sEditLink' => $sEditLink)); return 'block'; } }
public function deleteOption($iId) { Phpfox::getUserParam('custom.can_manage_custom_fields', true); $aOption = $this->database()->select('co.*, cf.field_name, cf.user_group_id, cf.var_type, cf.field_id')->from(Phpfox::getT('custom_option'), 'co')->join(Phpfox::getT('custom_field'), 'cf', 'cf.field_id = co.field_id')->where('co.option_id = ' . (int) $iId)->execute('getRow'); if (!isset($aOption['option_id'])) { return Phpfox_Error::set(Phpfox::getPhrase('custom.unable_to_find_the_custom_option_you_plan_on_deleting')); } if ($aOption['var_type'] == 'select' || $aOption['var_type'] == 'multiselect' || $aOption['var_type'] == 'checkbox' || $aOption['var_type'] == 'radio') { Phpfox::getService('language.phrase.process')->delete($aOption['phrase_var_name']); $this->database()->delete(Phpfox::getT('custom_option'), 'option_id = ' . $aOption['option_id']); $this->database()->delete(Phpfox::getT('user_custom_multiple_value'), 'option_id = ' . $aOption['option_id'] . ' AND field_id = ' . $aOption['field_id']); return true; } $sTable = 'user_custom'; $sValueTable = 'user_custom_value'; if ($aOption['user_group_id'] > 0) { if (Phpfox::getUserGroupParam($aOption['user_group_id'], 'custom.has_special_custom_fields')) { $sTable = Phpfox::getUserGroupParam($aOption['user_group_id'], 'custom.custom_table_name'); $sValueTable = $sTable . '_value'; } } $sFieldName = Phpfox::getService('custom')->getAlias() . $aOption['field_name']; $this->database()->update(Phpfox::getT($sTable), array($sFieldName => null), $sFieldName . ' = \'' . $this->database()->escape($aOption['phrase_var_name']) . '\''); $this->database()->update(Phpfox::getT($sValueTable), array($sFieldName => 0), $sFieldName . ' = \'' . $aOption['option_id'] . '\''); list($sModule, $sPhrase) = explode('.', $aOption['phrase_var_name']); $this->database()->delete(Phpfox::getT('language_phrase'), 'module_id = \'' . $sModule . '\' AND var_name = \'' . $sPhrase . '\''); $this->database()->delete(Phpfox::getT('custom_option'), 'option_id = ' . $aOption['option_id']); return true; }
/** * Controller */ public function process() { $bHideOptions = true; $iDefaultSelect = 4; $bIsEdit = false; if ($iEditId = $this->request()->getInt('id')) { Phpfox::getUserParam('custom.can_manage_custom_fields', true); $aField = Phpfox::getService('custom')->getForCustomEdit($iEditId); if (isset($aField['field_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aField)); if (isset($aField['option']) && $aField['var_type'] == 'select') { $bHideOptions = false; } } } else { Phpfox::getUserParam('custom.can_add_custom_fields', true); $this->template()->assign(array('aForms' => array())); } $aFieldValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'var_type' => Phpfox::getPhrase('custom.select_what_type_of_custom_field_this_is')); $oCustomValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_custom_field', 'aParams' => $aFieldValidation, 'bParent' => true)); $this->template()->assign(array('sCustomCreateJs' => $oCustomValidator->createJS(), 'sCustomGetJsForm' => $oCustomValidator->getJsForm())); if ($aVals = $this->request()->getArray('val')) { if ($oCustomValidator->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('custom.process')->update($aField['field_id'], $aVals)) { $this->url()->send('admincp.custom.add', array('id' => $aField['field_id']), Phpfox::getPhrase('custom.field_successfully_updated')); } } else { if (Phpfox::getService('custom.process')->add($aVals)) { $this->url()->send('admincp.custom.add', null, Phpfox::getPhrase('custom.field_successfully_added')); } } } if (isset($aVals['var_type']) && $aVals['var_type'] == 'select') { $bHideOptions = false; $iCnt = 0; $sOptionPostJs = ''; foreach ($aVals['option'] as $iKey => $aOptions) { if (!$iKey) { continue; } $aValues = array_values($aOptions); if (!empty($aValues[0])) { $iCnt++; } foreach ($aOptions as $sLang => $mValue) { $sOptionPostJs .= 'option_' . $iKey . '_' . $sLang . ': \'' . str_replace("'", "\\'", $mValue) . '\','; } } $sOptionPostJs = rtrim($sOptionPostJs, ','); $iDefaultSelect = $iCnt; } } $aTypes = array(); foreach (Phpfox::massCallback('getCustomFieldLocations') as $sModule => $aCustomFields) { foreach ($aCustomFields as $sKey => $sPhrase) { $aTypes[$sKey] = $sPhrase; } } $aGroupTypes = array(); foreach (Phpfox::massCallback('getCustomGroups') as $sModule => $aCustomGroups) { foreach ($aCustomGroups as $sKey => $sPhrase) { $aGroupTypes[$sKey] = $sPhrase; } } $aGroupValidation = array('product_id' => Phpfox::getPhrase('custom.select_a_product_this_custom_field_will_belong_to'), 'module_id' => Phpfox::getPhrase('custom.select_a_module_this_custom_field_will_belong_to'), 'type_id' => Phpfox::getPhrase('custom.select_where_this_custom_field_should_be_located')); $oGroupValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_group_field', 'aParams' => $aGroupValidation, 'bParent' => true)); $this->template()->assign(array('sGroupCreateJs' => $oGroupValidator->createJS(), 'sGroupGetJsForm' => $oGroupValidator->getJsForm(false))); $aUserGroups = Phpfox::getService('user.group')->get(); foreach ($aUserGroups as $iKey => $aUserGroup) { if (!Phpfox::getUserGroupParam($aUserGroup['user_group_id'], 'custom.has_special_custom_fields')) { unset($aUserGroups[$iKey]); } } // only show the input if there are custom fields $this->template()->assign(array('bShowUserGroups' => count($aUserGroups) > 0)); $this->template()->setSectionTitle('Custom Fields')->setTitle(Phpfox::getPhrase('custom.add_a_new_custom_field'))->setBreadcrumb($bIsEdit ? 'Edit Custom Field' : Phpfox::getPhrase('custom.add_a_new_custom_field'), $this->url()->current(), true)->setPhrase(array('custom.are_you_sure_you_want_to_delete_this_custom_option'))->setHeader(array('<script type="text/javascript"> var bIsEdit = ' . ($bIsEdit ? 'true' : 'false') . '</script>', 'admin.js' => 'module_custom', '<script type="text/javascript">$Behavior.custom_admin_add_init = function(){$Core.custom.init(' . ($bIsEdit == true ? 1 : $iDefaultSelect) . '' . (isset($sOptionPostJs) ? ', {' . $sOptionPostJs . '}' : '') . ');};</script>'))->assign(array('aTypes' => $aTypes, 'aLanguages' => Phpfox::getService('language')->getAll(), 'aGroupTypes' => $aGroupTypes, 'aGroups' => Phpfox::getService('custom.group')->get(), 'bHideOptions' => $bHideOptions, 'bIsEdit' => $bIsEdit, 'aUserGroups' => $aUserGroups)); }
public function getForEdit($aTypes, $iItemId = null, $iUserGroup = null, $bRegister = false, $iUserId = null) { $iGroup = 0; $sTable = 'user_custom_multiple_value'; if ($sPlugin = Phpfox_Plugin::get('custom.service_custom_getforedit_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } $sTypes = ''; foreach ($aTypes as $sType) { $sTypes .= '\'' . $sType . '\','; } $sTypes = rtrim($sTypes, ','); $aWhere = array('cf.type_id IN (' . $sTypes . ') AND cf.is_active = 1'); if ($iUserGroup !== null && Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) { $iGroup = $iUserGroup; $sTable = Phpfox::getUserGroupParam($iUserGroup, 'custom.custom_table_name') . '_value'; // Need to get the inherit user group id $iInherit = $this->database()->select('inherit_id')->from(Phpfox::getT('user_group'))->where('user_group_id = ' . (int) $iUserGroup)->execute('getSlaveField'); $aWhere[] = 'AND (cf.user_group_id = ' . (int) $iUserGroup . ' OR cf.user_group_id = ' . $iInherit . ' OR cf.user_group_id = 0)'; } else { $aWhere[] = 'AND cf.user_group_id = ' . (int) $iGroup . ''; } if ($bRegister == true) { $aWhere[] = 'AND cf.on_signup = 1'; } // Fixes 13743 if ($iUserId !== null) { $this->database()->leftjoin(Phpfox::getT('user_custom_multiple_value'), 'cmv', 'cmv.field_id = cf.field_id AND cmv.user_id = ' . (int) $iUserId); } else { $this->database()->leftjoin(Phpfox::getT('custom_option'), 'cmv', 'cmv.field_id = cf.field_id'); } $aRows = $this->database()->select('cf.*, cmv.option_id as customValue, cg.user_group_id as cg_user_group_id')->from($this->_sTable, 'cf')->join(Phpfox::getT('module'), 'm', 'm.module_id = cf.module_id AND m.is_active = 1')->leftjoin(Phpfox::getT('custom_group'), 'cg', 'cg.group_id = cf.group_id')->where($aWhere)->order('cf.ordering ASC')->execute('getSlaveRows'); // we already have the values from the multiple selection table now we need to // glue them into the same field_id $aTemp = array(); $aTexts = array(); $aOptions = array(); $aFields = array(); if ($iUserId !== null) { $aTexts = $this->database()->select('*')->from(Phpfox::getT('user_custom'))->where('user_id = ' . (int) $iUserId)->execute('getSlaveRow'); } else { if ($iItemId !== null) { $aTexts = $this->database()->select('*')->from(Phpfox::getT('user_custom_value'))->where('user_id = ' . (int) $iItemId)->execute('getSlaveRow'); } } foreach ($aRows as $iKey => $aRow) { if (!empty($aRow['cg_user_group_id']) && $aRow['cg_user_group_id'] != $iUserGroup) { unset($aRows[$iKey]); continue; } if (!isset($aTemp[$aRow['field_id']])) { $aTemp[$aRow['field_id']] = $aRow; } // merge duplicated fields (they have different customValue if (($aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'checkbox') && !is_array($aTemp[$aRow['field_id']]['customValue'])) { $aTemp[$aRow['field_id']]['customValue'] = array($aRow['customValue']); } elseif ($aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'checkbox') { $aTemp[$aRow['field_id']]['customValue'][] = $aRow['customValue']; } else { if ($aRow['type_name'] == 'MEDIUMTEXT' && isset($aTexts['cf_' . $aRow['field_name']]) || strpos($aRow['type_name'], 'VARCHAR') !== false && isset($aTexts['cf_' . $aRow['field_name']])) { $aRow['value'] = $aTexts['cf_' . $aRow['field_name']]; $aRow['value'] = str_replace('<br />', "\n", $aRow['value']); $aTemp[$aRow['field_id']] = $aRow; } } if ($aRow['type_name'] != 'MEDIUMTEXT') { $aRow['value'] = $aRow['customValue']; } $aFields[$this->_sAlias . $aRow['field_name']] = $aTemp[$aRow['field_id']]; if ($aRow['var_type'] == 'select' || $aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'radio' || $aRow['var_type'] == 'checkbox') { $aOptions[$aRow['field_id']] = $aRow['field_id']; } } $aRows = $aTemp; // Match the text areas if we are searching for a specific user if (count($aOptions)) { $aOptionsRows = $this->database()->select('*')->from(Phpfox::getT('custom_option'))->where('field_id IN(' . implode(',', array_values($aOptions)) . ')')->order('option_id ASC')->execute('getSlaveRows'); $aCacheOptions = array(); foreach ($aOptionsRows as $aOptionsRow) { $aCacheOptions[$aOptionsRow['field_id']][$aOptionsRow['option_id']] = Phpfox::getPhrase($aOptionsRow['phrase_var_name']); } } $oReq = Phpfox_Request::instance(); $bIsRegistration = $oReq->get('req1') == 'user' && $oReq->get('req2') == 'register' || $oReq->get('req1') == 'core' && ($oReq->get('req2') == 'index-visitor' || $oReq->get('req2') == 'index-visitor-mobile') || $oReq->get('req1') == ''; foreach ($aFields as $sFieldKey => $aField) { if (!isset($aField['value'])) { $aField['value'] = ''; } if ($aField['var_type'] == 'textarea') { continue; } if (!empty($aCacheOptions)) { foreach ($aCacheOptions as $iFieldId => $aValues) { if ($iFieldId == $aField['field_id']) { if (!isset($aFields[$sFieldKey]['options'])) { $aFields[$sFieldKey]['options'] = array(); } foreach ($aValues as $iOptionId => $sPhrase) { $aTemp = array('value' => $sPhrase); // check if this is a selected option if (is_array($aField['customValue']) && !$bIsRegistration) { foreach ($aField['customValue'] as $iOptionIdVal) { if ($iOptionIdVal == $iOptionId) { $aTemp['selected'] = true; } } } else { if (!$bIsRegistration && !empty($aField['customValue']) && $iOptionId == $aField['customValue']) { $aTemp['selected'] = true; } } $aFields[$sFieldKey]['options'][$iOptionId] = $aTemp; } } } } } return $aFields; }
/** * Get full info of user * @return array */ public function getUserInfo() { $iUserId = $this->_oApi->get('user_id'); $bIsLogin = $this->_oApi->get('login', false); $oUserService = Phpfox::getService('user'); $aRow = Phpfox::getService('user')->get($iUserId, true); if (Phpfox::getService('user.block')->isBlocked($aRow['user_id'], Phpfox::getUserId()) && !Phpfox::getUserParam('user.can_override_user_privacy')) { return Phpfox::getPhrase('profile.profile_is_private'); } if (Phpfox::getParam('friend.friends_only_profile') && empty($aRow['is_friend']) && !Phpfox::getUserParam('user.can_override_user_privacy') && $aRow['user_id'] != Phpfox::getUserId()) { return Phpfox::getPhrase('profile.profile_is_private'); } if (!Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'profile.view_profile')) { return Phpfox::getPhrase('profile.profile_is_private'); } $sImagePath = $aRow['user_image']; $aRow['photo_50px'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_50', 'return_url' => true)); $aRow['photo_50px_square'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_50_square', 'return_url' => true)); $aRow['photo_75px_square'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_75_square', 'return_url' => true)); $aRow['photo_120px'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_120', 'return_url' => true)); $aRow['photo_120px_square'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_120_square', 'return_url' => true)); $aRow['photo_200px_square'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '_200_square', 'return_url' => true)); $aRow['photo_original'] = Phpfox::getLib('image.helper')->display(array('user' => $aRow, 'server_id' => $aRow['server_id'], 'suffix' => '', 'return_url' => true)); $aCoverPhoto = Phpfox::getService('photo')->getCoverPhoto($aRow['cover_photo']); if (count($aCoverPhoto) > 0) { $aSizes = Phpfox::getParam('photo.photo_pic_sizes'); $aRow['cover_photo'] = array(); foreach ($aSizes as $iSize) { $aRow['cover_photo'][$iSize] = Phpfox::getLib('image.helper')->display(array('file' => $aCoverPhoto['destination'], 'server_id' => $aCoverPhoto['server_id'], 'path' => 'photo.url_photo', 'suffix' => '_' . $iSize, 'return_url' => true)); } } $aRow['birthday_time_stamp'] = $aRow['birthday']; $aRow['birthday'] = $oUserService->age($aRow['birthday']); $aRow['birthday_phrase'] = $oUserService->getProfileBirthDate($aRow); $aRow['birthday_phrase'] = end($aRow['birthday_phrase']); $aRow['gender_phrase'] = $oUserService->gender($aRow['gender']); $aRow['info'] = array(Phpfox::getPhrase('profile.gender') => $aRow['gender_phrase'], Phpfox::getPhrase('user.age') => $aRow['birthday_phrase'], 'Gender' => $aRow['gender_phrase'], 'Age' => $aRow['birthday_phrase']); $sExtraLocation = ''; $aRow['country_name'] = Phpfox::getService('core.country')->getCountry($aRow['country_iso']); if (!empty($aRow['city_location'])) { $sExtraLocation .= Phpfox::getLib('parse.output')->clean($aRow['city_location']) . ', '; } if ($aRow['country_child_id'] > 0) { $sExtraLocation .= Phpfox::getService('core.country')->getChild($aRow['country_child_id']); } if (!empty($aRow['country_iso'])) { $aRow['location_phrase'] = $sExtraLocation . ' ' . $aRow['country_name']; $aRow['info'][Phpfox::getPhrase('profile.location')] = $aRow['location_phrase']; $aRow['info']['Location'] = $aRow['location_phrase']; } if ((int) $aRow['last_login'] > 0 && (!$aRow['is_invisible'] || Phpfox::getUserParam('user.can_view_if_a_user_is_invisible') && $aRow['is_invisible'])) { $aRow['last_login_phrase'] = Phpfox::getLib('date')->convertTime($aRow['last_login'], 'core.profile_time_stamps'); $aRow['info'][Phpfox::getPhrase('profile.last_login')] = $aRow['last_login_phrase']; $aRow['info']['Last Login'] = $aRow['last_login_phrase']; } if ((int) $aRow['joined'] > 0) { $aRow['joined_phrase'] = Phpfox::getLib('date')->convertTime($aRow['joined'], 'core.profile_time_stamps'); $aRow['info'][Phpfox::getPhrase('profile.member_since')] = $aRow['joined_phrase']; $aRow['info']['Member Since'] = $aRow['joined_phrase']; } if (Phpfox::getUserGroupParam($aRow['user_group_id'], 'profile.display_membership_info')) { $aRow['membership'] = $aRow['prefix'] . Phpfox::getLib('locale')->convert($aRow['title']) . $aRow['suffix']; $aRow['info'][Phpfox::getPhrase('profile.membership')] = $aRow['membership']; $aRow['info']['Membership'] = $aRow['membership']; } $aRow['profile_views'] = $aRow['total_view']; $aRow['info'][Phpfox::getPhrase('profile.profile_views')] = $aRow['profile_views']; $aRow['info']['Profile Views'] = $aRow['profile_views']; if (Phpfox::isModule('rss') && Phpfox::getParam('rss.display_rss_count_on_profile') && Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'rss.display_on_profile')) { $aRow['rss_subscribers'] = $aRow['rss_count']; $aRow['info'][Phpfox::getPhrase('profile.rss_subscribers')] = $aRow['rss_subscribers']; $aRow['info']['RSS Subscribers'] = $aRow['rss_subscribers']; } // //get relationship // $sRelationship = Phpfox::getService('custom')->getRelationshipPhrase($aRow); // if(!empty($sRelationship)) { // $aRow['info'][Phpfox::getPhrase('user.custom_relationship_status')] = $sRelationship; // } //get smoker drinker // $aCustomMain['user_panel'] = Phpfox::getService('custom')->getForDisplay('user_panel', $iUserId); // // foreach ($aCustomMain['user_panel'] as $iKey => $aCustom) { // if (empty($aCustom['value'])) { // continue; // } // $aRow['info'][$aCustom['field_name']] = Phpfox::getPhrase($aCustom['value']); // } //add new $aMenus = Phpfox::getService('profile')->getProfileMenu($aRow); foreach ($aMenus as $iKey => $aMenu) { $aMenus[$iKey]['icon_image'] = Phpfox::getLib('image.helper')->display(array('theme' => $aMenu['icon'], 'return_url' => true)); $aMenus[$iKey]['link'] = Phpfox::getLib('url')->makeUrl($aMenu['url']); if (in_array($aMenu['actual_url'], array('profile', 'profile_info', 'profile_photo', 'profile_friend'))) { unset($aMenus[$iKey]); } } $aRow['menus'] = $aMenus; unset($aRow['password_salt']); unset($aRow['password']); if (!$bIsLogin) { return $aRow; } $aRow['sidebar_item'] = Phpfox::getService('accountapi.pages')->getPages(); //endnew // $aUserPanel = Phpfox::getService('custom')->getForDisplay('user_main', $aRow['user_id']); // $aRow['custom'] = array(); // foreach ($aUserPanel as $aField) { // $aRow['custom'][] = array( // 'phrase' => Phpfox::getPhrase($aField['phrase_var_name']), // 'value' => strip_tags($aField['value']), // ); // } // $aMods = Phpfox::getService('mobile')->getMenu(); $oLibInput = Phpfox::getLib('parse.input'); foreach ($aMods as $iKey => $aModule) { if (in_array($aModule['module'], array('feed', 'friend', 'mail', 'profile'))) { unset($aMods[$iKey]); } else { $aMods[$iKey]['phrase'] = $oLibInput->stripInnerHtml($aModule['phrase']); } } $aRow['appMod'] = $aMods; if (Phpfox::getParam('accountapi.admob_publish_key')) { $aRow['key_admob'] = Phpfox::getParam('accountapi.admob_publish_key'); } $oServiceAccountapiCore = Phpfox::getService('accountapi.core'); $aRow['settings'] = $oServiceAccountapiCore->getSettings(); // $aRow['user_settings'] = $oServiceAccountapiCore->getUserSettings(); return $aRow; }
/** * Get ads based on the block positioning. * * @param int $iId Block ID#. * @return mixed NULL returned if ads cannot be viewed by the user. FALSE is returned if no ads exists. An ARRAY of ads are returned of ads exist for the specific block. */ public function getForBlock($iId, $bAll = false, $bUpdateCounter = true) { static $aCacheAd = array(); if (Phpfox::getParam('ad.multi_ad')) { if ($iId != 3 && $iId != 50) { return false; } $iId = 50; } if (isset($aCacheAd[$iId])) { return $aCacheAd[$iId]; } if (Phpfox::getService('profile')->timeline() && $iId == '1') { $aCacheAd[$iId] = array(); return $aCacheAd[$iId]; } ($sPlugin = Phpfox_Plugin::get('ad.service_ad_getforblock__start')) ? eval($sPlugin) : false; $sCacheId = $this->cache()->set('ad_' . (int) $iId); if (Phpfox::getUserGroupParam(Phpfox::getUserBy('user_group_id'), 'ad.show_ads') == false) { $aCacheAd[$iId] = array(); return array(); } if (!($aAds = $this->cache()->get($sCacheId, Phpfox::getParam('ad.ad_cache_limit')))) { $aRows = $this->database()->select('a.*, ac.child_id, ac.country_id')->from($this->_sTable, 'a')->leftjoin(Phpfox::getT('ad_country'), 'ac', 'ac.ad_id = a.ad_id')->where('a.is_active = 1 AND a.location = \'' . $this->database()->escape($iId) . '\'')->execute('getRows'); $aAds = array(); $aIn = array(); foreach ($aRows as $iKey => $aAd) { if (!isset($aAds[$aAd['ad_id']])) { $aAds[$aAd['ad_id']] = $aAd; $aAds[$aAd['ad_id']]['country_child_id'] = array(); $aAds[$aAd['ad_id']]['countries_list'] = array(); unset($aAds[$aAd['ad_id']]['country_id']); } if (isset($aAd['child_id']) && !empty($aAd['child_id'])) { $aAds[$aAd['ad_id']]['country_child_id'][] = $aAd['child_id']; unset($aAds[$aAd['ad_id']]['child_id']); } if (isset($aAd['country_id']) && !empty($aAd['country_id'])) { $aAds[$aAd['ad_id']]['countries_list'][$aAd['country_id']] = $aAd['country_id']; } if ($aAd['location'] == 50) { $aContent = json_decode($aAd['html_code'], true); $aAds[$aAd['ad_id']]['body'] = $aContent['body']; $aAds[$aAd['ad_id']]['title'] = $aContent['title']; $aAds[$aAd['ad_id']]['trimmed_url'] = str_replace('http://', '', $aAd['url_link']); } // http://www.phpfox.com/tracker/view/15397/ if (!empty($aAd['disallow_controller'])) { $sControllerName = Phpfox::getLib('module')->getFullControllerName(); $aParts = explode(',', $aAd['disallow_controller']); foreach ($aParts as $sPart) { $sPart = trim($sPart); // str_replace for marketplace.invoice/index // str_replace for music.browse/album if ($sControllerName == $sPart || str_replace('/index', '', $sControllerName) == $sPart || str_replace('/', '.', $sControllerName) == $sPart) { unset($aAds[$aAd['ad_id']]); } } } } $this->cache()->save($sCacheId, $aAds); } if ($sPlugin = Phpfox_Plugin::get('ad.service_ad_getforblock__1')) { eval($sPlugin); } if (!is_array($aAds) || is_array($aAds) && !count($aAds)) { $aCacheAd[$iId] = array(); return array(); } foreach ($aAds as $iKey => $aAd) { // Check for Postal Code and for City if (Phpfox::getParam('ad.advanced_ad_filters') && Phpfox::getUserBy('postal_code') != '' && !empty($aAd['postal_code']) && strpos($aAd['postal_code'], Phpfox::getUserBy('postal_code')) === false) { unset($aAds[$iKey]); } if (Phpfox::getParam('ad.advanced_ad_filters') && !empty($aAd['postal_code']) && Phpfox::getUserBy('postal_code') == '') { unset($aAds[$iKey]); } if (Phpfox::getParam('ad.advanced_ad_filters') && !empty($aAd['country_iso']) && (isset($aAd['city_location']) && !empty($aAd['city_location']) && Phpfox::getUserBy('city_location') != false && strpos($aAd['city_location'], Phpfox::getUserBy('city_location')) === false || isset($aAd['postal_code']) && !empty($aAd['postal_code']) && Phpfox::getUserBy('postal_code') != false && strpos($aAd['postal_code'], Phpfox::getUserBy('postal_code')) === false)) { unset($aAds[$iKey]); } else { if (Phpfox::getParam('ad.advanced_ad_filters') && isset($aAd['city_location']) && !empty($aAd['city_location']) && Phpfox::getUserBy('city_location') == false) { unset($aAds[$iKey]); } } if ($aAd['is_cpm'] == 1 && $aAd['total_view'] > 0 && $aAd['count_view'] >= $aAd['total_view']) { unset($aAds[$iKey]); } if ($aAd['is_cpm'] != 1 && $aAd['total_click'] > 0 && $aAd['count_click'] >= $aAd['total_click']) { unset($aAds[$iKey]); } if (!empty($aAd['country_iso']) && Phpfox::isUser() && $aAd['country_iso'] != Phpfox::getUserBy('country_iso') && Phpfox::getUserBy('country_iso') != '') { unset($aAds[$iKey]); } if (isset($aAd['countries_list']) && !empty($aAd['countries_list']) && Phpfox::isUser()) { $bKeep = false; $iCountryChildId = Phpfox::getUserBy('country_child_id'); foreach ($aAd['countries_list'] as $sCountry) { if ($sCountry == Phpfox::getUserBy('country_iso') && empty($aAd['country_child_id'])) { $bKeep = true; break; } if ($sCountry == Phpfox::getUserBy('country_iso') && (!empty($aAd['country_child_id']) && Phpfox::getParam('ad.advanced_ad_filters') && in_array($iCountryChildId, $aAd['country_child_id']))) { $bKeep = true; break; } } if ($bKeep != true) { unset($aAds[$iKey]); } } if (!empty($aAd['gender']) && Phpfox::isUser() && $aAd['gender'] != Phpfox::getUserBy('gender')) { unset($aAds[$iKey]); } if (!empty($aAd['age_from']) && !empty($aAd['age_to']) && Phpfox::isUser() && ($aAd['age_from'] > Phpfox::getUserBy('age') || $aAd['age_to'] < Phpfox::getUserBy('age'))) { unset($aAds[$iKey]); } if (!empty($aAd['user_group']) && Phpfox::getLib('parse.format')->isSerialized($aAd['user_group'])) { if (!in_array(Phpfox::getUserBy('user_group_id'), unserialize($aAd['user_group']))) { unset($aAds[$iKey]); } } if (!empty($aAd['module_access']) && $aAd['module_access'] != Phpfox::getLib('module')->getModuleName()) { unset($aAds[$iKey]); } if ($aAd['start_date'] > PHPFOX_TIME) { unset($aAds[$iKey]); } if (!empty($aAd['end_date']) && $aAd['end_date'] < PHPFOX_TIME) { unset($aAds[$iKey]); } // This requires more code so its best to be put at the end $sCityInDB = strtolower($aAd['city_location']); $sCityUser = strtolower(Phpfox::getUserBy('city_location')); if (Phpfox::getParam('ad.advanced_ad_filters') && !empty($aAd['country_iso']) && !empty($sCityInDB) && !empty($sCityUser) && strpos($sCityInDB, $sCityUser) === false) { unset($aAds[$iKey]); } if (Phpfox::getParam('ad.advanced_ad_filters') && !empty($aAd['country_iso']) && !empty($sCityInDB) && empty($sCityUser)) { unset($aAds[$iKey]); } } if (!count($aAds)) { $aCacheAd[$iId] = array(); return array(); } $iTotal = Phpfox::getParam('ad.how_many_ads_per_location') > count($aAds) ? count($aAds) : Phpfox::getParam('ad.how_many_ads_per_location'); if (Phpfox::getParam('ad.multi_ad') != true && $iTotal < count($aAds) && Phpfox::getParam('ad.how_many_ads_per_location') > 0) { shuffle($aAds); $aAds = array_slice($aAds, 0, $iTotal); } else { if (Phpfox::getParam('ad.multi_ad') && count($aAds) > Phpfox::getParam('ad.ad_multi_ad_count')) { shuffle($aAds); $aAds = array_slice($aAds, 0, Phpfox::getParam('ad.ad_multi_ad_count')); } } if ($bAll) { foreach ($aAds as $aAd) { if ($bUpdateCounter) { $this->database()->updateCounter('ad', 'count_view', 'ad_id', $aAd['ad_id']); if ($aAd['is_cpm'] == 1 && $aAd['count_view'] >= $aAd['total_view'] && $aAd['total_view'] != 0 || $aAd['is_cpm'] != 1 && $aAd['count_click'] >= $aAd['total_click'] && $aAd['total_click'] != 0) { $this->database()->update(Phpfox::getT('ad'), array('is_active' => '0'), 'ad_id = ' . (int) $aAd['ad_id']); } } } $aCacheAd[$iId] = $aAds; return $aAds; } sort($aAds); shuffle($aAds); $aAd = $aAds[mt_rand(0, count($aAds) - 1)]; if ($bUpdateCounter) { $this->database()->updateCounter('ad', 'count_view', 'ad_id', $aAd['ad_id']); } ($sPlugin = Phpfox_Plugin::get('ad.service_ad_getforblock__end')) ? eval($sPlugin) : false; return $aAd; }
public function publishContest($iContestId) { $aContest = Phpfox::getService('contest.contest')->getContestById($iContestId); if (Phpfox::getUserGroupParam($aContest['user_group_id'], 'contest.approve_contests')) { $aUpdate = array('contest_status' => Phpfox::getService('contest.constant')->getContestStatusIdByStatusName('pending'), 'is_published' => 1); $this->database()->update($this->_sTable, $aUpdate, 'contest_id = ' . $iContestId); } else { // publish a Contest here $aUpdate = array('contest_status' => Phpfox::getService('contest.constant')->getContestStatusIdByStatusName('on_going'), 'is_published' => 1); $this->database()->update($this->_sTable, $aUpdate, 'contest_id = ' . $iContestId); //we will modify here if supporting pages $aCallback = null; $aContest = Phpfox::getService('contest.contest')->getContestById($iContestId); Phpfox::isModule('feed') ? Phpfox::getService('feed.process')->allowGuest()->callback($aCallback)->add('contest', $iContestId, $aContest['privacy'], isset($aContest['privacy_comment']) ? (int) $aContest['privacy_comment'] : 0, 0, $aContest['user_id']) : null; // Update user activity Phpfox::getService('user.activity')->update($aContest['user_id'], 'contest'); } ($sPlugin = Phpfox_Plugin::get('contest.service_contest_process_publishcontest_end')) ? eval($sPlugin) : false; return true; }
public function getForEdit($aTypes, $iItemId = null, $iUserGroup = null, $bRegister = false) { $iGroup = 0; $sTable = 'user_custom_value'; if ($iUserGroup !== null && Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) { $iGroup = $iUserGroup; $sTable = Phpfox::getUserGroupParam($iUserGroup, 'custom.custom_table_name') . '_value'; } $sTypes = ''; foreach ($aTypes as $sType) { $sTypes .= '\'' . $sType . '\','; } $sTypes = rtrim($sTypes, ','); $aRows = $this->database()->select('cf.*')->from($this->_sTable, 'cf')->join(Phpfox::getT('module'), 'm', 'm.module_id = cf.module_id AND m.is_active = 1')->where('cf.type_id IN(' . $sTypes . ') AND cf.user_group_id = ' . (int) $iGroup . ($bRegister ? ' AND cf.on_signup = 1' : ''))->order('cf.ordering ASC')->execute('getSlaveRows'); $aOptions = array(); $aFields = array(); foreach ($aRows as $aRow) { $aRow['value'] = ''; $aFields[$this->_sAlias . $aRow['field_name']] = $aRow; if ($aRow['var_type'] == 'select') { $aOptions[] = $aRow['field_id']; } } if (count($aOptions)) { $aOptionsRows = $this->database()->select('*')->from(Phpfox::getT('custom_option'))->where('field_id IN(' . implode(',', $aOptions) . ')')->execute('getSlaveRows'); $aCacheOptions = array(); foreach ($aOptionsRows as $aOptionsRow) { $aCacheOptions[$aOptionsRow['field_id']][$aOptionsRow['option_id']] = Phpfox::getPhrase($aOptionsRow['phrase_var_name']); } } if ($iItemId !== null) { $aItemData = $this->database()->select('*')->from(Phpfox::getT($sTable))->where('user_id = ' . (int) $iItemId)->execute('getSlaveRows'); foreach ($aItemData as $aRow) { foreach ($aRow as $sKey => $mValue) { if ($sKey == 'user_id') { continue; } if (!isset($aFields[$sKey])) { continue; } $aFields[$sKey]['value'] = $mValue; } } } foreach ($aFields as $sFieldKey => $aField) { if ($aField['var_type'] == 'select' && isset($aCacheOptions) && isset($aCacheOptions[$aField['field_id']])) { $aFields[$sFieldKey]['options'] = $aCacheOptions[$aField['field_id']]; } } return $aFields; }
/** * Get ads based on the block positioning. * * @param int $iId Block ID#. * @return mixed NULL returned if ads cannot be viewed by the user. FALSE is returned if no ads exists. An ARRAY of ads are returned of ads exist for the specific block. */ public function getForBlock($iId) { static $aCacheAd = array(); if (isset($aCacheAd[$iId])) { return $aCacheAd[$iId]; } (($sPlugin = Phpfox_Plugin::get('ad.service_ad_getforblock__start')) ? eval($sPlugin) : false); $sCacheId = $this->cache()->set('ad_' . (int) $iId); if (Phpfox::getUserGroupParam(Phpfox::getUserBy('user_group_id'), 'ad.show_ads') == false) { $aCacheAd[$iId] = array(); return array(); } if (!($aAds = $this->cache()->get($sCacheId, Phpfox::getParam('ad.ad_cache_limit')))) { $aAds = $this->database()->select('*') ->from($this->_sTable) ->where('is_active = 1 AND location = \'' . $this->database()->escape($iId) . '\'') ->execute('getRows'); $this->cache()->save($sCacheId, $aAds); } if (!is_array($aAds) || (is_array($aAds) && !count($aAds))) { $aCacheAd[$iId] = array(); return array(); } foreach ($aAds as $iKey => $aAd) { if ($aAd['total_view'] > 0 && $aAd['count_view'] > $aAd['total_view']) { unset($aAds[$iKey]); } if (!empty($aAd['country_iso']) && Phpfox::isUser() && $aAd['country_iso'] != Phpfox::getUserBy('country_iso')) { unset($aAds[$iKey]); } if (!empty($aAd['gender']) && Phpfox::isUser() && $aAd['gender'] != Phpfox::getUserBy('gender')) { unset($aAds[$iKey]); } if (!empty($aAd['age_from']) && !empty($aAd['age_to']) && Phpfox::isUser() && ($aAd['age_from'] > Phpfox::getUserBy('age') || $aAd['age_to'] < Phpfox::getUserBy('age')) ) { unset($aAds[$iKey]); } if (!empty($aAd['user_group']) && Phpfox::getLib('parse.format')->isSerialized($aAd['user_group'])) { if (!in_array(Phpfox::getUserBy('user_group_id'), unserialize($aAd['user_group']))) { unset($aAds[$iKey]); } } if (!empty($aAd['module_access']) && $aAd['module_access'] != Phpfox::getLib('module')->getModuleName()) { unset($aAds[$iKey]); } if (!empty($aAd['total_click']) && $aAd['total_click'] < $aAd['count_click']) { unset($aAds[$iKey]); } if ($aAd['start_date'] > PHPFOX_TIME) { unset($aAds[$iKey]); } if (!empty($aAd['end_date']) && $aAd['end_date'] < PHPFOX_TIME) { unset($aAds[$iKey]); } } if (!count($aAds)) { $aCacheAd[$iId] = array(); return array(); } sort($aAds); $aAd = $aAds[mt_rand(0, (count($aAds) - 1))]; $this->database()->updateCounter('ad', 'count_view', 'ad_id', $aAd['ad_id']); (($sPlugin = Phpfox_Plugin::get('ad.service_ad_getforblock__end')) ? eval($sPlugin) : false); $aCacheAd[$iId] = $aAd; return $aAd; }
/** * Class process method which is used to execute this component. */ public function process() { $bHideOptions = true; $iDefaultSelect = 4; $bIsEdit = false; if ($iEditId = $this->request()->getInt('id')) { Phpfox::getUserParam('custom.can_manage_custom_fields', true); $aField = Phpfox::getService('profiles.custom')->getForCustomEdit($iEditId); if (isset($aField['field_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aField)); if (isset($aField['option']) && $aField['var_type'] == 'select') { $bHideOptions = false; } } } else { Phpfox::getUserParam('custom.can_add_custom_fields', true); } $aFieldValidation = array('var_type' => Phpfox::getPhrase('custom.select_what_type_of_custom_field_this_is')); $oCustomValidator = Phpfox::getLib('validator')->set(array('sFormName' => 'js_custom_field', 'aParams' => $aFieldValidation, 'bParent' => true)); $this->template()->assign(array('sCustomCreateJs' => $oCustomValidator->createJS(), 'sCustomGetJsForm' => $oCustomValidator->getJsForm())); if ($aVals = $this->request()->getArray('val')) { if ($oCustomValidator->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('profiles.custom.process')->update($aField['field_id'], $aVals)) { $this->url()->send('admincp.profiles.add', array('id' => $aField['field_id']), Phpfox::getPhrase('custom.field_successfully_updated')); } } else { if (Phpfox::getService('profiles.custom.process')->add($aVals)) { $this->url()->send('admincp.profiles.add', null, Phpfox::getPhrase('custom.field_successfully_added')); } } } if (isset($aVals['var_type']) && $aVals['var_type'] == 'select') { $bHideOptions = false; $iCnt = 0; $sOptionPostJs = ''; foreach ($aVals['option'] as $iKey => $aOptions) { if (!$iKey) { continue; } $aValues = array_values($aOptions); if (!empty($aValues[0])) { $iCnt++; } foreach ($aOptions as $sLang => $mValue) { $sOptionPostJs .= 'option_' . $iKey . '_' . $sLang . ': \'' . str_replace("'", "\\'", $mValue) . '\','; } } $sOptionPostJs = rtrim($sOptionPostJs, ','); $iDefaultSelect = $iCnt; } } /* $aTypes = array(); foreach (Phpfox::massCallback('getCustomFieldLocations') as $sModule => $aCustomFields) { foreach ($aCustomFields as $sKey => $sPhrase) { $aTypes[$sKey] = $sPhrase; } } */ $aUserGroups = Phpfox::getService('user.group')->get(); foreach ($aUserGroups as $iKey => $aUserGroup) { if (!Phpfox::getUserGroupParam($aUserGroup['user_group_id'], 'custom.has_special_custom_fields')) { unset($aUserGroup[$iKey]); } } $this->template()->setTitle("Konsort.org Extra Profiles - " . ($bIsEdit ? "Edit Field" : "Add Field"))->setBreadcrumb("Konsort.org Extra Profiles - " . ($bIsEdit ? "Edit Field" : "Add Field"))->setPhrase(array('custom.are_you_sure_you_want_to_delete_this_custom_option'))->setHeader(array('admin.js' => 'module_profiles', '<script type="text/javascript">$(function(){$Core.custom.init(' . $iDefaultSelect . '' . (isset($sOptionPostJs) ? ', {' . $sOptionPostJs . '}' : '') . ');});</script>'))->assign(array('aGroups' => Phpfox::getService('custom.group')->get(), 'bHideOptions' => $bHideOptions, 'bIsEdit' => $bIsEdit, 'aUserGroups' => $aUserGroups)); }
/** * Class process method wnich is used to execute this component. */ public function process() { // Dealing with legacy versions if ($sReg2Legacy = $this->request()->get('req2')) { switch ($sReg2Legacy) { case 'gallery': $sLegacySend = 'photo'; break; case 'blogs': $sLegacySend = 'blog'; break; case 'guestbook': $sLegacySend = '#comment'; break; case 'friends': $sLegacySend = 'friend'; break; case 'favorites': $sLegacySend = 'favorite'; break; case 'videos': $sLegacySend = 'video'; break; } if (isset($sLegacySend)) { header('HTTP/1.1 301 Moved Permanently'); $this->url()->send($this->request()->get('req1'), $sLegacySend); } } $mUser = $this->request()->get('req1'); $sSection = $this->request()->get('req2'); if (!empty($sSection)) { $sSection = $this->url()->reverseRewrite($sSection); } ($sPlugin = Phpfox_Plugin::get('profile.component_controller_index_process_after_requests')) ? eval($sPlugin) : false; $bIsSubSection = false; if (!empty($sSection) && Phpfox::isModule($sSection) && $sSection != 'designer') { $bIsSubSection = true; } if (!$mUser) { if (Phpfox::isUser()) { $this->url()->send('profile'); } else { Phpfox::isUser(true); } } // If we are unable to find a user lets make sure we return a 404 page not found error $aRow = Phpfox::getService('user')->get($mUser, false); if (!isset($aRow['user_id']) || isset($aRow['user_id']) && $aRow['profile_page_id'] > 0) { if (empty($aRow['profile_page_id']) && $this->request()->get('req2') != '' && Phpfox::isModule($this->request()->get('req2'))) { if (preg_match('/profile-(.*)/i', $this->request()->get('req1'), $aProfileMatches)) { if (isset($aProfileMatches[1]) && is_numeric($aProfileMatches[1])) { $aActualUser = Phpfox::getService('user')->getUser($aProfileMatches[1]); if (isset($aActualUser['user_id'])) { $aAllRequests = $this->request()->getRequests(); $aActualRequests = array(); foreach ($aAllRequests as $mKey => $mValue) { if ($mKey == PHPFOX_GET_METHOD || $mValue == $this->request()->get('req1')) { continue; } if (substr($mKey, 0, 3) == 'req') { $aActualRequests[] = $mValue; } else { $aActualRequests[$mKey] = $mValue; } } header('HTTP/1.1 301 Moved Permanently'); $this->url()->send($aActualUser['user_name'], $aActualRequests); } } } // $this->url()->send(Phpfox::getUserBy('user_name'), $this->request()->get('req2')); } if (Phpfox::isModule('pages') && Phpfox::getService('pages')->isPage($this->request()->get('req1'))) { return Phpfox::getLib('module')->setController('pages.view'); } return Phpfox::getLib('module')->setController('error.404'); } if (($sSection == 'info' && $this->request()->get('req3') == 'design' || $sSection == 'designer') && $aRow['user_id'] == Phpfox::getUserId() && Phpfox::getUserParam('profile.can_custom_design_own_profile')) { define('PHPFOX_IN_DESIGN_MODE', true); define('PHPFOX_CAN_MOVE_BLOCKS', true); } $oUser = Phpfox::getService('user'); if (empty($aRow['dob_setting'])) { switch (Phpfox::getParam('user.default_privacy_brithdate')) { case 'month_day': $aRow['dob_setting'] = '1'; break; case 'show_age': $aRow['dob_setting'] = '2'; break; case 'hide': $aRow['dob_setting'] = '3'; break; } } $aRow['gender_name'] = $oUser->gender($aRow['gender']); $aRow['birthday_time_stamp'] = $aRow['birthday']; $aRow['birthday'] = $oUser->age($aRow['birthday']); $aRow['location'] = Phpfox::getPhraseT(Phpfox::getService('core.country')->getCountry($aRow['country_iso']), 'country'); if (isset($aRow['country_child_id']) && $aRow['country_child_id'] > 0) { $aRow['location_child'] = Phpfox::getService('core.country')->getChild($aRow['country_child_id']); } $aRow['birthdate_display'] = Phpfox::getService('user')->getProfileBirthDate($aRow); $aRow['is_user_birthday'] = empty($aRow['birthday_time_stamp']) ? false : (int) floor(Phpfox::getLib('date')->daysToDate($aRow['birthday_time_stamp'], null, false)) === 0 ? true : false; if (empty($aRow['landing_page'])) { $aRow['landing_page'] = Phpfox::getParam('profile.profile_default_landing_page'); } $this->setParam('aUser', $aRow); define('PHPFOX_CURRENT_TIMELINE_PROFILE', $aRow['user_id']); $this->template()->setHeader('cache', array('profile.css' => 'style_css'))->assign(array('aUser' => $aRow, 'aProfileLinks' => Phpfox::getService('profile')->getProfileMenu($aRow), 'bIsBlocked' => Phpfox::isUser() ? Phpfox::getService('user.block')->isBlocked(Phpfox::getUserId(), $aRow['user_id']) : false, 'bOwnProfile' => $aRow['user_id'] == Phpfox::getUserId())); if (Phpfox::getService('user.block')->isBlocked($aRow['user_id'], Phpfox::getUserId()) && !Phpfox::getUserParam('user.can_override_user_privacy')) { return Phpfox::getLib('module')->setController('profile.private'); } Phpfox::getUserParam('profile.can_view_users_profile', true); // Set it globaly that we are viewing a users profile, sometimes variables don't help. if (!defined('PHPFOX_IS_USER_PROFILE')) { define('PHPFOX_IS_USER_PROFILE', true); } if ($aRow['designer_style_id']) { $this->template()->setHeader('<script type="text/javascript">bCanByPassClick = true; sClickProfileName = \'' . $aRow['user_name'] . '\';</script>')->setStyle(array('style_id' => $aRow['designer_style_id'], 'style_folder_name' => $aRow['designer_style_folder'], 'theme_folder_name' => $aRow['designer_theme_folder'], 'theme_parent_id' => $aRow['theme_parent_id'], 'total_column' => $aRow['total_column'], 'l_width' => $aRow['l_width'], 'c_width' => $aRow['c_width'], 'r_width' => $aRow['r_width'])); } if (!empty($aRow['css_hash'])) { define('PHPFOX_TEMPLATE_CSS_FILE', Phpfox::getService('theme')->getCss(array('table' => 'user_css', 'field' => 'user_id', 'value' => $aRow['user_id'], 'hash' => $aRow['css_hash'], 'table_code' => 'user_css_code'))); } ($sPlugin = Phpfox_Plugin::get('profile.component_controller_index_process_is_sub_section')) ? eval($sPlugin) : false; if (Phpfox::isModule('friend') && Phpfox::getParam('friend.friends_only_profile') && empty($aRow['is_friend']) && !Phpfox::getUserParam('user.can_override_user_privacy') && $aRow['user_id'] != Phpfox::getUserId()) { return Phpfox::getLib('module')->setController('profile.private'); } if ($bIsSubSection === true) { $this->template()->setUrl(Phpfox::callback($sSection . '.getProfileLink')); return Phpfox::getLib('module')->setController($sSection . '.profile'); } if (!Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'profile.view_profile')) { return Phpfox::getLib('module')->setController('profile.private'); } Phpfox::getService('profile')->setUserId($aRow['user_id']); ($sPlugin = Phpfox_Plugin::get('profile.component_controller_index_process_start')) ? eval($sPlugin) : false; if (!isset($aRow['is_viewed'])) { $aRow['is_viewed'] = 0; } if (Phpfox::getParam('profile.profile_caches') != true && (Phpfox::isUser() && Phpfox::getUserId() != $aRow['user_id'] && !$aRow['is_viewed'] && !Phpfox::getUserBy('is_invisible'))) { if (Phpfox::isModule('track')) { Phpfox::getService('track.process')->add('profile', $aRow['user_id']); } Phpfox::getService('user.field.process')->update($aRow['user_id'], 'total_view', $aRow['total_view'] + 1); } if (Phpfox::getParam('profile.profile_caches') != true && isset($aRow['is_viewed']) && Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aRow['user_id'] && $aRow['is_viewed'] && !Phpfox::getUserBy('is_invisible')) { Phpfox::getService('track.process')->update('user_track', $aRow['user_id']); } $this->setParam(array('sTrackType' => 'profile', 'iTrackId' => $aRow['user_id'], 'iTrackUserId' => $aRow['user_id'])); $this->template()->assign(array('bIsUserProfileIndexPage' => true)); Phpfox::getLib('module')->setCacheBlockData(array('table' => 'user_design_order', 'field' => 'user_id', 'item_id' => $aRow['user_id'], 'controller' => 'profile.' . ($this->request()->get('req2') == 'info' ? 'info' : 'index'))); if (Phpfox::isModule('rss') && Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'rss.can_subscribe_profile')) { $this->template()->setHeader('<link rel="alternate" type="application/rss+xml" title="' . Phpfox::getPhrase('profile.updates_from') . ': ' . Phpfox::getLib('parse.output')->clean($aRow['full_name']) . '" href="' . $this->url()->makeUrl($aRow['user_name'], array('rss')) . '" />'); $this->template()->assign('bShowRssFeedForUser', true); } ($sPlugin = Phpfox_Plugin::get('profile.component_controller_index_process_section')) ? eval($sPlugin) : false; //define('PHPFOX_CAN_MOVE_BLOCKS', true); $this->setParam(array('bIsProfileIndex' => true, 'sType' => 'profile', 'iItemId' => $aRow['user_id'], 'iTotal' => $aRow['total_comment'], 'user_id' => $aRow['user_id'], 'user_group_id' => $aRow['user_group_id'], 'edit_user_id' => $aRow['user_id'], 'item_id' => $aRow['user_id'])); if ($this->request()->get('req2') == 'info' || !Phpfox::getService('user.privacy')->hasAccess($aRow['user_id'], 'feed.view_wall') || $aRow['landing_page'] == 'info' && empty($sSection)) { if (!$this->request()->get('status-id') && !$this->request()->get('comment-id') && !$this->request()->get('link-id') && !$this->request()->get('plink-id') && !$this->request()->get('poke-id') && !$this->request()->get('feed')) { return Phpfox::getLib('module')->setController('profile.info'); } } $sPageTitle = Phpfox::getService('profile')->getProfileTitle($aRow); if (!defined('PHPFOX_IS_USER_PROFILE_INDEX')) { define('PHPFOX_IS_USER_PROFILE_INDEX', true); } if ($aRow['user_id'] == Phpfox::getUserId()) { define('PHPFOX_FEED_CAN_DELETE', true); } define('PHPFOX_CURRENT_USER_PROFILE', $aRow['user_id']); $sDescription = Phpfox::getPhrase('profile.full_name_is_on_site_title', array('full_name' => $aRow['full_name'], 'location' => $aRow['location'] . (empty($aRow['location_child']) ? '' : ', ' . $aRow['location_child']), 'site_title' => Phpfox::getParam('core.site_title'), 'meta_description_profile' => Phpfox::getParam('core.meta_description_profile'), 'total_friend' => $aRow['total_friend'])); if (($iLinkId = $this->request()->get('link-id')) && ($aLinkShare = Phpfox::getService('link')->getLinkById($iLinkId)) && isset($aLinkShare['link_id'])) { $sPageTitle = $aLinkShare['title']; $sDescription = $aLinkShare['description']; $this->template()->setMeta('og:image', $aLinkShare['image']); } $this->template()->setTitle($sPageTitle)->setMeta('description', $sDescription)->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments')))->setUrl('profile')->setHeader('cache', array('feed.js' => 'module_feed', 'comment.css' => 'style_css', 'pager.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'player/flowplayer/flowplayer.js' => 'static_script')); ($sPlugin = Phpfox_Plugin::get('profile.component_controller_index_set_header')) ? eval($sPlugin) : false; if (Phpfox::isModule('video')) { $this->template()->setHeader('cache', array('video.css' => 'module_video')); } if ($sSection == 'designer') { if ($aRow['user_id'] == Phpfox::getUserId() && Phpfox::getUserParam('profile.can_custom_design_own_profile')) { if ($iTestStyle = $this->request()->get('test_style_id')) { if (Phpfox::getLib('template')->testStyle($iTestStyle)) { } } $aDesigner = array('current_style_id' => $aRow['designer_style_id'], 'design_header' => Phpfox::getPhrase('profile.profile_designer'), 'current_page' => $this->url()->makeUrl($aRow['user_name']), 'design_page' => $this->url()->makeUrl($aRow['user_name'], 'designer'), 'block' => 'profile.index', 'item_id' => $aRow['user_id'], 'type_id' => 'profile', 'css_code' => Phpfox::getService('theme')->getCssCode(array('table_code' => 'user_css_code', 'field' => 'user_id', 'value' => $aRow['user_id']))); $this->setParam('aDesigner', $aDesigner); ($sCmd = Phpfox::getLib('template')->getXml('design_css')) ? eval($sCmd) : null; if (isset($aAdvanced)) { Phpfox::getService('theme')->getDesignValues($aAdvanced, array('table' => 'user_css', 'field' => 'user_id', 'value' => $aRow['user_id'])); } $this->template()->setPhrase(array('theme.are_you_sure'))->setImage(array('css_edit_background' => 'layout/css_edit_background.png'))->setHeader('cache', array('jquery/ui.js' => 'static_script', 'style.css' => 'style_css', 'select.js' => 'module_theme', 'design.js' => 'module_theme', 'colorpicker.js' => 'static_script', 'colorpicker.css' => 'style_css', 'colorpicker/js/colorpicker.js' => 'static_script', 'switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'designer.js' => 'module_profile'))->setHeader('cache', array('design.js' => 'style_script'))->setHeader(array(Phpfox::getLib('parse.css')->getJavaScript())); if (isset($aAdvanced)) { $this->template()->assign(array('aAdvanced' => $aAdvanced)); } if (Phpfox::getParam('profile.can_drag_drop_blocks_on_profile')) { $this->template()->setHeader('cache', array('sort.js' => 'module_theme')); } } } else { if (Phpfox::getParam('profile.can_drag_drop_blocks_on_profile') && $aRow['user_id'] == Phpfox::getUserId() && Phpfox::getUserParam('profile.can_custom_design_own_profile')) { $this->template()->setHeader(array('jquery/ui.js' => 'static_script', 'sort.js' => 'module_theme', 'design.js' => 'module_theme', '<script type="text/javascript">$Behavior.profile_controller_designonupdate_3 = function() { function designOnUpdate() { $Core.design.updateSorting(); } };</script>', '<script type="text/javascript">$Behavior.profile_controller_init_3 = function() { $Core.design.init({type_id: \'profile\'}); };</script>')); } } if ($sSection != 'designer' && $sSection != 'design' && Phpfox::isModule('music') && (Phpfox::getUserGroupParam($aRow['user_group_id'], 'music.can_upload_music_public') || $aRow['total_profile_song'])) { $this->template()->setHeader(array('player/' . Phpfox::getParam('core.default_music_player') . '/core.js' => 'static_script', '<script type="text/javascript">$Behavior.profile_index_load_player = function() { $Core.player.load({id: \'js_music_player\', type: \'music\'}); $Core.player.load({id: \'js_music_favorite_player\', type: \'music\'}); };</script>')); } if (Phpfox::getParam('video.convert_servers_enable')) { $this->template()->setHeader('<script type="text/javascript">document.domain = "' . Phpfox::getParam('video.convert_js_parent') . '";</script>'); } }
public function getForEdit($aTypes, $iItemId = null, $iUserGroup = null, $bRegister = false, $iUserId = null) { $iGroup = 0; $sTable = 'user_custom_multiple_value'; if ($iUserGroup !== null && Phpfox::getUserGroupParam($iUserGroup, 'custom.has_special_custom_fields')) { $iGroup = $iUserGroup; $sTable = Phpfox::getUserGroupParam($iUserGroup, 'custom.custom_table_name') . '_value'; } $sTypes = ''; foreach ($aTypes as $sType) { $sTypes .= '\'' . $sType . '\','; } $sTypes = rtrim($sTypes, ','); $aRows = $this->database()->select('cf.*, cmv.option_id as customValue') ->from($this->_sTable, 'cf') ->join(Phpfox::getT('module'), 'm', 'm.module_id = cf.module_id AND m.is_active = 1') ->leftjoin(Phpfox::getT('user_custom_multiple_value'), 'cmv', 'cmv.field_id = cf.field_id' . ($iUserId !== null ? ' AND cmv.user_id = ' . (int)$iUserId : '')) ->where('cf.type_id IN(' . $sTypes . ') AND cf.user_group_id = ' . (int) $iGroup . ($bRegister ? ' AND cf.on_signup = 1' : '') . ' AND cf.is_active = 1') ->order('cf.ordering ASC') ->execute('getSlaveRows'); // we already have the values from the multiple selection table now we need to // glue them into the same field_id $aTemp = array(); $aTexts = array(); $aOptions = array(); $aFields = array(); if ($iUserId !== null) { $aTexts = $this->database()->select('*') ->from(Phpfox::getT('user_custom')) ->where('user_id = ' . (int)$iUserId) ->execute('getSlaveRow'); } else if ($iItemId !== null) { $aTexts = $this->database()->select('*') ->from(Phpfox::getT('user_custom_value')) ->where('user_id = ' . (int)$iItemId) ->execute('getSlaveRow'); } foreach ($aRows as $iKey => $aRow) { if (!isset($aTemp[$aRow['field_id']])) { $aTemp[$aRow['field_id']] = $aRow; } // merge duplicated fields (they have different customValue if ( ($aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'checkbox') && !is_array($aTemp[$aRow['field_id']]['customValue']) ) { $aTemp[$aRow['field_id']]['customValue'] = array($aRow['customValue']); } elseif ($aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'checkbox') { $aTemp[$aRow['field_id']]['customValue'][] = $aRow['customValue']; } // if this is a textarea and we have the value then assign it else if ($aRow['type_name'] == 'MEDIUMTEXT' && isset($aTexts['cf_' . $aRow['field_name']])) { $aRow['value'] = $aTexts['cf_' . $aRow['field_name']]; $aTemp[$aRow['field_id']] = $aRow; } if ($aRow['type_name'] != 'MEDIUMTEXT') { $aRow['value'] = $aRow['customValue']; } $aFields[$this->_sAlias . $aRow['field_name']] = $aTemp[$aRow['field_id']]; if ( $aRow['var_type'] == 'select' || $aRow['var_type'] == 'multiselect' || $aRow['var_type'] == 'radio' || $aRow['var_type'] == 'checkbox') { $aOptions[$aRow['field_id']] = $aRow['field_id']; } } $aRows = $aTemp; // Match the text areas if we are searching for a specific user if (count($aOptions)) { $aOptionsRows = $this->database()->select('*') ->from(Phpfox::getT('custom_option')) ->where('field_id IN(' . implode(',', array_values($aOptions)) . ')') ->execute('getSlaveRows'); $aCacheOptions = array(); foreach ($aOptionsRows as $aOptionsRow) { $aCacheOptions[$aOptionsRow['field_id']][$aOptionsRow['option_id']] = Phpfox::getPhrase($aOptionsRow['phrase_var_name']); } } foreach ($aFields as $sFieldKey => $aField) { if (!isset($aField['value'])) { $aField['value'] = ''; } if ($aField['var_type'] == 'textarea') { continue; } foreach ($aCacheOptions as $iFieldId => $aValues) { if ($iFieldId == $aField['field_id']) { if (!isset($aFields[$sFieldKey]['options'])) { $aFields[$sFieldKey]['options'] = array(); } foreach ($aValues as $iOptionId => $sPhrase) { $aTemp = array('value' => $sPhrase) ; // check if this is a selected option if (is_array($aField['customValue'])) { foreach ($aField['customValue'] as $iOptionIdVal) { if ($iOptionIdVal == $iOptionId) { $aTemp['selected'] = true; } } } else if (!empty($aField['customValue']) && $iOptionId == $aField['customValue']) { $aTemp['selected'] = true; } $aFields[$sFieldKey]['options'][$iOptionId] = $aTemp; } } } } return $aFields; }