Beispiel #1
0
 /**
  * 查找某人是否在团队中
  */
 public static function findRelation($uid, $gid)
 {
     if (!$uid || !$gid) {
         return false;
     }
     $info = GroupLink::model()->find('uid=:uid AND groupid=:gid', array(':uid' => $uid, ':gid' => $gid));
     if (!$info) {
         return false;
     }
     return $info;
 }
Beispiel #2
0
 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, '加入失败');
         }
     }
 }