示例#1
0
 /**
  * 返回用户除此外的热门作品
  * @param type $uid
  * @param type $notId
  * @return boolean
  */
 public static function getRecommends($uid, $notId)
 {
     if (!$uid) {
         return false;
     }
     $items = Naodong::model()->findAll(array('condition' => 'uid=:uid AND id!=:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title,content', 'order' => 'hits DESC', 'limit' => 10, 'params' => array(':uid' => $uid, ':id' => $notId)));
     return $items;
 }
示例#2
0
 /**
  * 删除内容
  */
 public function actionDelPost()
 {
     $logid = zmf::filterInput($_POST['logid']);
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $admin = false;
     if (empty($logid) or !is_numeric($logid)) {
         $this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
     }
     if (!Yii::app()->request->isAjaxRequest) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     if (!in_array($type, array('naodong', 'comment', 'notice'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if ($type == 'naodong') {
         $tinfo = Naodong::model()->findByPk($logid);
         if (!$tinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($tinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delpost', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => Posts::STATUS_DELED);
         if (Naodong::model()->updateByPk($logid, $attr)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'comment') {
         $cinfo = Comments::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delcomment', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => $status);
         if (Comments::model()->updateByPk($logid, $attr)) {
             if (strtolower($cinfo['classify']) == 'naodong') {
                 Posts::updateCount($cinfo['logid'], 'Naodong', -1, 'comments');
             }
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'notice') {
         $cinfo = Notification::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             $this->jsonOutPut(0, '请勿越权操作');
         }
         if (Notification::model()->deleteByPk($logid)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(0, '操作失败');
         }
     }
 }
示例#3
0
 public function actionMedia()
 {
     $id = tools::val('id');
     if (!$id || !is_numeric($id)) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $userInfo = Users::getUserInfo($id);
     if (!$userInfo || $userInfo['status'] != Posts::STATUS_PASSED) {
         throw new CHttpException(404, '您所查看的页面不存在或已删除');
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'hits DESC';
     //        $criteria->select='id,truename,`desc`,avatar,posts,hits';
     $criteria->condition = "uid='{$id}' AND status=" . Posts::STATUS_PASSED;
     $count = Naodong::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = $this->pageSize;
     $pager->applyLimit($criteria);
     $posts = Naodong::model()->findAll($criteria);
     $posts = self::foreachNaodong($posts);
     Posts::updateCount($id, 'Users');
     $this->pageTitle = $userInfo['truename'] . ' - ' . zmf::config('sitename');
     $this->mobileTitle = $userInfo['truename'];
     $this->pageDescription = $userInfo['desc'] != '' ? $userInfo['desc'] : zmf::config('siteDesc');
     $this->render('media', array('pages' => $pager, 'posts' => $posts, 'userInfo' => $userInfo));
 }