예제 #1
0
 function team_get()
 {
     // check that the id is at least a valid number
     $this->_check_id();
     // get the single team by id
     $team = new Team();
     $team->where('id', $this->get('id'))->limit(1)->get();
     if ($team->result_count() == 1) {
         $result = $team->to_array();
         $members = new Membership();
         // get members gives an actual object with ->profile_othervariable
         $memb = $members->get_members($team->id);
         // we have to select the user array manually because... we don't want to expose password hashes
         foreach ($memb->all as $key => $mem) {
             $result['members'][$key] = $mem->to_array(array('id', 'username'));
             $result['members'][$key]['display_name'] = $mem->profile_display_name;
             $result['members'][$key]['twitter'] = $mem->profile_twitter;
             $result['members'][$key]['bio'] = $mem->profile_bio;
         }
         // all good
         $this->response($result, 200);
         // 200 being the HTTP response code
     } else {
         // no team for this id
         $this->response(array('error' => _('Team could not be found')), 404);
     }
 }
예제 #2
0
 public function getteams()
 {
     $keyword = Input::get('q');
     $teams = Team::where('name', 'like', '%' . $keyword . '%')->get();
     $results = array();
     if ($teams->count() > 0) {
         foreach ($teams as $team) {
             array_push($results, array('id' => $team->id, 'text' => $team->name));
         }
     }
     $results = array('results' => $results);
     return Response::json($results);
 }
예제 #3
0
	function get_home_team() {
		$CI = & get_instance();
		if (isset($CI->fs_loaded->home_team))
			return $CI->fs_loaded->home_team;
		$hometeam = get_setting('fs_gen_default_team');
		$team = new Team();
		$team->where('name', $hometeam)->limit(1)->get();
		if ($team->result_count() < 1) {
			$team = new Team();
			$team->limit(1)->get();
		}

		return $team;
	}
예제 #4
0
 public function add_joint_via_name($teams)
 {
     $result = array();
     foreach ($teams as $team) {
         $tea = new Team();
         $tea->where('name', $team)->get();
         if ($tea->result_count() == 0) {
             set_notice('error', _('One of the named teams doesn\'t exist.'));
             log_message('error', 'add_joint_via_name: team does not exist');
             return false;
         }
         $result[] = $tea->id;
     }
     return $this->add_joint($result);
 }
예제 #5
0
파일: members.php 프로젝트: Nakei/FoOlSlide
	function team_get() {
		if (!$this->get('id') || !is_numeric($this->get('id'))) {
			$this->response(NULL, 400);
		}

		$team = new Team();
		$team->where('id', $this->get('id'))->limit(1)->get();

		if ($team->result_count() == 1) {
			$result = $team->to_array();
			$members = new Membership();
			$memb = $members->get_members($team->id);
			foreach($memb->all as $key => $mem) {
				$result['members'][$key] = $memb->to_array(array('id','username'));
				$result['members'][$key]['display_name'] = $memb->profile_display_name;
				$result['members'][$key]['twitter'] = $memb->profile_twitter;
				$result['members'][$key]['bio'] = $memb->profile_bio;
			}
			$this->response($result, 200); // 200 being the HTTP response code
		} else {
			$this->response(array('error' => _('Team could not be found')), 404);
		}
	}
예제 #6
0
파일: reader.php 프로젝트: Nakei/FoOlSlide
	function team_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;

		$team = new Team();
		$team->where('id', $this->get('id'))->limit(1)->get();

		if ($team->result_count() == 1) {
			$result = array();
			$result['team'] = $team->to_array();

			// get joints to get also the chapters from joints
			$joints = new Joint();
			$joints->where('team_id', $team->id)->get();


			$chapters = new Chapter();
			$chapters->where('team_id', $team->id);
			foreach ($joints->all as $joint) {
				$chapters->or_where('joint_id', $joint->joint_id);
			}
			$chapters->limit(100, $page)->get();
			$chapters->get_comic();

			$result['chapters'] = array();
			foreach ($chapters->all as $key => $chapter) {
				if (!$chapter->team_id) {
					$chapter->get_teams();
					foreach ($chapter->teams as $item) {
						$result['chapters'][$key]['teams'][] = $item->to_array();
					}
				} else {
						$result['chapters'][$key]['teams'][] = $team->to_array();
				}
				$result['chapters'][$key]['comic'] = $chapter->comic->to_array();
				$result['chapters'][$key]['chapter'] = $chapter->to_array();
			}

			$this->response($result, 200); // 200 being the HTTP response code
		} else {
			$this->response(array('error' => _('Team could not be found')), 404);
		}
	}
 public function teamName($team_id)
 {
     $team_info = Team::where('id', '=', $team_id)->first();
     $team_name = $team_info->team_title;
     return $team_name;
 }
