function sgang_app_accept() { global $gvars; if (!gang_auth_all($gvars->userid, array('pres', 'vice'))) { echo "<h3>You are not authorized to access this portion of the staff panel.</h3>"; gang_go_back('yourgang.php?action=sgang_home'); return; } if (!isset($_REQUEST['app_id']) or intval($_REQUEST['app_id']) < 1) { echo "<h3>Which application are you accepting?</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } $app_id = intval($_REQUEST['app_id']); $q_count = sprintf('select count(*) from users where gang = %d', $gvars->ir['gang']); list($num_members) = mysql_fetch_row(mysql_query($q_count)); $max_members = $gvars->data['gangCAPACITY']; if ($num_members >= $gvars->data['gangCAPACITY']) { echo "<h3>The {$gvars->name_sl} cannot hold any more members.</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } // appID, appUSER, appGANG, appTEXT <<< $q_get = sprintf('select a.appUSER, u.username from applications as a left join users as u on a.appUSER = u.userid where a.appGANG = %d and a.appID = %d', $gvars->ir['gang'], $app_id); $q_get = mysql_query($q_get); if (!$q_get or mysql_num_rows($q_get) < 1) { echo "<h3>This application does not exist.</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } list($them_id, $them_name) = mysql_fetch_array($q_get); $q_del = sprintf('delete from applications where appGANG = %d and appID = %d', $gvars->ir['gang'], $app_id); mysql_query($q_del); if (mysql_affected_rows() < 1) { echo "<h3>The application could not be accepted.</h3>"; } else { $q_set = sprintf('update users set gang = %d where userid = %d and gang = 0', $gvars->ir['gang'], $them_id); mysql_query($q_set); if (mysql_affected_rows() < 1) { echo "<h3>The application could not be accepted.</h3>"; } else { echo "<h3>The application was accepted.</h3>"; $them_p = gang_get_profile_link($them_id, $them_name); $us_p = gang_get_profile_link($gvars->ir['userid'], $gvars->ir['username']); gang_new_event($gvars->ir['gang'], sprintf('%s accepted an application from %s', $us_p, $them_p), 'escape'); event_add($them_id, sprintf('%s accepted your application to %s', $us_p, $gvars->data['gangNAME']), $gvars->c); } } gang_go_back('yourgang.php?action=sgang_apps'); }
return true; break; } } /** * Check a user against multiple gang ranks. * This function calls gang_auth() once for each rank checked. * It returns true if any of the ranks validated. In other words, * this performs a logical OR comparison. * * @param int $userid * @param array $ranks * @return bool */ function gang_auth_all($userid, $ranks) { global $gvars; if (!is_array($ranks)) { $ranks = array($ranks); } foreach ($ranks as $rank) { if (gang_auth($userid, $rank)) { return true; } } return false; } if (gang_auth_all($gvars->userid, array('pres', 'vice'))) { $gvars->tabs += array('sgang_home' => 'Staff'); $gvars->links_mygang += array('sgang_home' => array('label' => 'Staff Room', 'order' => 7)); }