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 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 actionRelational() { $report_id = Yii::app()->getRequest()->getParam('id'); $thread_id = Complaint::model()->findByPk($report_id)->post_item_id; //Yii::log('Thread ID: ' . $thread_id, 'log'); $model = new Complaint('search'); $model->unsetAttributes(); $gridColumns = array(array('name' => 'user.username', 'header' => 'Username'), array('name' => 'reply.message', 'value' => '$data->reply_id ? $data->reply->message : "<strong>(OP)</strong> " . $data->postItem->description ', 'header' => 'Message', 'type' => 'html'), array('name' => 'reason', 'header' => 'Complaint'), array('htmlOptions' => array('nowrap' => 'nowrap'), 'class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view} | {safe} {disable}', 'cssClassExpression' => '!$data->reply_id ? "op" : "reply"', 'viewButtonUrl' => 'Yii::app()->controller->createUrl("/post/readTopic", array("id"=>$data->post_item_id))', 'buttons' => array('safe' => array('label' => 'Safe', 'icon' => 'thumbs-up', 'url' => 'Yii::app()->createUrl("complaint/replySafe", array("id"=>$data->complaint_id))'), 'disable' => array('label' => 'Disable', 'icon' => 'eye-close', 'url' => 'Yii::app()->createUrl("complaint/disableReply", array("reply_id"=>$data->reply_id, "complaint_id" => $data->complaint_id))', 'click' => 'function() {confirm("ok?");}')))); $this->renderPartial('_relational', array('id' => $thread_id, 'gridDataProvider' => $model->search(false, $thread_id), 'gridColumns' => $gridColumns)); }
public function actionReported() { $model = new Complaint('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Thread'])) { $model->attributes = $_GET['Thread']; } $dataProvider = $model->search(); $this->render('admin', array('model' => $model, 'dataProvider' => $dataProvider)); }