public static function _doAddMember() { $user = User::find(intval($_SESSION['userid'])); $member = Member::find(intval($_SESSION['memberid'])); $division = Division::findById($member->game_id); $platoon_id = $user->role >= 3 || User::isDev() ? $_POST['platoon_id'] : $member->platoon_id; $squad_id = $user->role >= 2 || User::isDev() ? $_POST['squad_id'] : Squad::mySquadId($member->id) ?: 0; $recruiter = $member->member_id; $position_id = 6; // provide params for brand new members $params = array('member_id' => $_POST['member_id'], 'forum_name' => trim($_POST['forum_name']), 'recruiter' => $recruiter, 'game_id' => $_POST['game_id'], 'status_id' => 999, 'join_date' => date("Y-m-d H:i:s"), 'last_forum_login' => date("Y-m-d H:i:s"), 'last_activity' => date("Y-m-d H:i:s"), 'last_forum_post' => date("Y-m-d H:i:s"), 'last_promotion' => date("Y-m-d H:i:s"), 'rank_id' => 1, 'platoon_id' => $platoon_id, 'squad_id' => $squad_id, 'position_id' => $position_id); if (Member::exists($_POST['member_id'])) { // update existing record $existing_member_id = Member::findId($_POST['member_id']); $params = array_merge($params, array('id' => $existing_member_id)); $affected_rows = Member::modify($params); if ($affected_rows > 0) { UserAction::create(array('type_id' => 10, 'date' => date("Y-m-d H:i:s"), 'user_id' => $member->member_id, 'target_id' => $params['member_id'])); $data = array('success' => true, 'message' => "Existing member successfully updated!"); } else { $data = array('success' => false, 'message' => "Existing member could not be updated."); } } else { // member doesn't exist $insert_id = Member::create($params); if ($insert_id != 0) { UserAction::create(array('type_id' => 1, 'date' => date("Y-m-d H:i:s"), 'user_id' => $member->member_id, 'target_id' => $params['member_id'])); $data = array('success' => true, 'message' => "Member successfully added!"); } else { $data = array('success' => false, 'message' => "Member could not be added."); } } if ($insert_id != 0) { if (isset($_POST['played_games'])) { $games = $_POST['played_games']; foreach ($games as $game) { $memberGame = new stdClass(); $memberGame->member_id = $insert_id; $memberGame->game_id = $game; MemberGame::add($memberGame); } } if (isset($_POST['ingame_name'])) { $ingame_name = trim($_POST['ingame_name']); $handle = new stdClass(); $handle->member_id = $insert_id; $handle->handle_type = $division->primary_handle; $handle->handle_value = $ingame_name; $handle->handle_account_id = '0'; $handle->invalid = '0'; $handle->invalid_date = '0000-00-00'; MemberHandle::add($handle); } } echo json_encode($data); }
<?php if ($user->role == 1) { ?> <!-- if squad leader --> <?php $squad_id = Squad::mySquadId($member->id) ? Squad::mySquadId($member->id) : NULL; ?> <?php $squadMembers = arrayToObject(Squad::findSquadMembers($squad_id)); ?> <?php if (!is_null($squad_id)) { ?> <?php if (count((array) $squadMembers)) { ?> <div class='panel panel-default'> <div class='panel-heading'><strong> Your <?php echo Locality::run("squad", $member->game_id); ?> </strong> <span class="pull-right"><?php echo count((array) $squadMembers); ?> members</span></div> <div class='list-group' id='squad'> <?php
<?php if ($member->position_id == 5) { ?> <!-- if squad leader --> <?php $squad_id = Squad::mySquadId($member->id); ?> <?php $squadMembers = arrayToObject(Squad::findSquadMembers($squad_id)); ?> <?php if (count((array) $squadMembers)) { ?> <div class='panel panel-primary'> <div class='panel-heading'><strong><?php echo $member->forum_name; ?> 's <?php echo Locality::run('Squad', $member->game_id); ?> </strong> <span class="pull-right"><?php echo count((array) $squadMembers); ?> members</span></div> <div class='list-group'> <?php