The Hubzilla
 All Classes Namespaces Files Functions Variables Pages
Zotlabs\Access\Permissions Class Reference

Extensible permissions. More...

Static Public Member Functions

static version ()
 Permissions version. More...
 
static Perms ($filter= '')
 Return an array with Permissions. More...
 
static BlockedAnonPerms ()
 Perms from the above list that are blocked from anonymous observers. More...
 
static FilledPerms ($arr)
 Converts indexed perms array to associative perms array. More...
 
static OPerms ($arr)
 Convert perms array to indexed array. More...
 
static FilledAutoperms ($channel_id)
 
static PermsCompare ($p1, $p2)
 Compares that all Permissions from $p1 exist also in $p2. More...
 
static connect_perms ($channel_id)
 

Detailed Description

Extensible permissions.

To add new permissions, add to the list of $perms below, with a simple description.

Also visit PermissionRoles.php and add to the $ret['perms_connect'] property for any role if this permission should be granted to new connections.

Next look at PermissionRoles::new_custom_perms() and provide a handler for updating custom permission roles. You will want to set a default PermissionLimit for each channel and also provide a sane default for any existing connections. You may or may not wish to provide a default auto permission. If in doubt, leave this alone as custom permissions by definition are the responsibility of the channel owner to manage. You just don't want to create any suprises or break things so you have an opportunity to provide sane settings.

Update the version here and in PermissionRoles.

Permissions with 'view' in the name are considered read permissions. Anything else requires authentication. Read permission limits are PERMS_PUBLIC and anything else is given PERMS_SPECIFIC.

PermissionLimits::Std_limits() retrieves the standard limits. A permission role MAY alter an individual setting after retrieving the Std_limits if you require something different for a specific permission within the given role.

Member Function Documentation

static Zotlabs\Access\Permissions::BlockedAnonPerms ( )
static

Perms from the above list that are blocked from anonymous observers.

e.g. you must be authenticated.

Returns
array Associative array with permissions and short description.
Hooks:
write_perms
  • array permissions

Referenced by get_all_perms(), and perm_is_allowed().

static Zotlabs\Access\Permissions::connect_perms (   $channel_id)
static
Parameters
int$channel_idA channel id
Returns
array Associative array with
  • array perms Permission array
  • int automatic 0 or 1

Referenced by Zotlabs\Module\Defperms\get(), Zotlabs\Module\Connedit\get(), new_contact(), Zotlabs\Module\Connedit\post(), and zot_refresh().

static Zotlabs\Access\Permissions::FilledAutoperms (   $channel_id)
static
Parameters
int$channel_id
Returns
boolean|array

Referenced by Zotlabs\Access\Permissions\connect_perms(), and zotinfo().

static Zotlabs\Access\Permissions::FilledPerms (   $arr)
static

Converts indexed perms array to associative perms array.

Converts [ 0 => 'view_stream', ... ] to [ 'view_stream' => 1 ] for any permissions in $arr; Undeclared permissions which exist in Perms() are added and set to 0.

Parameters
array$arr
Returns
array

Referenced by Zotlabs\Lib\Permcat\__construct(), Zotlabs\Access\Permissions\connect_perms(), create_identity(), and Zotlabs\Module\Settings\Channel\post().

static Zotlabs\Access\Permissions::OPerms (   $arr)
static

Convert perms array to indexed array.

Converts [ 'view_stream' => 1 ] for any permissions in $arr to [ 0 => ['name' => 'view_stream', 'value' => 1], ... ]

Parameters
array$arrassociative perms array 'view_stream' => 1
Returns
array Indexed array with elements that look like
  • string name the perm name (e.g. view_stream)
  • int value the value of the perm (e.g. 1)
static Zotlabs\Access\Permissions::PermsCompare (   $p1,
  $p2 
)
static

Compares that all Permissions from $p1 exist also in $p2.

Parameters
array$p1The perms that have to exist in $p2
array$p2The perms to compare against
Returns
boolean true if all perms from $p1 exist also in $p2
static Zotlabs\Access\Permissions::version ( )
static

Permissions version.

This must match the version in PermissionRoles.php before permission updates can run.

Returns
number

The documentation for this class was generated from the following file: