Example #1
0
 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;
     }
 }
Example #2
0
 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';
 }
Example #3
0
 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;
 }
Example #4
0
 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;
 }