예제 #8
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);
 }
예제 #9
0
	function get_setting_facebook($team = NULL)
	{
		$hometeam = get_setting('fs_gen_default_team');
		$team = new Team();
		$team->where('name', $hometeam)->limit(1)->get();
		return $team->facebook;
	}
예제 #10
0
파일: reader.php 프로젝트: Nakei/FoOlSlide
	public function download($comic, $language = 'en', $volume = 0, $chapter = "", $subchapter = 0, $team = 0, $joint = 0, $pagetext = 'page', $page = 1) {
		if(!get_setting('fs_dl_enabled'))
			show_404();
		$comice = new Comic();
		$comice->where('stub', $comic)->get();
		if ($comice->result_count() == 0) {
			set_notice('warn', 'This comic doesn\'t exist.');
		}

		if ($chapter == "") {
			redirect('/reader/comic/' . $comic);
		}

		$chaptere = new Chapter();
		$chaptere->where('comic_id', $comice->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->order_by('subchapter', 'ASC');

		if (!is_int($subchapter) && $subchapter == 'page') {
			$current_page = $team;
		}
		else {
			$chaptere->where('subchapter', $subchapter);

			if ($team == 'page')
				$current_page = $joint;
			else {
				if ($team != 0) {
					$teame = new Team();
					$teame->where('stub', $team)->get();
					$chaptere->where('team_id', $teame->id);
				}

				if ($joint == 'page')
					$current_page = $pagetext;

				if ($joint != 0) {
					$chaptere->where('joint_id', $joint);
				}
			}
		}

		if (!isset($current_page)) {
			if ($page != 1)
				$current_page = $page;
			else
				$current_page = 1;
		}

		$chaptere->get();
		if ($chaptere->result_count() == 0) {
			show_404();
		}
		
		$archive = new Archive();
		$url = $archive->compress($chaptere);
		redirect($url);
	}
 public function postStepThree()
 {
     $code = Input::get('code');
     $validation = Validator::make(['teamname' => Input::get('teamname')], ['teamname' => 'required|max:20|min:4']);
     if ($validation->fails()) {
         return Redirect::route('setprofile_step3', array($code))->withErrors($validation)->withInput(Input::except('_token'));
     } else {
         $teamname = Input::get('teamname');
         try {
             $userQuery = User::where('code', '=', $code)->first();
             $creatorID = $userQuery->id;
             $orgIDQuery = DB::table('organizations')->where('creator_id', '=', $creatorID)->first();
             $orgID = $orgIDQuery->id;
             if ($userQuery && $orgIDQuery) {
                 $team = new Team();
                 $team->team_title = $teamname;
                 $team->leader_id = $creatorID;
                 $team->org_id = $orgID;
                 $team->save();
                 $teamQuery = Team::where('team_title', '=', $teamname)->first();
                 $teamID = $teamQuery->id;
                 $userQuery->team_id = $teamID;
                 $userQuery->save();
                 return Redirect::route('setprofile_step4', array($code));
             } else {
                 return 'Cant Find User';
             }
         } catch (Exception $e) {
             return Redirect::route('setprofile_step3', array($code));
         }
     }
 }
 public function addplayer($id)
 {
     setlocale(LC_MONETARY, "en_US");
     $user = Auth::user();
     $club = $user->Clubs()->FirstOrFail();
     $followers = new Follower();
     $title = 'League Together - ' . $club->name . ' Teams';
     $team = Team::where("id", "=", $id)->where("club_id", '=', $club->id)->FirstOrFail();
     $plan = $club->plans()->lists('name', 'id');
     return View::make('pages.user.club.team.addplayer')->with('page_title', $title)->with('team', $team)->with('followers', $followers->getPlayers())->withUser($user);
 }
예제 #13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $teams = Team::where('id', $id)->get();
     return view('admin/edit_team')->withTeam($teams);
 }
