Documentation

Admin_session extends Session
in package

A Matrix administrator session that can be derived from a regular session by using 'Session::sudo' method.

Note that an Admin session obtained with 'Session::sudo' shares the access token with the parent session, so you must call either 'Session::logout' or 'Admin_session::logout' to log out from the server.

XXX: Most of the methods here are only applicable to a specific Matrix implementation (Synapse.)

Tags
see
Session::sudo

Table of Contents

Properties

$access_token  : string
$matrix_client  : mixed
Matrix client instance.
$user_id  : ID

Methods

__construct()  : mixed
The main constructor of the class that builds an Admin_session instance based on a given Session instance. Make sure that given session belongs to a user with admin rights.
change_password()  : void
Change user password.
create_room()  : Room
Create a new room.
deactivate_account()  : mixed
Deactivate an account.
get_access_token()  : string
Get the access token.
get_avatar()  : Content_URI
Get avatar Content URI.
get_joined_rooms()  : array<string|int, mixed>
Get list of joined rooms.
get_matrix_client()  : string
Get the Matrix client instance.
get_server_location()  : string
Get the server location.
get_user_id()  : ID
Get the USER ID.
get_user_info()  : JSON
Get information about a specific user.
is_admin()  : true
Check if a user has admin rights.
is_username_available()  : true
Check if a username is available for registration.
join_room()  : string
Join a room.
logout()  : void
End the current session by invalidating the access token. Please note that you cannot use this session after calling this method.
reset_password()  : mixed
Reset the password of the specified user.
send_message()  : Unique
Send a message.
set_avatar()  : void
Set avatar by a Content URI.
set_displayname()  : mixed
Set new display name for the specified user.
sudo()  : Admin_session
Try to acquire admin rights.
sync()  : User
Get all the user's state.
whoami()  : JSON
Return information about the owner of the current access token.

Properties

$access_token

protected string $access_token

$matrix_client

Matrix client instance.

protected mixed $matrix_client

Methods

__construct()

The main constructor of the class that builds an Admin_session instance based on a given Session instance. Make sure that given session belongs to a user with admin rights.

public __construct(Session $session) : mixed
Parameters
$session : Session

An administrator session instance.

change_password()

Change user password.

public change_password( $old_password,  $new_password) : void

XXX: This only works when user's old password is needed for the 2nd stage of the authentication.

Parameters
$old_password :

Old user password.

$new_password :

New user password.

create_room()

Create a new room.

public create_room(string $name) : Room
Parameters
$name : string

A room name.

Tags
throws
Matrix_exception

on errors.

Return values
Room

A new room instance.

deactivate_account()

Deactivate an account.

public deactivate_account(ID $user_id[, bool $should_erase = false ]) : mixed
Parameters
$user_id : ID

ID of the user that should be deactivated.

$should_erase : bool = false

Marks the user as GDPR-erased[1], if set to 'true'. Defaults to 'false'.

[1] General Data Protection Regulation (GDPR): https://en.wikipedia.org/wiki/General_Data_Protection_Regulation

get_access_token()

Get the access token.

public get_access_token() : string
Return values
string

The access token (can be NULL.)

get_joined_rooms()

Get list of joined rooms.

public get_joined_rooms() : array<string|int, mixed>
Tags
throws
Matrix_exception

on errors.

Return values
array<string|int, mixed>

Array of joined rooms.

get_matrix_client()

Get the Matrix client instance.

public get_matrix_client() : string
Return values
string

The Matrix client instance.

get_server_location()

Get the server location.

public get_server_location() : string
Return values
string

The server location.

get_user_id()

Get the USER ID.

public get_user_id() : ID
Return values
ID

User ID.

get_user_info()

Get information about a specific user.

public get_user_info(ID $id) : JSON
Parameters
$id : ID
Tags
throws
Matrix_exception

on errors.

Return values
JSON

with user information; NULL if user does not exist.

is_admin()

Check if a user has admin rights.

public is_admin(ID $user_id) : true
Parameters
$user_id : ID

ID of the user to check.

Return values
true

if the user has admin rights, false otherwise.

is_username_available()

Check if a username is available for registration.

public is_username_available(string $username) : true
Parameters
$username : string

Username to check.

Tags
throws
Matrix_exception

on errors.

Return values
true

if username is available, false otherwise.

join_room()

Join a room.

public join_room(object $room[, array<string|int, mixed> $third_party_signed = [] ]) : string
Parameters
$room : object

A room ID, alias or Room class instance.

$third_party_signed : array<string|int, mixed> = []

If the parameter was supplied, the homeserver must verify that it matches a pending 'm.room.third_party_invite' event in the room, and perform key validity checking if required by the event.

Tags
throws
Matrix_exception

on errors.

Return values
string

ID of a joined room.

logout()

End the current session by invalidating the access token. Please note that you cannot use this session after calling this method.

public logout() : void
Tags
throws
Matrix_exception

on errors.

reset_password()

Reset the password of the specified user.

public reset_password(ID $user_id, string $new_password[, bool $logout_devices = true ]) : mixed
Parameters
$user_id : ID

Fully qualified ID of the user.

$new_password : string

New password to set.

$logout_devices : bool = true

Should the user be logged out from all devices? Defaults to 'true'.

send_message()

Send a message.

public send_message( $room,  $type,  $body[, string $fmbody = '' ]) : Unique
Parameters
$room :

A Room instance.

$type :

Message type (e.g. 'm.text'.)

$body :

Message body.

$fmbody : string = ''
Tags
throws
Matrix_exception

on errors.

Return values
Unique

event ID that identifies the sent message.

set_displayname()

Set new display name for the specified user.

public set_displayname(ID $user_id, string $new_displayname) : mixed
Parameters
$user_id : ID

Fully qualified ID of the user.

$new_displayname : string

New display name to set.

sync()

Get all the user's state.

public sync() : User
Tags
throws
Matrix_exception

on errors.

Return values
User

state.

whoami()

Return information about the owner of the current access token.

public whoami() : JSON
Return values
JSON

response.


        
On this page

Search results