/* pull the default access levels from the db */ $getGroupLevels = "SELECT * FROM sms_accesslevels WHERE id = {$accessID} LIMIT 1"; $getGroupLevelsResult = mysql_query($getGroupLevels); $groups = mysql_fetch_array($getGroupLevelsResult); $update = "UPDATE sms_crew SET accessPost = %s, accessManage = %s, accessReports = %s, accessUser = %s, accessOthers = %s "; $update .= "WHERE crewid = {$crew} LIMIT 1"; $query = sprintf($update, escape_string($groups[1]), escape_string($groups[2]), escape_string($groups[3]), escape_string($groups[4]), escape_string($groups[5])); $crewUpdateResult = mysql_query($query); /* optimize the tables */ optimizeSQLTable("sms_crew"); optimizeSQLTable("sms_positions"); } if ($oldPosition2 != $position2 && in_array("u_bio3", $sessionAccess)) { /* update the position they're being given */ update_position($position2, 'give'); update_position($oldPosition2, 'take'); /* optimize the table */ optimizeSQLTable("sms_positions"); } } /* close the crewType check */ } /* close the check for the POST action */ $getCrew = "SELECT * FROM sms_crew WHERE crewid = '{$crew}' LIMIT 1"; $getCrewResult = mysql_query($getCrew); while ($fetchCrew = mysql_fetch_array($getCrewResult)) { extract($fetchCrew, EXTR_OVERWRITE); $getRank = "SELECT rankName, rankImage FROM sms_ranks WHERE rankid = '{$fetchCrew['rankid']}'"; $getRankResult = mysql_query($getRank); $fetchRank = mysql_fetch_assoc($getRankResult); if (in_array("u_bio3", $sessionAccess)) {
update_position($oldPosition[0], 'give'); if (!empty($oldPosition[1])) { update_position($oldPosition[1], 'give'); } /* optimize the table */ optimizeSQLTable("sms_positions"); } if ($action_type == 'delete') { $get = "SELECT * FROM sms_crew WHERE crewid = {$action_id} LIMIT 1"; $getR = mysql_query($get); $fetch = mysql_fetch_assoc($getR); /* if the crew member is active, make sure to adjust the available positions */ if ($fetch['crewType'] == 'active') { update_position($fetch['positionid'], 'take'); if (!empty($fetch['positionid2'])) { update_position($fetch['positionid2'], 'take'); } } $query = "DELETE FROM sms_crew WHERE crewid = {$action_id} LIMIT 1"; $result = mysql_query($query); $action = $action_type; /* optimize the table */ optimizeSQLTable("sms_positions"); optimizeSQLTable("sms_crew"); } } /* build an array of all the positions to check for invalid ones */ $posArray = "SELECT p.positionid, p.positionName, d.deptColor FROM sms_positions AS p, sms_departments AS d "; $posArray .= "WHERE p.positionDept = d.deptid ORDER BY p.positionid ASC"; $posArrayResult = mysql_query($posArray); $pos_array = array();
$accessID = 3; } else { $accessID = 4; } /* pull the default access levels from the db */ $getGroupLevels = "SELECT * FROM sms_accesslevels WHERE id = {$accessID} LIMIT 1"; $getGroupLevelsResult = mysql_query($getGroupLevels); $groups = mysql_fetch_array($getGroupLevelsResult); $update = "UPDATE sms_crew SET positionid = %d, crewType = %s, accessPost = %s, "; $update .= "accessManage = %s, accessReports = %s, accessUser = %s, accessOthers = %s, "; $update .= "rankid = %d, leaveDate = %s, moderatePosts = %s, moderateLogs = %s, moderateNews = %s "; $update .= "WHERE crewid = {$action_id} LIMIT 1"; $query = sprintf($update, escape_string($position), escape_string('active'), escape_string($groups[1]), escape_string($groups[2]), escape_string($groups[3]), escape_string($groups[4]), escape_string($groups[5]), escape_string($rank), escape_string(''), escape_string($moderatePosts), escape_string($moderateLogs), escape_string($moderateNews)); $result = mysql_query($query); /* update the position they're being given */ update_position($position, 'give'); /** EMAIL THE APPROVAL **/ /* set the email author */ $userFetch = "SELECT email FROM sms_crew WHERE crewid = '{$action_id}' LIMIT 1"; $userFetchResult = mysql_query($userFetch); $userEmail = mysql_fetch_row($userFetchResult); /* define the variables */ $to = $userEmail[0] . ", " . printCOEmail(); $from = printCO('short_rank') . " < " . printCOEmail() . " >"; $subject = $emailSubject . " Your Application"; /* new instance of the replacement class */ $message = new MessageReplace(); $message->message = $acceptMessage; $message->shipName = $shipPrefix . " " . $shipName; $message->player = $action_id; $message->rank = $_POST['rank'];
$oldCrewType = $_POST['oldCrewType']; if ($crewType != $oldCrewType) { /* get their positions */ $getPos = "SELECT positionid, positionid2 FROM sms_crew WHERE crewid = {$crew} LIMIT 1"; $getPosR = mysql_query($getPos); $positions = mysql_fetch_array($getPosR); if ($oldCrewType == 'active') { update_position($positions[0], 'take'); if (count($positions) > 1) { update_position($positions[1], 'take'); } } if ($crewType == 'active') { update_position($positions[0], 'give'); if (count($positions) > 1) { update_position($positions[1], 'give'); } } /* optimize the table */ optimizeSQLTable("sms_positions"); } /* close the not equal check */ } /* close the array check */ /* optimize the table */ optimizeSQLTable("sms_crew"); } /* close if action is set */ $accountInfo = "SELECT username, password, loa, realName, email, aim, yim, msn, icq, contactInfo, emailPosts, emailLogs, "; $accountInfo .= "emailNews, crewType, moderatePosts, moderateLogs, moderateNews FROM sms_crew WHERE crewid = {$crew} LIMIT 1"; $accountInfoResult = mysql_query($accountInfo);