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() { $controller = $this->getController(); $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Replys') . ' - ' . $controller->_setting['site_name']; //我的回复 $uid = Yii::app()->user->id; $comment_mod = new Comment(); $reply_mod = new Reply(); $criteria = new CDbCriteria(); $criteria->addColumnCondition(array('t.user_id' => $uid)); $criteria->order = 't.id DESC'; //分页 $count = $reply_mod->count($criteria); $pages = new CPagination($count); $pages->pageSize = 15; $pages->applyLimit($criteria); $datalist = $reply_mod->findAll($criteria); foreach ((array) $datalist as $k => $v) { $reply = $comment_mod->findByPk($v->cid); if ($reply) { $c_mod_class = $controller->_content_models[$reply->type]; $c_mod_name = strtolower($c_mod_class); $content_mod = new $c_mod_class(); $content = $content_mod->findByPk($reply->content_id); $datalist[$k]['title'] = $content->title; $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $reply->content_id)); } } $controller->render('my_replys', array('datalist' => $datalist, 'pages' => $pages)); }
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 generate(Reply $reply, $perPage = 20) { $precedingReplyCount = $reply->getPrecedingReplyCount(); // $numberthreadsBefore = Thread::where('parent_id', '=', $thread->parent_id)->where('created_at', '<', $thread->created_at)->count(); $pageNumber = $this->getPageNumber($precedingReplyCount, $perPage); // $page = round($numberthreadsBefore / $this->threadsPerPage, 0, PHP_ROUND_HALF_DOWN) + 1; // return Redirect::to(action('ForumController@getViewThread', [$thread]) . "?page={$page}#thread-{$threadId}"); return "?page={$pageNumber}#reply-{$reply->id}"; }
public function run() { $ids = Yii::app()->request->getParam('id'); $command = Yii::app()->request->getParam('command'); empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select')); if (!is_array($ids)) { $ids = array($ids); } $criteria = new CDbCriteria(); $criteria->addInCondition('id', $ids); switch ($command) { case 'delete': //删除 Reply::model()->deleteAll($criteria); break; case 'show': //显示 Reply::model()->updateAll(['status' => Reply::STATUS_SHOW], $criteria); break; case 'hide': //隐藏 Reply::model()->updateAll(['status' => Reply::STATUS_HIDE], $criteria); break; default: $this->controller->message('error', Yii::t('admin', 'Error Operation')); } $this->controller->message('success', Yii::t('admin', 'Batch Operate Success')); }
public function actionIndex() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!$shop_id) { Error::output(Error::ERR_NO_SHOPID); } //获取该店的留言 $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; $criteria->condition = 't.shop_id=:shop_id AND t.status=:status'; $criteria->params = array(':shop_id' => $shop_id, ':status' => 1); $messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria); $message = array(); foreach ($messageMode as $k => $v) { $message[$k] = $v->attributes; $message[$k]['shop_name'] = $v->shops->name; $message[$k]['user_name'] = $v->members->name; $message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time); $message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status]; $message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id))); if (!empty($_replys)) { foreach ($_replys as $kk => $vv) { $message[$k]['replys'][$kk] = $vv->attributes; $message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time); $message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '前台妹子说' : $vv->members->name; } } } Out::jsonOutput($message); }
public function getRelatedRelpies() { $cate = Input::get('cate', ''); $id = Input::get('id', 0); $last_id = Input::get('last_id', 0); $per_page = Input::get('per_page', 30); $mapping = Reply::getRepliableCate(); try { if (array_key_exists($cate, $mapping)) { $cate = $mapping[$cate]; } else { throw new Exception("需要传入有效的评论分类", 2001); } $query = Reply::with(['user'])->select('replies.*')->where('replies.status', '=', 1); if ($last_id) { $query = $query->where('replies.id', '<', $last_id); } $query = $query->join('repliables', function ($q) use($cate, $id) { $q->on('repliables.reply_id', '=', 'replies.id')->where('repliables.repliable_type', '=', $cate)->where('repliables.repliable_id', '=', $id); }); $list = $query->orderBy('replies.id', 'DESC')->paginate($per_page); $data = []; foreach ($list as $key => $reply) { $data[] = $reply->showInList(); } $re = Tools::reTrue('获取评论成功', $data); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '获取评论失败:' . $e->getMessage()); } return Response::json($re); }
/** * 重载callback() * 将微信服务器请求的数据进行解析 * 并回调控制器的接口方法 */ public function callback() { $postXML = parent::callback(); empty($_GET) && die; // 必须有附带参数 extract($_GET); if ($this->sha1_sign($postXML->Encrypt, $timest, $nonce, $msg_signature)) { $req = $this->crypt_extract(parent::callback()); $reply = ''; switch (strtolower($req->MsgType)) { case 'text': $reply = ES_controller::get_instance()->_keywords($req->Content); break; case 'event': $reply = ES_controller::get_instance()->_events($req); break; } empty($reply) && die; list($method, $args) = $reply; $args = array('to' => $req->FromUserName, 'from' => $req->ToUserName) + $args; $reflector = new ReflectionClass('Reply'); $rMethod = $reflector->getMethod($method); $xml = $rMethod->invokeArgs($reflector->newInstanceWithoutConstructor(), $args); // log_msg($xml); // 未加密的消息体 $xml = $this->crypt_generate($xml); $signature = $this->set_sha1_sign($xml, $timestamp, $nonce); $xml = Reply::crypt_xml($xml, $signature, $timestamp, $nonce); // log_msg($xml); // 加密后的消息体 echo $xml; exit; } exit; }
/** * Execute the console command. * * @return mixed */ public function fire() { $replies = Reply::all(); $markdown = new Markdown(); $transfer_count = 0; $convert_count = 0; foreach ($replies as $reply) { if (empty($reply->body_original)) { // store the original data $reply->body_original = $reply->body; // convert to markdown $reply->body = $markdown->convertMarkdownToHtml($reply->body); $reply->save(); $transfer_count++; } else { // convert to markdown $reply->body = $markdown->convertMarkdownToHtml($reply->body_original); $reply->save(); $convert_count++; } } $this->info("Transfer old data count: " . $transfer_count); $this->info("Convert original to body count: " . $convert_count); $this->info("It's Done, have a good day."); }
protected function loadReplyList() { $this->num_per_page = $this->db->real_escape_string($this->num_per_page); $this->page_num = $this->db->real_escape_string($this->page_num); $this->newsID = trim($this->db->real_escape_string($this->newsID)); $start_record = $this->page_num * $this->num_per_page; $query = "select nr.*, ur.UserID, ur.displayName, ur.fullname, ur.fbName, \n\t\t\t\t\tnr.createdDateTime as replyCreatedDateTime from `news_reply` nr \n\t\t\t\t\tinner join user_registration ur on ur.userID = nr.userID\n\t\t\t\t\twhere nr.replyStatus = 'active'\n\t\t\t\t\tand nr.newsID = {$this->newsID} and parentReplyID = 0\n\t\t\t\t\torder by nr.createdDateTime desc limit {$start_record}, {$this->num_per_page}"; $resultArr = $this->db->query($query); if (is_array($resultArr) && count($resultArr) > 0) { $replyObj = new Reply(0, $this->withSubReplies); foreach ($resultArr as $id => $reply) { $replyResult = $replyObj->setModelReply($reply)->getArray(); $resultArr[$id] = $replyResult["reply"]; } $this->replyArr["replyList"] = $resultArr; } }
public function delete($id) { $reply = Reply::find($id); $this->authorOrAdminPermissioinRequire($reply->user_id); $reply->delete(); $reply->topic->decrement('reply_count', 1); Flash::success(lang('Operation succeeded.')); return Redirect::route('topics.show', $reply->topic_id); }
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')))); } }
/** * 判断数据是否存在 * * return \$this->model */ public function loadModel() { if ($this->model === null) { if (isset($_GET['id'])) { $this->model = Reply::model()->findbyPk($_GET['id']); } if ($this->model === null) { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } } return $this->model; }
/** * * $call * $content 回复的内容 * $referred 指明$content是直接回复的内容,还是定义的文本素材 */ public function __construct($call, $content, $referred = true) { parent::__construct($call); if ($referred) { if ($txt = \TMS_APP::model('matter\\text')->byId($content, 'content')) { $content = $txt->content; } else { $content = "文本回复【{$content】不存在}"; } } $this->content = $content; }
public function run() { $faker = Faker::create(); $users = User::lists('id'); $topics = Topic::lists('id'); foreach (range(1, 500) as $index) { Reply::create(['user_id' => $faker->randomElement($users), 'topic_id' => $faker->randomElement($topics), 'body' => $faker->sentence()]); } foreach (range(1, 60) as $index) { Reply::create(['user_id' => 1, 'topic_id' => $faker->randomElement($topics), 'body' => $faker->sentence()]); } }
public function run() { $model = new Reply(); //条件 $criteria = new CDbCriteria(); $status = trim(Yii::app()->request->getParam('status')); $status && $criteria->addColumnCondition(array('status' => $status)); $title = trim(Yii::app()->request->getParam('content')); $title && $criteria->addSearchCondition('content', $title); $criteria->order = 't.id DESC'; $count = $model->count($criteria); //分页 $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); //查询 $result = $model->findAll($criteria); Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css"); Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END); $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages)); }
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 run() { $controller = $this->getController(); $this->_setting = $controller->_setting; $this->_stylePath = $controller->_stylePath; $this->_static_public = $controller->_static_public; $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Replys') . ' - ' . $this->_setting['site_name']; //加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); //我的回复 $uid = Yii::app()->user->id; $comment_mod = new Comment(); $reply_mod = new Reply(); $model_type = new ModelType(); $uid = Yii::app()->user->id; $criteria = new CDbCriteria(); $criteria->condition = 't.user_id=' . $uid; $criteria->order = 't.id DESC'; //分页 $count = $reply_mod->count($criteria); $pages = new CPagination($count); $pages->pageSize = 15; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $datalist = $reply_mod->findAll($criteria); foreach ((array) $datalist as $k => $v) { $reply = $comment_mod->findByPk($v->cid); if ($reply) { $c_mod_class = $controller->_content_models[$reply->type]; $c_mod_name = strtolower($c_mod_class); $content_mod = new $c_mod_class(); $content = $content_mod->findByPk($reply->topic_id); $datalist[$k]['title'] = $content->title; $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $reply->topic_id)); } } $controller->render('my_replys', array('datalist' => $datalist)); }
function getNoticeIds($offset, $limit, $since_id, $max_id) { $reply = new Reply(); $reply->selectAdd(); $reply->selectAdd('notice_id'); $reply->whereAdd(sprintf('reply.profile_id = %u', $this->userId)); Notice::addWhereSinceId($reply, $since_id, 'notice_id', 'reply.modified'); Notice::addWhereMaxId($reply, $max_id, 'notice_id', 'reply.modified'); if (!empty($this->selectVerbs)) { $reply->joinAdd(array('notice_id', 'notice:id')); $reply->whereAddIn('notice.verb', $this->selectVerbs, 'string'); } $reply->orderBy('reply.modified DESC, reply.notice_id DESC'); if (!is_null($offset)) { $reply->limit($offset, $limit); } $ids = array(); if ($reply->find()) { while ($reply->fetch()) { $ids[] = $reply->notice_id; } } return $ids; }
public function reply() { if (Session::has('account') && Session::has('password')) { $inputs = Input::all(); $id = Input::get('id'); $rule = array('reply' => 'required'); $validator = Validator::make($inputs, $rule); if ($validator->fails()) { return Redirect::to('seven')->withErrors($validator); } Reply::create(array('memo' => nl2br(htmlspecialchars(Input::get('reply'))), 'name' => Session::get('name'), 'photo' => Session::get('photo'), 'id' => $id)); //存進資料庫裡 &&檢查是否有XSS return Redirect::to('seven'); } return Redirect::to('seven'); }
function _streamDirect($user_id, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0) { $reply = new Reply(); $reply->profile_id = $user_id; if ($since_id != 0) { $reply->whereAdd('notice_id > ' . $since_id); } if ($max_id != 0) { $reply->whereAdd('notice_id <= ' . $max_id); } $reply->orderBy('notice_id DESC'); if (!is_null($offset)) { $reply->limit($offset, $limit); } $ids = array(); if ($reply->find()) { while ($reply->fetch()) { $ids[] = $reply->notice_id; } } return $ids; }
/** * Transform the \Reply entity. * * @param \Reply $model * * @return array */ public function transformData($model) { return $model->toArray(); }
public function replies($id) { $user = User::findOrFail($id); $replies = Reply::whose($user->id)->recent()->paginate(15); return View::make('users.replies', compact('user', 'replies')); }
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 run() { $this->controller->layout = false; $view_url = Yii::app()->request->getParam('view_url'); $content_id = Yii::app()->request->getParam('content_id'); $topic_type = Yii::app()->request->getParam('topic_type'); $cur_url = Yii::app()->request->hostinfo . Yii::app()->request->getUrl(); $post = false; //评论类型 switch ($topic_type) { case 'post': $post = Post::model()->findByPk($content_id); break; case 'image': $post = Image::model()->findByPk($content_id); break; case 'soft': $post = Soft::model()->findByPk($content_id); break; case 'video': $post = Video::model()->findByPk($content_id); break; } if (!$post) { throw new CHttpException(404, Yii::t('admin', 'Loading Error')); } //评论内容 $model = new Comment('create'); $criteria = new CDbCriteria(); $criteria->with = array('user'); $criteria->addColumnCondition(array('content_id' => $content_id)); $criteria->addColumnCondition(array('t.status' => Comment::STATUS_SHOW)); $criteria->addColumnCondition(array('type' => $this->controller->_type_ids[$topic_type])); $criteria->addCondition('u.uid > 0'); $criteria->order = 't.id DESC'; $criteria->select = 't.id, user_id, content_id, content, t.create_time '; //分页 $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $comments = $model->findAll($criteria); //回复 if ($comments) { foreach ($comments as $c) { $replies[$c->id] = Reply::model()->with('user')->findAll(array('condition' => 'cid = ' . $c->id . ' AND t.status = "' . Reply::STATUS_SHOW . '" AND u.uid > 0', 'order' => 'id')); } } else { $comments = array(); $replies = array(); } if (Yii::app()->request->isPostRequest) { $uid = Yii::app()->user->id; if (!$uid) { $this->message('script', Yii::t('common', 'You Need Login')); } $model->attributes = $_POST['Comment']; $model->content_id = $content_id; $model->type = $this->controller->_type_ids[$topic_type]; $model->user_id = $uid; $model->status = 'N'; $model->client_ip = Yii::app()->request->userHostAddress; $model->create_time = time(); $ret_url = $_POST['ret_url']; if ($model->save()) { $this->controller->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url); } } $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies); $this->controller->render('create', $data); }
/** * Constructor. */ public function __construct() { parent::__construct($this->defaults); }
function onHandleQueuedNotice($notice) { $paths = array(); // Add to the author's timeline $user = User::staticGet('id', $notice->profile_id); if (!empty($user)) { $paths[] = array('showstream', $user->nickname); } // Add to the public timeline if ($notice->is_local == Notice::LOCAL_PUBLIC || $notice->is_local == Notice::REMOTE_OMB && !common_config('public', 'localonly')) { $paths[] = array('public'); } // Add to the tags timeline $tags = $this->getNoticeTags($notice); if (!empty($tags)) { foreach ($tags as $tag) { $paths[] = array('tag', $tag); } } // Add to inbox timelines // XXX: do a join $ni = $notice->whoGets(); foreach (array_keys($ni) as $user_id) { $user = User::staticGet('id', $user_id); $paths[] = array('all', $user->nickname); } // Add to the replies timeline $reply = new Reply(); $reply->notice_id = $notice->id; if ($reply->find()) { while ($reply->fetch()) { $user = User::staticGet('id', $reply->profile_id); if (!empty($user)) { $paths[] = array('replies', $user->nickname); } } } // Add to the group timeline // XXX: join $gi = new Group_inbox(); $gi->notice_id = $notice->id; if ($gi->find()) { while ($gi->fetch()) { $ug = User_group::staticGet('id', $gi->group_id); $paths[] = array('showgroup', $ug->nickname); } } if (count($paths) > 0) { $json = $this->noticeAsJson($notice); $this->_connect(); foreach ($paths as $path) { $timeline = $this->_pathToChannel($path); $this->_publish($timeline, $json); } $this->_disconnect(); } return true; }
function saveStatusMentions($notice, $status) { $mentions = array(); if (empty($status->entities) || empty($status->entities->user_mentions)) { return; } foreach ($status->entities->user_mentions as $mention) { $flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE); if (!empty($flink)) { $user = User::staticGet('id', $flink->user_id); if (!empty($user)) { $reply = new Reply(); $reply->notice_id = $notice->id; $reply->profile_id = $user->id; $reply->modified = $notice->created; common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}"); $id = $reply->insert(); } } } }
?> </span></p> <p>Posted: <span><?php echo CHtml::encode($data['date_created']); ?> </span></p> </div> <div class="media-body well"> <div class="forum-text-area"> <?php if ($data['child_reply']) { ?> <?php $childReply = Reply::model()->getChildReplyPosting($data['child_reply']); $this->widget('bootstrap.widgets.TbBox', array('title' => "In reply to <a href='#'>" . PostHelper::PrintPosterName($childReply['username'], $childReply['user_group_id']) . "</a>", 'headerIcon' => 'icon-arrow-left', 'content' => $childReply['is_active'] ? CHtml::decode($childReply['message']) : PostHelper::PrintDisabledMessage())); ?> <?php } ?> <?php echo $data['is_active'] ? CHtml::decode($data['message']) : PostHelper::PrintDisabledMessage(); ?> </div> <?php if ($data['is_active']) { ?>
static function fillReplies(&$notices) { $ids = self::_idsOf($notices); $replyMap = Reply::listGet('notice_id', $ids); foreach ($notices as $notice) { $replies = $replyMap[$notice->id]; $ids = array(); foreach ($replies as $reply) { $ids[] = $reply->profile_id; } $notice->_setReplies($ids); } }