public function process() { $aIdEntry = $this->getParam('aIdEntry'); $number_entry_max = 0; $aId = explode(',', $aIdEntry); $aEntries = array(); $aContestWinning = array(); $TotalWinning = 0; $limit_entries = 0; $link = ''; foreach ($aId as $Id) { $aEntries[] = $aContestWinning = PHpfox::getService('contest.entry')->getContestEntryById($Id); if ($number_entry_max == 0) { $number_entry_max = $aEntries[count($aEntries) - 1]['number_winning_entry_max']; } } if ($aContestWinning) { $TotalWinning = Phpfox::getService('contest.entry')->getTotalWinningEntries($aContestWinning['contest_id'], $aIdEntry); $link = Phpfox::getLib('url')->permaLink('contest', $aContestWinning['contest_id'], $aContestWinning['contest_name']) . "view_winning/"; } if ($TotalWinning + count($aId) > $number_entry_max) { $limit_entries = 1; } $this->template()->assign(array('aEntries' => $aEntries, 'limit_entries' => $limit_entries, 'abc' => $number_entry_max, 'link' => $link)); }
public function favoriteContest($iContestId, $iUserId, $iType) { $iParticipantId = Phpfox::getService('contest.participant.process')->insertNewParticipantEntryIfNeccessary($iContestId, $iUserId); if ($iType == 1) { //follow $aUpdate = array('is_favorite' => 1); $bResult = $this->database()->update($this->_sTable, $aUpdate, 'participant_id = ' . $iParticipantId); $iItemId = $iParticipantId; if (PHpfox::isModule('foxfavorite')) { ($sPlugin = Phpfox_Plugin::get('contest.service_process_addfavorite_end')) ? eval($sPlugin) : false; } if ($bResult) { Phpfox::getService('contest.contest.process')->sendNotificationAndEmail('favorite_contest', $iContestId); } return $bResult; } else { if ($iType == 0) { //un follow $aUpdate = array('is_favorite' => 0); $iItemId = $iParticipantId; if (PHpfox::isModule('foxfavorite')) { ($sPlugin = Phpfox_Plugin::get('contest.service_process_deletefavorite_end')) ? eval($sPlugin) : false; } return $this->database()->update($this->_sTable, $aUpdate, 'participant_id = ' . $iParticipantId); } } }
public function getDataToInsertIntoEntry($iItemId) { $aItem = $this->getItemFromFox($iItemId); $sFullSourcePath = Phpfox::getParam('core.dir_pic') . $aItem['image_path']; if ($aItem['image_server_id'] != 0) { $sOriginalSource = sprintf($sFullSourcePath, $this->_sOriginalSuffix); $sOriginalSource = str_replace(PHPFOX_DIR, Phpfox::getParam('core.path'), $sOriginalSource); $sSrc = Phpfox::getLib('cdn')->getUrl($sOriginalSource, $aItem['image_server_id']); $p = PHPFOX_DIR_FILE . PHPFOX_DS . 'pic' . PHPFOX_DS . 'contest' . PHPFOX_DS; if (!is_dir($p)) { if (!@mkdir($p, 0777, 1)) { } } $sImage = $sSrc; $sImageLocation = Phpfox::getLib('file')->getBuiltDir(Phpfox::getParam('core.dir_pic') . "contest/") . md5(PHPFOX_TIME . PHpfox::getUserId() . 'contest') . '%s.jpg'; $oImage = Phpfox::getLib('request')->send($sImage, array(), 'GET'); $sTempImage = 'contest_temporal_image_' . PHPFOX_TIME . PHpfox::getUserId(); Phpfox::getLib('file')->writeToCache($sTempImage, $oImage); @copy(PHPFOX_DIR_CACHE . $sTempImage, sprintf($sImageLocation, $this->_sOriginalSuffix)); unlink(PHPFOX_DIR_CACHE . $sTempImage); $tmp = sprintf($sImageLocation, $this->_sOriginalSuffix); $tmp = str_replace("/", '\\', $tmp); $sImagePath = Phpfox::getService('contest.entry.process')->copyImageToContest($sImageLocation, $this->_sOriginalSuffix, $this->_aImageSize); unlink($tmp); } else { $sImagePath = Phpfox::getService('contest.entry.process')->copyImageToContest($sFullSourcePath, $this->_sOriginalSuffix, $this->_aImageSize); } //copy db // column name here must comply with column in db $aReturn = array('embed_code' => $aItem['embed_code'], 'video_url' => $aItem['video_url'], 'image_path' => $sImagePath); return $aReturn; //copy file }
private function _view($sView, $bIsProfile, $aUser) { switch ($sView) { case 'my': Phpfox::isUser(true); $this->search()->setCondition('AND ct.user_id = ' . Phpfox::getUserId()); break; case 'friend': Phpfox::isUser(true); $this->search()->setCondition(' AND ct.privacy IN(%PRIVACY%) AND (ct.contest_status = 5 or ct.contest_status = 4) '); break; case 'pending': Phpfox::isUser(true); $this->search()->setCondition(' AND ct.privacy IN(%PRIVACY%) AND ct.contest_status = 2'); break; case 'featured': Phpfox::isUser(true); $this->search()->setCondition('AND ct.privacy IN(%PRIVACY%) AND ct.is_feature = 1 and ct.contest_status=4'); break; case 'premium': Phpfox::isUser(true); $this->search()->setCondition(' AND ct.privacy IN(%PRIVACY%) AND ct.is_premium = 1 and ct.contest_status=4'); break; case 'ending_soon': Phpfox::isUser(true); $this->search()->setCondition(' AND ct.privacy IN(%PRIVACY%) AND ct.is_ending_soon = 1 and ct.contest_status=4'); $setting = PHpfox::getParam('contest.ending_soon_setting'); $day = Phpfox::getParam('contest.ending_soon_before'); $time = $day * 24 * 3600; if ($setting == 'End of Submission') { $where = ' AND ' . (PHPFOX_TIME + $time) . " >=ct.stop_time and " . PHPFOX_TIME . "<=ct.stop_time"; } else { $where = ' AND ' . (PHPFOX_TIME + $time) . " >=ct.end_time and " . PHPFOX_TIME . "<=ct.end_time"; } $this->search()->setCondition($where); break; case 'closed': Phpfox::isUser(true); $this->search()->setCondition('AND ct.privacy IN(%PRIVACY%) AND ct.contest_status = 5'); break; case 'my_following': Phpfox::isUser(true); $this->search()->setCondition('AND ct.privacy IN(%PRIVACY%) AND (ct.contest_status = 5 or ct.contest_status = 4) AND pa.is_followed=1'); break; case 'my_favorite': Phpfox::isUser(true); $this->search()->setCondition('AND ct.privacy IN(%PRIVACY%) AND (ct.contest_status = 5 or ct.contest_status = 4) AND pa.is_favorite=1'); break; default: if ($bIsProfile === true) { $this->search()->setCondition("AND ct.user_id = " . $aUser['user_id'] . " AND ct.privacy IN(" . (Phpfox::getParam('core.section_privacy_item_browsing') ? '%PRIVACY%' : Phpfox::getService('core')->getForBrowse($aUser)) . ")"); } else { $this->search()->setCondition("AND ct.privacy IN(%PRIVACY%) AND ct.contest_status=4"); } break; } }
public function process() { $iLimit = PHpfox::getParam('contest.number_of_contest_block_home_page'); list($iCnt, $aContests) = Phpfox::getService('contest.contest')->getTopContests($sType = 'premium', $iLimit); $this->template()->assign(array('corepath' => phpfox::getParam('core.path'), 'aPremiumContests' => $aContests, 'iCntPremiumContests' => $iCnt, 'iLimit' => $iLimit)); if ($iCnt == 0 || defined('PHPFOX_IS_USER_PROFILE')) { return false; } else { $this->template()->assign(array('sHeader' => Phpfox::getPhrase('contest.premium_contest'))); } return 'block'; }
public function process() { Phpfox::getService('contest.contest.process')->checkAndUpdateStatusOfContests(); $this->template()->setBreadcrumb(Phpfox::getPhrase('contest.contest'), $this->url()->makeUrl('contest')); $this->_buildSubsectionMenu(); //search contest $aSearchNumber = array(10, 20, 30, 40); $sActionUrl = $this->url()->makeUrl('contest', array('view' => $this->request()->get('view'))); $this->search()->set(array('type' => 'entry', 'field' => 'en.entry_id', 'search' => 'search', 'search_tool' => array('table_alias' => 'en', 'search' => array('action' => $sActionUrl, 'default_value' => Phpfox::getPhrase('contest.search_entries'), 'name' => 'search', 'field' => 'en.title'), 'sort' => array('latest' => array('en.time_stamp', Phpfox::getPhrase('contest.lastest')), 'most-viewed' => array('en.total_view', Phpfox::getPhrase('contest.most_viewed')), 'most-vote' => array('en.total_vote', Phpfox::getPhrase('contest.most_voted')), 'most-liked' => array('en.total_like', Phpfox::getPhrase('contest.most_liked'))), 'show' => $aSearchNumber))); $sView = $this->request()->get('view', false); $sDefaultType = Phpfox::getService('contest.entry')->getDefaultSearchType($sView); $sType = $this->request()->get('type', $sDefaultType); $iType = Phpfox::getService('contest.constant')->getContestTypeIdByTypeName($sType); $this->search()->setCondition('AND en.type = ' . $iType); $aBrowseParams = array('module_id' => 'contest', 'alias' => 'en', 'field' => 'entry_id', 'table' => Phpfox::getT('contest_entry'), 'hide_view' => array('my')); $this->_view($sView); $this->search()->browse()->params($aBrowseParams)->execute(); $aEntries = $this->search()->browse()->getRows(); //here we should and a funtion corresponding with entry/view // foreach ($aEntries as $key => $aEntry) { $aEntry['status_entry'] = $aEntry['status']; $aEntry['approve'] = $aEntry['status_entry'] == 1 ? 0 : 1; $aEntry['deny'] = $aEntry['status_entry'] == 2 ? 0 : 1; $is_entry_winning = Phpfox::getService("contest.entry")->CheckExistEntryWinning($aEntry['entry_id']); $aEntry['winning'] = $aEntry['contest_status'] == 5 && $is_entry_winning == 0 ? 1 : 0; $aEntry['offaction'] = 0; if ($aEntry['contest_user_id'] != Phpfox::getUserId() && !PHpfox::isAdmin()) { $aEntry['offaction'] = 1; } $aEntry = Phpfox::getService('contest.entry')->retrieveEntryPermission($aEntry); $aEntries[$key] = $aEntry; } Phpfox::getLib('pager')->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount())); $this->template()->assign(array('aEntries' => $aEntries, 'sView' => $sView, 'sType' => $sType, 'bIsEntryIndex' => true, 'corepath' => phpfox::getParam('core.path')))->setHeader(array('pager.css' => 'style_css', 'yncontest.css' => 'module_contest', 'yncontest.js' => 'module_contest')); }
public function getInfoForAction($aItem) { // now we check if its a music-album or a music-song if ($aItem['item_type_id'] == 'music-song') { $aRow = $this->database()->select('ms.song_id, ms.title, ms.user_id, u.gender, u.full_name')->from(PHpfox::getT('music_song'), 'ms')->join(Phpfox::getT('user'), 'u', 'u.user_id = ms.user_id')->where('ms.song_id = ' . (int) $aItem['item_id'])->execute('getSlaveRow'); $aRow['link'] = Phpfox::getLib('url')->permalink('music', $aRow['song_id'], $aRow['title']); return $aRow; } // else its a music-album $aRow = $this->database()->select('ma.album_id, ma.name as title, ma.user_id, u.gender, u.full_name')->from(PHpfox::getT('music_album'), 'ma')->join(Phpfox::getT('user'), 'u', 'u.user_id = ma.user_id')->where('ma.album_id = ' . (int) $aItem['item_id'])->execute('getSlaveRow'); $aRow['link'] = Phpfox::getLib('url')->permalink('music.album', $aRow['album_id'], $aRow['title']); return $aRow; }
public function canViewBrowseContest($iContestId, $iUserId = 0) { $aContest = Phpfox::getService('contest.contest')->getContestForCheckingPermission($iContestId); if (!$this->canViewBrowseContestModule()) { return false; } if (!$aContest['is_active'] && PHpfox::getUserId() != $aContest['user_id'] && !PHpfox::isAdmin()) { return false; } if (Phpfox::isModule('privacy')) { if (!Phpfox::getService('privacy')->check('contest', $aContest['contest_id'], $aContest['user_id'], $aContest['privacy'], $aContest['is_friend'], true)) { return false; } } // if not owner, not admin, contes must be closed or on-going to watch if ($aContest['user_id'] != Phpfox::getUserId() && !Phpfox::isAdmin() && !in_array($aContest['contest_status'], array(Phpfox::getService('contest.constant')->getContestStatusIdByStatusName('closed'), Phpfox::getService('contest.constant')->getContestStatusIdByStatusName('on_going')))) { return false; } return true; }
public function hideRoom() { PHpfox::getService('im.process')->hideRoom($this->get('id')); $this->call('deleteCookie(\'im_last_open_window\');'); }
private function _entryImplementFields($aEntry) { $format_datetime = 'M j, Y g:i a'; $aEntry['bookmark_url'] = Phpfox::permalink('contest', $aEntry['contest_id'], $aEntry['contest_name']) . 'entry_' . $aEntry['entry_id'] . '/'; $aEntry['bitlyUrl'] = Phpfox::getService('contest.entry.process')->getShortBitlyUrl($aEntry['bookmark_url']); $aEntry['is_voted'] = Phpfox::getService('contest.entry.process')->isVoted(Phpfox::getUserId(), $aEntry['entry_id']); $aEntry['submit_date'] = Phpfox::getTime($format_datetime, $aEntry['time_stamp']); $aEntry['approve_date'] = Phpfox::getTime($format_datetime, $aEntry['approve_stamp']); $aEntry['previous'] = Phpfox::getService("contest.entry")->getContestEntryBesideId($aEntry['entry_id'], $aEntry['contest_id'], 'previous'); $aEntry['next'] = Phpfox::getService("contest.entry")->getContestEntryBesideId($aEntry['entry_id'], $aEntry['contest_id'], 'next'); $aEntry['approve'] = $aEntry['status_entry'] == 1 ? 0 : 1; $aEntry['deny'] = $aEntry['status_entry'] == 2 ? 0 : 1; $is_entry_winning = Phpfox::getService("contest.entry")->CheckExistEntryWinning($aEntry['entry_id']); $aEntry['winning'] = $aEntry['contest_status'] == 5 && $is_entry_winning == 0 ? 1 : 0; $aEntry['offaction'] = 0; if ($aEntry['contest_user_id'] != Phpfox::getUserId() && !PHpfox::isAdmin()) { $aEntry['offaction'] = 1; } if (!$aEntry['bitlyUrl']) { $aEntry['bitlyUrl'] = $aEntry['bookmark_url']; } return $aEntry; }
/** * @param int $iId video_id * @return array in the format: * array( * 'title' => 'item title', <-- required * 'link' => 'makeUrl()'ed link', <-- required * 'paypal_msg' => 'message for paypal' <-- required * 'item_id' => int <-- required * 'user_id' => owner's user id <-- required * 'error' => 'phrase if item doesnt exit' <-- optional * 'extra' => 'description' <-- optional * 'image' => 'path to an image', <-- optional * 'image_dir' => 'photo.url_photo|... <-- optional (required if image) * ) */ public function getToSponsorThreadInfo($iId) { $aThread = $this->database()->select('fp.user_id, f.name, f.name_url, fpt.text_parsed as extra, fp.thread_id as item_id, ft.title, ft.title_url') ->from(Phpfox::getT('forum'),'f') ->join(Phpfox::getT('forum_thread'),'ft','ft.forum_id = f.forum_id') ->join(Phpfox::getT('forum_post'),'fp', 'fp.thread_id = ft.thread_id') ->join(Phpfox::getT('forum_post_text'),'fpt','fpt.post_id = fp.post_id') ->where('fp.post_id = ' . (int)$iId) ->execute('getSlaveRow'); if (empty($aThread)) { return array('error' => Phpfox::getPhrase('forum.sponsor_error_not_found')); } $aThread['title'] = Phpfox::getPhrase('forum.sponsor_title',array('sThreadTitle' => $aThread['title'])); $aThread['paypal_msg'] = PHpfox::getPhrase('forum.sponsor_paypal_message', array('sThreadTitle' => $aThread['title'])); $aThread['link'] = Phpfox::getLib('url')->makeUrl('forum.'.$aThread['name_url'].'.'.$aThread['title_url']); return $aThread; }
public function isShowContestEndingSoonLabel($iContestId) { $aContest = Phpfox::getService('contest.contest')->getContestForCheckingPermission($iContestId); if (!$aContest['is_ending_soon']) { return false; } $sSetting = PHpfox::getParam('contest.ending_soon_setting'); $iDay = Phpfox::getParam('contest.ending_soon_before'); $iTime = $iDay * 24 * 3600; $iStartEndingSoonTime = 0; if ($sSetting == 'End of Submission') { $iStartEndingSoonTime = $aContest['stop_time'] - $iTime; } elseif ($sSetting == 'End of Contest') { $iStartEndingSoonTime = $aContest['end_time'] - $iTime; } if (PHPFOX_TIME > $iStartEndingSoonTime && $aContest['contest_status'] == Phpfox::getService('contest.constant')->getContestStatusIdByStatusName('on_going')) { return true; } return false; }
public function winningEntry($aListVals) { $iLastEntryId = null; foreach ($aListVals as $key => $aVals) { $this->database()->delete(PHpfox::getT('contest_winner'), 'entry_id = ' . $aVals['entry_id']); $aInserts = array('entry_id' => $aVals['entry_id'], 'user_id' => $aVals['user_id'], 'award' => $aVals['award'], 'rank' => $aVals['rank'], 'time_stamp' => PHPFOX_TIME); $this->database()->insert(Phpfox::getT('contest_winner'), $aInserts, 'entry_id = ' . $aVals['entry_id']); $iLastEntryId = $aVals['entry_id']; } $aEntry = Phpfox::getService('contest.entry')->getContestEntryById($iLastEntryId); Phpfox::getService('contest.contest.process')->sendNotificationAndEmail('inform_winning_entry', $aEntry['contest_id']); }
public function getListCountries() { $aCountries = Phpfox::getService('core.country')->get(); $sUserCountryIso = PHpfox::getUserBy('country_iso'); $aReturn = array(); foreach ($aCountries as $sIso => $sCountryName) { $aReturn[] = array('iso' => $sIso, 'name' => $sCountryName, 'default' => $sIso == $sUserCountryIso ? true : false); } return $aReturn; }
/** * Get countries * @param null $sValue * @return array */ public function getCountries($sValue = null) { $aReturn = array(); if (!empty($sValue)) { $aCountries = Phpfox::getService('core.country')->getChildren($sValue); if (!empty($aCountries)) { $aReturn[] = array('value' => 0, 'name' => Phpfox::getPhrase('core.state_province'), 'default' => true); } } else { $aCountries = Phpfox::getService('core.country')->get(); $sUserCountryIso = PHpfox::getUserBy('country_iso'); } foreach ($aCountries as $sIso => $sCountryName) { $aReturn[] = array('value' => $sIso, 'name' => $sCountryName, 'default' => isset($sUserCountryIso) && $sIso == $sUserCountryIso ? true : false); } return $aReturn; }
public function getInfoForAction($aItem) { if (is_numeric($aItem)) { $aItem = array('item_id' => $aItem); } $aRow = $this->database()->select('p.post_id, p.thread_id, p.title, pt.text_parsed, p.user_id, u.gender, u.full_name')->from(PHpfox::getT('forum_post'), 'p')->join(Phpfox::getT('forum_post_text'), 'pt', 'pt.post_id = p.post_id')->join(Phpfox::getT('user'), 'u', 'u.user_id = p.user_id')->where('p.post_id = ' . (int) $aItem['item_id'])->execute('getSlaveRow'); if (empty($aRow['title'])) { $aRow['title'] = $aRow['text_parsed']; } $aRow['link'] = Phpfox_Url::instance()->permalink('forum.thread', $aRow['thread_id'], $aRow['title']); return $aRow; }
public function endingSoonContest($iContestId, $iType = 1) { if ($this->database()->update($this->_sTable, array('is_ending_soon' => $iType == '1' ? 1 : 0), 'contest_id = ' . (int) $iContestId)) { if ($iType == 1) { $aContest = Phpfox::getService('contest.contest')->getContestById($iContestId); $sSubject = Phpfox::getPhrase('contest.contest_ending_soon_email_subject', array('title' => $aContest['contest_name'])); $sSetting = PHpfox::getParam('contest.ending_soon_setting'); $iDay = Phpfox::getParam('contest.ending_soon_before'); $iTime = $iDay * 24 * 3600; $iStartEndingSoonTime = 0; if ($sSetting == 'End of Submission') { $sCriteria = Phpfox::getPhrase('contest.end_of_submission'); } elseif ($sSetting == 'End of Contest') { $sCriteria = Phpfox::getPhrase('contest.end_of_contest'); } $sMessage = Phpfox::getPhrase('contest.your_contest_title_has_been_set_ending_soon_link', array('title' => $aContest['contest_name'], 'link' => Phpfox::permalink('contest', $aContest['contest_id'], $aContest['contest_name']), 'num_of_day' => $iDay, 'criteria' => $sCriteria)); //here we use fox mailing function Phpfox::getLib('mail')->sendToSelf(true)->to($aContest['user_id'])->subject($sSubject)->message($sMessage)->send(); } return true; } return false; }
public function getListVotesByEntryId($iEntryId) { $aRows = $this->database()->select('*')->from(Phpfox::getT('contest_entry_vote'), 'env')->join(PHpfox::getT('user'), 'u', 'u.user_id = env.user_id')->where('env.entry_id = ' . $iEntryId)->execute('getRows'); return $aRows; }
public function getProfileMenu($aUser) { $total_contest = PHpfox::getService('contest.contest')->getCountContestByType('profile', $aUser['user_id']); $aUser['total_contest'] = $total_contest; $this->database()->update(Phpfox::getT('user_field'), array('total_contest' => $total_contest), 'user_id = ' . $aUser['user_id']); $aMenus[] = array('phrase' => Phpfox::getPhrase('contest.contest'), 'url' => 'profile.contest', 'total' => (int) (isset($aUser['total_contest']) ? $aUser['total_contest'] : 0), 'icon' => 'feed/contest.png'); return $aMenus; }