public function listMembersCallback(StdClass $args, ReadOnlyObject $action, ReadWriteObject $mem_redirect, ReadWriteObject $mem_resend)
 {
     $vars = $args->post;
     $member = false;
     if (isset($vars['member']) && $vars['member'] != '0') {
         $temp = new Member();
         $member = $temp->findById($vars['member']);
     }
     $history = false;
     if (isset($vars['history']) && $vars['history'] != '0') {
         $history = true;
     }
     $mem_redirect->vars = $vars;
     $mem_redirect->members = $this->model->getMembersWithFlags(false, $history);
     // get list of members with Flags (as assigned, filter by $member if set)
     $mem_redirect->membersWithFlags = $this->model->getMembersWithFlags($member, $history);
 }
 public static function _doSubmitIssue()
 {
     if (!empty($_POST['title'])) {
         $user = Member::findById($_POST['user'])->forum_name;
         $title = $_POST['title'];
         $link = $_POST['link'];
         $body = $_POST['body'];
         $body .= !empty($link) ? "<hr /><strong>Page reported</strong>: {$link}<br />" : null;
         $body .= "<strong>Reported by</strong>: {$user}";
         $issue = GitHub::createIssue($title, $body);
         if (is_object($issue)) {
             if ($issue->getNumber()) {
                 $data = array('success' => true, 'message' => "Your report has been submitted");
             }
         } else {
             $data = array('success' => false, 'message' => "Something went wrong");
         }
     } else {
         $data = array('success' => false, 'message' => "You must provide a title");
     }
     echo json_encode($data);
 }
    ?>
 members</span></div>
			<div class='list-group' id='squads'>
				<?php 
    if (count((array) $squads)) {
        $i = 1;
        ?>

					<!-- get squads -->

					<?php 
        foreach ($squads as $squad) {
            ?>

						<?php 
            $leader = $squad->leader_id != 0 ? Member::findById($squad->leader_id) : false;
            ?>

						<a href='#collapseSquad_<?php 
            echo $i;
            ?>
' data-toggle='collapse' class='list-group-item active accordion-toggle' data-parent='#squads'>

							<?php 
            if ($squad->leader_id) {
                ?>

								<?php 
                echo ordsuffix($i) . " Squad - " . Rank::convert($leader->rank_id)->abbr;
                ?>
 <?php 
							<label for='squad_id' class='control-label'><?php 
    echo Locality::run('squad', $member->game_id);
    ?>
</label>
							<select name='squad_id' id='squad_id' class='form-control'>

								<?php 
    if (count(Division::countSquadLeaders($member->game_id))) {
        ?>

									<?php 
        foreach ($squads as $squad) {
            ?>

										<?php 
            $leader = Member::findById($squad->leader_id);
            ?>
										<?php 
            $platoon = Platoon::findById($squad->platoon_id);
            ?>

										<option value='<?php 
            echo $squad->id;
            ?>
'><?php 
            echo $squad->leader_id != 0 ? Rank::convert($leader->rank_id)->abbr . " " . ucwords($leader->forum_name) : "TBA (Squad #{$squad->id})";
            ?>
 - <?php 
            echo $platoon->name;
            ?>
</option>
 public function generate()
 {
     // header
     $division_structure = "[table='align:center,width: {$this->info_width}']";
     $division_structure .= "[tr][td]";
     // banner
     $division_structure .= "[center][img]http://puu.sh/kGjU9/4f331d1a99.jpg[/img][/center]\r\n";
     /**
      * ------division leaders-----
      */
     $division_structure .= "\r\n\r\n[center][size=5][color={$this->div_name_color}][b][i][u]Division Leaders[/u][/i][/b][/color][/size][/center]\r\n";
     $division_structure .= "[center][size=4]";
     $division_leaders = Division::findDivisionLeaders($this->game_id);
     foreach ($division_leaders as $player) {
         $player_name = Rank::convert($player->rank_id)->abbr . " " . $player->forum_name;
         $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => $player_name, 'color' => $this->division_leaders_color));
         $division_structure .= "{$aod_url} - {$player->position_desc}\r\n";
     }
     $division_structure .= "[/size][/center]\r\n\r\n";
     /**
      * -----general sergeants-----
      */
     $division_structure .= "[center][size=3][color={$this->platoon_pos_color}]General Sergeants[/color]\r\n";
     $general_sergeants = Division::findGeneralSergeants($this->game_id);
     foreach ($general_sergeants as $player) {
         $player_name = Rank::convert($player->rank_id)->abbr . " " . $player->forum_name;
         $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => $player_name));
         $division_structure .= "{$aod_url}\r\n";
     }
     $division_structure .= "[/size][/center]";
     $division_structure .= "[/td][/tr][/table]";
     /**
      * ---------platoons----------
      */
     $division_structure .= "\r\n\r\n[table='align:center,width: {$this->players_width}']";
     $platoons = $this->platoons;
     $i = 1;
     foreach ($platoons as $platoon) {
         $countMembers = Platoon::countPlatoon($platoon->id);
         if ($i == 1) {
             $division_structure .= "[tr]";
             $division_structure .= "[td]";
         } else {
             $division_structure .= "[td]";
         }
         $division_structure .= "[size=5]{$platoon->name}[/size]\r\n\r\n";
         // Legion Commander
         $player = Member::findByMemberId($platoon->leader_id);
         // is a Legion Commander assigned?
         if ($platoon->leader_id != 0) {
             $player_name = Rank::convert($player->rank_id)->abbr . " " . $player->forum_name;
             $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => $player_name, 'color' => $this->platoon_leaders_color));
             $division_structure .= "[size=3][color={$this->platoon_pos_color}]Legion Commander[/color]\r\n{$aod_url}[/size]\r\n\r\n";
         } else {
             $division_structure .= "[size=3][color={$this->platoon_pos_color}]Legion Commander[/color]\r\n[color={$this->platoon_leaders_color}]TBA[/color][/size]\r\n\r\n";
         }
         // Regimental Leaders
         $squads = Squad::findAll($this->game_id, $platoon->id);
         foreach ($squads as $squad) {
             if ($squad->leader_id != 0) {
                 $squad_leader = Member::findById($squad->leader_id);
                 $player_name = Rank::convert($squad_leader->rank_id)->abbr . " " . $squad_leader->forum_name;
                 $aod_url = Member::createAODlink(array('member_id' => $squad_leader->member_id, 'forum_name' => $player_name, 'color' => $this->squad_leaders_color));
                 $division_structure .= "[size=3][color={$this->platoon_pos_color}]Regimental Leader[/color]\r\n{$aod_url}[/size]\r\n\r\n";
                 $division_structure .= "[size=1]";
                 // direct recruits
                 $recruits = arrayToObject(Member::findRecruits($squad_leader->member_id, $squad_leader->platoon_id, $squad->id, true));
                 if (count((array) $recruits)) {
                     $division_structure .= "[list=1]";
                     foreach ($recruits as $player) {
                         $player_name = Rank::convert($player->rank_id)->abbr . " " . $player->forum_name;
                         $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => $player_name));
                         $division_structure .= "[*]{$aod_url}\r\n";
                     }
                     $division_structure .= "[/list]";
                 }
             } else {
                 $division_structure .= "[size=3][color={$this->platoon_pos_color}]Regimental Leader[/color]\r\n[color={$this->squad_leaders_color}]TBA[/color][/size]\r\n";
                 $division_structure .= "[size=1]";
             }
             $division_structure .= "\r\n";
             // squad members
             $squadMembers = arrayToObject(Squad::findSquadMembers($squad->id, true, $squad_leader->member_id));
             if (count((array) $squadMembers)) {
                 foreach ($squadMembers as $player) {
                     $player_name = Rank::convert($player->rank_id)->abbr . " " . $player->forum_name;
                     $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => $player_name));
                     $division_structure .= "{$aod_url}\r\n";
                 }
             }
             $division_structure .= "[/size]\r\n";
         }
         $division_structure .= "\r\n\r\n";
         if ($i % $this->num_columns == 0) {
             $division_structure .= "[/td][/tr][tr]";
         }
         $division_structure .= "[/td]";
         $i++;
     }
     // end last platoon
     $division_structure .= "[/tr][/table]\r\n\r\n";
     /**
      * --------part timers--------
      */
     $i = 1;
     // header
     $division_structure .= "\r\n[table='align:center,width: {$this->info_width}']";
     $division_structure .= "[tr][td]\r\n[center][size=3][color={$this->platoon_pos_color}][b]Part Time Members[/b][/color][/size][/center][/td][/tr]";
     $division_structure .= "[/table]\r\n\r\n";
     // players
     $division_structure .= "[table='align:center,width: {$this->info_width}']";
     $division_structure .= "[tr][td]";
     $partTimers = PartTime::find_all($this->game_id);
     foreach ($partTimers as $player) {
         if ($i % 20 == 0) {
             $division_structure .= "[/td][td]";
         }
         $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => "AOD_" . $player->forum_name));
         $division_structure .= "{$aod_url}\r\n";
         $i++;
     }
     $division_structure .= "[/td]";
     $division_structure .= "[/tr][/table]\r\n\r\n";
     /**
      * -----------LOAS------------
      */
     if (count((array) LeaveOfAbsence::find_all($this->game_id))) {
         $i = 1;
         // header
         $division_structure .= "\r\n[table='align:center,width: {$this->info_width}']";
         $division_structure .= "[tr][td]\r\n[center][size=3][color={$this->platoon_pos_color}][b]Leaves of Absence[/b][/color][/size][/center][/td][/tr]";
         $division_structure .= "[/table]\r\n\r\n";
         // players
         $division_structure .= "[table='align:center,width: {$this->info_width}']";
         $loas = LeaveOfAbsence::find_all($this->game_id);
         foreach ($loas as $player) {
             $date_end = strtotime($player->date_end) < strtotime('now') ? "[COLOR='#FF0000']Expired " . formatTime(strtotime($player->date_end)) . "[/COLOR]" : date("M d, Y", strtotime($player->date_end));
             $profile = Member::findByMemberId($player->member_id);
             $aod_url = Member::createAODlink(array('member_id' => $player->member_id, 'forum_name' => "AOD_" . $profile->forum_name));
             $division_structure .= "[tr][td]{$aod_url}[/td][td]{$date_end}[/td][td]{$player->reason}[/td][/tr]";
             $i++;
         }
         $division_structure .= "[/table]";
     }
     $this->content = $division_structure;
 }
 public function generate()
 {
     // header
     $division_structure = "[table='width: {$this->info_width}']";
     $division_structure .= "[tr][td]";
     // banner
     $division_structure .= "[center][img]http://i.imgur.com/iWpjGZG.png[/img][/center]\r\n";
     /**
      * ------division leaders-----
      */
     $division_structure .= "\r\n\r\n[center][size=5][color={$this->div_name_color}][b][i][u]Division Leaders[/u][/i][/b][/color][/size][/center]\r\n";
     $division_structure .= "[center][size=4]";
     $division_leaders = Division::findDivisionLeaders($this->game_id);
     foreach ($division_leaders as $leader) {
         $leader_name = Rank::convert($leader->rank_id)->abbr . " " . $leader->forum_name;
         $memberHandle = MemberHandle::findHandle($leader->id, $this->division->primary_handle);
         $leader->handle = $memberHandle->handle_value;
         $aod_url = "[url=" . CLANAOD . $leader->member_id . "]";
         $bl_url = "[url=" . $memberHandle->url . $leader->handle . "][BL][/url]";
         $division_structure .= "{$aod_url}[color={$this->division_leaders_color}]{$leader_name}[/url] {$bl_url}[/color] - {$leader->position_desc}\r\n";
     }
     $division_structure .= "[/size][/center]\r\n\r\n";
     /**
      * -----general sergeants-----
      */
     $genSgts = Division::findGeneralSergeants($this->game_id);
     $division_structure .= "[center][size=3][color={$this->platoon_pos_color}]General Sergeants[/color]\r\n";
     foreach ($genSgts as $sgt) {
         $sgt_name = Rank::convert($sgt->rank_id)->abbr . " " . $sgt->forum_name;
         $memberHandle = MemberHandle::findHandle($sgt->id, $this->division->primary_handle);
         $sgt->handle = $memberHandle->handle_value;
         $aod_url = "[url=" . CLANAOD . $sgt->member_id . "]";
         $bl_url = "[url=" . $memberHandle->url . $sgt->handle . "][BL][/url]";
         $division_structure .= "{$aod_url}{$sgt_name}[/url] {$bl_url}\r\n";
     }
     $division_structure .= "[/size][/center]";
     $division_structure .= "[/td][/tr][/table]";
     /**
      * ---------platoons----------
      */
     $division_structure .= "\r\n\r\n[table='width: {$this->players_width}']";
     $platoons = $this->platoons;
     $i = 1;
     foreach ($platoons as $platoon) {
         $countMembers = Platoon::countPlatoon($platoon->id);
         if ($i == 1) {
             $division_structure .= "[tr]";
             $division_structure .= "[td]";
         } else {
             $division_structure .= "[td]";
         }
         $division_structure .= "[size=5][color={$this->platoon_num_color}]" . ordsuffix($i) . " Platoon[/color][/size] \r\n[i][size=3]{$platoon->name} [/size][/i]\r\n\r\n";
         // platoon leaders
         $leader = Member::findByMemberId($platoon->leader_id);
         if ($platoon->leader_id != 0) {
             $memberHandle = MemberHandle::findHandle($leader->id, $this->division->primary_handle);
             $leader->handle = $memberHandle->handle_value;
             $aod_url = "[url=" . CLANAOD . $leader->member_id . "]";
             $bl_url = "[url=" . $memberHandle->url . $leader->handle . "][BL][/url]";
             $leader_name = Rank::convert($leader->rank_id)->abbr . " " . ucwords($leader->forum_name);
             $division_structure .= "{$aod_url}[size=3][color={$this->platoon_pos_color}]Platoon Leader[/color]\r\n[color={$this->platoon_leaders_color}]{$leader_name}[/color][/url] {$bl_url}[/size]\r\n\r\n";
         } else {
             $division_structure .= "[size=3][color={$this->platoon_pos_color}]Platoon Leader[/color]\r\n[color={$this->platoon_leaders_color}]TBA[/color][/size]\r\n\r\n";
         }
         // squad leaders
         $squads = Squad::findAll($this->game_id, $platoon->id);
         foreach ($squads as $squad) {
             if ($squad->leader_id != 0) {
                 $leader = Member::findById($squad->leader_id);
                 $memberHandle = MemberHandle::findHandle($leader->id, $this->division->primary_handle);
                 $leader->handle = $memberHandle->handle_value;
                 $aod_url = "[url=" . CLANAOD . $leader->member_id . "]";
                 $bl_url = "[url=" . $memberHandle->url . $leader->handle . "][BL][/url]";
                 $division_structure .= "[size=3][color={$this->platoon_pos_color}]Squad Leader[/color]\r\n{$aod_url}[color={$this->squad_leaders_color}]" . Rank::convert($leader->rank_id)->abbr . " {$leader->forum_name}[/color][/url] {$bl_url}[/size]\r\n\r\n";
                 $division_structure .= "[size=1]";
                 // direct recruits
                 $recruits = arrayToObject(Member::findRecruits($leader->member_id, $leader->platoon_id, $squad->id, true));
                 if (count((array) $recruits)) {
                     $division_structure .= "[list=1]";
                     foreach ($recruits as $recruit) {
                         $memberHandle = MemberHandle::findHandle($recruit->id, $this->division->primary_handle);
                         // does member have a member handle?
                         if (count((array) $memberHandle)) {
                             $recruit->handle = $memberHandle->handle_value;
                             $bl_url = "[url=" . $memberHandle->url . $recruit->handle . "][BL][/url]";
                             $aod_url = "[url=" . CLANAOD . $recruit->member_id . "]";
                             $division_structure .= "[*]{$aod_url}" . Rank::convert($recruit->rank_id)->abbr . " {$recruit->forum_name}[/url]";
                             $division_structure .= "{$bl_url}\r\n";
                         } else {
                             $division_structure .= " [color=red]XX[/color]\r\n";
                         }
                     }
                     $division_structure .= "[/list]";
                 }
             } else {
                 $division_structure .= "[size=3][color={$this->platoon_pos_color}]Squad Leader[/color]\r\n[color={$this->squad_leaders_color}]TBA[/color][/size]\r\n";
                 $division_structure .= "[size=1]";
             }
             $division_structure .= "\r\n";
             // squad members
             $squadMembers = arrayToObject(Squad::findSquadMembers($squad->id, true, $leader->member_id));
             if (count((array) $squadMembers)) {
                 foreach ($squadMembers as $player) {
                     $memberHandle = MemberHandle::findHandle($player->id, $this->division->primary_handle);
                     $player->handle = $memberHandle->handle_value;
                     $aod_url = "[url=" . CLANAOD . $player->member_id . "]";
                     $bl_url = "[url=" . $memberHandle->url . $player->handle . "][BL][/url]";
                     $division_structure .= "{$aod_url}" . Rank::convert($player->rank_id)->abbr . " {$player->forum_name}[/url] {$bl_url}\r\n";
                 }
             }
             $division_structure .= "[/size]\r\n";
         }
         $division_structure .= "\r\n\r\n";
         if ($i % $this->num_columns == 0) {
             $division_structure .= "[/td][/tr][tr]";
         }
         $division_structure .= "[/td]";
         $i++;
     }
     // end last platoon
     $division_structure .= "[/tr][/table]\r\n\r\n";
     /**
      * --------part timers--------
      */
     $i = 1;
     // header
     $division_structure .= "\r\n[table='width: {$this->info_width}']";
     $division_structure .= "[tr][td]\r\n[center][size=3][color={$this->platoon_pos_color}][b]Part Time Members[/b][/color][/size][/center][/td][/tr]";
     $division_structure .= "[/table]\r\n\r\n";
     // players
     $division_structure .= "[table='width: {$this->info_width}']";
     $division_structure .= "[tr][td]";
     $partTimers = PartTime::find_all($this->game_id);
     foreach ($partTimers as $player) {
         if ($i % 20 == 0) {
             $division_structure .= "[/td][td]";
         }
         $bl_url = "[url=" . BATTLELOG . $player->ingame_alias . "][BL][/url]";
         $aod_url = "[url=" . CLANAOD . $player->member_id . "]";
         $division_structure .= "{$aod_url}AOD_{$player->forum_name}[/url] {$bl_url}\r\n";
         $i++;
     }
     $division_structure .= "[/td]";
     $division_structure .= "[/tr][/table]\r\n\r\n";
     /**
      * -----------LOAS------------
      */
     $i = 1;
     // header
     $division_structure .= "\r\n[table='width: {$this->info_width}']";
     $division_structure .= "[tr][td]\r\n[center][size=3][color={$this->platoon_pos_color}][b]Leaves of Absence[/b][/color][/size][/center][/td][/tr]";
     $division_structure .= "[/table]\r\n\r\n";
     // players
     $division_structure .= "[table='width: {$this->info_width}']";
     $loas = LeaveOfAbsence::find_all($this->game_id);
     foreach ($loas as $player) {
         $date_end = strtotime($player->date_end) < strtotime('now') ? "[COLOR='#FF0000']Expired " . formatTime(strtotime($player->date_end)) . "[/COLOR]" : date("M d, Y", strtotime($player->date_end));
         $aod_url = "[url=" . CLANAOD . $player->member_id . "]";
         $profile = Member::findByMemberId($player->member_id);
         $division_structure .= "[tr][td]{$aod_url}" . Member::findForumName($profile->member_id) . "[/url][/td][td]{$date_end}[/td][td]{$player->reason}[/td][/tr]";
         $i++;
     }
     $division_structure .= "[/table]";
     $this->content = $division_structure;
 }
 public static function Leader($leader_id)
 {
     $params = Member::findById($leader_id);
     return arrayToObject($params);
 }
		<div class="row mod-plt">


			<div class="col-xs-8">
				<div class="row">
					
					<?php 
    $i = 1;
    ?>
					<?php 
    foreach ($squads as $squad) {
        ?>

						<?php 
        $leader = $squad->leader_id != 0 ? arrayToObject(Member::findById($squad->leader_id)) : NULL;
        ?>
						<?php 
        $leader_name = !is_null($leader) ? $leader->forum_name : "TBA";
        ?>
						<?php 
        $members = Squad::members($squad->id);
        ?>

						<div class="col-xs-6">
							<h3 class="page-header squad-header"><?php 
        echo $leader_name;
        ?>
 <a href="#" class="btn btn-xs btn-default modify-squad" style="position: absolute; left: 15px;"><i class="fa fa-wrench"></i> Edit Squad</a><span class="badge pull-right"><?php 
        echo count((array) $members);
        ?>
 private function getReaperGroup($division_structure)
 {
     $platoon = Platoon::findByName('reaper group');
     $squads = Squad::findAll($this->game_id, $platoon->id);
     $group_leader = Member::findByMemberId($platoon->leader_id);
     $this->squad_leader_color = "orange";
     $reaper_leader = Member::createAODlink(array('member_id' => $group_leader->member_id, 'rank' => Rank::convert($group_leader->rank_id)->abbr, 'forum_name' => $group_leader->forum_name));
     // fancy image and title
     $division_structure .= "\r\n\r\n\r\n[center][IMG]http://i.imgur.com/z1DbehX.png[/IMG]\r\n[SIZE=5][B][COLOR=\"#FF0000\"]\r\nR[SIZE=4]EAPERS[/SIZE] S[SIZE=4]PECIAL[/SIZE] O[SIZE=4]PERATIONS[/SIZE] G[SIZE=4]ROUP[/SIZE][/COLOR][/B][/SIZE]\r\n[SIZE=2]C[COLOR=\"#000000\"]-[/COLOR] O[COLOR=\"#000000\"]-[/COLOR] M[COLOR=\"#000000\"]-[/COLOR] P[COLOR=\"#000000\"]-[/COLOR] E[COLOR=\"#000000\"]-[/COLOR] T[COLOR=\"#000000\"]-[/COLOR] I[COLOR=\"#000000\"]-[/COLOR] T[COLOR=\"#000000\"]-[/COLOR] I[COLOR=\"#000000\"]-[/COLOR] V[COLOR=\"#000000\"]-[/COLOR] E[COLOR=\"#000000\"]-[/COLOR] [COLOR=\"#000000\"]---[/COLOR] T[COLOR=\"#000000\"]-[/COLOR] E[COLOR=\"#000000\"]-[/COLOR] A[COLOR=\"#000000\"]-[/COLOR] M[/SIZE]\r\n\r\n\r\n";
     $division_structure .= "[COLOR=\"#FF0000\"][SIZE=5]Group Leader[/SIZE][/COLOR]\r\n";
     $division_structure .= "[SIZE=4][profile=33860]{$reaper_leader}[/profile][/size]\r\n\r\n";
     foreach ($squads as $squad) {
         if ($squad->leader_id != 0) {
             $squad_leader = Member::findById($squad->leader_id);
             $aod_url = Member::createAODlink(['member_id' => $squad_leader->member_id, 'forum_name' => Rank::convert($squad_leader->rank_id)->abbr . " " . ucfirst($squad_leader->forum_name), 'color' => $this->squad_leader_color]);
             $division_structure .= "[COLOR=\"#FF0000\"][SIZE=4]Squad Leader[/SIZE][/COLOR]\r\n";
             $division_structure .= "[size=3]{$aod_url}[/size]\r\n\r\n";
         } else {
             $division_structure .= "[size=3][color={$this->squad_leader_color}]TBA[/color][/size]\r\n\r\n";
         }
         // end squad leader
         // squad members
         $squadMembers = arrayToObject(Squad::findSquadMembers($squad->id, true, $squad_leader->member_id));
         if (count((array) $squadMembers)) {
             $division_structure .= "[COLOR=\"#FF0000\"][SIZE=3]Group Members[/SIZE][/COLOR]\r\n\r\n";
             foreach ($squadMembers as $squadMember) {
                 $player_name = Rank::convert($squadMember->rank_id)->abbr . " " . $squadMember->forum_name;
                 $aod_url = Member::createAODlink(array('member_id' => $squadMember->member_id, 'forum_name' => $player_name));
                 $division_structure .= "{$aod_url}\r\n";
             }
         }
     }
     $division_structure .= "[/center]";
     return $division_structure;
 }