public function actionReadTopic($id) { $thread = Thread::model()->getThreadInfoById($id); $this->areaLarge = $thread['program_name']; $this->areaSmall = $thread['semester_name']; $reply = new Reply(); $complaint = new Complaint('postComplaint'); if (isset($_POST['Reply'])) { $reply->attributes = $_POST['Reply']; $reply->post_item_id = $id; if ($reply->save()) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success')); $reply->unsetAttributes(); } else { Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error')); } } if (isset($_POST['Complaint'])) { $complaint->attributes = $_POST['Complaint']; if ($complaint->save()) { if ($complaint->post_item_id == $id) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } else { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } $complaint->unsetAttributes(); } else { Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY); } } $dataProvider = Thread::model()->getPostsDataInThread($id); Yii::log(CVarDumper::dumpAsString($dataProvider->getData())); $this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint)); }
public function actionReadTopic($id) { $thread = Thread::model()->getThreadInfoById($id); $this->forumBreadcrumb = array('Programs' => array('forum/index'), $thread['program_name'] => array('forum/programView', 'programId' => $thread['program_id']), $thread['semester_name'] => array('forum/viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id']), $thread['title'] < Yii::app()->params['forum_max_crumb_length'] ? $thread['title'] : substr($thread['title'], 0, Yii::app()->params['forum_max_crumb_length']) . '...'); $this->areaLarge = $thread['program_name']; $this->areaSmall = $thread['semester_name']; $reply = new Reply(); $complaint = new Complaint('postComplaint'); if (isset($_POST['Reply'])) { $reply->attributes = $_POST['Reply']; $reply->post_item_id = $id; if ($reply->save()) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success')); $reply->unsetAttributes(); } else { Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error')); } } if (isset($_POST['Complaint'])) { $complaint->attributes = $_POST['Complaint']; if ($complaint->save()) { if ($complaint->post_item_id == $id) { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } else { Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success')); } $complaint->unsetAttributes(); } else { Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY); } } $dataProvider = Thread::model()->getPostsDataInThread($id); Yii::log(CVarDumper::dumpAsString($dataProvider->getData())); $this->render('view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint)); }
public function run() { $this->controller->layout = false; if (Yii::app()->request->isPostRequest) { //当前登录用户id $uid = Yii::app()->user->id; if (!$uid) { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'You Need Login')))); } $cid = intval($_POST['cid']); $reply_id = intval($_POST['reply_id']); $content = $_POST['content']; $comment = Comment::model()->findByPk($cid); $reply = Reply::model()->findByPk($reply_id); if ($comment) { //不能对自己的评论和回复而回复 if ($comment->user_id == $uid && !$reply || $reply && $reply->user_id == $uid) { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'You Can not Rely Yourself')))); } if (!$content || strlen($content) < 10) { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Content Is Too Small')))); } $model = new Reply('create'); $model->cid = $cid; $model->user_id = $uid; $model->reply_id = $reply_id; $model->content = $content; $model->status = 'Y'; $model->create_time = time(); if ($model->save()) { exit(CJSON::encode(array('status' => 'success', 'message' => Yii::t('common', 'Reply Success')))); } else { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed')))); } } else { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed')))); } } else { exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed')))); } }
public function actionReplyMsg() { $message_id = Yii::app()->request->getParam('message_id'); $content = Yii::app()->request->getParam('content'); if (!$content) { $this->errorOutput(array('errorCode' => 1, 'errorText' => '回复内容不能为空')); } if (!$message_id) { $this->errorOutput(array('errorCode' => 2, 'errorText' => '没有留言id')); } $model = new Reply(); $model->message_id = $message_id; $model->user_id = -1; $model->content = $content; $model->create_time = time(); if ($model->save()) { $this->output(array('success' => 1, 'successText' => '回复成功')); } else { $this->errorOutput(array('errorCode' => 3, 'errorText' => '回复失败')); } }
public function actionReplyMessage() { $message_id = Yii::app()->request->getParam('reply_id'); $reply_content = Yii::app()->request->getParam('reply_content'); if (!isset(Yii::app()->user->member_userinfo)) { $this->errorOutput(array('errorCode' => 1, 'errorText' => '你还未登录,请先去登录')); } else { $user_id = Yii::app()->user->member_userinfo['id']; } if (!$reply_content) { $this->errorOutput(array('errorCode' => 2, 'errorText' => '回复内容不能为空')); } if (!$message_id) { $this->errorOutput(array('errorCode' => 3, 'errorText' => '未选择回复留言')); } $model = new Reply(); $model->message_id = $message_id; $model->user_id = $user_id; $model->content = $reply_content; $model->create_time = time(); if ($model->save()) { $this->output(array('success' => 1, 'successText' => '回复成功')); } else { $this->errorOutput(array('errorCode' => 4, 'errorText' => '回复失败')); } }
public function post_replyticket() { $postStr = Input::get('data'); parse_str($postStr, $post); $validator = Validator::make(array('Reply' => $post['inputReplyTicket'], 'tid' => $post['tid']), array('Reply' => 'required', 'tid' => 'required|integer'), array('Reply.required' => 'Please enter a reply.', 'tid.required' => 'The system cannot find a ticket to reply to.', 'tid.integer' => 'The system has been sent an invalid ticket id to reply to.')); //Verify some smart ass didn't try to change the hidden input field (tid) or reply to a closed ticket. $count = Ticket::where('id', '=', $post['tid'])->where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->count(); if ($count == 0) { //Damn them. echo '<div class="alert alert-error"><li>Seriously? Nice try.</li></div>'; } if ($validator->fails()) { $messages = $validator->messages(); $errorStr = ''; foreach ($messages->all('<li>:message</li>') as $message) { $errorStr .= '<div class="alert alert-error">' . $message . '</div>'; } echo $errorStr; } else { $reply = new Reply(); $reply->tid = $post['tid']; $reply->author = Auth::user()->get()->cid; $reply->content = $post['inputReplyTicket']; //Save our ticket update $reply->save(); //Find or reply id $reply = Reply::orderBy('updated_at', 'DESC')->first(); //Finally we need to update the updated_at field of our master ticket table $ticket = Ticket::find($post['tid']); $ticket->updated_at = $reply->updated_at; //Save our ticket update $ticket->save(); //Check to see if there is an assigned auditor. If so send them an email notification if (!empty($ticket->assigned)) { $data = array(); $auditor = ConsoleUser::find($ticket->assigned); if (!empty($auditor)) { $data['auditor'] = $auditor; $data['subject'] = "VATSIM VA New Ticket Update"; if (!empty($auditor->email)) { $body = "Hello " . ConsoleUser::getName($ticket->assigned) . ",<br /><br />There has been an update to your assigned ticket " . $ticket->subject . " by VA Administrator " . User::getFullName($ticket->vid) . ". <br /><br />" . $reply->content . "<br /><br /><br /> <strong>Do not reply to this email. If you wish to reply to this ticket, please do so through the auditor console.</strong>"; Mail::send('email.default', array("content" => $body), function ($message) use($data) { $message->to($data['auditor']->email, $data['auditor']->name)->subject($data['subject']); }); } } } //Return 1 to inform the client this was successful. echo '1'; } }
/** * Send a reply * * @param int $id * @return Response */ public function reply($id) { $chat = Chat::findOrfail($id); $chat->last_reply = date("Y-m-d H:i:s"); $chat->save(); $reply = new Reply(); $reply->text = Input::get('text'); $reply->chat_id = $chat->id; $reply->user_id = Auth::user()->id; $reply->save(); //Set up notifications for this chat foreach ($chat->user()->get() as $user) { $reply->notification()->save($user); } $notification = Notification::where('user_id', '=', Auth::user()->id)->where('reply_id', '=', $reply->id)->firstOrFail(); $notification->has_read = 1; $notification->save(); return Redirect::to('/community/chats/' . $id)->with('flash_chat', 'Your chat has been sent!')->with('alert_class', 'alert-success'); }
public function actionReplyMessage() { $message_id = Yii::app()->request->getParam('reply_id'); $reply_content = Yii::app()->request->getParam('reply_content'); $user_id = $this->module->user['id']; if (!$message_id) { Error::output(Error::ERR_NO_MSGID); } if (!$reply_content) { Error::output(Error::ERR_NO_REPLY_CONTENT); } $model = new Reply(); $model->message_id = $message_id; $model->user_id = $user_id; $model->content = $reply_content; $model->create_time = time(); if ($model->save()) { Out::jsonOutput(array('return' => 1)); //留言成功 } else { Error::output(Error::ERR_SAVE_FAIL); } }