Пример #1
0
 public function actionView($id, $view_id)
 {
     if (!($model = ContestEntry::model()->with(array('contest', 'contest.fields', 'items', 'contest.fields.multi' => array('index' => 'id')))->findByPk($view_id))) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $this->render('view', array('model' => $model));
 }
 public static function LoadAll($blnIncludeArchived = false)
 {
     if ($blnIncludeArchived === false) {
         $strExtra = ' WHERE delDate IS NULL';
     } elseif ($blnIncludeArchived === true) {
         $strExtra = ' WHERE delDate IS NOT NULL';
     } elseif (is_null($blnIncludeArchived)) {
         $strExtra = '';
     }
     $sql = sprintf("SELECT * FROM %s %s;", self::TABLE_NAME, $strExtra);
     $result = LoadDriver::query($sql);
     $coll = new BaseEntityCollection();
     while ($data = mysql_fetch_assoc($result)) {
         $tObj = new ContestEntry();
         $tObj->materilize($data);
         $coll->addItem($tObj);
     }
     return $coll;
 }
 public static function AddEntry($arrEntryData)
 {
     if (!FBContestApplication::CanSubmit()) {
         return false;
     }
     $objEntry = new ContestEntry();
     $objEntry->fbuid = FBContestApplication::FBUid();
     $objEntry->creDate = MFBDateTime::Now();
     $objEntry->Save();
     foreach ($arrEntryData as $strName => $arrData) {
         $objEntryAnswer = new ContestFormAnswer();
         $objEntryAnswer->idContestEntry = $objEntry->idContestEntry;
         $objEntryAnswer->name = $strName;
         $objEntryAnswer->idContestFormFieldType = $arrData['type'];
         $objEntryAnswer->value = $arrData['value'];
         $objEntryAnswer->save();
     }
     return true;
 }
Пример #4
0
 public function MFBDeleteBtn_click($mixActionParameter)
 {
     $objContestEntry = ContestEntry::Load($mixActionParameter);
     FBContestApplication::DeleteContestEntry($objContestEntry);
     $this->displayEntries_change();
 }
