コード例 #1
0
ファイル: GroupController.php プロジェクト: ph7pal/wedding
 public function actionView($id)
 {
     $this->layout = '/layouts/group';
     $this->currentModule = 'group';
     $info = WeddingGroup::model()->findByPk($id);
     if (!$info) {
         throw new CHttpException(404, '你所查看的页面不存在');
     }
     $info->avatar = $info->getAvatar($info->avatar);
     if (zmf::uid()) {
         $reInfo = GroupLink::findRelation($this->uid, $id);
         if ($reInfo) {
             $this->joined = true;
         }
     }
     //获取团队成员
     $criteria = new CDbCriteria(array('condition' => 'gl.groupid=' . $id, 'join' => 'LEFT JOIN {{group_link}} gl ON t.id=gl.uid', 'select' => 't.id,t.truename,t.avatar'));
     $members = new CActiveDataProvider('Users', array('pagination' => array('pageSize' => 10), 'criteria' => $criteria));
     //获取团队案例列表
     $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p WHERE p.groupid='{$id}' AND p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $posts[$k]['faceimg'] = $_url;
             } else {
                 $posts[$k]['faceimg'] = '';
             }
         }
     }
     $data = array('info' => $info, 'posts' => $posts, 'pages' => $pages);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
コード例 #2
0
ファイル: AjaxController.php プロジェクト: ph7pal/wedding
 public function actionJoinGroup()
 {
     self::checkLogin();
     $uid = zmf::uid();
     $groupid = zmf::filterInput(Yii::app()->request->getParam('gid'));
     if (zmf::actionLimit('joinGroup', $groupid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if (!$groupid || !is_numeric($groupid)) {
         $this->jsonOutPut(0, '加入失败');
     }
     $groupInfo = WeddingGroup::model()->findByPk($groupid);
     if (!$groupInfo) {
         $this->jsonOutPut(0, '您所查看的页面不存在');
     } elseif ($groupInfo['status'] == Posts::STATUS_STAYCHECK) {
         $this->jsonOutPut(0, '该团队暂未通过认证');
     }
     $reInfo = GroupLink::findRelation($uid, $groupid);
     if ($reInfo) {
         //已存在则退出
         if (GroupLink::model()->deleteByPk($reInfo['id'])) {
             $this->jsonOutPut(4, '已退出');
         } else {
             $this->jsonOutPut(0, '退出失败');
         }
     } else {
         $attr = array('groupid' => $groupid, 'uid' => $uid);
         if (GroupLink::add($attr)) {
             $this->jsonOutPut(3, '已加入');
         } else {
             $this->jsonOutPut(0, '加入失败');
         }
     }
 }