2016-06-27 11:44:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zotlabs\Access;
|
|
|
|
|
2017-09-04 22:23:42 +00:00
|
|
|
/**
|
|
|
|
* @brief PermissionRoles class.
|
|
|
|
*
|
|
|
|
* @see Permissions
|
|
|
|
*/
|
2016-06-27 11:44:10 +00:00
|
|
|
class PermissionRoles {
|
|
|
|
|
2017-09-04 22:23:42 +00:00
|
|
|
/**
|
|
|
|
* @brief PermissionRoles version.
|
|
|
|
*
|
|
|
|
* This must match the version in Permissions.php before permission updates can run.
|
|
|
|
*
|
|
|
|
* @return number
|
|
|
|
*/
|
2016-12-02 00:40:49 +00:00
|
|
|
static public function version() {
|
2017-02-02 02:05:02 +00:00
|
|
|
return 2;
|
2016-12-02 00:40:49 +00:00
|
|
|
}
|
2016-06-27 11:44:10 +00:00
|
|
|
|
2016-07-05 05:37:30 +00:00
|
|
|
static function role_perms($role) {
|
|
|
|
|
|
|
|
$ret = array();
|
|
|
|
|
|
|
|
$ret['role'] = $role;
|
|
|
|
|
|
|
|
switch($role) {
|
|
|
|
case 'social':
|
|
|
|
$ret['perms_auto'] = false;
|
|
|
|
$ret['default_collection'] = false;
|
|
|
|
$ret['directory_publish'] = true;
|
|
|
|
$ret['online'] = true;
|
2018-08-06 01:40:36 +00:00
|
|
|
$ret['perms_connect'] = [ 'view_stream', 'view_profile', 'view_contacts', 'view_storage', 'send_stream', 'post_wall', 'post_comments' ];
|
2016-07-05 05:37:30 +00:00
|
|
|
$ret['limits'] = PermissionLimits::Std_Limits();
|
2018-08-06 01:40:36 +00:00
|
|
|
$ret['limits']['post_comments'] = PERMS_AUTHED;
|
|
|
|
$ret['limits']['post_mail'] = PERMS_AUTHED;
|
|
|
|
$ret['limits']['post_like'] = PERMS_AUTHED;
|
|
|
|
$ret['limits']['chat'] = PERMS_AUTHED;
|
2016-07-05 05:37:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2016-06-27 11:44:10 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 05:37:30 +00:00
|
|
|
$x = get_config('system','role_perms');
|
2017-09-04 22:23:42 +00:00
|
|
|
// let system settings over-ride any or all
|
2016-07-05 05:37:30 +00:00
|
|
|
if($x && is_array($x) && array_key_exists($role,$x))
|
|
|
|
$ret = array_merge($ret,$x[$role]);
|
2016-06-27 11:44:10 +00:00
|
|
|
|
2017-09-04 22:23:42 +00:00
|
|
|
/**
|
|
|
|
* @hooks get_role_perms
|
|
|
|
* * \e array
|
|
|
|
*/
|
2018-07-11 02:58:18 +00:00
|
|
|
$x = [ 'role' => $role, 'result' => $ret ];
|
2016-07-05 05:37:30 +00:00
|
|
|
|
2018-07-11 02:58:18 +00:00
|
|
|
call_hooks('get_role_perms', $x);
|
|
|
|
|
|
|
|
return $x['result'];
|
2016-07-05 05:37:30 +00:00
|
|
|
}
|
2016-06-27 11:44:10 +00:00
|
|
|
|
2016-07-06 03:21:47 +00:00
|
|
|
|
2017-09-04 22:23:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Array with translated role names and grouping.
|
|
|
|
*
|
|
|
|
* Return an associative array with grouped role names that can be used
|
|
|
|
* to create select groups like in \e field_select_grouped.tpl.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2016-07-06 03:21:47 +00:00
|
|
|
static public function roles() {
|
2017-09-04 22:23:42 +00:00
|
|
|
$roles = [
|
2016-07-06 03:21:47 +00:00
|
|
|
t('Social Networking') => [
|
2018-08-06 01:40:36 +00:00
|
|
|
'social' => t('Social - Federation'),
|
2016-07-06 03:21:47 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
2018-05-15 03:23:00 +00:00
|
|
|
call_hooks('list_permission_roles',$roles);
|
|
|
|
|
2017-09-04 22:23:42 +00:00
|
|
|
return $roles;
|
2016-07-06 03:21:47 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 11:44:10 +00:00
|
|
|
}
|