コード例 #1
0
 /**
  * Creates a new Message model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     $model = new Message();
     $model->recipient_id = $id;
     $model->sender_id = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
     }
     return $this->renderAjax('create', ['model' => $model]);
 }
コード例 #2
0
ファイル: MessageController.php プロジェクト: buuug7/game4039
 /**
  * Creates a new Message model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Message();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #3
0
 /**
  * Translates current message to any given language: updates or creates new
  * Message model with translation text given
  * @param string $language    Language to translate to
  * @param string $translation Text to be applied as translation
  * @return bool               Whether operation is successful or not
  */
 public function translate($language, $translation)
 {
     $params = ['id' => $this->id, 'language' => $language];
     $model = Message::findOne($params);
     if (empty($model)) {
         $model = new Message($params);
     }
     $model->translation = $translation;
     return $model->save();
 }
コード例 #4
0
 /**
  * Creates a new Message model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Message();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', '留言提交成功,我们会尽快回复');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #5
0
 /**
  * Creates a new Message model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Message();
     $model->status = 1;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('message-create-success');
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #6
0
ファイル: Messages.php プロジェクト: ninetor/yii-classifield
 /**
  * @inheritdoc
  */
 public function send(MessageForm $message, User $user)
 {
     if ($message->validate()) {
         $node = new Message($message->attributes);
         $node->from = $this->user->id;
         if ($node->validate() && $node->save(false)) {
             return $node;
         }
     }
     return null;
 }
コード例 #7
0
 public function addMessage()
 {
     foreach ($this->receiver as $receiverId) {
         $message = new Message();
         $message['subject'] = $this->subject;
         $message['content'] = $this->content;
         $message['create_at'] = $this->create_at;
         $message['status'] = $this->status;
         $message['sender_id'] = $this->sender_id;
         $message['receiver_id'] = $receiverId;
         $message->save();
     }
 }
コード例 #8
0
 public function actionCreate()
 {
     $model = new Message();
     $parseData['model'] = $model;
     $parseData['sensors'] = $this->getSensor();
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         $model->load($post);
         $model->save();
         return $this->redirect(['index']);
     }
     return $this->render('create', $parseData);
 }
コード例 #9
0
ファイル: Message.php プロジェクト: smilehaha/bag-test
 /**
  * 添加关注日志
  * @param integer $from_uid 发送者uid
  * @param integer $to_uid   接受者uid
  * @param boolean $is_concern true关注,false取消关注
  * @return boolean
  */
 public static function addConcernLog($from_uid, $to_uid, $is_concern = true, $table_id = 0)
 {
     $model = new Message();
     $model->from_uid = $from_uid;
     $model->to_uid = $to_uid;
     if ($is_concern) {
         $model->title = '关注';
         $model->content = '关注成功';
     } else {
         $model->title = '取消关注';
         $model->content = '取消关注';
     }
     $model->group_id = '';
     $model->table = 'users_friends';
     $model->table_id = $table_id;
     $model->add_time = date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']);
     return $model->save();
 }
コード例 #10
0
 /**
  * 发布评论
  */
 public function actionAdd()
 {
     $id = Yii::$app->request->get('id', 0);
     $id = $id ? (int) $id : 0;
     $to_uid = Yii::$app->request->get('tid', 0);
     $to_uid = $to_uid ? (int) $to_uid : 0;
     $uid = ZCommonSessionFun::get_user_id();
     $content = Yii::$app->request->get('content', '');
     //         if ($id < 1)
     //             ZCommonFun::output_json(null, 1, '页面不存在');
     /*
      * if($to_uid < 1 )
      * ZCommonFun::output_json(null, 1, '页面不存在3');
      */
     if (empty($content)) {
         ZCommonFun::output_json(null, 2, '评论内容不能为空');
     }
     if ($uid < 1) {
         ZCommonFun::output_json(null, -1, '请登录');
     }
     if ($to_uid == $uid) {
         ZCommonFun::output_json(null, 3, '私信不能发给自己');
     }
     $model_Message = new Message();
     $model_Message->from_uid = $uid;
     $model_Message->to_uid = $to_uid;
     $model_Message->table = self::$messageTable;
     $model_Message->table_id = $id;
     $model_Message->add_time = NOW_TIME_YmdHis;
     $model_Message->content = $content;
     $model_Message->is_read = 0;
     $model_Message->parent_id = 0;
     $model_Message->title = '';
     $model_Message->group_id = $uid . $to_uid;
     $model_Message->status = 0;
     // save success
     if ($model_Message->save()) {
         //             $model_AnswerSurveyResulte = new AnswerSurveyResulte();
         //             $model_AnswerSurveyResulte->setcomment_count($model_Message->table_id);
         ZCommonFun::output_json(null, 0, '评论成功');
     } else {
         ZCommonFun::output_json($model_Message->errors, -2, '评论失败');
     }
 }