예제 #14
0
	/**
	 * Returns leader team objects, false in case user is not a team leader
	 * 
	 * @author Woxxy
	 * @param int $team_id if NULL returns each team in which this user is leader
	 * @return object Teams
	 * 
	 */
	function is_team_leader($team_id = NULL) {
		if (!$this->is_logged_in())
			return FALSE;

		$leaderships = new Membership();
		$leaderships->where('user_id', $this->get_user_id())->where('accepted', 1)->where('is_leader', 1);

		if (is_numeric($team_id)) {
			$leaderships->where('team_id', $team_id);
			$leaderships->get();
			if ($leaderships->result_count() != 1)
				return FALSE;
			$team = new Team();
			$team->where('id', $team_id)->get();
			return $team;
		}

		$leaderships->get();
		if ($leaderships->result_count() < 1)
			return FALSE;
		$teams = new Team();
		// Notice that if you remove the result count on $leaderships, this will not run and the user will be leader of any team!
		foreach ($leaderships->all as $key => $leadership) {
			$teams->or_where('id', $leadership->team_id);
		}
		$teams->get();
		return $teams;
	}
 /**
  * Show the form for editing the specified resource.
  * GET /members/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($team, $id)
 {
     setlocale(LC_MONETARY, "en_US");
     $user = Auth::user();
     $club = $user->Clubs()->FirstOrFail();
     $member = Member::find($id);
     $title = 'League Together - ' . $club->name . ' Teams';
     $team = Team::where("id", "=", $team)->where("club_id", '=', $club->id)->FirstOrFail();
     return View::make('app.club.member.edit')->with('page_title', $title)->with('team', $team)->with('member', $member)->with('club', $club)->withUser($user);
 }
예제 #16
0
파일: chapter.php 프로젝트: Nakei/FoOlSlide
	/**
	 * Handles both creating of new chapters in the database and editing old ones.
	 * It determines if it should update or not by checking if $this->id has
	 * been set. It can get the values from both the $data array and direct 
	 * variable assignation. Be aware that array > variables. The latter ones
	 * will be overwritten. Particularly, the variables that the user isn't
	 * allowed to set personally are unset and reset with the automated values.
	 * It's quite safe to throw stuff at it.
	 *
	 * @author	Woxxy
	 * @param	array $data contains the minimal data
	 * @return	object the comic the chapter derives from.
	 */
	public function update_chapter_db($data = array()) {
		// Check if we're updating or creating a new chapter by looking at $data["id"].
		// False is returned if the chapter ID was not found.
		if (isset($data["id"]) && $data['id'] != "") {
			$this->where("id", $data["id"])->get();
			if ($this->result_count() == 0) {
				set_notice('error', _('The chapter you tried to edit doesn\'t exist.'));
				log_message('error', 'update_chapter_db: failed to find requested id');
				return false;
			}
			// Save the stub in case it gets changed (different chapter number/name etc.)
			// Stub is always automatized.
			$old_stub = $this->stub;
		}
		else { // if we're here, it means that we're creating a new chapter
			// Set the creator name if it's a new chapter.	
			if (!isset($this->comic_id)) {
				set_notice('error', 'You didn\'t select a comic to refer to.');
				log_message('error', 'update_chapter_db: comic_id was not set');
				return false;
			}

			// Check that the related comic is defined, and exists.
			$comic = new Comic($this->comic_id);
			if ($comic->result_count() == 0) {
				set_notice('error', _('The comic you were referring to doesn\'t exist.'));
				log_message('error', 'update_chapter_db: comic_id does not exist in comic database');
				return false;
			}

			// Set the creator. This happens only on new chapter creation.
			$this->creator = $this->logged_id();
		}

		// Always set the editor
		$this->editor = $this->logged_id();

		// Unset the sensible variables. 
		// Not even admins should touch these, for database stability.
		unset($data["creator"]);
		unset($data["editor"]);
		unset($data["uniqid"]);
		unset($data["stub"]);
		unset($data["team_id"]);
		unset($data["joint_id"]);

		// Loop over the array and assign values to the variables.
		foreach ($data as $key => $value) {
			$this->$key = $value;
		}

		// Double check that we have all the necessary automated variables
		if (!isset($this->uniqid))
			$this->uniqid = uniqid();
		if (!isset($this->stub))
			$this->stub = $this->stub();

		// This is necessary to make the checkbox work.
		/**
		 *  @todo make the checkbox work consistently across the whole framework
		 */
		if (!isset($data['hidden']) || $data['hidden'] != 1)
			$this->hidden = 0;

		// Prepare a new stub.
		$this->stub = $this->chapter . '_' . $this->subchapter . '_' . $this->name;
		// stub() is also able to restub the $this->stub. Already stubbed values won't change.
		$this->stub = $this->stub();

		// If the new stub is different from the old one (if the chapter was 
		// already existing), rename the folder.
		if (isset($old_stub) && $old_stub != $this->stub) {
			$this->get_comic();
			$dir_old = "content/comics/" . $this->comic->directory() . "/" . $old_stub . "_" . $this->uniqid;
			$dir_new = "content/comics/" . $this->comic->directory() . "/" . $this->stub . "_" . $this->uniqid;
			rename($dir_old, $dir_new);
		}


		// $data['team'] must be an array of team NAMES
		if (isset($data['team'])) {
			// Remove the empty values in the array of team names.
			// It happens that the POST contains extra empty values.
			if (is_array($data['team'])) {
				foreach ($data['team'] as $key => $value) {
					if ($value == "") {
						unset($data['team'][$key]);
					}
				}
				sort($data["team"]);
			}

			// In case there's more than a team name in array, get the joint_id.
			// The joint model is able to create new joints on the fly, do not worry.
			// Worry rather that the team names must exist.
			if (count($data['team']) > 1) {
				// Set team_id to 0 since it's a joint.
				$this->team_id = 0;
				$joint = new Joint();
				// If the search returns false, something went wrong.
				// GUI errors are inside the function.
				if (!$this->joint_id = $joint->add_joint_via_name($data['team'])) {
					log_message('error', 'update_chapter_db: error with joint_id');
					return false;
				}
			}
			// In case there's only one team in the array, find the team.
			// return false in case one of the names doesn't exist.
			else if (count($data['team']) == 1) {
				// Set joint_id to 0 since it's a single team
				$this->joint_id = 0;
				$team = new Team();
				$team->where("name", $data['team'][0])->get();
				if ($team->result_count() == 0) {
					set_notice('error', _('The team you were referring this chapter to doesn\'t exist.'));
					log_message('error', 'update_chapter_db: team_id does not exist in team database');
					return false;
				}
				$this->team_id = $team->id;
			}
			else {
				set_notice('error', _('You must select at least one team for this chapter'));
				log_message('error', 'update_chapter_db: team_id not defined');
				return false;
			}
		}
		else if (!isset($this->team)) { // If we're here it means that this is a new chapter with no teams assigned.
			// The system doesn't allow chapters without related teams. It must be at
			// least "anonymous" or a default anonymous team.
			set_notice('error', _('You haven\'t selected any team in relation to this chapter.'));
			log_message('error', 'update_chapter_db: team_id does not defined');
			return false;
		}


		// Save with validation. Push false if fail, true if good.
		$success = $this->save();
		if (!$success) {
			if (!$this->valid) {
				log_message('error', $this->error->string);
				set_notice('error', _('Check that you have inputted all the required fields.'));
				log_message('error', 'update_chapter_db: failed validation');
			}
			else {
				set_notice('error', _('Failed to save to database for unknown reasons.'));
				log_message('error', 'update_chapter_db: failed to save');
			}
			return false;
		}
		else {
			// Here we go!
			return true;
		}
	}
