Exemplo n.º 1
0
 public function initGroupRole()
 {
     $uid = Yii::app()->user->id;
     if (empty($uid)) {
         return false;
     }
     $gid = Yii::app()->request->getQuery('gid');
     $tid = Yii::app()->request->getQuery('tid');
     if (empty($gid) and !empty($tid)) {
         $topic = GroupTopic::model()->loadTopic($tid);
         $gid = $topic->gid;
     }
     if (!empty($gid)) {
         $model = new Group();
         $model->primaryKey = $gid;
         $member = $model->loadMember($uid);
         if (!empty($member)) {
             $status = $member->status;
             //申请加入 但未通过
             if ($status == 0) {
                 $this->isGroupApplicant = true;
             }
             //申请通过
             $level = $member->level;
             if ($level > 0) {
                 $this->isGroupMember = true;
             }
             if ($level > 1) {
                 $this->isGroupAdmin = true;
             }
             if ($level > 2) {
                 $this->isGroupBoss = true;
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['tid'])) {
             $condition = '';
             $this->_model = GroupTopic::model()->findByPk($_GET['tid'], $condition);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Exemplo n.º 3
0
 /**
  * 删除话题/回复后业务处理
  */
 protected function afterDelete()
 {
     if ($this->istopic == '1') {
         GroupTopic::model()->deleteByPk($this->tid);
         //Group::model()->updateCounters(array('threadcount'=>-1), "id={$this->gid}");
     } else {
         GroupTopic::model()->updateCounters(array('postcount' => -1), "id={$this->tid}");
     }
 }