addPage (function)

Last updated: Fri, Apr 14, 2023 7:34 am
Return to Knowledgebase

Purpose

Add a permission level to a page

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $page integer Yes The ID of the page you wish to add a permission to. Can also pass an array to do multiple at once.
2 $permission integer Yes The ID of the permission you wish to add to the page. Can also pass an array to do multiple at once.

Returns

Data Type Description of Returned Data
int The number of permission levels added to the page

Example

addPage(28,2);

Further Documentation:

Add a permission level to a page in the database. Must be called by the page id. This is usually done in the UI of UserSpice and this function is not really used by developers.

addPage(28,2);


The addPage function takes two parameters: $page and $permission. It adds a new permission-page match to the database table permission_page_matches. The function returns the number of affected rows.

If $permission is an array, the function loops through each element of the array, and for each element, it inserts a new row in the permission_page_matches table with the corresponding permission_id and $page.

If $page is an array, the function loops through each element of the array, and for each element, it inserts a new row in the permission_page_matches table with the corresponding $permission and page_id.

If neither $permission nor $page is an array, the function inserts a single row in the permission_page_matches table with the corresponding $permission and $page.
The function increments the $i counter for each row that is inserted.

Finally, the function returns the $i counter.