Пример #1
0
 static function createContest($data)
 {
     require_once "common.php";
     $data = Filter::filterArray($data);
     $c = new Contest($data);
     $c->save();
     return $c;
 }
 /**
  * @see Form::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     // get contest
     if (!$this->contest->isCommentable()) {
         throw new PermissionDeniedException();
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (!MODULE_CONTEST) {
         throw new IllegalLinkException();
     }
     $this->contestID = intval($_REQUEST['contestID']);
     if (isset($_REQUEST['contestAction'])) {
         $this->contestAction = $_REQUEST['contestAction'];
     }
     $this->contest = new Contest($this->contestID);
     if (!$this->contest->isViewable()) {
         throw new IllegalLinkException();
     }
 }
 /**
  * @see Form::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // display branding
     require_once WCF_DIR . 'lib/util/ContestUtil.class.php';
     ContestUtil::assignVariablesBranding();
     // save ratings
     if ($this->solutionObj->isRateable()) {
         require_once WCF_DIR . 'lib/form/ContestSolutionRatingUpdateForm.class.php';
         new ContestSolutionRatingUpdateForm($this->solutionObj);
     }
     // init form
     if ($this->action == 'edit') {
         require_once WCF_DIR . 'lib/form/ContestSolutionCommentEditForm.class.php';
         new ContestSolutionCommentEditForm($this->solutionObj);
     } else {
         if ($this->entry->isCommentable()) {
             require_once WCF_DIR . 'lib/form/ContestSolutionCommentAddForm.class.php';
             new ContestSolutionCommentAddForm($this->solutionObj);
         }
     }
     if (!$this->entry->enableOpenSolution && $this->entry->state != 'closed' && ($this->entry->state != 'scheduled' || !($this->entry->fromTime < TIME_NOW && TIME_NOW < $this->entry->untilTime))) {
         WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.enableOpenSolution.info') . '</p>');
     }
     if ($this->entry->enableParticipantCheck) {
         WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.enableParticipantCheck.info') . '</p>');
     }
     $this->sidebar->assignVariables();
     WCF::getTPL()->assign(array('entry' => $this->entry, 'solutionObj' => $this->solutionObj, 'contestID' => $this->contestID, 'solutionID' => $this->solutionID, 'userID' => $this->entry->userID, 'comments' => $this->commentList->getObjects(), 'ratings' => $this->ratingList->getObjects(), 'todos' => $this->todoList ? $this->todoList->getObjects() : array(), 'templateName' => $this->templateName, 'allowSpidersToIndexThisPage' => true, 'attachments' => $this->attachments, 'contestmenu' => ContestMenu::getInstance()));
 }
Пример #5
0
 public function actionShow($id)
 {
     $model = Contest::model()->findByPk((int) $id);
     if (is_null($model)) {
         throw new CHttpException(404, Yii::t('contest', 'Страница не найдена!'));
     }
     $image = new Image();
     if (Yii::app()->request->isPostRequest && isset($_POST['Image'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $image = $image->create($_POST['Image']);
             if (!$image->hasErrors()) {
                 if ($model->addImage($image)) {
                     Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('contest', 'Фотография добавлена!'));
                 }
                 $transaction->commit();
                 $this->redirect(array('/contest/contest/show/', 'id' => $model->id));
             }
             throw new CDbException(Yii::t('contest', 'При добавлении изображения произошла ошибка!'));
         } catch (Exception $e) {
             $transaction->rollback();
             Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('contest', $e->getMessage()));
         }
     }
     $dataProvider = new CActiveDataProvider('ImageToContest', array('criteria' => array('condition' => 'contest_id = :contest_id', 'params' => array(':contest_id' => $model->id), 'limit' => self::CONTEST_PER_PAGE, 'order' => 't.creation_date DESC', 'with' => 'image'), 'pagination' => array('pageSize' => self::CONTEST_PER_PAGE)));
     $this->render('show', array('image' => $image, 'dataProvider' => $dataProvider, 'model' => $model));
 }
Пример #6
0
 public function actionStats($id)
 {
     if (!($model = Contest::model()->with(array('fields'))->findByPk($id))) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $this->render('stats', array('model' => $model));
 }
 /**
  * @see ContestNotificationInterface::getRecipients()
  */
 public function getRecipients()
 {
     $ids = array();
     switch ($this->state) {
         // tell contest owner that s.o. did apply
         case 'applied':
             require_once WCF_DIR . 'lib/data/contest/Contest.class.php';
             $contest = Contest::getInstance($this->contestID);
             $ids = array_merge($ids, $contest->getOwner()->getUserIDs());
             break;
         case 'invited':
             $ids = array_merge($ids, $this->getInstance()->getOwner()->getUserIDs());
             break;
             // tell recipient that s.o. did moderator interaction
         // tell recipient that s.o. did moderator interaction
         case 'accepted':
             $ids = array_merge($ids, $this->getInstance()->getOwner()->getUserIDs());
             // maybe the user applied himself, then tell the owners
             require_once WCF_DIR . 'lib/data/contest/Contest.class.php';
             $contest = Contest::getInstance($this->contestID);
             if ($contest->enableSponsorCheck == false) {
                 $ids = array_merge($ids, $contest->getOwner()->getUserIDs());
             }
             break;
     }
     return array_unique($ids);
 }