Пример #5
0
 public function actionDetail($n, $confirmation = 0)
 {
     if (Yii::app()->user->getState('siteVersion') == 'mobile') {
         Yii::app()->clientScript->registerCssFile('/css/mobile/blocs.css');
         $this->layout = '//mobileLayouts/column1';
     }
     if (!($contest = Contest::model()->with(array('fields' => array('order' => 'fields.rank ASC'), 'fields.multi' => array('order' => 'multi.rank ASC')))->find('i18nContest.l_title_url=:n', array('n' => $n)))) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $currentDate = date('Y-m-d H:i:s');
     $contestMultilang = Contest::model()->multilang()->find('i18nContest.l_title_url=:n', array('n' => $n));
     Yii::app()->languageManager->translatedGetVars['n'] = array();
     foreach (array_keys(Yii::app()->languageManager->languages) as $language) {
         Yii::app()->languageManager->translatedGetVars['n'][$language] = $contestMultilang->{'title_url_' . $language};
     }
     // In case detail page is accessed directly and contest is inactive.
     if ($contest->status == "inactive") {
         $this->redirect($this->createUrl('index'));
     }
     if ($confirmation) {
         $this->render('confirmation', array('contest' => $contest));
     } elseif ($contest->end_date !== null && $contest->end_date < $currentDate || $contest->status == "archived") {
         $this->render('conclusion', array('contest' => $contest));
     } else {
         $entry = new EntryForm();
         $validators = $entry->getValidatorList();
         $required = 'verify_code, ';
         $files = '';
         $length = '';
         $email = '';
         $entry->verify_code = null;
         $entry->attributeLabels['verify_code'] = Yii::t('contestModule.common', 'Code de sécurité');
         $validators->add(CValidator::createValidator('captcha', $this, 'verify_code', array('message' => Yii::t('contestModule.common', 'Le code saisi est invalide. Veuillez entrer le code à nouveau.'), 'allowEmpty' => !CCaptcha::checkRequirements(), 'captchaAction' => '/site/captcha')));
         foreach ($contest->fields as $field) {
             $entry->{$field->id} = null;
             $entry->attributeLabels[$field->id] = CHtml::encode($field->title);
             if ($field->required) {
                 $required .= $field->id . ', ';
             }
             $length .= $field->id . ', ';
             if ($field->type == 'email') {
                 $email .= $field->id . ', ';
             }
             if ($field->type == 'file') {
                 $files = $field->id . ', ';
                 $behaviors = array('class' => 'application.models.behaviors.UploadingBehavior.ModelUploadingBehavior', 'attribute' => $field->id, 'dir' => 'files/_user/contest_entries', 'tempDir' => 'files/_user/contest_entries/_temp', 'cacheTime' => 10 * 24 * 60 * 60, 'uploadcare' => null, 'allowDelete' => false);
                 $entry->{$field->id . 'Handler'} = $entry->attachBehavior($field->id . 'Handler', $behaviors);
                 $entry->behaviors = array($behaviors);
             }
         }
         if ($required != '') {
             $validators->add(CValidator::createValidator('required', $this, substr($required, 0, -2)));
         }
         if ($length != '') {
             $validators->add(CValidator::createValidator('length', $this, substr($length, 0, -2), array('max' => 1000)));
         }
         if ($email != '') {
             $validators->add(CValidator::createValidator('email', $this, substr($email, 0, -2)));
         }
         if ($files != '') {
             $validators->add(CValidator::createValidator('file', $this, substr($files, 0, -2), array('allowEmpty' => true)));
         }
         if (isset($_POST['EntryForm'])) {
             foreach ($_POST['EntryForm'] as $id => $attribute) {
                 if (is_array($attribute)) {
                     $entry->{$id} = serialize($attribute);
                 } else {
                     $entry->{$id} = $attribute;
                 }
             }
             if ($entry->validate()) {
                 $entryModel = new ContestEntry();
                 $entryModel->contest_id = $contest->id;
                 $entryModel->ip = $_SERVER['REMOTE_ADDR'];
                 $entryModel->save();
                 foreach ($contest->fields as $field) {
                     if ($field->type == 'checkbox') {
                         $entry->{$field->id} = unserialize($entry->{$field->id});
                     }
                     if (is_array($entry->{$field->id})) {
                         foreach ($entry->{$field->id} as $entryValue) {
                             $model = new ContestEntryItem();
                             $model->contest_entry_id = $entryModel->id;
                             $model->contest_field_id = $field->id;
                             $model->content = $entryValue;
                             $model->save();
                         }
                     } else {
                         $model = new ContestEntryItem();
                         $model->contest_entry_id = $entryModel->id;
                         $model->contest_field_id = $field->id;
                         $model->content = $entry->{$field->id};
                         $model->save();
                     }
                 }
                 if ($contest->send_notification_email == 1) {
                     $message = $this->renderPartial('_notificationEmail', array('entry' => $entryModel, 'contest' => $contest), true);
                     Helper::sendMail($this->module->notificationEmail, 'Nouvelle participation à "' . CHtml::encode($contest->title) . '"', $message);
                 }
                 $this->redirect(array('detail', 'n' => $n, 'confirmation' => 1));
             }
             foreach ($contest->fields as $field) {
                 if ($field->type == 'checkbox') {
                     $entry->{$field->id} = unserialize($entry->{$field->id});
                 }
             }
         }
         $this->render('detail', array('contest' => $contest, 'currentDate' => $currentDate, 'entry' => $entry));
     }
 }
Пример #6
0
        echo Yii::t('contestModule.common', 'Le formulaire de participation sera accessible à partir du') . Helper::formatDate($contest->start_date, "reg") . Yii::t('contestModule.common', 'à') . substr($contest->start_date, 11, 5);
        ?>
.</p>
		
		<?php 
    } elseif ($contest->max_participation !== null && ContestEntry::model()->countByAttributes(array('contest_id' => $contest->id)) >= $contest->max_participation) {
        // Max. participation has been reached.
        ?>
		
		<p class="alert alert-danger"><?php 
        echo Yii::t('contestModule.common', 'Le nombre maximum de participations a été atteint pour ce concours');
        ?>
.</p>
		
		<?php 
    } elseif (!$contest->multiple_entries && ContestEntry::model()->countByAttributes(array('contest_id' => $contest->id, 'ip' => $_SERVER['REMOTE_ADDR'])) > 0) {
        ?>
		
		<p class="alert alert-danger"><?php 
        echo Yii::t('contestModule.common', 'Vous ne pouvez participer plus d’une fois à ce concours/sondage');
        ?>
.</p>
		
		<?php 
    } else {
        $form = $this->beginWidget('CActiveForm', array('id' => 'contest-form', 'enableAjaxValidation' => false, 'errorMessageCssClass' => 'alert alert-danger', 'action' => array('detail', 'n' => $contest->title_url, '#' => 'contest-form'), 'htmlOptions' => array('enctype' => 'multipart/form-data')));
        ?>
			
			<p class="text-small"><span class="required">*</span> = <?php 
        echo Yii::t('common', 'champs obligatoires');
        ?>