Exemple #1
0
 private static function addComment($from)
 {
     $notice = Notice::findOne(['type' => self::TYPE_COMMENT, 'topic_id' => $from['topic_id'], 'status' => 0]);
     if ($notice) {
         if ($notice->position == $from['position']) {
             return;
         } else {
             $notice->updateCounters(['notice_count' => 1]);
             return;
         }
     }
     $notice = new Notice($from);
     $notice->save(false);
 }
Exemple #2
0
 private static function addComment($from)
 {
     $notice = Notice::findOne(['type' => self::TYPE_COMMENT, 'topic_id' => $from['topic_id'], 'status' => 0]);
     if ($notice) {
         return $notice->updateCounters(['notice_count' => 1]);
     }
     if (!($topic = Topic::find()->select(['user_id'])->where(['id' => $from['topic_id']])->asArray()->one())) {
         return false;
     }
     if ($topic['user_id'] == $from['source_id']) {
         return true;
     }
     $notice = new Notice($from);
     //		$notice->attributes = $from;
     $notice->target_id = $topic['user_id'];
     return $notice->save(false);
 }
 /**
  * Finds the Notice model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Notice the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Notice::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionDelete($id)
 {
     Notice::findOne($id)->delete();
     $this->redirect('/notice/index');
 }