예제 #1
0
파일: team.php 프로젝트: KasaiDot/FoOlSlide
 public function get_teams($team_id, $joint_id = 0)
 {
     // if it's a joint, let's deal it as a joing
     if ($joint_id > 0) {
         // get all the joint entries so we have all the teams
         $joint = new Joint();
         $joint->where("joint_id", $joint_id)->get();
         // not an existing joint?
         if ($joint->result_count() < 1) {
             log_message('error', 'get_teams: joint -> joint not found');
             return false;
         }
         // result array
         $teamarray = array();
         foreach ($joint->all as $key => $join) {
             if (!($team = $this->get_cached($join->team_id))) {
                 $team = new Team();
                 $team->where('id', $join->team_id);
                 $team->get();
             }
             $teamarray[] = $team->get_clone();
         }
         if (empty($teamarray)) {
             log_message('error', 'get_teams: joint -> no teams found');
             return false;
         }
         return $teamarray;
     }
     // if we're here, it means it's a simple team
     if (!($team = $this->get_cached($team_id))) {
         $team = new Team($team_id);
     }
     return array($team);
 }
예제 #2
0
 public function remove_team_from_all($team_id)
 {
     $joints = new Joint();
     $joints->where('team_id', $team_id)->get();
     if (!$joints->delete_all()) {
         set_notice('error', _('Couldn\'t remove the team from all the joints.'));
         log_message('error', 'remove_team_from_all (joint.php): removing failed');
         return false;
     }
 }
예제 #3
0
 /**
  * Returns chapters per page by joint ID
  * Also returns the teams
  * 
  * This is not a method light enough to lookup teams. use api/members/joint for that
  * 
  * Available filters: id (required), page, per_page (default:30, max:100), orderby
  * 
  * @author Woxxy
  */
 function joint_get()
 {
     // check that the id is at least a valid number
     $this->_check_id();
     // grab by joint_id, id for joints means nothing much
     $joint = new Joint();
     $joint->where('joint_id', $this->get('id'))->limit(1)->get();
     if ($joint->result_count() == 1) {
         // good old get_teams() will give us all Team objects in an array
         $team = new Team();
         $teams = $team->get_teams(0, $this->get('id'));
         // $teams is a normal array, so we have to do a loop
         $result = array();
         foreach ($teams as $item) {
             $result['teams'][] = $item->to_array();
         }
         // grab all the chapters from the same joint
         $chapters = new Chapter();
         $chapters->where('joint_id', $joint->joint_id);
         // apply the limit and orderby filters
         $this->_orderby($chapters);
         $this->_page_to_offset($chapters);
         $chapters->get();
         $chapters->get_comic();
         // let's put the chapters in a nice [comic][chapter][teams] list
         $result['chapters'] = array();
         foreach ($chapters->all as $key => $chapter) {
             $result['chapters'][$key]['comic'] = $chapter->comic->to_array();
             $result['chapters'][$key]['chapter'] = $chapter->to_array();
             $result['chapters'][$key]['teams'] = $result['teams'];
         }
         // all good
         $this->response($result, 200);
         // 200 being the HTTP response code
     } else {
         // nothing for this joint or page
         $this->response(array('error' => _('Team could not be found')), 404);
     }
 }
예제 #4
0
파일: reader.php 프로젝트: Nakei/FoOlSlide
	function joint_get() {
		if (!$this->get('id') || !is_numeric($this->get('id'))) {
			$this->response(NULL, 400);
		}

		if (!$this->get('page') || !is_numeric($this->get('page')) || $this->get('page') < 1)
			$page = 1;
		else
			$page = (int) $this->get('page');

		$page = ($page * 100) - 100;

		$joint = new Joint();
		$joint->where('joint_id', $this->get('id'))->limit(1)->get();

		if ($joint->result_count() == 1) {

			$team = new Team();
			$teams = $team->get_teams(0, $this->get('id'));

			$result = array();
			foreach ($teams as $item) {
				$result['teams'][] = $item->to_array();
			}

			$chapters = new Chapter();
			$chapters->where('joint_id', $joint->joint_id);
			$chapters->limit(100, $page)->get();
			$chapters->get_comic();

			$result['chapters'] = array();
			foreach ($chapters->all as $key => $chapter) {
				$result['chapters'][$key]['comic'] = $chapter->comic->to_array();
				$result['chapters'][$key]['chapter'] = $chapter->to_array();
				$result['chapters'][$key]['teams'] = $result['teams'];
			}

			$this->response($result, 200); // 200 being the HTTP response code
		} else {
			$this->response(array('error' => _('Team could not be found')), 404);
		}
	}
예제 #5
0
파일: team.php 프로젝트: Nakei/FoOlSlide
	public function get_teams($team_id, $joint_id = 0) {
		if ($joint_id > 0) {
			$joint = new Joint();
			$joint->where("joint_id", $joint_id)->get();
			if ($joint->result_count() < 1) {
				log_message('error', 'get_teams: joint -> joint not found');
				return false;
			}

			$teamarray = array();
			$team = new Team();
			foreach ($joint->all as $key => $join) {
				$team->where('id', $join->team_id);
				$team->get();
				$teamarray[] = $team->get_clone();
			}

			if ($team->result_count() < 1) {
				log_message('error', 'get_teams: joint -> no teams found');
				return false;
			}

			return $teamarray;
		}

		$team = new Team($team_id);
		return array($team);
	}