webCOMAND

repo::pop_user()

Pop users from the repository user stack until the index passed in is reached, which is typically the index returned by switch_user(), push_super_user() and push_user() so that it will return the repository user and stack to their state before they were called.

Prototype

User pop_user(integer $index)

Parameter

  • index - The index into the stack of the user that should become the repository user.  This should typically be the index returned by switch_user(), push_super_user() and push_user() to return the repository user and stack to their state before they were called.

Return

The new repository User is returned on success.  Otherwise FALSE is returned, which will happen if an invalid index is provided.

Example

$user = $repo->get_first("FROM User WHERE OID=123");

// switch the "user of record" to user with OID 123
$index = $repo->push_user($user);
if($index == FALSE) {
    exit("Could not push user.");
}

// get all contacts user with OID 123 can view
$contacts = $repo->get("SELECT Name FROM Contact");
foreach($contacts as $contact) {
	echo($contact->Name . "\n");
}

// return to previous "user of record"
$repo->pop_user($index);

See Also

switch_user(), peek_user(), push_super_user(), push_user()