Example #1
0
 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
 }
Example #2
0
 private function _view($sView)
 {
     switch ($sView) {
         case 'pending_entries':
             Phpfox::isUser(true);
             if (!Phpfox::isAdmin()) {
                 $this->search()->setCondition('AND en.status = 0 and ct.user_id = ' . PHpfox::getUserId());
             } else {
                 $this->search()->setCondition('AND en.status = 0 ');
             }
             break;
         default:
             Phpfox::isUser(true);
             $this->search()->setCondition('AND en.user_id = ' . Phpfox::getUserId());
             break;
     }
 }
Example #3
0
 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;
 }
Example #4
0
 public function getCountContestByType($type, $user_id = 0)
 {
     $where = '(ct.contest_status = 4 OR ct.contest_status = 5)';
     if ($type != 'myinactive') {
         $where .= "  and ct.is_active = 1 ";
     } else {
         $where .= "  and ct.is_active = 0 ";
     }
     $type_contest = array('blog' => '1', 'music' => '4', 'photo' => '2', 'video' => '3');
     switch ($type) {
         case 'blog':
         case 'music':
         case 'photo':
         case 'video':
             $where .= " and ct.type = " . $type_contest[$type];
             break;
         case 'profile':
             $where .= " and ct.user_id = " . $user_id;
         case 'myinactive':
             $where .= " and ct.user_id = " . PHpfox::getUserId();
             break;
     }
     $iCount = $this->database()->select('count(*)')->from(Phpfox::getT('contest'), 'ct')->where($where)->execute('getField');
     return $iCount;
 }