AutoPulse v 1.0.1
 
Loading...
Searching...
No Matches
C:/Users/ivans/OneDrive/Документы/ZWA/sem/get_admin_rights_requests.php File Reference

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
 

Detailed Description

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.

Function Documentation

◆ terminateGARRWithError()

terminateGARRWithError ( $errorParam)

Redirects the user to a specified location with an error parameter.

Parameters
string$errorParamThe 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.

Variable Documentation

◆ $records

$records = $stmt->fetchAll(PDO::FETCH_ASSOC)

◆ $user

$user = $stmt->fetch(PDO::FETCH_ASSOC)

◆ catch

catch ( PDOException $e)
Initial value:
{
$stmt = $pdo->prepare("INSERT INTO images (insertion_id, order_number, image_path) VALUES (:insertion_id, :order_number, :image_path)")
if(! $user) catch(PDOException $e) $pdo
Definition myprofile.php:59
if(! $userExists) $stmt
Definition process-accountDelete.php:48

◆ else

if (count(value:$records)===0) else

◆ endforeach

endforeach

◆ endif

endif

◆ if

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.

◆ try

if(! $user||(int) $user['admin'] !=1) catch (PDOException $e) try
Initial value:
{
$stmt = $pdo->prepare("SELECT admin FROM users WHERE id = :id")

Verifies if there was a database access failure during connection setup. If such an error occurred, redirects with an error parameter.