aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-19 01:26:28 -0700
committerredmatrix <git@macgirvin.com>2016-07-19 01:26:28 -0700
commit7272b97e9a50ff6070a38196aa0b080a993f776d (patch)
tree0c03c98b577bf8b090204bc4eb2cb0f4b244ca4d /include
parent8a9f062b95ce35a65fe48603b6e7d3110a28e3ac (diff)
downloadvolse-hubzilla-7272b97e9a50ff6070a38196aa0b080a993f776d.tar.gz
volse-hubzilla-7272b97e9a50ff6070a38196aa0b080a993f776d.tar.bz2
volse-hubzilla-7272b97e9a50ff6070a38196aa0b080a993f776d.zip
yet more grungy perms work.
Diffstat (limited to 'include')
-rw-r--r--include/channel.php73
1 files changed, 36 insertions, 37 deletions
diff --git a/include/channel.php b/include/channel.php
index de0ac70e8..1101e39e9 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -226,42 +226,26 @@ function create_identity($arr) {
if(array_key_exists('publish', $arr))
$publish = intval($arr['publish']);
- $primary = true;
-
- if(array_key_exists('primary', $arr))
- $primary = intval($arr['primary']);
-
$role_permissions = null;
- $global_perms = get_perms();
if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) {
- $role_permissions = get_role_perms($arr['permissions_role']);
-
- if($role_permissions) {
- foreach($role_permissions as $p => $v) {
- if(strpos($p,'channel_') !== false) {
- $perms_keys .= ', ' . $p;
- $perms_vals .= ', ' . intval($v);
- }
- if($p === 'directory_publish')
- $publish = intval($v);
- }
- }
- }
- else {
- $defperms = site_default_perms();
- foreach($defperms as $p => $v) {
- $perms_keys .= ', ' . $global_perms[$p][0];
- $perms_vals .= ', ' . intval($v);
- }
+ $role_permissions = \Zotlabs\Access\PermissionRoles::role_perms($arr['permissions_role']);
}
+ if($role_permissions && array_key_exists('directory_publish',$role_permissions))
+ $publish = intval($role_permissions['directory_publish']);
+
+ $primary = true;
+
+ if(array_key_exists('primary', $arr))
+ $primary = intval($arr['primary']);
+
$expire = 0;
$r = q("insert into channel ( channel_account_id, channel_primary,
channel_name, channel_address, channel_guid, channel_guid_sig,
- channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone $perms_keys )
- values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' $perms_vals ) ",
+ channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone )
+ values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' ) ",
intval($arr['account_id']),
intval($primary),
@@ -289,6 +273,17 @@ function create_identity($arr) {
return $ret;
}
+ if($role_permissions && array_key_exists('limits',$role_permissions))
+ $perm_limits = $role_permissions['limits'];
+ else
+ $perm_limits = site_default_perms();
+
+ foreach($perm_limits as $p => $v)
+ \Zotlabs\Access\PermissionLimits::Set($r[0]['channel_id'],$p,$v);
+
+ if($role_permissions && array_key_exists('perms_auto',$role_permissions))
+ set_pconfig($r[0]['channel_id'],'system','autoperms',intval($role_permissions['perms_auto']));
+
$ret['channel'] = $r[0];
if(intval($arr['account_id']))
@@ -352,25 +347,29 @@ function create_identity($arr) {
);
if($role_permissions) {
- $myperms = ((array_key_exists('perms_accept',$role_permissions)) ? intval($role_permissions['perms_accept']) : 0);
+ $myperms = ((array_key_exists('perms_connect',$role_permissions)) ? $role_permissions['perms_connect'] : array());
+ }
+ else {
+ $x = \Zotlabs\Access\PermissionRoles::role_perms('social');
+ $myperms = $x['perms_connect'];
}
- else
- $myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK
- |PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
- |PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
- $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self, abook_my_perms )
- values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ",
+ $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self )
+ values ( %d, %d, '%s', %d, '%s', '%s', %d ) ",
intval($ret['channel']['channel_account_id']),
intval($newuid),
dbesc($hash),
intval(0),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- intval(1),
- intval($myperms)
+ intval(1)
);
+ $x = \Zotlabs\Access\Permissions::FilledPerms($myperms);
+ foreach($x as $k => $v) {
+ set_abconfig($newuid,$hash,'my_perms',$k,$v);
+ }
+
if(intval($ret['channel']['channel_account_id'])) {
// Save our permissions role so we can perhaps call it up and modify it later.
@@ -383,7 +382,7 @@ function create_identity($arr) {
$autoperms = intval($role_permissions['perms_auto']);
set_pconfig($newuid,'system','autoperms',$autoperms);
if($autoperms) {
- $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['connect']);
+ $x = \Zotlabs\Access\Permissions::FilledPerms($role_permissions['perms_connect']);
foreach($x as $k => $v) {
set_pconfig($newuid,'autoperms',$k,$v);
}