コード例 #1
0
 public function actionMarkSpam($id, $spam = 1)
 {
     if ($spam === 1) {
         $message = Yii::t('app', 'Entry successfully marked as spam');
     } else {
         $message = Yii::t('app', 'Entry successfully marked as not spam');
     }
     /** @var Submission $submission */
     $submission = Submission::findOne($id);
     if (is_null($submission)) {
         throw new NotFoundHttpException();
     }
     $submission->spam = $spam;
     if ($spam == 1) {
         /** @var Review $review */
         $review = Review::findOne(['submission_id' => $id]);
         if (!is_null($review)) {
             $review->status = Review::STATUS_NOT_APPROVED;
             $review->save(true, ['status']);
         }
     }
     if ($submission->save(true, ['spam'])) {
         Yii::$app->session->setFlash('success', $message);
     }
     return $this->redirect(Url::toRoute(['view', 'id' => $id]));
 }
コード例 #2
0
 public static function saveReviewProperties(AfterSaveEvent $event)
 {
     $submission = null;
     $reviewId = Yii::$app->request->get('id');
     $post = Yii::$app->request->post();
     if (null !== ($review = Review::findOne(['id' => $reviewId]))) {
         $submission = Submission::findOne(['id' => $review->submission_id]);
     } else {
         $m = preg_grep('%Properties_Submission_([\\d]+)$%', array_keys($post));
         if (false === empty($m)) {
             $submissionId = array_pop(explode('_', array_shift($m)));
             $submission = Submission::findOne(['id' => $submissionId]);
         }
     }
     if (null !== $submission) {
         if (isset($post['Submission'])) {
             $submission->attributes = $post['Submission'];
             $submission->save();
         }
         $submission->saveProperties($post);
     }
 }
コード例 #3
0
 public function actionDownload($key, $sumissionId)
 {
     $submission = Submission::findOne($sumissionId);
     if ($submission === null) {
         throw new NotFoundHttpException('Submission not found');
     }
     $prop = $submission->getPropertyValuesByKey($key);
     return \Yii::$app->response->sendFile(Yii::getAlias("@webroot") . $prop->values[0]['value']);
 }
コード例 #4
0
ファイル: FormController.php プロジェクト: tqsq2005/dotplant2
 public function actionDownload($key, $submissionId)
 {
     $submission = Submission::findOne($submissionId);
     if ($submission === null) {
         throw new NotFoundHttpException('Submission not found');
     }
     $prop = $submission->getPropertyValuesByKey($key);
     return \Yii::$app->response->sendFile(Yii::getAlias(Yii::$app->getModule('core')->visitorsFileUploadPath) . DIRECTORY_SEPARATOR . $prop->values[0]['value']);
 }