public static function memberOf($uid) { $condition = sprintf('uid=%d AND deleted=0', $uid); return MaTeamMember::find($condition); }
public function deleteAction() { // 使用默认视图 MyTool: simpleView(); // 验证登录状态 if (!MyTool::loginAuth($this)) { return $this->onExit(MyConst::STATUS_NOT_LOGIN, 'must login first'); } $targetId = @intval($targetId); $uid = @intval(MyTool::getCookie($this, MyConst::COOKIE_UID)); // 获取团队信息 $team = TeamLogic::getTeam($targetId); if (empty($team)) { return MyTool::onExit($this, MyConst::STATUS_INVALID_TEAM, 'invalid team id'); } if (TeamLogic::isOwner($uid, $targetId)) { return MyTool::onExit($this, MyConst::STATUS_ERROR, 'owner of team'); } // 团队成员 $member = MaTeamMember::getMember($targetId, $uid); if (empty($member)) { return MyTool::onExit($this, MyConst::STATUS_NOT_EXISTS, 'not a member of team'); } // 删除成员 try { if (true !== $member->delete()) { return MyTool::onExit($this, MyConst::STATUS_DB, 'delete team fail'); } } catch (Exception $e) { return MyTool::onExit($this, MyConst::STATUS_ERROR, $e->getMessage()); } // 返回 MyTool::setVar($this, MyConst::FIELD_STATUS, MyConst::STATUS_OK); return true; }
public static function getMembers($tid) { $condition = sprintf('tid=%d AND deleted=0', $tid, $uid); return MaTeamMember::find($condition); }