This script executes retrieving and displaying of the user requests for admin rights with options to aprrove or decline them. More...
Functions | |
terminateGARRWithError ($errorParam) | |
Variables | |
if(!isset( $_SESSION[ 'user_id'])) | if (!isset( $_SESSION[ 'admin'])||$_SESSION[ 'admin'] !=1) |
if(isset($error) && $error==="db_access_failed") | try |
$user = $stmt->fetch(PDO::FETCH_ASSOC) | |
$records = $stmt->fetchAll(PDO::FETCH_ASSOC) | |
catch (PDOException $e) | |
if(count(value:$records)===0) | else |
endforeach | |
endif | |
This script executes retrieving and displaying of the user requests for admin rights with options to aprrove or decline them.
Checks if 'user_id' and 'admin' is set in $_SESSION. Connects to the database. Checks if the user with the user_id set in $_SESSION has in fact the admin rights by checking the value of 'admin' column in 'users' table of the database for the current 'user_id' in $_SESSION. If the user is a valid website admin, retrieves all the users from the database, whose admin_requested == 1, sorting the retrieved records email alphabetically. Displays the results. Buttons of 'approve' and 'decline' are available next to the each displayed user to approve of decline their requests for admin rights. In case of invalid user_id, invaid admin rights or error occuring during the communication with the database, terminates and redirects to the main page with an error context info as a parameter of the redirecting GET request.
terminateGARRWithError | ( | $errorParam | ) |
Redirects the user to a specified location with an error parameter.
string | $errorParam | The error parameter to append to the URL. |
Handles PDO exceptions that occur while fetching the admin status by redirecting with an error parameter.
Handles PDO exceptions that occur while retrieving admin requests by redirecting with an error parameter.
$records = $stmt->fetchAll(PDO::FETCH_ASSOC) |
$user = $stmt->fetch(PDO::FETCH_ASSOC) |
catch | ( | PDOException | $e | ) |
if (count(value:$records)===0) else |
endforeach |
endif |
if(!isset($_SESSION['user_id'])) if(!isset($_SESSION['admin'])|| $_SESSION['admin'] !=1) | ( | !isset($_SESSION['admin'])|| $_SESSION ! | [ 'admin'] = 1 | ) |
Checks if the user session contains a valid user ID. If not, redirects with an error parameter indicating an invalid session. Checks if the user has admin rights. If not, redirects with an error parameter indicating insufficient rights.