예제 #17
0
 public function TeamB()
 {
     return Team::where('id', '=', $this->teamB_id)->first();
 }
예제 #18
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);
	}
예제 #19
0
파일: members.php 프로젝트: Nakei/FoOlSlide
	function home_team() {
		$team = new Team();
		$team->where('name', get_setting('fs_gen_default_team'))->get();
		redirect('/admin/members/teams/' . $team->stub);
	}
예제 #20
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $team = Team::where('identifier', '=', $id)->first();
     $players = Player::where('teamIdentifier', '=', $id)->get();
     return View::make('team.details', ['team' => $team, 'players' => $players]);
 }
예제 #21
0
 /**
  * Returns chapters per page from team ID
  * Includes releases from joints too
  * 
  * This is NOT a method light enough to lookup teams. use api/members/team for that
  * 
  * Available filters: id (required), page, per_page (default:30, max:100), orderby
  * 
  * @author Woxxy
  */
 function team_get()
 {
     // get the single team by id or stub
     if ($this->get('stub')) {
         $team = new Team();
         $team->where('stub', $this->get('stub'))->limit(1)->get();
     } else {
         // check that the id is at least a valid number
         $this->_check_id();
         $team = new Team();
         $team->where('id', $this->get('id'))->limit(1)->get();
     }
     // team found?
     if ($team->result_count() == 1) {
         $result = array();
         $result['team'] = $team->to_array();
         // get joints to get also the chapters from joints
         $joints = new Joint();
         $joints->where('team_id', $team->id)->get();
         $chapters = new Chapter();
         // get all chapters with the team ID
         $chapters->where('team_id', $team->id);
         foreach ($joints->all as $joint) {
             // get also all chapters with the joints by the team
             $chapters->or_where('joint_id', $joint->joint_id);
         }
         // filter for the page and the order
         $this->_orderby($chapters);
         $this->_page_to_offset($chapters);
         $chapters->get();
         $chapters->get_comic();
         // let's save some power by reusing the variables we already have for team
         // and put everything in the usual clean [comic][chapter][teams]
         $result['chapters'] = array();
         foreach ($chapters->all as $key => $chapter) {
             if (!$chapter->team_id) {
                 $chapter->get_teams();
                 foreach ($chapter->teams as $item) {
                     $result['chapters'][$key]['teams'][] = $item->to_array();
                 }
             } else {
                 $result['chapters'][$key]['teams'][] = $team->to_array();
             }
             $result['chapters'][$key]['comic'] = $chapter->comic->to_array();
             $result['chapters'][$key]['chapter'] = $chapter->to_array();
         }
         // all good
         $this->response($result, 200);
         // 200 being the HTTP response code
     } else {
         // that single team id wasn't found
         $this->response(array('error' => _('Team could not be found')), 404);
     }
 }
