/** * Adds a new job to send the newsletter, first there is no cron jobs/tabs so this function's return * directs the flow of the script (refresh) to process the batches. * Sets the errors using Phpfox_Error::set * @param <type> $aVals * @return Int Next round to process | false on error. */ public function add($aVals, $iUser) { // Check validations using the new method $aForm = array('subject' => array('message' => Phpfox::getPhrase('newsletter.add_a_subject'), 'type' => 'string:required'), 'total' => array('message' => Phpfox::getPhrase('newsletter.how_many_users_to_contact_per_round'), 'type' => 'int:required'), 'text' => array('message' => Phpfox::getPhrase('newsletter.you_need_to_write_a_message_to_send'), 'type' => 'string:required')); $aVals['type_id'] = 2; // Internal newsletters are deprecated since 3.3.0 beta 1 $this->validator()->process($aForm, $aVals); if (!Phpfox_Error::isPassed()) { return false; } // Phpfox::getService('ban')->checkAutomaticBan($aVals['subject'] . ' ' . $aVals['text'] . ' ' . $aVals['txtPlain']); $iActive = $this->database()->select('COUNT(newsletter_id)')->from($this->_sTable)->where('state = 1')->execute('getSlaveField'); // insert the values in the database $aInsert = array('subject' => $this->preParse()->clean($aVals['subject']), 'round' => 0, 'state' => $iActive > 0 ? 0 : 1, 'age_from' => (int) $aVals['age_from'], 'age_to' => (int) $aVals['age_to'], 'type_id' => (int) $aVals['type_id'], 'country_iso' => $this->preParse()->clean($aVals['country_iso']), 'gender' => (int) $aVals['gender'], 'user_group_id' => '', 'total' => (int) $aVals['total'], 'user_id' => (int) $iUser, 'time_stamp' => Phpfox::getTime(), 'archive' => isset($aVals['archive']) ? (int) $aVals['archive'] : 2, 'privacy' => isset($aVals['privacy']) ? (int) $aVals['privacy'] : 2); if (isset($aVals['is_user_group']) && $aVals['is_user_group'] == 2) { $aGroups = array(); $aUserGroups = Phpfox::getService('user.group')->get(); if (isset($aVals['user_group'])) { foreach ($aUserGroups as $aUserGroup) { if (in_array($aUserGroup['user_group_id'], $aVals['user_group'])) { $aGroups[] = $aUserGroup['user_group_id']; } } } $aInsert['user_group_id'] = count($aGroups) ? serialize($aGroups) : null; } // ** when we implement the cron job this is the place to set the state differently $iId = $this->database()->insert($this->_sTable, $aInsert); $this->database()->insert(Phpfox::getT('newsletter_text'), array('newsletter_id' => $iId, 'text_plain' => $this->preParse()->clean($aVals['txtPlain']), 'text_html' => $aVals['text'])); // store that we are processing a job $aInsert['newsletter_id'] = $iId; $aInsert['round'] = 0; return $aInsert; }
/** * Controller */ public function process() { if (!$this->getParam('bIsValidImage')) { return false; } $aUser = $this->getParam('aUser'); $aPhoto = $this->getParam('aPhoto'); $bIsInPhoto = $this->getParam('is_in_photo'); if ($aPhoto === null) { return false; } $sCategories = ''; if (isset($aPhoto['categories']) && is_array($aPhoto['categories'])) { foreach ($aPhoto['categories'] as $aCategory) { $sCategories .= $aCategory[0] . ','; } $sCategories = rtrim($sCategories, ','); } $aInfo = array(Phpfox::getPhrase('photo.added') => '<span itemprop="dateCreated">' . Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aPhoto['time_stamp']) . '</span>', Phpfox::getPhrase('photo.category') => $sCategories, Phpfox::getPhrase('photo.file_size') => Phpfox_File::instance()->filesize($aPhoto['file_size']), Phpfox::getPhrase('photo.resolution') => $aPhoto['width'] . '×' . $aPhoto['height'], Phpfox::getPhrase('photo.comments') => $aPhoto['total_comment'], Phpfox::getPhrase('photo.views') => '<span itemprop="interactionCount">' . $aPhoto['total_view'] . '</span>', Phpfox::getPhrase('photo.rating') => round($aPhoto['total_rating']), Phpfox::getPhrase('photo.battle_wins') => round($aPhoto['total_battle']), Phpfox::getPhrase('photo.downloads') => $aPhoto['total_download']); if ($bIsInPhoto) { unset($aInfo[Phpfox::getPhrase('photo.added')]); } foreach ($aInfo as $sKey => $mValue) { if (empty($mValue)) { unset($aInfo[$sKey]); } } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('photo.image_details'), 'aPhotoDetails' => $aInfo, 'bIsInPhoto' => $bIsInPhoto, 'sUrlPath' => preg_match("/\\{file\\/pic\\/(.*)\\/(.*)\\.jpg\\}/i", $aPhoto['destination'], $aMatches) ? Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]) : ($aPhoto['server_id'] && Phpfox::getParam('core.allow_cdn') ? Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500'), $aPhoto['server_id']) : Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500')))); // return 'block'; }
public function process() { (($sPlugin = Phpfox_Plugin::get('announcement.component_block_index__start')) ? eval($sPlugin) : false); $aAnnouncement = Phpfox::getService('announcement')->getLatest(null, true, Phpfox::getTime()); if ($aAnnouncement === false) { return false; } $aAnnouncement = reset($aAnnouncement); if (isset($aAnnouncement['is_seen']) && $aAnnouncement['is_seen'] == true) return false; if (Phpfox::getLib('phpfox.locale')->isPhrase($aAnnouncement['intro_var'])) { $aAnnouncement['intro_var'] = Phpfox::getPhrase($aAnnouncement['intro_var']); } else { $aAnnouncement['intro_var'] = ''; } $this->template()->assign(array( 'aAnnouncement' => $aAnnouncement ) ); (($sPlugin = Phpfox_Plugin::get('announcement.component_block_index__end')) ? eval($sPlugin) : false); }
/** * Class process method wnich is used to execute this component. */ public function process() { // If the user is not a member don't display this block if (!Phpfox::isUser()) { return false; } $sUserProfileImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true)), array( 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50_square', 'max_width' => 50, 'max_height' => 50 ) ) ); // Assign template vars $this->template()->assign(array( 'sUserProfileImage' => $sUserProfileImage, 'sUserProfileUrl' => $this->url()->makeUrl('profile', Phpfox::getUserBy('user_name')), // Create the users profile URL 'sCurrentUserName' => Phpfox::getLib('parse.output')->shorten(Phpfox::getLib('parse.output')->clean(Phpfox::getUserBy('full_name')), 50, '...'), // Get the users display name 'sCurrentTimeStamp' => Phpfox::getTime(Phpfox::getParam('core.global_welcome_time_stamp'), PHPFOX_TIME), // Get the current time stamp 'iTotalActivityPoints' => (int) Phpfox::getUserBy('activity_points'), 'iTotalProfileViews' => (int) Phpfox::getUserBy('total_view') ) ); }
/** * Class process method wnich is used to execute this component. */ public function process() { $aUser = PHPFOX_IS_AJAX ? Phpfox::getService('user')->get($this->request()->getInt('profile_user_id'), true) : $this->getParam('aUser'); $aBirthDay = Phpfox::getService('user')->getAgeArray(PHPFOX_IS_AJAX ? $aUser['birthday'] : $aUser['birthday_time_stamp']); if (empty($aUser['birthday'])) { return false; } $this->template()->assign(array('aUser' => $aUser, 'sBirthDisplay' => Phpfox::getTime(Phpfox::getParam('user.user_dob_month_day'), mktime(0, 0, 0, $aBirthDay['month'], $aBirthDay['day'], $aBirthDay['year']), false))); }
public function getNew() { ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getnew__start')) ? eval($sPlugin) : false; return $this->database()->select('b.blog_id, b.time_stamp, b.title, bt.text_parsed, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('blog_text'), 'bt', 'bt.blog_id = b.blog_id')->where('b.is_approved = 1 AND b.privacy = 0 AND b.post_status = 1')->limit((int) Phpfox::getParam('stnewblogs.how_many_nblogs'))->order('b.time_stamp DESC')->execute('getSlaveRows'); foreach ($aRows as $iKey => $aRow) { $aRows[$iKey]['posted_on'] = Phpfox::getPhrase('blog.posted_on_post_time_by_user_link', array('post_time' => Phpfox::getTime(Phpfox::getParam('blog.blog_time_stamp'), $aRow['time_stamp']), 'user' => $aRow)); } ($sPlugin = Phpfox_Plugin::get('blog.component_service_blog_getnew__end')) ? eval($sPlugin) : false; return $aRows; }
/** * Class process method wnich is used to execute this component. */ public function process() { $aVideo = $this->getParam('aVideo'); $sGroup = $this->getParam('sGroup', ''); $aItems = array(Phpfox::getPhrase('video.added') => Phpfox::getTime(Phpfox::getParam('video.video_time_stamp'), $aVideo['time_stamp'])); if (Phpfox::isModule('comment')) { $aItems[Phpfox::getPhrase('video.comments')] = $aVideo['total_comment']; } $this->template()->assign(array('aVideoDetails' => $aItems, 'sGroup' => $sGroup)); }
/** * Creates a record of the purchase into phpfox_ad_sponsor and returns the ID * to be used as an invoice with the payment gateway. * * @example if admin is adding, aVals looks like: array('module' => 'music', 'section' => 'album', 'item_id' => $this->get('album_id')) * @param array $aVals * @return int */ public function addSponsor($aVals) { // check required fields $aForms = array('name' => array('message' => Phpfox::getPhrase('ad.provide_a_campaign_name'), 'type' => array('string:required')), 'total_view' => array('message' => Phpfox::getPhrase('ad.impressions_cant_be_less_than_a_thousand'), 'type' => 'int:required')); $sParam = $aVals['module'] . '.can_sponsor_'; $sParam .= isset($aVals['section']) && !empty($aVals['section']) ? $aVals['section'] : $aVals['module']; if (Phpfox::getUserParam($sParam)) { $iCpm = $aVals['total_view'] = $aVals['age_to'] = $aVals['age_from'] = $aVals['gender'] = 0; $aVals['is_active'] = 1; // $aVals['is_custom'] = 3; $iIsCustom = 3; $aVals['country_iso_custom'] = ''; $aVals['name'] = '{phrase var=\'ad.default_campaign_name\'}'; $aVals['cpm'] = 0; } else { // done here for extra safety $aPrices = unserialize(Phpfox::getUserParam($aVals['module'] . '.' . $aVals['module'] . (isset($aVals['section']) ? '_' . $aVals['section'] : '') . '_sponsor_price')); if (!isset($aPrices[Phpfox::getService('core.currency')->getDefault()])) { return Phpfox_Error::display('The default currency has no price'); } $iCpm = $aPrices[Phpfox::getService('core.currency')->getDefault()]; } $this->validator()->process($aForms, $aVals); if (!Phpfox_Error::isPassed()) { return false; } $iAutoPublish = 0; if (isset($aVals['section']) && !empty($aVals['section'])) { $iAutoPublish = Phpfox::getUserParam($aVals['module'] . '.auto_publish_sponsored_' . $aVals['section']); } else { $iAutoPublish = Phpfox::getUserParam($aVals['module'] . '.auto_publish_sponsored_item'); } if (empty($iAutoPublish)) { $iAutoPublish = '0'; } // if its an admin sponsoring something we dont need all the checks: $aInsertSponsor = array('module_id' => $aVals['module'] . (isset($aVals['section']) && !empty($aVals['section']) ? '-' . $aVals['section'] : ''), 'item_id' => $aVals['item_id'], 'user_id' => Phpfox::getUserId(), 'country_iso' => $aVals['country_iso_custom'], 'gender' => empty($aVals['gender']) ? 0 : (int) $aVals['gender'], 'age_from' => empty($aVals['age_from']) ? 0 : (int) $aVals['age_from'], 'age_to' => empty($aVals['age_from']) ? 0 : (int) $aVals['age_to'], 'campaign_name' => $aVals['name'], 'impressions' => $aVals['total_view'], 'cpm' => $iCpm, 'start_date' => Phpfox::getUserParam($sParam) ? PHPFOX_TIME : Phpfox::getLib('date')->mktime($aVals['start_hour'], $aVals['start_minute'], 0, $aVals['start_month'], $aVals['start_day'], $aVals['start_year']), 'auto_publish' => $iAutoPublish, 'is_custom' => isset($iIsCustom) ? $iIsCustom : '1'); if (isset($aVals['is_active'])) { $aInsertSponsor['is_active'] = $aVals['is_active']; } $iInsert = $this->database()->insert(Phpfox::getT('ad_sponsor'), $aInsertSponsor); if (Phpfox::getUserParam($sParam)) { return $iInsert; } /** * @param `phpfox_ad_invoice`.`status`: * 1 => Submitted but not paid or approved. * 2 => Paid but not approved, * 3 => Approved and should be displayed */ $aInsertInvoice = array('ad_id' => $iInsert, 'price' => round($iCpm * $aVals['total_view'] / 1000 * 100) / 100, 'currency_id' => Phpfox::getService('core.currency')->getDefault(), 'status' => null, 'user_id' => Phpfox::getUserId(), 'is_sponsor' => 1, 'time_stamp' => Phpfox::getTime()); $iInsertInvoice = $this->database()->insert(Phpfox::getT('ad_invoice'), $aInsertInvoice); return $iInsertInvoice; }
/** * Class process method wnich is used to execute this component. */ public function process() { $sCurrentTimeZone = Phpfox::getTimeZone() == '0' ? '' : ' ' . (substr(Phpfox::getTimeZone(), 0, 1) == '-' ? Phpfox::getTimeZone() : '+' . Phpfox::getTimeZone()); if (substr(Phpfox::getTimeZone(), 0, 1) == 'z' && PHPFOX_USE_DATE_TIME) { $aTimeZones = Phpfox::getService('core')->getTimeZones(); if (isset($aTimeZones[Phpfox::getTimeZone()])) { $oDTZ = new DateTime('now', new DateTimeZone($aTimeZones[Phpfox::getTimeZone()])); $sCurrentTimeZone = $oDTZ->getOffset() / 3600; } } $this->template()->assign(array('sCurrentSiteTime' => Phpfox::getTime(Phpfox::getParam('forum.global_forum_timezone'), PHPFOX_TIME), 'sCurrentTimeZone' => $sCurrentTimeZone)); }
public function getTimeLineYears($iUserId, $iLastTimeStamp) { static $aCachedYears = array(); if (isset($aCachedYears[$iUserId])) { return $aCachedYears[$iUserId]; } $aNewYears = array(); $sCacheId = $this->cache()->set(array('timeline', $iUserId)); if (!($aNewYears = $this->cache()->get($sCacheId))) { $aYears = range(date('Y', PHPFOX_TIME), date('Y', $iLastTimeStamp)); foreach ($aYears as $iYear) { $iStartYear = mktime(0, 0, 0, 1, 1, $iYear); $iEndYear = mktime(0, 0, 0, 12, 31, $iYear); $iCnt = $this->database()->select('COUNT(*)')->from(Phpfox::getT('feed'))->forceIndex('time_stamp')->where('user_id = ' . (int) $iUserId . ' AND feed_reference = 0 AND time_stamp > \'' . $iStartYear . '\' AND time_stamp <= \'' . $iEndYear . '\'')->execute('getSlaveField'); if ($iCnt) { $aNewYears[] = $iYear; } } $this->cache()->save($sCacheId, $aNewYears); } if (!is_array($aNewYears)) { $aNewYears = array(); } $iBirthYear = date('Y', $iLastTimeStamp); $sDobCacheId = $this->cache()->set(array('udob', $iUserId)); if (!($iDOB = $this->cache()->get($sDobCacheId))) { $iDOB = $this->database()->select('dob_setting')->from(Phpfox::getT('user_field'))->where('user_id = ' . (int) $iUserId)->execute('getSlaveField'); $this->cache()->save($sDobCacheId, $iDOB); } if ($iDOB == 0) { $sPermission = Phpfox::getParam('user.default_privacy_brithdate'); $bShowBirthYear = $sPermission == 'full_birthday' || $sPermission == 'show_age'; } if (!in_array($iBirthYear, $aNewYears) && ($iDOB == 2 || $iDOB == 4 || $iDOB == 0 && isset($bShowBirthYear) && $bShowBirthYear)) { $aNewYears[] = $iBirthYear; } $aYears = array(); foreach ($aNewYears as $iYear) { $aMonths = array(); foreach (range(1, 12) as $iMonth) { if ($iYear == date('Y', PHPFOX_TIME) && $iMonth > date('n', PHPFOX_TIME)) { } elseif ($iYear == date('Y', $iLastTimeStamp) && $iMonth > date('n', $iLastTimeStamp)) { } else { $aMonths[] = array('id' => $iMonth, 'phrase' => Phpfox::getTime('F', mktime(0, 0, 0, $iMonth, 1, $iYear), false)); } } $aMonths = array_reverse($aMonths); $aYears[] = array('year' => $iYear, 'months' => $aMonths); } $aCachedYears[$iUserId] = $aYears; return $aYears; }
/** * get database in block * @return array */ public function get() { $sType = Phpfox::getParam('themesupporter.block_event_type'); $sCacheId = $this->cache()->set('brodev_themesupporter_event_' . $sType); if (!($aRecords = $this->cache()->get($sCacheId, 300))) { $iTimeDisplay = Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y')); $sWhere = 'e.view_id = 0 AND e.privacy = 0 AND e.item_id = 0 '; switch ($sType) { case 'Today': $sWhere .= " AND e.start_time > " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y')) . " AND e.start_time < " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d') + 1, Phpfox::getTime('Y')); $this->database()->order('e.time_stamp'); break; case 'Week': $iFirstDay = @date("w", @mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y'))); $iLastDay = 7 - $iFirstDay; $sWhere .= " AND e.start_time > " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d') - $iFirstDay, Phpfox::getTime('Y')) . " AND e.start_time < " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d') + $iLastDay, Phpfox::getTime('Y')); $this->database()->order('e.time_stamp'); break; case 'Month': $sWhere .= " AND e.start_time > " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), 1, Phpfox::getTime('Y')) . " AND e.start_time < " . Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m') + 1, 1, Phpfox::getTime('Y')); $this->database()->order('e.time_stamp'); break; case 'All': $this->database()->order('e.time_stamp'); $sWhere .= " AND e.start_time >= " . $iTimeDisplay; break; case 'Most': $sWhere .= " AND e.start_time >= " . $iTimeDisplay; $aMostEventId = $this->database()->select('event_id')->from(Phpfox::getT('event_invite'))->group('event_id')->order('count(event_id) desc')->limit(Phpfox::getParam('themesupporter.block_event_number'))->execute('getRows'); $aEventIds[] = 0; foreach ($aMostEventId as $aMostEvent) { $aEventIds[] = $aMostEvent['event_id']; } $sWhere .= " AND e.event_id IN (" . implode(", ", $aEventIds) . ")"; } $iLimit = Phpfox::getParam('themesupporter.block_event_number'); $aRecords = $this->database()->select('e.*, u.user_name as user_name, u.full_name as full_name, u.user_image as user_image, et.description_parsed as description')->from($this->_sTable, 'e')->leftJoin(Phpfox::getT('user'), 'u', 'e.user_id = u.user_id')->leftJoin(Phpfox::getT('event_text'), 'et', 'e.event_id = et.event_id')->where($sWhere)->limit($iLimit)->execute('getRows'); if (empty($aRecords)) { return false; } foreach ($aRecords as $iKey => $aVal) { $aRecords[$iKey]['attending'] = $this->countInvite($aVal['event_id']); $aRecords[$iKey]['url'] = Phpfox::getLib('url')->permalink('event', $aVal['event_id'], $aVal['title']); $aRecords[$iKey]['start_time_phrase'] = Phpfox::getTime(Phpfox::getParam('event.event_browse_time_stamp'), $aVal['start_time']); $aRecords[$iKey]['start_time_phrase_stamp'] = Phpfox::getTime('g:sa', $aVal['start_time']); $aRecords[$iKey]['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'event', 'privacy' => $aVal['privacy'], 'comment_privacy' => $aVal['privacy_comment'], 'like_type_id' => 'event', 'feed_is_liked' => isset($aVal['is_liked']) ? $aVal['is_liked'] : false, 'feed_is_friend' => isset($aVal['is_friend']) ? $aVal['is_friend'] : false, 'item_id' => $aVal['event_id'], 'user_id' => $aVal['user_id'], 'total_comment' => $aVal['total_comment'], 'feed_total_like' => $aVal['total_like'], 'total_like' => $aVal['total_like'], 'feed_link' => Phpfox::getLib('url')->permalink('event', $aVal['event_id'], $aVal['title']), 'feed_title' => $aVal['title']); } $this->cache()->save($sCacheId, $aRecords); } return $aRecords; }
public function execute() { $this->_iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'p')->leftjoin(Phpfox::getT('ko_profiles_field_values'), 'pfv', 'pfv.extra_id = p.extra_id')->where($this->_aConditions)->execute('getSlaveField'); if ($this->_iCnt) { $aListings = $this->database()->select('p.*, pfv.*,p.extra_id AS extra_id, ' . Phpfox::getUserField('u', 'extra_'))->from($this->_sTable, 'p')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->leftJoin(Phpfox::getT('ko_profiles_field_values'), 'pfv', 'pfv.extra_id = p.extra_id')->where($this->_aConditions)->order($this->_sOrder)->limit($this->_iPage, $this->_iPageSize, $this->_iCnt)->execute('getSlaveRows'); //echo '<pre>'; print_r($aListings); echo '</pre>'; exit; foreach ($aListings as $aListing) { $aListing['user_name_link'] = '<a href="' . Phpfox::getLib('url')->makeUrl($aListing['extra_user_name']) . '">' . Phpfox::getLib('parse.output')->clean($aListing['extra_full_name']) . '</a>'; $aListing['time_stamp_phrase'] = Phpfox::getTime(Phpfox::getParam('profiles.profiles_browse_time_stamp'), $aListing['time_stamp']); $aListing['url'] = Phpfox::getLib('url')->makeUrl('profiles', $aListing['title_url']); $this->_aListings[] = $aListing; } } }
/** * Class process method wnich is used to execute this component. */ public function process() { if ($this->template()->getThemeFolder() == 'nebula' || $this->template()->getParentThemeFolder() == 'nebula') { return false; } // If the user is not a member don't display this block if (!Phpfox::isUser()) { return false; } $sUserProfileImage = Phpfox::getLib('image.helper')->display(array_merge(array('user' => Phpfox::getService('user')->getUserFields(true)), array('path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50_square', 'max_width' => 50, 'max_height' => 50))); $aGroup = Phpfox::getService('user.group')->getGroup(Phpfox::getUserBy('user_group_id')); // Assign template vars $this->template()->assign(array('sUserProfileImage' => $sUserProfileImage, 'sUserProfileUrl' => $this->url()->makeUrl('profile', Phpfox::getUserBy('user_name')), 'sCurrentUserName' => Phpfox::getLib('parse.output')->shorten(Phpfox::getLib('parse.output')->clean(Phpfox::getUserBy('full_name')), Phpfox::getParam('user.max_length_for_username'), '...'), 'sCurrentTimeStamp' => Phpfox::getTime(Phpfox::getParam('core.global_welcome_time_stamp'), PHPFOX_TIME), 'iTotalActivityPoints' => (int) Phpfox::getUserBy('activity_points'), 'iTotalProfileViews' => (int) Phpfox::getUserBy('total_view'), 'sUserGroupFullName' => Phpfox::getLib('locale')->convert($aGroup['title']))); }
public function getPost($iId) { ($sPlugin = Phpfox_Plugin::get('forum.service_post_getpost')) ? eval($sPlugin) : false; if (Phpfox::isModule('like')) { $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'forum_post\' AND l.item_id = fp.post_id AND l.user_id = ' . Phpfox::getUserId()); } $aPost = $this->database()->select('fp.*, ' . (Phpfox::getParam('core.allow_html') ? 'fpt.text_parsed' : 'fpt.text') . ' AS text, ' . Phpfox::getUserField() . ', u.joined, u.country_iso, uf.signature, uf.total_post, ft.forum_id, ft.group_id, ft.user_id AS thread_user_id, ft.title AS thread_title')->from(Phpfox::getT('forum_post'), 'fp')->join(Phpfox::getT('forum_thread'), 'ft', 'ft.thread_id = fp.thread_id')->join(Phpfox::getT('forum_post_text'), 'fpt', 'fpt.post_id = fp.post_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = fp.user_id')->join(Phpfox::getT('user_field'), 'uf', 'uf.user_id = fp.user_id')->where('fp.post_id = ' . $iId)->execute('getRow'); $aPost['aFeed'] = array('privacy' => 0, 'comment_privacy' => 0, 'like_type_id' => 'forum_post', 'feed_is_liked' => $aPost['is_liked'] ? true : false, 'item_id' => $aPost['post_id'], 'user_id' => $aPost['user_id'], 'total_like' => $aPost['total_like'], 'feed_link' => Phpfox::permalink('forum.thread', $aPost['thread_id'], $aPost['thread_title']) . 'view_' . $aPost['post_id'] . '/', 'feed_title' => $aPost['thread_title'], 'feed_display' => 'mini', 'feed_total_like' => $aPost['total_like'], 'report_module' => 'forum_post', 'report_phrase' => Phpfox::getPhrase('forum.report_this_post'), 'time_stamp' => $aPost['time_stamp']); if ($aPost['total_attachment']) { list($iAttachmentCnt, $aPost['attachments']) = Phpfox::getService('attachment')->get('attachment.item_id = ' . $aPost['post_id'] . ' AND attachment.view_id = 0 AND attachment.category_id = \'forum\' AND attachment.is_inline = 0', 'attachment.attachment_id DESC', '', '', false); } $aPost['last_update_on'] = Phpfox::getPhrase('forum.last_update_on_time_stamp_by_update_user', array('time_stamp' => Phpfox::getTime(Phpfox::getParam('forum.forum_time_stamp'), $aPost['update_time']), 'update_user' => $aPost['update_user'])); return $aPost; }
private function _build($aPhoto) { $sJs = ''; foreach ($aPhoto as $sKey => $sValue) { if ($sKey == 'destination') { $sValue = Phpfox::getLib('image.helper')->display(array('server_id' => $aPhoto['server_id'], 'path' => 'photo.url_photo', 'file' => $aPhoto['destination'], 'suffix' => '_500', 'max_width' => 400, 'max_height' => 400)); } elseif ($sKey == 'full_name') { $sValue = '<a href="' . Phpfox::getLib('url')->makeUrl($aPhoto['user_name']) . '">' . $aPhoto['full_name'] . '</a>'; } elseif ($sKey == 'time_stamp') { $sValue = Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aPhoto['time_stamp']); } $sJs .= $sKey . ': \'' . str_replace("'", "\\'", $sValue) . '\','; } $sJs = rtrim($sJs, ','); return $sJs; }
/** * Class process method wnich is used to execute this component. */ public function process() { if (!Phpfox::isUser()) { return false; } if ($this->template()->bIsSample === true) { return false; } if (Phpfox::isUser() && Phpfox::isModule('subscribe') && Phpfox::getParam('subscribe.subscribe_is_required_on_sign_up') && Phpfox::getUserBy('user_group_id') == '2' && (int) Phpfox::getUserBy('subscribe_id') > 0) { return false; } if (defined('PHPFOX_IN_DESIGN_MODE')) { return false; } $sImage = Phpfox::getLib('image.helper')->display(array('server_id' => Phpfox::getUserBy('server_id'), 'title' => Phpfox::getUserBy('full_name'), 'path' => 'core.url_user', 'file' => Phpfox::getUserBy('user_image'), 'suffix' => '_50', 'max_width' => 50, 'max_height' => 50, 'no_default' => true, 'style' => 'vertical-align:middle; padding-right:5px;', 'user' => array('gender' => Phpfox::getUserBy('gender'), 'user_image' => Phpfox::getUserBy('user_image'), 'full_name' => Phpfox::getUserBy('full_name'), 'user_name' => Phpfox::getUserBy('user_name')))); $this->template()->assign(array('sGlobalUserImage' => $sImage, 'sGlobalUserFullname' => Phpfox::getUserBy('full_name'), 'sGlobalUserStatus' => Phpfox::getUserBy('status'), 'iGlobalUserId' => Phpfox::getUserId(), 'sGlobalTimeStamp' => Phpfox::getTime(Phpfox::getParam('core.footer_bar_tool_tip_time_stamp'), PHPFOX_TIME), 'sGlobalTimeStampMini' => Phpfox::getTime(Phpfox::getParam('core.footer_watch_time_stamp'), PHPFOX_TIME), 'aDashboards' => Phpfox::isModule('core') ? Phpfox::getService('core')->getDashboardLinks() : array())); }
/** * Controller */ public function process() { if (!Phpfox::isModule('ad')) { return false; } if (defined('PHPFOX_IS_GROUP_VIEW') || defined('PHPFOX_IS_PAGES_VIEW') || defined('PHPFOX_IS_USER_PROFILE')) { return false; } $aSponsorPhoto = Phpfox::getService('photo')->getRandomSponsored(); if (empty($aSponsorPhoto)) { return false; } Phpfox::getService('ad.process')->addSponsorViewsCount($aSponsorPhoto['sponsor_id'], 'photo'); $aSponsorPhoto['details'] = array(Phpfox::getPhrase('photo.submitted') => Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aSponsorPhoto['time_stamp']), Phpfox::getPhrase('photo.file_size') => Phpfox_File::instance()->filesize($aSponsorPhoto['file_size']), Phpfox::getPhrase('photo.resolution') => $aSponsorPhoto['width'] . '×' . $aSponsorPhoto['height'], Phpfox::getPhrase('photo.views') => $aSponsorPhoto['total_view']); $this->template()->assign(array('aSponsorPhoto' => $aSponsorPhoto, 'sHeader' => Phpfox::getPhrase('photo.sponsored_photo'), 'aFooter' => array(Phpfox::getPhrase('photo.encourage_sponsor') => $this->url()->makeUrl('profile.photo', array('sponsor' => '1'))))); return 'block'; }
/** * Class process method wnich is used to execute this component. */ public function process() { if (!$this->getParam('bIsValidImage')) { return false; } $aUser = $this->getParam('aUser'); $aPhoto = $this->getParam('aPhoto'); if ($aPhoto === null) { return false; } $sCategories = ''; if (isset($aPhoto['categories']) && is_array($aPhoto['categories'])) { foreach ($aPhoto['categories'] as $aCategory) { $sCategories .= $aCategory[0] . ','; } $sCategories = rtrim($sCategories, ','); } $this->template()->assign(array( 'sHeader' => Phpfox::getPhrase('photo.image_details'), 'aPhotoDetails' => array( 'Added' => Phpfox::getTime(Phpfox::getParam('photo.photo_image_details_time_stamp'), $aPhoto['time_stamp']), Phpfox::getPhrase('photo.category') => $sCategories, Phpfox::getPhrase('photo.file_size') => Phpfox::getLib('file')->filesize($aPhoto['file_size']), Phpfox::getPhrase('photo.resolution') => $aPhoto['width'] . '×' . $aPhoto['height'], Phpfox::getPhrase('photo.comments') => $aPhoto['total_comment'], Phpfox::getPhrase('photo.views') => $aPhoto['total_view'], Phpfox::getPhrase('photo.rating') => round($aPhoto['total_rating']), Phpfox::getPhrase('photo.battle_wins') => round($aPhoto['total_battle']), Phpfox::getPhrase('photo.downloads') => $aPhoto['total_download'] ), 'sUrlPath' => (preg_match("/\{file\/pic\/(.*)\/(.*)\.jpg\}/i", $aPhoto['destination'], $aMatches) ? Phpfox::getParam('core.path') . str_replace(array('{', '}'), '', $aMatches[0]) : (($aPhoto['server_id'] && Phpfox::getParam('core.allow_cdn')) ? Phpfox::getLib('cdn')->getUrl(Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500')) : Phpfox::getParam('photo.url_photo') . sprintf($aPhoto['destination'], '_500'))) ) ); return 'block'; }
public function get($sSelect, $aConds, $sSort = 'cmt.time_stamp DESC', $iRange = '', $sLimit = '', $iCnt = null, $bIncludeOwnerDetails = false) { ($sPlugin = Phpfox_Plugin::get('comment.service_comment_get__start')) ? eval($sPlugin) : false; $aRows = array(); if ($iCnt === null) { ($sPlugin = Phpfox_Plugin::get('comment.service_comment_get_count_query')) ? eval($sPlugin) : false; $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'cmt')->where($aConds)->execute('getSlaveField'); } if ($iCnt) { if (Phpfox::isUser()) { $this->database()->select('cr.comment_id AS has_rating, cr.rating AS actual_rating, ')->leftJoin(Phpfox::getT('comment_rating'), 'cr', 'cr.comment_id = cmt.comment_id AND cr.user_id = ' . (int) Phpfox::getUserId()); } if ($bIncludeOwnerDetails === true) { $this->database()->select(Phpfox::getUserField('owner', 'owner_') . ', ')->leftJoin(Phpfox::getT('user'), 'owner', 'owner.user_id = cmt.owner_user_id'); } if (Phpfox::isModule('like')) { $this->database()->select('l.like_id AS is_liked, ')->leftJoin(Phpfox::getT('like'), 'l', 'l.type_id = \'feed_mini\' AND l.item_id = cmt.comment_id AND l.user_id = ' . Phpfox::getUserId()); } ($sPlugin = Phpfox_Plugin::get('comment.service_comment_get_query')) ? eval($sPlugin) : false; $aRows = $this->database()->select($sSelect . ", " . (Phpfox::getParam('core.allow_html') ? "comment_text.text_parsed" : "comment_text.text") . " AS text, " . Phpfox::getUserField())->from($this->_sTable, 'cmt')->leftJoin(Phpfox::getT('comment_text'), 'comment_text', 'comment_text.comment_id = cmt.comment_id')->leftJoin(Phpfox::getT('user'), 'u', 'u.user_id = cmt.user_id')->where($aConds)->order($sSort)->limit($iRange, $sLimit, $iCnt)->execute('getSlaveRows'); } $oUrl = Phpfox_Url::instance(); $oParseOutput = Phpfox::getLib('parse.output'); foreach ($aRows as $iKey => $aRow) { $aRows[$iKey]['link'] = ''; if ($aRow['user_name']) { $aRows[$iKey]['link'] = $oUrl->makeUrl($aRow['user_name']); $aRows[$iKey]['is_guest'] = false; } else { $aRows[$iKey]['full_name'] = $oParseOutput->clean($aRow['author']); $aRows[$iKey]['is_guest'] = true; if ($aRow['author_url']) { $aRows[$iKey]['link'] = $aRow['author_url']; } } $aRows[$iKey]['unix_time_stamp'] = $aRow['time_stamp']; $aRows[$iKey]['time_stamp'] = Phpfox::getTime(Phpfox::getParam('comment.comment_time_stamp'), $aRow['time_stamp']); $aRows[$iKey]['posted_on'] = Phpfox::getPhrase('comment.user_link_at_item_time_stamp', array('item_time_stamp' => Phpfox::getTime(Phpfox::getParam('comment.comment_time_stamp'), $aRow['time_stamp']), 'user' => $aRow)); $aRows[$iKey]['update_time'] = Phpfox::getTime(Phpfox::getParam('comment.comment_time_stamp'), $aRow['update_time']); $aRows[$iKey]['post_convert_time'] = Phpfox::getLib('date')->convertTime($aRow['time_stamp'], 'comment.comment_time_stamp'); } ($sPlugin = Phpfox_Plugin::get('comment.service_comment_get__end')) ? eval($sPlugin) : false; return array($iCnt, $aRows); }
public function get($iUserId) { $aFavorites = $this->database()->select('f.*')->from($this->_sTable, 'f')->where('f.user_id = ' . (int) $iUserId)->order('f.time_stamp DESC')->execute('getSlaveRows'); if (!count($aFavorites)) { return array(0, array()); } $aGroups = array(); $aCache = array(); $aCacheFavorite = array(); $iOwnerUserId = 0; foreach ($aFavorites as $aFavorite) { $aGroups[$aFavorite['type_id']][] = $aFavorite['item_id']; $aCacheFavorite[$aFavorite['type_id']][] = $aFavorite['favorite_id']; $iOwnerUserId = $aFavorite['user_id']; } unset($aFavorites, $aFavorite); foreach ($aGroups as $sType => $aFavorites) { $sModule = $sType; if (strpos($sModule, '_')) { $aParts = explode('_', $sModule); $sModule = $aParts[0]; } if (!Phpfox::isModule($sModule)) { continue; } $aCallback = Phpfox::callback($sType . '.getFavorite', $aFavorites, $iUserId); foreach ($aCacheFavorite[$sType] as $iKey => $iCacheFavId) { if (isset($aCallback['items'][$iKey])) { $aCallback['items'][$iKey]['favorite_id'] = $iCacheFavId; } } foreach ($aCallback as $sKey => $aCallbackItem) { if ($sKey != 'items') { continue; } foreach ($aCallbackItem as $iItemKey => $aSub) { $aCallback['items'][$iItemKey]['time_stamp_phrase'] = Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aSub['time_stamp']); } } $aCache[] = $aCallback; } return array($iOwnerUserId, $aCache); }
public function process() { Phpfox::getLib('setting')->setParam(array('profile.url_image' => Phpfox::getParam('core.url_pic') . 'subprofiles/')); $aInfo = array(); $aInfo = Phpfox::getLib('phpfox.database')->select('e.title, e.title_url, e.image_path, e.time_stamp, e.server_id, ' . Phpfox::getUserField('u'))->from(Phpfox::getT('ko_profiles'), 'e')->innerjoin(Phpfox::getT('user'), 'u', 'u.user_id = e.user_id')->order('e.time_stamp DESC')->limit(5)->execute('getSlaveRows'); if (!count($aInfo)) { return false; } foreach ($aInfo as $k => $v) { $aInfo[$k]['time'] = Phpfox::getTime(Phpfox::getParam('feed.feed_display_time_stamp'), $v['time_stamp']); } $this->template()->assign(array('sHeader' => Phpfox::getPhrase('profiles.recent_extra_profiles'), 'aExtraProfiles' => $aInfo)); $iUserId = Phpfox::getUserId(); $bUrlCheck = $this->url()->getUrl(); if ($bUrlCheck == "" && $iUserId) { $this->template()->assign('sDeleteBlock', 'dashboard'); } return 'block'; }
public function getForBrowse($iPage = 0, $iPageTotal = 10) { $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'n')->join(Phpfox::getT('user'), 'u', 'u.user_id = n.owner_user_id')->where('n.user_id = ' . Phpfox::getUserId() . '')->execute('getSlaveField'); $aRows = $this->database()->select('n.*, n.user_id as item_user_id, ' . Phpfox::getUserField())->from($this->_sTable, 'n')->join(Phpfox::getT('user'), 'u', 'u.user_id = n.owner_user_id')->where('n.user_id = ' . Phpfox::getUserId() . '')->order('n.time_stamp DESC')->limit($iPage, $iPageTotal, $iCnt)->execute('getSlaveRows'); $sIds = ''; $aNotifications = array(); foreach ($aRows as $aRow) { $sIds .= (int) $aRow['notification_id'] . ','; $iDate = Phpfox::getTime('dmy', $aRow['time_stamp']); if ($iDate == Phpfox::getTime('dmy', PHPFOX_TIME)) { $iDate = Phpfox::getPhrase('notification.today'); } elseif ($iDate == Phpfox::getTime('dmy', PHPFOX_TIME - 86400)) { $iDate = Phpfox::getPhrase('notification.yesterday'); } else { $iDate = Phpfox::getTime(Phpfox::getParam('notification.notification_browse_messages'), $aRow['time_stamp']); } if (substr($aRow['type_id'], 0, 8) != 'comment_' && !Phpfox::hasCallback($aRow['type_id'], 'getNotification')) { $aRow['link'] = '#'; $aRow['message'] = '1. Notification is missing a callback. [' . $aRow['type_id'] . '::getNotification]'; $aNotifications[$iDate][] = $aRow; continue; } if (substr($aRow['type_id'], 0, 8) == 'comment_' && substr($aRow['type_id'], 0, 12) != 'comment_feed' && !Phpfox::hasCallback(substr_replace($aRow['type_id'], '', 0, 8), 'getCommentNotification')) { $aRow['link'] = '#'; $aRow['message'] = 'Notification is missing a callback. [' . substr_replace($aRow['type_id'], '', 0, 8) . '::getCommentNotification]'; $aNotifications[$iDate][] = $aRow; continue; } if ($aCallBack = Phpfox::callback($aRow['type_id'] . '.getNotification', $aRow)) { if (!isset($aCallBack['message'])) { $aRow['link'] = '#'; $aRow['message'] = 'Notification is missing a message/link param. [' . $aRow['type_id'] . '::getNotification]'; } $aNotifications[$iDate][] = array_merge($aRow, (array) $aCallBack); } } $sIds = rtrim($sIds, ','); if (!empty($sIds)) { $this->database()->update(Phpfox::getT('notification'), array('is_seen' => '1'), 'notification_id IN(' . $sIds . ')'); } return array($iCnt, $aNotifications); }
public function processRows(&$aRows) { $aNewRows = $aRows; $aRows = array(); foreach ($aNewRows as $aListing) { $afevent['start_time'] = Phpfox::getLib('date')->convertFromGmt($aListing['start_time'], $aListing['start_gmt_offset']); $iDate = Phpfox::getTime('dmy', $aListing['start_time']); if ($iDate == Phpfox::getTime('dmy', PHPFOX_TIME)) { $iDate = Phpfox::getPhrase('fevent.today'); } elseif ($iDate == Phpfox::getTime('dmy', PHPFOX_TIME + 86400)) { $iDate = Phpfox::getPhrase('fevent.tomorrow'); } else { $iDate = Phpfox::getTime(Phpfox::getParam('fevent.fevent_browse_time_stamp'), $aListing['start_time']); } $aListing['start_time_phrase'] = Phpfox::getTime(Phpfox::getParam('fevent.fevent_browse_time_stamp'), $aListing['start_time']); $aListing['start_time_phrase_stamp'] = Phpfox::getTime(Phpfox::getParam('fevent.fevent_basic_information_time_short'), $aListing['start_time']); $aListing['start_time_micro'] = Phpfox::getTime('Y-m-d', $afevent['start_time']); $aListing['aFeed'] = array('feed_display' => 'mini', 'comment_type_id' => 'fevent', 'privacy' => $aListing['privacy'], 'comment_privacy' => $aListing['privacy_comment'], 'like_type_id' => 'fevent', 'feed_is_liked' => isset($aListing['is_liked']) ? $aListing['is_liked'] : false, 'feed_is_friend' => isset($aListing['is_friend']) ? $aListing['is_friend'] : false, 'item_id' => $aListing['fevent_id'], 'user_id' => $aListing['user_id'], 'total_comment' => $aListing['total_comment'], 'feed_total_like' => $aListing['total_like'], 'total_like' => $aListing['total_like'], 'feed_link' => Phpfox::getLib('url')->permalink('fevent', $aListing['fevent_id'], $aListing['title']), 'feed_title' => $aListing['title'], 'type_id' => 'fevent'); $aListing['url'] = Phpfox::getLib('url')->permalink('fevent', $aListing['fevent_id'], $aListing['title']); $aRows[$iDate][] = $aListing; } }
public function process() { Phpfox::getLib('setting')->setParam(array('profile.url_image' => Phpfox::getParam('core.url_pic') . 'subprofiles/')); $oServiceProfilesBrowse = Phpfox::getService('profiles.browse'); $oDatabase = Phpfox::getLib('database'); $oParseInput = Phpfox::getLib('parse.input'); $iPage = $this->request()->get('page'); $iPageSize = 25; $iTimeDisplay = Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y')); $aPages = Phpfox::isMobile() ? array(10) : array(21, 31, 41, 51); $aDisplays = array(); foreach ($aPages as $iPageCnt) { $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt)); } //get the additional browse filters $aBrowseFilters = Phpfox::getService('profiles.browse')->getBrowseFilter(); $aFilters = array('display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '21'), 'sort' => array('type' => 'select', 'options' => array('time_stamp' => Phpfox::getPhrase('profiles.date_added'), 'title' => Phpfox::getPhrase('profiles.name')), 'default' => 'time_stamp', 'alias' => 'p'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC'), 'keyword' => array('type' => 'input:text', 'size' => 15, 'search' => 'AND p.title LIKE \'%[VALUE]%\'')); //add the additional admin enabled browse field filters to $aFilters if (!empty($aBrowseFilters)) { foreach ($aBrowseFilters as $aBrowseFilter) { $aBrowseFilter[$aBrowseFilter['field_name']] = array('type' => 'input:text', 'size' => 15, 'search' => 'AND pfv.cf_' . $aBrowseFilter['field_name'] . ' LIKE \'%[VALUE]%\''); $aFilters[$aBrowseFilter['field_name']] = $aBrowseFilter[$aBrowseFilter['field_name']]; } } $oFilter = Phpfox::getLib('search')->set(array('type' => 'browse', 'filters' => $aFilters, 'search' => 'keyword', 'custom_search' => true)); $oServiceProfilesBrowse->condition($oFilter->getConditions())->order($oFilter->getSort())->page($iPage)->size($oFilter->getDisplay())->execute(); Phpfox::getLib('pager')->set(array('page' => $iPage, 'size' => $oFilter->getDisplay(), 'count' => $oFilter->getSearchTotal($oServiceProfilesBrowse->getCount()))); //This is for adding the snippet fields that have been enabled by the Admin $oProfileFields = Phpfox::getService('profiles.browse')->getBrowseDisplay(); $this->template()->setTitle(Phpfox::getPhrase('profiles.extra_profiles'))->setBreadcrumb(Phpfox::getPhrase('profiles.extra_profiles'))->setHeader('cache', array('pager.css' => 'style_css'))->assign(array('aProfiles' => $oProfileFields, 'aBrowseFilters' => $aBrowseFilters)); if ($sPlugin = Phpfox_Plugin::get('profiles.component_controller_browse_end')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } }
public function get($iId = 0) { /* @title @info Get a list of all public events. If you pass a user ID# it will return a list of the users events. If you pass a ID# it will return just that event. @method GET @extra user_id=#{User ID#|int|no}&id=#{Event ID#|int|no} @return event_id=#{Event ID#|int}&title=#{Title of the event|string}&likes=#{Total number of likes|int}&permalink=#{Link to the event|string}&info=#{Information about the event|string}&created_by=#{Person who created the event|string}&created_by_url=#{Link to creators profile|string}&photo_200px=#{Default photo for the event. Max 200px|string} */ $iUserId = $this->_oApi->get('user_id'); if ((int) $this->_oApi->get('id') !== 0) { $iId = $this->_oApi->get('id'); } $iTimeDisplay = Phpfox::getLib('date')->mktime(0, 0, 0, Phpfox::getTime('m'), Phpfox::getTime('d'), Phpfox::getTime('Y')); $iCnt = $this->database()->select('COUNT(*)')->from($this->_sTable, 'b')->where(empty($iId) ? 'b.view_id = 0 AND b.privacy = 0 AND b.item_id = 0 AND ' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.start_time >= \'' . Phpfox::getLib('date')->convertToGmt($iTimeDisplay) . '\'' : 'b.event_id = ' . (int) $iId)->execute('getSlaveField'); $this->_oApi->setTotal($iCnt); $aRows = $this->database()->select('b.*, bt.description_parsed, ' . Phpfox::getUserField())->from($this->_sTable, 'b')->join(Phpfox::getT('user'), 'u', 'u.user_id = b.user_id')->join(Phpfox::getT('event_text'), 'bt', 'bt.event_id = b.event_id')->where(empty($iId) ? 'b.view_id = 0 AND b.privacy = 0 AND b.item_id = 0 AND ' . (empty($iUserId) ? '' : 'b.user_id = ' . (int) $iUserId . ' AND ') . ' b.start_time >= \'' . Phpfox::getLib('date')->convertToGmt($iTimeDisplay) . '\'' : 'b.event_id = ' . (int) $iId)->limit($this->_oApi->get('page'), 10, $iCnt)->order('b.time_stamp DESC')->execute('getSlaveRows'); $aReturn = array(); foreach ($aRows as $iKey => $aRow) { $aReturn[$iKey] = array('event_id' => $aRow['event_id'], 'title' => $aRow['title'], 'likes' => $aRow['total_like'], 'permalink' => Phpfox::permalink('event', $aRow['event_id'], $aRow['title']), 'info' => Phpfox::getLib('parse.output')->parse($aRow['description_parsed']), 'created_by' => $aRow['full_name'], 'created_by_url' => Phpfox::getLib('url')->makeUrl($aRow['user_name'])); $aReturn[$iKey]['photo_200px'] = Phpfox::getLib('image.helper')->display(array('path' => 'event.url_image', 'server_id' => $aRow['server_id'], 'file' => $aRow['image_path'], 'suffix' => '_200', 'return_url' => true)); } return $aReturn; }
public function get_History_log() { $history_log = PhpFox::getService('backuprestore.history')->getBTDBallHistory(); if (count($history_log) > self::MAX_HISTORY_ITEMS) { reset($history_log); $first_entry = current($history_log); PhpFox::getService('backuprestore.history')->deleteBTDBHistory($first_entry['history_id']); array_shift($history_log); } if (!$history_log || !count($history_log)) { return FALSE; } foreach ($history_log as $history) { $historylog[] = array('iDate' => Phpfox::getTime(Phpfox::getParam('backuprestore.tme_stamp'), $history['time_stamp']), 'iHM' => Phpfox::getTime(Phpfox::getParam('backuprestore.schedule_hour_min_format'), $history['time_stamp']), 'backed_file' => $history['backed_file']); } return $historylog; }
/** * Class process method wnich is used to execute this component. */ public function process() { Phpfox::getUserParam('quiz.can_access_quiz', true); if (Phpfox::isModule('notification') && Phpfox::isUser()) { Phpfox::getService('notification.process')->delete('comment_quiz', $this->request()->getInt('req2'), Phpfox::getUserId()); Phpfox::getService('notification.process')->delete('quiz_like', $this->request()->getInt('req2'), Phpfox::getUserId()); } if ($this->request()->get('req4') && $this->request()->get('req4') == 'answer') { // check that this user has not taken the quiz yet $aVals = $this->request()->getArray('val'); if (Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $this->request()->get('req2'))) { Phpfox_Error::set(Phpfox::getPhrase('quiz.you_have_already_answered_this_quiz')); } elseif (!isset($aVals['answer'])) { Phpfox_Error::set(Phpfox::getPhrase('quiz.you_have_to_answer_the_questions_if_you_want_to_do_that')); } else { Phpfox::isUser(true); // check if user is allowed to answer their own quiz $aQuizC = Phpfox::getService('quiz')->getQuizById($this->request()->get('req2')); if (!isset($aQuizC['user_id']) || empty($aQuizC['user_id'])) { $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.that_quiz_does_not_exist_or_its_awaiting_moderation')); } if (!Phpfox::getUserParam('quiz.can_answer_own_quiz') && $aQuizC['user_id'] == Phpfox::getUserId()) { $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.you_are_not_allowed_to_answer_your_own_quiz')); } $iScore = false; $iScore = Phpfox::getService('quiz.process')->answerQuiz($this->request()->get('req2'), $aVals['answer']); if (is_numeric($iScore)) { // Answers submitted correctly $aUser = $this->getParam('aUser'); $this->url()->permalink('quiz', $this->request()->get('req2'), $this->request()->get('req3'), true, Phpfox::getPhrase('quiz.your_answers_have_been_submitted_and_your_score_is_score', array('score' => $iScore)), array('results', 'id' => Phpfox::getUserId())); } else { Phpfox_Error::set($iScore); } } } $this->setParam('bViewingQuiz', true); $aQuiz = array(); $bShowResults = false; $bShowUsers = false; $bCanTakeQuiz = true; // $bShowResults == true -> only when viewing results for one user only // $bShowUsers == true -> when viewing all results from a quiz $sQuizUrl = $this->request()->get('req2'); $sQuizUrl = Phpfox::getLib('parse.input')->clean($sQuizUrl); if ($this->request()->get('req4') == 'results') { $bHasTaken = Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $sQuizUrl); if ($bHasTaken) { $bCanTakeQuiz = false; } if ($iUser = $this->request()->getInt('id')) { // show the results of just one user $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, $iUser); $bShowResults = true; } else { $bShowUsers = true; $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false); } // need it here to have the quiz' info if (!Phpfox::getUserParam('quiz.can_view_results_before_answering') && !$bHasTaken && $aQuiz['user_id'] != Phpfox::getUserId()) { $this->url()->send($this->request()->get('req1') . '/' . $this->request()->get('req2') . '/' . $sQuizUrl, null, Phpfox::getPhrase('quiz.you_need_to_answer_the_quiz_before_looking_at_the_results')); } if (Phpfox::getUserParam('quiz.can_post_comment_on_quiz')) { $this->template()->assign(array('bShowInputComment' => true))->setHeader(array('comment.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'pager.css' => 'style_css')); if (Phpfox::getUserId()) { $this->template()->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments'))); } } } elseif ($this->request()->get('req4') == 'take') { $bShowResults = false; $bShowUsers = false; $bCanTakeQuiz = false; $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, true, true); } else { if (Phpfox::getService('quiz')->hasTakenQuiz(Phpfox::getUserId(), $sQuizUrl)) { $bCanTakeQuiz = false; $bShowResults = false; $bShowUsers = true; $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false); } else { $bCanTakeQuiz = true; $aQuiz = Phpfox::getService('quiz')->getQuizByUrl($sQuizUrl, false, true); } if (Phpfox::getUserParam('quiz.can_post_comment_on_quiz')) { $this->template()->assign(array('bShowInputComment' => true))->setHeader(array('comment.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'pager.css' => 'style_css')); if (Phpfox::getUserId()) { $this->template()->setEditor(array('load' => 'simple', 'wysiwyg' => Phpfox::isModule('comment') && Phpfox::getParam('comment.wysiwyg_comments') && Phpfox::getUserParam('comment.wysiwyg_on_comments'))); } } } // crash control, in a perfect world this shouldnt happen if (empty($aQuiz)) { $this->url()->send('quiz', null, Phpfox::getPhrase('quiz.that_quiz_does_not_exist_or_its_awaiting_moderation')); } if (Phpfox::getUserId() == $aQuiz['user_id'] && Phpfox::isModule('notification')) { Phpfox::getService('notification.process')->delete('quiz_approved', $this->request()->getInt('req2'), Phpfox::getUserId()); } Phpfox::getService('core.redirect')->check($aQuiz['title']); if (Phpfox::isModule('privacy')) { if (!isset($aQuiz['is_friend'])) { $aQuiz['is_friend'] = 0; } Phpfox::getService('privacy')->check('quiz', $aQuiz['quiz_id'], $aQuiz['user_id'], $aQuiz['privacy'], $aQuiz['is_friend']); } // extra info: used for displaying results for one user if (isset($aQuiz['results'][0])) { $aQuiz['takerInfo']['userinfo'] = array('user_name' => $aQuiz['results'][0]['user_name'], 'user_id' => $aQuiz['results'][0]['user_id'], 'server_id' => $aQuiz['results'][0]['server_id'], 'full_name' => $aQuiz['results'][0]['full_name'], 'gender' => $aQuiz['results'][0]['gender'], 'user_image' => $aQuiz['results'][0]['user_image']); $aQuiz['takerInfo']['time_stamp'] = $aQuiz['results'][0]['time_stamp']; } if (!isset($aQuiz['is_viewed'])) { $aQuiz['is_viewed'] = 0; } if (Phpfox::isUser() && Phpfox::getUserId() != $aQuiz['user_id'] && !$aQuiz['is_viewed'] && !Phpfox::getUserBy('is_invisible')) { // the updateView should only happen when the user has submitted a Phpfox::getService('quiz.process')->updateView($aQuiz, Phpfox::getUserId()); if (Phpfox::isModule('track')) { Phpfox::getService('track.process')->add('quiz', $aQuiz['quiz_id']); } } if (Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aQuiz['quiz_id'] && $aQuiz['is_viewed'] && !Phpfox::getUserBy('is_invisible')) { Phpfox::getService('track.process')->update('quiz_track', $aQuiz['quiz_id']); } if (isset($aQuiz['aTakenBy'])) { $this->setParam('aTakers', $aQuiz['aTakenBy']); } if (Phpfox::isModule('notification') && $aQuiz['user_id'] == Phpfox::getUserId()) { Phpfox::getService('notification.process')->delete('quiz_notifyLike', $aQuiz['quiz_id'], Phpfox::getUserId()); } /* * the quiz_track table is used to track who has viewed the quiz * the quiz_result to track who has taken the quiz. */ $this->setParam(array('sTrackType' => 'quiz', 'iTrackId' => $aQuiz['quiz_id'], 'iTrackUserId' => $aQuiz['user_id'])); $this->setParam('aFeed', array('comment_type_id' => 'quiz', 'privacy' => $aQuiz['privacy'], 'comment_privacy' => $aQuiz['privacy_comment'], 'like_type_id' => 'quiz', 'feed_is_liked' => $aQuiz['is_liked'], 'feed_is_friend' => $aQuiz['is_friend'], 'item_id' => $aQuiz['quiz_id'], 'user_id' => $aQuiz['user_id'], 'total_comment' => $aQuiz['total_comment'], 'total_like' => $aQuiz['total_like'], 'feed_link' => $this->url()->permalink('quiz', $aQuiz['quiz_id'], $aQuiz['title']), 'feed_title' => $aQuiz['title'], 'feed_display' => 'view', 'feed_total_like' => $aQuiz['total_like'], 'report_module' => 'quiz', 'report_phrase' => Phpfox::getPhrase('quiz.report_this_quiz'))); $this->template()->setTitle($aQuiz['title'])->setTitle(Phpfox::getPhrase('quiz.quizzes'))->setBreadcrumb(Phpfox::getPhrase('quiz.quizzes'), $this->url()->makeUrl('quiz'))->setBreadcrumb($aQuiz['title'], $this->url()->permalink('quiz', $aQuiz['quiz_id'], $aQuiz['title']), true)->setMeta('description', Phpfox::getPhrase('quiz.full_name_s_quiz_from_time_stamp_title', array('full_name' => $aQuiz['full_name'], 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.description_time_stamp'), $aQuiz['time_stamp']), 'title' => $aQuiz['title'])))->setMeta('keywords', $this->template()->getKeywords($aQuiz['title']))->setMeta('keywords', Phpfox::getParam('quiz.quiz_meta_keywords'))->setMeta('description', Phpfox::getParam('quiz.quiz_meta_description'))->assign(array('bIsViewingQuiz' => true, 'bShowResults' => $bShowResults, 'bShowUsers' => $bShowUsers, 'bCanTakeQuiz' => $bCanTakeQuiz, 'aQuiz' => $aQuiz, 'sSuffix' => '_' . Phpfox::getParam('quiz.quiz_max_image_pic_size')))->setPhrase(array('quiz.are_you_sure_you_want_to_delete_this_quiz'))->setHeader('cache', array('quiz.js' => 'module_quiz', 'quick_edit.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'feed.js' => 'module_feed')); ($sPlugin = Phpfox_Plugin::get('quiz.component_controller_view_process_end')) ? eval($sPlugin) : false; }
public function getTweets() { $sCacheId = $this->cache()->set('phpfox_twitter'); if (!($aCache = $this->cache()->get($sCacheId, 60))) { $sHtml = Phpfox_Request::instance()->send('http://twitter.com/statuses/user_timeline/16987205.rss', array(), 'GET'); if (preg_match('/<html(.*?)>/i', $sHtml)) { return false; } $aTweets = Phpfox::getLib('xml.parser')->parse($sHtml); $aCache = array(); $iCnt = 0; if (!isset($aTweets['channel']['item'])) { return false; } foreach ($aTweets['channel']['item'] as $aItem) { $iCnt++; $aCache[] = array('title' => str_replace('phpFox: ', '', $aItem['title']), 'link' => $aItem['link'], 'time_stamp' => strtotime($aItem['pubDate'])); if ($iCnt === 5) { break; } } $this->cache()->save($sCacheId, $aCache); } foreach ($aCache as $iKey => $aRow) { $aCache[$iKey]['posted_on'] = Phpfox::getPhrase('admincp.posted_on_time_stamp', array('time_stamp' => Phpfox::getTime(Phpfox::getParam('core.global_update_time'), $aRow['time_stamp']))); } return $aCache; }
public static function internalVersion() { $version = self::getCleanVersion(); $version .= Phpfox::getParam('core.css_edit_id'); if (defined('PHPFOX_NO_CSS_CACHE')) { return Phpfox::getTime(); } return $version; }
/** * Controller */ public function process() { Phpfox::getUserParam('poll.can_access_polls', true); ($sPlugin = Phpfox_Plugin::get('poll.component_controller_view_process_start')) ? eval($sPlugin) : false; // there are times when this controller is actually called // in the Poll_Component_Controller_Profile like when the poll // is in the profile $sSuffix = '_' . Phpfox::getParam('poll.poll_max_image_pic_size'); $iPage = $this->request()->getInt('page', 0); $iPageSize = 10; // we need to make sure we're getting the if (!($iPoll = $this->request()->getInt('req2'))) { $this->url()->send('poll'); } if (Phpfox::isModule('notification') && Phpfox::isUser()) { Phpfox::getService('notification.process')->delete('comment_poll', $this->request()->getInt('req2'), Phpfox::getUserId()); Phpfox::getService('notification.process')->delete('poll_like', $this->request()->getInt('req2'), Phpfox::getUserId()); } // we need to load one poll $aPoll = Phpfox::getService('poll')->getPollByUrl($iPoll, $iPage, $iPageSize, true); Phpfox_Pager::instance()->set(array('ajax' => 'poll.pageVotes', 'page' => 0, 'size' => Phpfox::getParam('poll.show_x_users_who_took_poll'), 'count' => $aPoll['total_votes'])); if ($aPoll === false) { return Phpfox_Error::display('Not a valid poll.'); } if (Phpfox::getUserId() == $aPoll['user_id'] && Phpfox::isModule('notification')) { Phpfox::getService('notification.process')->delete('poll_approved', $this->request()->getInt('req2'), Phpfox::getUserId()); } if (!isset($aPoll['is_friend'])) { $aPoll['is_friend'] = 0; } Phpfox::getService('core.redirect')->check($aPoll['question']); if (Phpfox::isModule('privacy')) { Privacy_Service_Privacy::instance()->check('poll', $aPoll['poll_id'], $aPoll['user_id'], $aPoll['privacy'], $aPoll['is_friend']); } // set if we can show the poll results // is guest the owner of the poll $bIsOwner = $aPoll['user_id'] == Phpfox::getUserId(); $bShowResults = false; if ($bIsOwner && Phpfox::getUserParam('poll.can_view_user_poll_results_own_poll') || !$bIsOwner && Phpfox::getUserParam('poll.can_view_user_poll_results_other_poll')) { $bShowResults = true; } $this->template()->assign(array('bShowResults' => $bShowResults)); if ($aPoll['view_id'] == 1) { if (!Phpfox::getUserParam('poll.poll_can_moderate_polls') && $aPoll['user_id'] != Phpfox::getUserId()) { return Phpfox_Error::display(Phpfox::getPhrase('poll.unable_to_view_this_poll')); } if ($sModerate = $this->request()->get('moderate')) { Phpfox::getUserParam('poll.poll_can_moderate_polls', true); switch ($sModerate) { case 'approve': if (Phpfox::getService('poll.process')->moderatePoll($aPoll['poll_id'], 0)) { $this->url()->send($aUser['user_name'], array('poll', $aPoll['question_url']), Phpfox::getPhrase('poll.poll_successfully_approved')); } break; default: break; } } } // Track users if (Phpfox::isModule('track') && Phpfox::isUser() && Phpfox::getUserId() != $aPoll['user_id'] && !$aPoll['poll_is_viewed'] && !Phpfox::getUserBy('is_invisible')) { Phpfox::getService('track.process')->add('poll', $aPoll['poll_id']); Phpfox::getService('poll.process')->updateView($aPoll['poll_id']); } if (Phpfox::isUser() && Phpfox::isModule('track') && Phpfox::getUserId() != $aPoll['user_id'] && $aPoll['poll_is_viewed'] && !Phpfox::getUserBy('is_invisible')) { Phpfox::getService('track.process')->update('poll_track', $aPoll['poll_id']); } // check editing permissions $aPoll['bCanEdit'] = Phpfox::getService('poll')->bCanEdit($aPoll['user_id']); // Define params for "review views" block tracker $this->setParam(array('sTrackType' => 'poll', 'iTrackId' => $aPoll['poll_id'], 'iTrackUserId' => $aPoll['user_id'], 'aPoll' => $aPoll)); $this->setParam('aFeed', array('comment_type_id' => 'poll', 'privacy' => $aPoll['privacy'], 'comment_privacy' => $aPoll['privacy_comment'], 'like_type_id' => 'poll', 'feed_is_liked' => $aPoll['is_liked'], 'feed_is_friend' => $aPoll['is_friend'], 'item_id' => $aPoll['poll_id'], 'user_id' => $aPoll['user_id'], 'total_comment' => $aPoll['total_comment'], 'total_like' => $aPoll['total_like'], 'feed_link' => $this->url()->permalink('poll', $aPoll['poll_id'], $aPoll['question']), 'feed_title' => $aPoll['question'], 'feed_display' => 'view', 'feed_total_like' => $aPoll['total_like'], 'report_module' => 'poll', 'report_phrase' => Phpfox::getPhrase('poll.report_this_poll_lowercase'))); $this->template()->setTitle($aPoll['question'])->setBreadcrumb(Phpfox::getPhrase('poll.polls'), $this->url()->makeUrl('poll'))->setBreadcrumb($aPoll['question'], $this->url()->permalink('poll', $aPoll['poll_id'], $aPoll['question']), true)->setMeta('keywords', $this->template()->getKeywords($aPoll['question']))->setMeta('description', Phpfox::getPhrase('poll.full_name_s_poll_from_time_stamp_question', array('full_name' => $aPoll['full_name'], 'time_stamp' => Phpfox::getTime(Phpfox::getParam('core.description_time_stamp'), $aPoll['time_stamp']), 'question' => $aPoll['question'])))->setMeta('description', Phpfox::getParam('poll.poll_meta_description'))->setMeta('keywords', Phpfox::getParam('poll.poll_meta_keywords'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'quick_edit.js' => 'static_script', 'poll.css' => 'module_poll', 'feed.js' => 'module_feed'))->setEditor(array('load' => 'simple'))->assign(array('bIsViewingPoll' => true, 'aPoll' => $aPoll, 'sSuffix' => $sSuffix)); if (isset($aPoll['answer']) && is_array($aPoll['answer'])) { foreach ($aPoll['answer'] as $aAnswer) { $this->template()->setMeta('keywords', $this->template()->getKeywords($aAnswer['answer'])); } } ($sPlugin = Phpfox_Plugin::get('poll.component_controller_view_process_end')) ? eval($sPlugin) : false; }