Пример #8
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Contest::create([]);
     }
 }
Пример #9
0
 public function Insert(Contest $data)
 {
     try {
         $query = "INSERT INTO Concursos (id_type, name, question, initial_date, final_date, winner, active)\n                          VALUES (?, ?, ?, ?, ?, ?, ?)";
         $this->pdo->prepare($query)->execute(array($data->__GET('id_type'), $data->__GET('name'), $data->__GET('question'), $data->__GET('initial_date'), $data->__GET('final_date'), $data->__GET('winner'), $data->__GET('active')));
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
 /**
  * finish the contest
  */
 public function close()
 {
     if (!($this->contest->state == 'scheduled' && $this->contest->untilTime < time())) {
         throw new Exception('contest needs to be scheduled, and time has to be over.');
     }
     // make a jury instance from the contst owner
     $jury = ContestJury::find($this->contest->contestID, $this->contest->userID, $this->contest->groupID);
     if ($jury === null) {
         $jury = ContestJuryEditor::create($this->contest->contestID, $this->contest->userID, $this->contest->groupID, $state = 'accepted');
     }
     $userID = $this->contest->userID;
     if ($userID == 0 && $this->contest->groupID > 0) {
         $sql = "SELECT          userID\n\t\t\t\tFROM            wcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE           groupID = " . intval($this->contest->groupID);
         $row = WCF::getDB()->getFirstRow($sql);
         $userID = $row['userID'];
     }
     if (!$userID) {
         throw new Exception('cannot determine a user from which the ratings will be added.');
     }
     $classIDs = array_keys($this->contest->getClasses());
     $ratingoptionIDs = array_keys(ContestRatingoption::getByClassIDs($classIDs));
     if (empty($ratingoptionIDs)) {
         throw new Exception('cannot determine a ratingoption from classes [' . implode(',', $classIDs) . '] needed for contest ratings to be added.');
     }
     // get interactions
     $interactionList = new ContestInteractionList($this->contest);
     $interactionList->sqlLimit = 0;
     $interactionList->readObjects();
     $owners = $interactionList->getObjects();
     foreach ($owners as $owner) {
         $this->sum += $owner->c;
     }
     // get prices
     $priceList = new ContestPriceList();
     $priceList->sqlConditions .= 'contest_price.state = "accepted" AND contest_price.contestID = ' . intval($this->contest->contestID);
     $priceList->sqlLimit = 0;
     $priceList->readObjects();
     $score = 5 + $priceList->countObjects();
     foreach ($priceList->getObjects() as $price) {
         // choose a winner
         $owner = $this->chooseWinner($price, $owners);
         // error, there are more prices than participants
         if (!$owner) {
             throw new Exception('there are more prices than participants.');
         }
         $lang = 'wcf.contest.interaction.tickets.solution';
         $message = WCF::getLanguage()->getDynamicVariable($lang, array('tickets' => $owner->c));
         // create pseudo solution
         $solution = ContestSolutionEditor::create($this->contest->contestID, $owner->participantID, $message, $state = 'accepted');
         foreach ($ratingoptionIDs as $ratingOptionID) {
             // create pseudo rating
             $rating = ContestSolutionRatingEditor::create($solution->solutionID, $ratingOptionID, $score, $userID);
         }
         // decrease score
         $score--;
     }
     // close contest state
     $this->contest->getEditor()->updateState('closed');
 }
 public function execute()
 {
     if (!ContestSettings::get('contestDeletionEnabled')) {
         $this->dieUsage('Contest deletion is disabled', 'contestdeletiondisabled');
     }
     global $wgUser;
     if (!$wgUser->isAllowed('contestadmin') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $everythingOk = true;
     foreach ($params['ids'] as $id) {
         $contest = new Contest(array('id' => $id));
         $everythingOk = $contest->removeAllFromDB() && $everythingOk;
     }
     $this->getResult()->addValue(null, 'success', $everythingOk);
 }
 /**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\tuser_table.username, contest.*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest contest\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = contest.userID)\n\t\t\t" . $this->sqlJoins . "\n\t\t\t" . (!empty($this->sqlConditions) ? "WHERE (" . $this->sqlConditions . ")" : '') . "\n\t\t\tAND (" . Contest::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->entries[] = new ContestFeedEntry(null, $row);
     }
 }
Пример #13
0
 /**
  * Returns true, if the active user can delete this entry.
  * 
  * @return	boolean
  */
 public function isDeletable()
 {
     $contest = Contest::getInstance($this->contestID);
     if ($contest->isOwner()) {
         return true;
     }
     return false;
 }
 /**
  * returns available states
  */
 protected function getStates()
 {
     $flags = (!isset($this->entry) || $this->entry->isOwner() ? ContestState::FLAG_USER : 0) + ($this->contest->isOwner() ? ContestState::FLAG_CONTESTOWNER : 0) + (ContestCrew::isMember() ? ContestState::FLAG_CREW : 0);
     if (isset($this->entry) && $this->entry->enableOpenSolution) {
         $flags += ContestSolutionEditor::FLAG_OPENSOLUTION;
     }
     return ContestSolutionEditor::getStates(isset($this->entry) ? $this->entry->state : '', $flags);
 }
Пример #15
0
 /**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\tcontest.*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest contest\n\t\t\t" . $this->sqlJoins . "\n\n\t\t\tWHERE\t\t(" . Contest::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->entries[] = new Contest(null, $row);
     }
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     // get entry
     if (isset($_REQUEST['contestID'])) {
         $this->contestID = intval($_REQUEST['contestID']);
     }
     $this->entry = new ViewableContest($this->contestID);
     if (!$this->entry->isViewable()) {
         throw new IllegalLinkException();
     }
     // validation
     if ($this->entry->enableInteraction == 0) {
         throw new Exception('invalid contest type');
     }
     // init price list
     $this->interactionList = new ContestInteractionList($this->entry);
 }
 /**
  * @see ContestNotificationInterface::getRecipients()
  */
 public function getRecipients()
 {
     $ids = array();
     // tell all jury members, that a new entry exists
     require_once WCF_DIR . 'lib/data/contest/Contest.class.php';
     $contest = Contest::getInstance($this->contestID);
     foreach ($contest->getJurys() as $jury) {
         $ids = array_merge($ids, $jury->getOwner()->getUserIDs());
     }
     return array_unique($ids);
 }
 /**
  * Gets the object ids.
  */
 protected function readObjectIDArray()
 {
     $sql = "SELECT\t\tcontest.contestID, contest.attachments\n\t\t\tFROM\t\twcf" . WCF_N . "_contest contest\n\t\t\t\t" . $this->sqlJoins . "\n\t\t\tWHERE (" . Contest::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND (" . $this->sqlConditions . ")" : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->objectIDArray[] = $row['contestID'];
         if ($row['attachments']) {
             $this->attachmentEntryIDArray[] = $row['contestID'];
         }
     }
 }
 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('contestadmin') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $everythingOk = true;
     $contestIds = is_null($params['contestids']) ? array() : $params['contestids'];
     $challengeIds = is_null($params['challengeids']) ? array() : $params['challengeids'];
     if (!is_null($params['challengetitles'])) {
         $challenges = ContestChallenge::s()->select('id', array('title' => $params['challengetitles']));
         if ($challenges === false) {
             // TODO: error
         }
         foreach ($challenges as $challenge) {
             $challengeIds[] = $challenge->getId();
         }
     }
     if (!is_null($params['contestnames'])) {
         $contests = Contest::s()->select('id', array('name' => $params['contestnames']));
         if ($contests === false) {
             // TODO: error
         }
         foreach ($contests as $contest) {
             $contestIds[] = $contest->getId();
         }
     }
     $conditions = array();
     if (count($contestIds) > 0) {
         $conditions['contest_id'] = $contestIds;
     }
     if (count($challengeIds) > 0) {
         $conditions['challenge_id'] = $challengeIds;
     }
     if (!is_null($params['ids']) && count($params['ids']) > 0) {
         $conditions['id'] = $params['ids'];
     }
     $contestants = ContestContestant::s()->select(array('id', 'user_id', 'contest_id', 'email'), $conditions);
     $contestantCount = count($contestants);
     if ($contestants !== false && $contestantCount > 0) {
         $setSize = ContestSettings::get('reminderJobSize');
         $limit = count($contestants);
         for ($i = 0; $i <= $limit; $i += $setSize) {
             $this->createReminderJob(array_slice($contestants, $i, $setSize));
         }
     } else {
         $everythingOk = false;
     }
     $this->getResult()->addValue(null, 'success', $everythingOk);
     if ($everythingOk) {
         $this->getResult()->addValue(null, 'contestantcount', $contestantCount);
     }
 }
 /**
  * Gets the object ids.
  */
 protected function readObjectIDArray()
 {
     $sql = "SELECT\t\tcontest.contestID, contest.attachments\n\t\t\tFROM\t\twcf" . WCF_N . "_tag_to_object tag_to_object,\n\t\t\t\t\twcf" . WCF_N . "_contest contest\n\t\t\tWHERE\t\ttag_to_object.tagID = " . intval($this->tagID) . "\n\t\t\t\t\tAND tag_to_object.taggableID = " . $this->taggable->getTaggableID() . "\n\t\t\t\t\tAND contest.contestID = tag_to_object.objectID\n\t\t\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '') . "\n\t\t\t\t\tAND (" . Contest::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->objectIDArray[] = $row['contestID'];
         if ($row['attachments']) {
             $this->attachmentEntryIDArray[] = $row['contestID'];
         }
     }
 }
Пример #21
0
 public function index()
 {
     // $this->layout->content =
     if (Sentry::getUser()->hasPermission('admin')) {
         return View::make('dashboard.indexadmin')->withtitle("Dashboard Admin");
     } elseif (Sentry::getUser()->hasPermission('panitia')) {
         return View::make('dashboard.indexadmin')->withtitle("Dashboard Panitia");
     } elseif (Sentry::getUser()->hasPermission('user')) {
         $menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
         $jenjang = Sentry::getUser()->last_name;
         if ($jenjang === 'SMA') {
             $runpas = Contest::where('nocontest', 'Lari 100m pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $runpis = Contest::where('nocontest', 'Lari 100m pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpas = Contest::where('nocontest', 'Lompat Jauh pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpis = Contest::where('nocontest', 'Lompat Jauh pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $tppas = Contest::where('nocontest', 'Tolak Peluru pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $tppis = Contest::where('nocontest', 'Tolak Peluru pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ltpas = Contest::where('nocontest', 'Lompat Tinggi pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ltpis = Contest::where('nocontest', 'Lompat Tinggi pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $juma = Contest::where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $jumpa = $runpas + $ljpas + $tppas + $ltpas;
             $jumpi = $runpis + $ljpis + $tppis + $ltpis;
             return View::make('dashboard.indexuser')->withtitle("Dashboard User")->with('menu', $menu)->with('runpas', $runpas)->with('runpis', $runpis)->with('ljpas', $ljpas)->with('ljpis', $ljpis)->with('tppas', $tppas)->with('tppis', $tppis)->with('ltpas', $ltpas)->with('ltpis', $ltpis)->with('juma', $juma)->with('jumpa', $jumpa)->with('jumpi', $jumpi);
         } elseif ($jenjang === 'SMP') {
             $runpas = Contest::where('nocontest', 'Lari 60m pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $runpis = Contest::where('nocontest', 'Lari 60m pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpas = Contest::where('nocontest', 'Lompat Jauh pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpis = Contest::where('nocontest', 'Lompat Jauh pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $tppas = Contest::where('nocontest', 'Tolak Peluru pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $tppis = Contest::where('nocontest', 'Tolak Peluru pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ltpas = Contest::where('nocontest', 'Lompat Tinggi pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ltpis = Contest::where('nocontest', 'Lompat Tinggi pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $juma = Contest::where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $jumpa = $runpas + $ljpas + $tppas + $ltpas;
             $jumpi = $runpis + $ljpis + $tppis + $ltpis;
             return View::make('dashboard.indexuser')->withtitle("Dashboard User")->with('menu', $menu)->with('runpas', $runpas)->with('runpis', $runpis)->with('ljpas', $ljpas)->with('ljpis', $ljpis)->with('tppas', $tppas)->with('tppis', $tppis)->with('ltpas', $ltpas)->with('ltpis', $ltpis)->with('juma', $juma)->with('jumpa', $jumpa)->with('jumpi', $jumpi);
         } elseif ($jenjang === 'SD') {
             $runpas = Contest::where('nocontest', 'Lari 50m pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $runpis = Contest::where('nocontest', 'Lari 50m pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpas = Contest::where('nocontest', 'Lompat Jauh pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $ljpis = Contest::where('nocontest', 'Lompat Jauh pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $lbpas = Contest::where('nocontest', 'Lempar Bola pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $lbpis = Contest::where('nocontest', 'Lempar Bola pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $lespa = Contest::where('nocontest', 'Lari Estafet pa')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $lespi = Contest::where('nocontest', 'Lari Estafet pi')->where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $juma = Contest::where('user_id', Sentry::getUser()->id)->where(DB::raw('tahun'), '=', date('Y'))->count();
             $jumpa = $runpas + $ljpas + $lbpas + $lespa;
             $jumpi = $runpis + $ljpis + $lbpis + $lespi;
             return View::make('dashboard.indexuser')->withtitle("Dashboard User")->with('menu', $menu)->with('runpas', $runpas)->with('runpis', $runpis)->with('ljpas', $ljpas)->with('ljpis', $ljpis)->with('lbpas', $lbpas)->with('lbpis', $lbpis)->with('lespa', $lespa)->with('lespi', $lespi)->with('juma', $juma)->with('jumpa', $jumpa)->with('jumpi', $jumpi);
         }
     }
 }
Пример #22
0
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->view->error_message = "You need to login to change the contest.";
         return;
     }
     $contest = $this->_request->get("contest");
     $contestM = Contest::factory($contest);
     if (!$contestM->authenticateUser($auth->getIdentity())) {
         $this->view->error_message = "You have not been granted access to this contest. This might be a restricted contest.";
         return;
     }
     $session = new Zend_Session_Namespace(webconfig::$session_namespace);
     $session->contestid = $contest;
     $session->contestname = "Custom Contest";
     $this->_redirect("/");
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     if (!MODULE_CONTEST) {
         echo "Das Contest Modul ist komplett deaktiviert, " . "aktiviere es im Admin Control Panel unter System > Optionen > Module an/aus<br />";
     }
     if (WCF::getUser()->getPermission('user.contest.canViewContest') == false) {
         echo "Deine Benutzergruppe darf keine Contests nutzen, überprüfe die Benutzerrechte unter " . "Benutzer > Benutzergruppen auflisten > bearbeiten > Allgemeine Rechte > Wettbewerb<br />";
     }
     // get entry
     if (isset($_REQUEST['contestID'])) {
         $this->contestID = intval($_REQUEST['contestID']);
     }
     $this->entry = new ViewableContest($this->contestID);
     if (!$this->entry->contestID) {
         echo "Der angegebene Contest existiert nicht, überprüfe den aufgerufenen Link<br />";
     }
     if ($this->entry->state != 'scheduled') {
         echo "Damit der Contest für andere Benutzer sichtbar ist, musst du den Status auf 'geplant' ändern.<br />";
     }
     if ($this->entry->fromTime > TIME_NOW) {
         echo "Damit der Contest für andere Benutzer sichtbar ist, muss die Startzeit erreicht werden.<br />";
     }
     if ($this->entry->isOwner()) {
         echo "Du bist selbst der Besitzer, daher kannst du nicht am Contest teilnehmen.<br />";
     }
     if ($this->entry->state == 'closed' || !($this->entry->state == 'scheduled' && $this->entry->untilTime > TIME_NOW)) {
         echo "Der Contest ist beendet, daher kannst du nicht am Contest teilnehmen.<br />";
     }
     if ($this->entry->state == 'closed' || !($this->entry->state == 'scheduled' && $this->entry->untilTime > TIME_NOW)) {
         echo "Der Contest ist beendet, daher kannst du nicht am Contest teilnehmen.<br />";
     }
     foreach ($this->entry->getJurys() as $jury) {
         if ($jury->isOwner()) {
             echo "Du bist in der Jury und kannst deswegen nicht am Contest teilnehmen.<br />";
         }
     }
     // alreay participant
     $isParticipant = false;
     foreach ($this->entry->getParticipants() as $participant) {
         if ($participant->isOwner()) {
             $isParticipant = true;
             echo "Du bist bereits Teilnehmer am am Contest.<br />";
         }
     }
     if (!$isParticipant && !$this->entry->isParticipantable()) {
         echo "Du kannst nicht am Contest teilnehmen!<br />";
     }
     if (!$this->entry->isViewable()) {
         echo "Du kannst den Contest nicht sehen!<br />";
     }
     parent::show();
 }
Пример #24
0
 /**
  * @see Page::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // display branding
     require_once WCF_DIR . 'lib/util/ContestUtil.class.php';
     ContestUtil::assignVariablesBranding();
     // init form
     if ($this->action == 'edit') {
         require_once WCF_DIR . 'lib/form/ContestCommentEditForm.class.php';
         new ContestCommentEditForm($this->entry);
     } else {
         if ($this->entry->isCommentable()) {
             require_once WCF_DIR . 'lib/form/ContestCommentAddForm.class.php';
             new ContestCommentAddForm($this->entry);
         }
     }
     $this->sidebar->assignVariables();
     WCF::getTPL()->assign(array('entry' => $this->entry, 'contestID' => $this->contestID, 'tags' => MODULE_TAGGING ? $this->entry->getTags(WCF::getSession()->getVisibleLanguageIDArray()) : array(), 'events' => $this->eventmixList->getObjects(), 'todos' => $this->todoList ? $this->todoList->getObjects() : array(), 'classes' => $this->entry->getClasses(), 'jurys' => $this->entry->getJurys(), 'participants' => $this->entry->getParticipants(), 'attachments' => $this->attachments, 'location' => $this->entry->location, 'action' => $this->action, 'commentID' => $this->commentID, 'previousEntry' => $this->previousEntry, 'nextEntry' => $this->nextEntry, 'templateName' => $this->templateName, 'allowSpidersToIndexThisPage' => true, 'contestmenu' => ContestMenu::getInstance()));
 }
Пример #25
0
 public function getContestState($contestname)
 {
     $contest = Contest::factory((string) $contestname);
     if (empty($contest)) {
         return "before";
     }
     $start = $contest->getContestTime();
     $end = $contest->getContestEndTime();
     $current = time();
     if ($current < $start) {
         return "before";
     }
     if ($current < $end) {
         return "ongoing";
     }
     if (!$contest->isResultDeclared()) {
         return "pending_result";
     }
     return "after";
 }
Пример #26
0
 public function indexAction()
 {
     $page = $this->getRequest()->get("page");
     $contest = Contest::factory(webconfig::getContestId());
     if (!$contest) {
         return;
     }
     $xp = $contest->getXPath();
     $res = $xp->query("/contest/frontend/page[@id='{$page}']/@href");
     $href = $res->item(0)->nodeValue;
     if (substr($href, 0, 5) == "http:" or substr($href, 0, 6) == "https:") {
         $this->_redirect($href);
     }
     $file = config::getFilename("data/contests/" . $res->item(0)->nodeValue);
     if (!is_file($file)) {
         echo "Please edit '{$file}' to view this page.";
     } else {
         echo file_get_contents($file);
     }
 }
 /**
  * @see ContestNotificationInterface::getRecipients()
  */
 public function getRecipients()
 {
     $ids = array();
     switch ($this->state) {
         // tell contest jury that a solution was commited
         case 'applied':
             require_once WCF_DIR . 'lib/data/contest/Contest.class.php';
             $contest = Contest::getInstance($this->contestID);
             foreach ($contest->getJurys() as $jury) {
                 $ids = array_merge($ids, $jury->getOwner()->getUserIDs());
             }
             break;
             // tell solution member, that moderator did interaction
         // tell solution member, that moderator did interaction
         case 'accepted':
         case 'declined':
             $ids = array_merge($ids, $this->getInstance()->getOwner()->getUserIDs());
             break;
     }
     return array_unique($ids);
 }
Пример #28
0
<?php

require_once "common.php";
require_once $NPADMIN_PATH . "API.php";
$contestId = $_GET['contest_id'];
$contest = Contest::loadContest($contestId);
if ($contest->status !== STATUS_FINISHED) {
    npadmin_security($contest->getAllowedGroups(), false, _("You are not invited to this contest"), true);
    $userId = npadmin_loginData()->getUser()->userId;
} else {
    $userId = null;
}
if ($contest->status === STATUS_OPEN) {
    $photos = $contest->photosOfUser($userId);
} else {
    $photos = $contest->photosOfUser(null);
    if ($contest->status === STATUS_VOTING) {
        shuffle($photos);
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

    <head>
        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
        <style type="text/css" media="all">
        @import url("static/style.css");
        </style>
        
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 /**
  * Gets a list of contests that can be fed directly to the options field of
  * an HTMLForm radio input.
  * challenge title => challenge id
  *
  * @since 0.1
  *
  * @param Contest $contest
  *
  * @return array
  */
 protected function getChallengesList(Contest $contest)
 {
     $list = array();
     foreach ($contest->getChallenges() as $challenge) {
         $list[$challenge->getField('title')] = $challenge->getId();
     }
     return $list;
 }
 /**
  * Tests the overriding reloadOnInsert at runtime.
  *
  * @link       http://trac.propelorm.org/ticket/378
  * @link       http://trac.propelorm.org/ticket/555
  */
 public function testDefaultExpresions_ReloadOnInsert_Override()
 {
     if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
         $this->markTestSkipped("Cannot test default date expressions with SQLite");
     }
     // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry
     $b = new Bookstore();
     $b->setStoreName("Barnes & Noble");
     $b->save();
     $c = new Contest();
     $c->setName("Bookathon Contest");
     $c->save();
     $bc = new BookstoreContest();
     $bc->setBookstore($b);
     $bc->setContest($c);
     $bc->save();
     $c = new Customer();
     $c->setName("Happy Customer");
     $c->save();
     $bce = new BookstoreContestEntry();
     $bce->setBookstore($b);
     $bce->setBookstoreContest($bc);
     $bce->setCustomer($c);
     $bce->save(null, $skipReload = true);
     $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save.");
 }