public function actionShowPosts($id, $mid, $sid) { $posts = Posts::model()->findByPk($sid); $multimedia = json_decode($posts->multimedia); $count = count($multimedia); foreach ($multimedia as $ind => $file) { if ($file->nomber == $mid) { $num = $ind + 1; if ($ind == 0) { $prev = $multimedia[$count - 1]->nomber . '/' . $sid; } else { $prev = $multimedia[$ind - 1]->nomber . '/' . $sid; } if ($ind == $count - 1) { $next = $multimedia[0]->nomber . '/' . $sid; } else { $next = $multimedia[$ind + 1]->nomber . '/' . $sid; } $current_photo = $file; } } $myPage = $id == Yii::app()->user->id; $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $ext = Files::model()->findByPk($current_photo->id)->extension; $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next); $comments = Comments::model()->getLast('posts_' . $sid, $mid, 10); $comments = array_reverse($comments); $file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date); $this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid)); }
public function actionIndex() { $step = Yii::app()->request->getParam("step", 1); switch ($step) { case 1: $this->render('index'); break; case 2: $this->render('check', array('check' => environmentChecksUpdate::run())); break; case 3: $authGet = Yii::app()->request->getParam("auth", 'sorry'); if (Yii::app()->request->csrfToken != $authGet) { $this->render('check'); } databaseConfiguration::SplitSQL(Yii::app()->getModulePath() . '/update/data/0_4/mysql_update.sql'); $updated = array(); $comments = Comments::model()->findAll(); foreach ($comments as $comment) { if (!in_array($comment->comment_resourceid . "," . $comment->module_id, $updated)) { $module = Modules::model()->findByPk($comment->module_id)->module_className; $modelClass = new $module(); $project = $modelClass::model()->findByPk($comment->comment_resourceid)->project_id; Comments::model()->updateAll(array('project_id' => $project), 'comment_resourceid = :resourceid AND module_id = :moduleid', array(':resourceid' => $comment->comment_resourceid, ':moduleid' => $comment->module_id)); array_push($updated, $comment->comment_resourceid . "," . $comment->module_id); } } $this->render('finish'); break; default: $this->render('index'); break; } }
/** * Добавление / редактирование комментариев */ public function actionSave_comment() { if (Yii::app()->user->isGuest) { $this->redirect($this->createAbsoluteUrl('base')); } // Редактирование или добавление новой if (isset($_GET['idComment'])) { $model = Comments::model()->findByPk($_GET['idComment']); } else { $model = new Comments(); } if (isset($_POST['idArticle']) && isset($_POST['text']) && isset($_POST['idAuthor'])) { $model->idArticle = $_POST['idArticle']; $model->text = $_POST['text']; $model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser']; $model->typeUser = $model->idUser == $_POST['idAuthor'] ? 'author' : (empty($this->_user) ? 'admin' : 'user'); if ($model->save()) { if (Yii::app()->request->isAjaxRequest) { $criteria = new CDbCriteria(); $criteria->with = array('idUser0'); $criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1'; $criteria->params = array(':idArticle' => $_POST['idArticle']); $comments = Comments::model()->findAll($criteria); $commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50))); $listComments = $this->renderPartial('_list_comments', array('dataProvider' => $commentsDataProvider), true); echo CJSON::encode(array('listComments' => $listComments)); exit; } } } }
public function actionShow($id, $mid) { //$photos = Photos::model(); //$photo = $photos->findByPk($mid); $ap = Bookmarks::model()->findAll(array('select' => 'content_id', 'condition' => 'owner_id = :id AND type = 1', 'params' => array(':id' => $id))); $count = count($ap); foreach ($ap as $ind => $ph) { if ($ph['content_id'] == $mid) { $num = $ind + 1; if ($ind == 0) { $prev = $ap[$count - 1]['content_id']; } else { $prev = $ap[$ind - 1]['content_id']; } if ($ind == $count - 1) { $next = $ap[0]['content_id']; } else { $next = $ap[$ind + 1]['content_id']; } } } $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next); $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $myPage = $id == Yii::app()->user->id; $comments = Comments::model()->getLast('photos', $mid, 10); $comments = array_reverse($comments); $photo = Photos::model()->findByPk($mid); $this->renderPartial('_show_photo', array('photo' => $photo, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'photos')); }
public function loadModel($id) { $model = Comments::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function run() { $criteria = new CDbCriteria(); $criteria->order = "id DESC"; $criteria->limit = 2; // $criteria->addCondition("is_deleted = 0"); $this->render('lastComment', array('comments' => Comments::model()->findAll($criteria))); }
/** * 后台主页信息 */ public function actionSystemmain() { $SYS = array('PHP版本:' => $_SERVER['SERVER_SOFTWARE'], '当前系统类型:' => php_uname('s'), 'PHP运行方式:' => php_sapi_name(), '服务器域名:' => $_SERVER['SERVER_NAME'], '服务器端口:' => $_SERVER['SERVER_PORT'], '北京时间:' => date('Y年m月d日 H:i:s', time())); $count = array('会员总数:' => Account::model()->count('id!=:ID', array(':ID' => 0)), '文章总数:' => article::model()->count('id!=:ID', array(':ID' => 0)), '评论总数:' => Comments::model()->count('id!=:ID', array(':ID' => 0))); $Role = Role::model()->find('id=:ID', array(':ID' => Yii::app()->session['USER_ACCOUNT']['roleId'])); $basic = array('权限级别:' => $Role->name); $this->render('Systemmain', array('SYS' => $SYS, 'Info' => $count, 'basic' => $basic)); }
public function actionStat() { $posts = Posts::model()->count(); $commentsNum = Comments::model()->count(); $attachsNum = Attachments::model()->count(); $feedbackNum = Feedback::model()->count(); $arr = array('posts' => $posts, 'commentsNum' => $commentsNum, 'attachsNum' => $attachsNum, 'feedbackNum' => $feedbackNum); $this->render('stat', $arr); }
public function getListUserCommentedOnPost($post_id) { $criteria = new CDbCriteria(); $criteria->select = 't.created_by'; $criteria->condition = "t.post_id = {$post_id}"; $criteria->distinct = true; $data = Comments::model()->findAll($criteria); return $data; }
public function getCommentsByEvent($event_id, $limit, $offset) { $criteria = new CDbCriteria(); $criteria->limit = $limit; $criteria->offset = $offset; $criteria->condition = "event_id = {$event_id}"; $data = Comments::model()->findAll($criteria); return $data; }
public function actionGetContentByID($id) { $arr = explode(",", $id); $id = $arr[count($arr) - 1]; $model = Comments::model()->findByPk($id); $data = array(); $data[0] = $model->content; $data[1] = $model->title; $data[2] = $model->address; echo json_encode($data); }
public function actionComment() { $rows = Comments::model()->findAll(); $model = new Comments(); if (isset($_POST['Comments'])) { $model->attributes = $_POST['Comments']; if ($model->save()) { $this->redirect($this->createUrl('pages/comment')); } } $this->render('comment', array('rows' => $rows, 'model' => $model)); }
public function actionGetCommentByEvent() { $request = Yii::app()->request; try { $event_id = StringHelper::filterString($request->getQuery('event_id')); $limit = StringHelper::filterString($request->getQuery('limit')); $offset = StringHelper::filterString($request->getQuery('offset')); $data = Comments::model()->getCommentsByEvent($event_id, $limit, $offset); ResponseHelper::JsonReturnSuccess($data, 'Success'); } catch (Exception $ex) { var_dump($ex->getMessage()); } }
/** * Changes whether or not the comment should be approved or not * * With approval I'm not too worried about the parent->child tree being messed up, as the nodes still exist in the tree * and are simply ignored. * * @param int $id The id of the comment * @return boolean If the comment was modified or not */ public function actionApprove($id = NULL) { if ($id === NULL) { throw new CHttpException(400, Yii::t('Dashboard.main', 'No comment with that id exists.')); } $comment = Comments::model()->findByPk($id); if ($comment->approved != 1) { $comment->approved = 1; } else { $comment->approved = -1; } return $comment->save(); }
public function actionGetCounters() { Yii::import('mod.cart.models.Order'); Yii::import('mod.cart.models.ProductNotifications'); Yii::import('mod.support.models.TicketMessage'); $json = array(); if (Yii::app()->hasModule('comments')) { $json['comments'] = (int) Comments::model()->waiting()->count(); } $json['orders'] = (int) Order::model()->new()->count(); $json['notify'] = (int) ProductNotifications::model()->count(); $json['support'] = (int) TicketMessage::model()->count(); echo CJSON::encode($json); }
public function actionRemoveImage() { $response = array("status" => "fail"); if (isset($_REQUEST['id']) && isset($_REQUEST['field']) && isset($_REQUEST['model'])) { $id = $_REQUEST['id']; $field = $_REQUEST['field']; $modelName = $_REQUEST['model']; switch ($modelName) { case 'news': $model = News::model()->findByPk($id); break; case 'articles': $model = Articles::model()->findByPk($id); break; case 'articles_categories': $model = ArticlesCategories::model()->findByPk($id); break; case 'clinics': $model = Clinics::model()->findByPk($id); break; case 'experts': $model = Experts::model()->findByPk($id); break; case 'book_pages': $model = BookPages::model()->findByPk($id); break; case 'comments': $model = Comments::model()->findByPk($id); break; case 'banners': $model = Banners::model()->findByPk($id); break; default: $model = false; break; } if (is_object($model) && isset($model->{$field})) { $imagePath = Yii::app()->basePath . "/.." . $model->{$field}; if (is_file($imagePath)) { unlink($imagePath); $model->{$field} = ''; if ($model->save()) { $response = array("status" => "success"); } } } } echo json_encode($response); }
public function actionUpdateStatus() { $ids = Yii::app()->request->getPost('ids'); $switch = Yii::app()->request->getPost('switch'); $models = Comments::model()->findAllByPk($ids); if (!array_key_exists($switch, Comments::getStatuses())) { throw new CHttpException(404, Yii::t('CommentsModule.default', 'ERROR_UPDATE_STATUS')); } if (!empty($models)) { foreach ($models as $comment) { $comment->switch = $switch; $comment->save(); } } echo Yii::t('CommentsModule.default', 'SUCCESS_UPDATE_STATUS'); }
/** * Provides functionality for authenticated users to flag a comment * @param int $id The id of a user * @return true on success, CHttpException 400 on error */ public function actionFlag($id = NULL) { if (Yii::app()->request->isPostRequest) { $comment = Comments::model()->findByPk($id); if ($comment == NULL) { throw new CHttpException(400, Yii::t('ciims.controllers.Comments', 'Invalid request. Please do not repeat this request again.')); } $comment->approved = '-1'; if ($comment->save()) { return true; } else { throw new CHttpException(400, Yii::t('ciims.controllers.Comments', 'There was an error flagging this comment.')); } } else { throw new CHttpException(400, Yii::t('ciims.controllers.Comments', 'Invalid request. Please do not repeat this request again.')); } }
public function actionShow($id, $mid) { $videos = new Videos(); $video = $videos->findByPk($mid); $aroundInfo = $videos->getAroundInfo($mid); $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id); $my_videos = array(); if (Yii::app()->user->id == $id) { $myPage = true; } else { $mypage = false; $videos_on_my_page = Videos::model()->findAll(array('select' => 'file', 'condition' => 'user_id=:id', 'params' => array(':id' => Yii::app()->user->id))); foreach ($videos_on_my_page as $my_video) { $my_videos[] = $my_video['file']; } } $comments = Comments::model()->getLast('videos', $mid, 10); $comments = array_reverse($comments); $this->renderPartial('show_video', array('video' => $video, 'my_videos' => $my_videos, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'videos', 'comments_item_id' => $video->id)); }
public function actionDelete($id) { if (Yii::app()->request->isAjaxRequest) { //Comments::model()->deleteAll(''); $comment = Comments::model()->findByPk($id); if ($comment->author_id == Yii::app()->user->id || $comment->owner_id == Yii::app()->user->id) { // удаляем только если автор комментария == текущему авторизованному пользователю, либо если хозяин стены == текущему авторизованному пользователю $res = $comment->delete($id); if ($res) { echo json_encode(array('status' => 'ok')); } else { echo json_encode(array('status' => 'error', 'data' => 'Не могу подключиться к БД')); } } else { throw new CException('Not Found', 404); } } else { throw new CException('Not Found', 404); } }
/** * Главная страница админцентра * @throws CHttpException */ public function actionIndex() { // Если гость, выдаем эксепшн if (Yii::app()->user->isGuest) { throw new CHttpException(403, 'У Вас недостаточно прав'); } // Только главный админ имеет право входить в аминцентр if (Yii::app()->user->id != '1') { throw new CHttpException(403, 'У Вас недостаточно прав'); } $this->render('index', array('sysinfo' => array('bancount' => History::model()->cache(300)->count(), 'activebans' => Bans::model()->cache(300)->count(), 'filescount' => Files::model()->cache(300)->count(), 'commentscount' => Comments::model()->cache(300)->count()))); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @return CActiveRecord Cases */ public function loadModel() { if ($this->_model === null) { if (isset($_REQUEST['id'])) { $this->_model = Comments::model()->findbyPk($_REQUEST['id']); } if ($this->_model === null) { throw new CHttpException(404, Yii::t('site', '404_Error')); } } return $this->_model; }
/** * 验证用户具体发帖权限,并不影响其他权限 * @param type $uid 验证的用户 * @param type $type 验证的类型 * @param type $field 是否检查总数 * @return type */ public static function check($type, $field = false, $uid = '') { if (!$uid) { $uid = Yii::app()->user->id; } if (!$uid) { if (zmf::config('officalUid')) { return array('status' => 1, 'msg' => ''); } return array('status' => 0, 'msg' => '用户不存在'); } $uinfo = Users::getUserInfo($uid); if (!$uinfo) { return array('status' => 0, 'msg' => '用户不存在'); } if (!$uinfo['groupid']) { return array('status' => 0, 'msg' => '无组织用户'); } $groupInfo = UserPower::model()->find('groupid=:gid', array(':gid' => $uinfo['groupid'])); if (!$groupInfo) { return array('status' => 0, 'msg' => '无组织用户'); } $num = $groupInfo->getAttribute($type); if ($num === null) { return array('status' => 0, 'msg' => '无法完成验证的type:' . $type); } elseif ($num === 0) { return array('status' => 0, 'msg' => '不允许'); } elseif ($field) { switch ($field) { case 'addPost': $totalNum = $groupInfo['postNum']; $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addQuestion': $totalNum = $groupInfo['questionNum']; $hasNum = Question::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addAnswer': $totalNum = $groupInfo['answerNum']; $hasNum = Answer::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addPoiPost': $totalNum = $groupInfo['poiPostNum']; $hasNum = PoiPost::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addPoiTips': $totalNum = $groupInfo['poiTipsNum']; $hasNum = PoiTips::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addImage': $totalNum = $groupInfo['imageNum']; $hasNum = Attachments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addComment': $totalNum = $groupInfo['commentNum']; $hasNum = Comments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'addPlan': $totalNum = $groupInfo['planNum']; $hasNum = Plans::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; case 'yueban': $totalNum = $groupInfo['yuebanNum']; $hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime)); break; } if (!$totalNum) { return array('status' => 1, 'msg' => '无限制'); } else { if ($hasNum >= $totalNum) { return array('status' => 0, 'msg' => '已超出限制:' . $totalNum); } else { return array('status' => 1, 'msg' => ''); } } } else { return array('status' => 1, 'msg' => ''); } }
/** * Retrieves the Comment model * @param int $id The comment model * @return Comment */ private function getCommentModel($id = NULL) { if ($id === NULL) { throw new CHttpException(400, Yii::t('Api.comment', 'Missing id')); } $model = Comments::model()->findByPk($id); if ($model === NULL) { throw new CHttpException(404, Yii::t('Api.comment', 'Comment #{{id}} was not found.', array('{{id}}' => $id))); } return $model; }
/** * 统计访问者所在国家 * Enter description here ... */ public function actionRegionCountry() { $result = Statistics::model()->getAllRegionInfo(); foreach ($result['Country'] as $key => $value) { $pie[] = array('name' => $key, 'y' => $value / Comments::model()->count() * 100); } $this->render('regioncountry', array('pie' => $pie, 'columns' => $result['Country'])); }
private function removeComment($id) { $comment = Comments::model()->findByPk($id); if ($comment->delete()) { Yii::app()->notify->add("Комментарий удален", "default"); } }
/** * Retrievers the comment count for this article, as comment_count has been broken since 1.1 * @return int The number of comments for this content piece */ public function getCommentCount() { return Comments::model()->countByAttributes(array('content_id' => $this->id, 'approved' => 1)); }
public static function getSimpleInfo($keyid) { $info = Comments::model()->findByPk($keyid); return $info; }
/** * Просмотр статьи с комментами */ public function actionView_article() { if (isset($_GET['idArticle']) || isset($_POST['idArticle'])) { $idArticle = isset($_GET['idArticle']) ? $_GET['idArticle'] : $_POST['idArticle']; $criteria = new CDbCriteria(); // Комментарии к статье $criteria->with = array('idUser0'); $criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1'; $criteria->params = array(':idArticle' => $idArticle); $comments = Comments::model()->findAll($criteria); $commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50))); // Статья $criteria->with = array('idCategory0', 'idMenu0', 'idUser0', 'commentsCount', 'tagstoarticles'); $criteria->condition = 't.idArticle = :idArticle AND moderationAppruv = 1 AND public = 1 AND deleted = 0'; if (Yii::app()->request->isAjaxRequest) { if (isset($_POST['type'])) { if ('appruve' == $_POST['type']) { $criteria->condition = 't.idArticle = :idArticle AND moderationAppruv = 0 AND deleted = 0'; } } } $criteria->params = array(':idArticle' => $idArticle); $model = Articles::model()->find($criteria); // Теги $model['tagArray'] = AuxiliaryFunctions::getTagsList($model->tagstoarticles); // Счетчик просмотров статьи if ($model->idUser != Yii::app()->user->id && 'Admins' != Yii::app()->session->get("typeAuthorize")) { $model->saveCounters(array('numberOfViews' => 1)); } if (isset($_GET['idMenu'])) { // Категории раздела $this->_listCategory = Categorys::getAllCategories($_GET['idMenu'], true, true); } $bookmarks = Bookmarks::model()->find(array('select' => 'idBookmarks', 'condition' => 'idUser = :idUser AND idArticle = :idArticle AND idMenu = :idMenu AND idCategory = :idCategory', 'params' => array(':idUser' => Yii::app()->user->id, ':idArticle' => $model->idArticle, ':idMenu' => $model->idMenu, ':idCategory' => $model->idCategory))); if (Yii::app()->request->isAjaxRequest) { $articlePopup = $this->renderPartial('view_article', array('model' => $model, 'commentsDataProvider' => $commentsDataProvider, 'modelComment' => new Comments(), 'idBookmarks' => null === $bookmarks ? null : $bookmarks->idBookmarks), true); echo CJSON::encode(array('popup' => $articlePopup)); exit; } $this->breadcrumbs = AuxiliaryFunctions::fillingBreadcrumbs($idArticle, 'article'); $this->render('view_article', array('model' => $model, 'commentsDataProvider' => $commentsDataProvider, 'modelComment' => new Comments(), 'idBookmarks' => null === $bookmarks ? null : $bookmarks->idBookmarks)); } }
</tr> <tr> <td></td> <td> <div id="post_appending_preview"></div> <input type="submit" id="send" value="Отправить" /> <input type="button" id="cancel" value="Отмена" style="display: none" /> </td> </tr> </table> </form> </div> <div id="postsContainer"> <?php foreach ($wall as $item) { $this->renderPartial('//posts/_postItem', array('item' => $item, 'comments' => Comments::model()->getLast('posts', $item->id), 'count' => Comments::model()->countComments('posts', $item->id), 'owner' => $profile->user_id)); } ?> </div> <?php if (count($wall) == Yii::app()->params->maxPostPerRequest) { ?> <input type="button" class="loadMore" value="Загрузить еще" onclick="loadMorePosts(this, 'userwall', 'user', <?php echo $profile->user_id; ?> )" /> <?php } ?> </td> <?php