public function actionupdatePost() { $message = $_POST['message']; $tag = $_POST['tag']; if (!empty($tag)) { $tagging = explode(',', $tag); $i = 0; foreach ($tagging as $t) { if ($t == Yii::app()->user->userId) { $model = new Post(); $model->user_id = Yii::app()->user->userId; //$model->sender_id = Yii::app()->user->userId; $model->message = $message; $model->date = date('Y-m-d H:i:s'); $model->save(); $Id = Yii::app()->db->getLastInsertId(); } $pt = new PostTagging(); $pt->user_id = $t; $pt->sender_id = Yii::app()->user->userId; $pt->post_id = $Id; $pt->save(); if ($i != 0) { $name = UserProfile::model()->find('user_id=:uid', array(':uid' => Yii::app()->user->userId)); $text = $name['first_name'] . " " . $name['last_name'] . " Tag on your wall <b>" . $message . "</b>"; $date = date('Y-m-d H:i:s'); $this->notification(Yii::app()->user->userId, $t, $text, $date, 'taggin'); } $i++; } $noti_senderId = $tagging[0]; $noti_userId = $tagging[1]; /*$name = UserProfile::model()->find('user_id=:uid',array(':uid'=>$noti_senderId)); $text = $name['first_name']. " " .$name['last_name']." Wrote on your wall <b>".$message."</b>"; $date = date('Y-m-d H:i:s'); $this->notification($noti_senderId,$noti_userId,$text,$date,'wall_post'); */ } //Yii::app()->user->setFlash('success', "Your status has been sent posted."); //$this->redirect(Yii::app()->baseUrl . '/index.php/user/dashboard'); $data = Post::model()->findByPk($Id); $user = UserProfile::model()->find('user_id=:userId', array('userId' => $data['user_id'])); $array = array(); $array['user'] = $user['attributes']; $array['post'] = $data['attributes']; echo json_encode($array); }
public function actionupdatePost() { $message = $_POST['message']; $tag = $_POST['tag']; if (!empty($tag)) { $tagging = explode(',', $tag); foreach ($tagging as $t) { if ($t == Yii::app()->user->userId) { $model = new Post(); $model->user_id = Yii::app()->user->userId; //$model->sender_id = Yii::app()->user->userId; $model->message = $message; $model->date = date('Y-m-d H:i:s'); $model->save(); $Id = Yii::app()->db->getLastInsertId(); } $pt = new PostTagging(); $pt->user_id = $t; $pt->sender_id = Yii::app()->user->userId; $pt->post_id = $Id; $pt->save(); } } //Yii::app()->user->setFlash('success', "Your status has been sent posted."); //$this->redirect(Yii::app()->baseUrl . '/index.php/user/dashboard'); $data = Post::model()->findByPk($Id); $user = UserProfile::model()->find('user_id=:userId', array('userId' => $data['user_id'])); $array = array(); $array['user'] = $user['attributes']; $array['post'] = $data['attributes']; echo json_encode($array); }