예제 #22
0
 function leave_leadership($team_stub)
 {
     $this->viewdata["navbar"] = "";
     $team = new Team();
     $team->where('stub', $team_stub)->get();
     if ($team->result_count() != 1) {
         show_404();
     }
     if (!$this->tank_auth->is_team_leader($team->id) && !$this->tank_auth->is_allowed()) {
         show_404();
     }
     if ($this->input->post()) {
         $member = new Membership();
         if (!$member->remove_team_leader($team->id)) {
             return show_404();
         }
         redirect('/account/teams/');
     }
     $this->viewdata["function_title"] = _("Leave team leadership");
     $data["team_name"] = $team->name;
     $data["team_id"] = $team->id;
     $this->viewdata["main_content_view"] = $this->load->view('account/profile/leave_leadership', $data, TRUE);
     $this->load->view("account/default.php", $this->viewdata);
 }
예제 #23
0
 public function read($comic, $language = 'en', $volume = 0, $chapter = "", $subchapter = 0, $team = 0, $joint = 0, $pagetext = 'page', $page = 1)
 {
     $comice = new Comic();
     $comice->where('stub', $comic)->get();
     if ($comice->result_count() == 0) {
         set_notice('warn', 'This comic doesn\'t exist.');
     }
     if ($chapter == "") {
         redirect('series/' . $comic);
     }
     if (!$this->_check_adult($comice)) {
         // or this function won't stop
         return FALSE;
     }
     $chaptere = new Chapter();
     $chaptere->where('comic_id', $comice->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->order_by('subchapter', 'ASC');
     if (!is_int($subchapter) && $subchapter == 'page') {
         $current_page = $team;
     } else {
         $chaptere->where('subchapter', $subchapter);
         if ($team == 'page') {
             $current_page = $joint;
         } else {
             if ($team != 0) {
                 $teame = new Team();
                 $teame->where('stub', $team)->get();
                 $chaptere->where('team_id', $teame->id);
             }
             if ($joint == 'page') {
                 $current_page = $pagetext;
             }
             if ($joint != 0) {
                 $chaptere->where('joint_id', $joint);
             }
         }
     }
     if (!isset($current_page)) {
         if ($page != 1) {
             $current_page = $page;
         } else {
             $current_page = 1;
         }
     }
     $chaptere->get();
     if ($chaptere->result_count() == 0) {
         show_404();
     }
     $pages = $chaptere->get_pages();
     foreach ($pages as $page) {
         unset($page["object"]);
     }
     $next_chapter = $chaptere->next();
     if ($current_page > count($pages)) {
         redirect($next_chapter);
     }
     if ($current_page < 1) {
         $current_page = 1;
     }
     $chapters = new Chapter();
     $chapters->where('comic_id', $comice->id)->order_by('volume', 'desc')->order_by('chapter', 'desc')->order_by('subchapter', 'desc')->get_bulk();
     $comics = new Comic();
     $comics->order_by('name', 'ASC')->limit(100)->get();
     $this->template->set('is_reader', TRUE);
     $this->template->set('comic', $comice);
     $this->template->set('chapter', $chaptere);
     $this->template->set('chapters', $chapters);
     $this->template->set('comics', $comics);
     $this->template->set('current_page', $current_page);
     $this->template->set('pages', $pages);
     $this->template->set('next_chapter', $next_chapter);
     $this->template->title($comice->name, _('Chapter') . ' ' . $chaptere->chapter, get_setting('fs_gen_site_title'));
     switch ($comice->format) {
         case 1:
             $format = 'readtoon';
             break;
         default:
             $format = 'read';
     }
     $this->template->build($format);
 }