webCOMAND

repo::push_user()

Switch the repository "user of record".  All subsequent queries performed on this repository will apply the new user's authorizations until pop_user() is called.

Prototype

integer push_user(Object $user, boolean $user_of_record = FALSE)

Parameter

  • user - A User Object that represents the new "user of record".
  • user_of_record - If TRUE, make this new user the "user of record" like switch_user() will do automatically.

Return

If successful, the number of users on the user stack is returned.  Otherwise FALSE is returned.  The number of users on the stack is incremented each time switch_user() or push_user() is called successfully and decremented each time pop_user() is called.

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(), pop_user(), push_super_user()