diff options
author | Mario <mario@mariovavti.com> | 2022-01-21 07:28:24 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-01-21 07:28:24 +0000 |
commit | 755d0f54f7ddfc2a932e17c425c7a1aacb8d7efb (patch) | |
tree | db1616efe407092127a273de1889bc1cd852132f /include/channel.php | |
parent | a40babbf0d09e0131a00a1e88d359caebb997a65 (diff) | |
parent | f62d66ff25ffac7dbfdc663d2a64c5b415b6e294 (diff) | |
download | volse-hubzilla-755d0f54f7ddfc2a932e17c425c7a1aacb8d7efb.tar.gz volse-hubzilla-755d0f54f7ddfc2a932e17c425c7a1aacb8d7efb.tar.bz2 volse-hubzilla-755d0f54f7ddfc2a932e17c425c7a1aacb8d7efb.zip |
Merge branch '7.0RC'
Diffstat (limited to 'include/channel.php')
-rw-r--r-- | include/channel.php | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/include/channel.php b/include/channel.php index 102a03489..4e84b1b32 100644 --- a/include/channel.php +++ b/include/channel.php @@ -15,11 +15,13 @@ use Zotlabs\Render\Comanche; use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Connect; use Zotlabs\Lib\Libsync; +use Zotlabs\Lib\AccessList; require_once('include/crypto.php'); require_once('include/menu.php'); require_once('include/perm_upgrade.php'); require_once('include/photo/photo_driver.php'); +require_once('include/security.php'); /** * @brief Called when creating a new channel. @@ -240,7 +242,7 @@ function create_identity($arr) { // Force a few things on the short term until we can provide a theme or app with choice - $publish = 1; + $publish = 0; if(array_key_exists('publish', $arr)) $publish = intval($arr['publish']); @@ -325,6 +327,12 @@ function create_identity($arr) { if($role_permissions && array_key_exists('perms_auto',$role_permissions)) set_pconfig($r[0]['channel_id'],'system','autoperms',intval($role_permissions['perms_auto'])); + $group_actor = false; + if($role_permissions && array_key_exists('channel_type', $role_permissions) && $role_permissions['channel_type'] === 'group') { + set_pconfig($r[0]['channel_id'], 'system', 'group_actor', 1); + $group_actor = true; + } + $ret['channel'] = $r[0]; if(intval($arr['account_id'])) @@ -374,7 +382,8 @@ function create_identity($arr) { 'xchan_network' => 'zot6', 'xchan_photo_date' => datetime_convert(), 'xchan_name_date' => datetime_convert(), - 'xchan_system' => $system + 'xchan_system' => $system, + 'xchan_pubforum' => $group_actor ] ); if(! $r) @@ -399,14 +408,6 @@ function create_identity($arr) { ] ); - if($role_permissions) { - $myperms = ((array_key_exists('perms_connect',$role_permissions)) ? $role_permissions['perms_connect'] : array()); - } - else { - $x = PermissionRoles::role_perms('social'); - $myperms = $x['perms_connect']; - } - $r = abook_store_lowlevel( [ 'abook_account' => intval($ret['channel']['channel_account_id']), @@ -419,19 +420,18 @@ function create_identity($arr) { ] ); - $x = 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. + + // Set the default permcat + set_pconfig($newuid,'system','default_permcat','default'); if($role_permissions) { + // Save our permissions role so we can perhaps call it up and modify it later. set_pconfig($newuid,'system','permissions_role',$arr['permissions_role']); + if(array_key_exists('online',$role_permissions)) - set_pconfig($newuid,'system','hide_presence',1-intval($role_permissions['online'])); + set_pconfig($newuid,'system','show_online_status', intval($role_permissions['online'])); if(array_key_exists('perms_auto',$role_permissions)) { $autoperms = intval($role_permissions['perms_auto']); set_pconfig($newuid,'system','autoperms',$autoperms); @@ -453,11 +453,10 @@ function create_identity($arr) { // Create a group with yourself as a member. This allows somebody to use it // right away as a default group for new contacts. - require_once('include/group.php'); - $group_hash = group_add($newuid, t('Friends')); + $group_hash = AccessList::add($newuid, t('Friends')); if($group_hash) { - group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']); + AccessList::member_add($newuid,t('Friends'),$ret['channel']['channel_hash']); $default_collection_str = ''; // if our role_permissions indicate that we're using a default collection ACL, add it. @@ -496,8 +495,7 @@ function create_identity($arr) { if($acct) { $f = connect_and_sync($ret['channel'], $acct); if($f['success']) { - $can_view_stream = their_perms_contains($ret['channel']['channel_id'],$f['abook']['abook_xchan'],'view_stream'); - + $can_view_stream = intval(get_abconfig($ret['channel']['channel_id'], $f['abook']['abook_xchan'], 'their_perms', 'view_stream')); // If we can view their stream, pull in some posts if(($can_view_stream) || ($f['abook']['xchan_network'] === 'rss')) { Master::Summon([ 'Onepoll',$f['abook']['abook_id'] ]); @@ -881,6 +879,14 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals } if(in_array('connections',$sections)) { + $r = q("select * from atoken where atoken_uid = %d", + intval($channel_id) + ); + + if ($r) { + $ret['atoken'] = $r; + } + $xchans = array(); $r = q("select * from abook where abook_channel = %d ", intval($channel_id) @@ -1488,6 +1494,7 @@ function profile_load($nickname, $profile = '') { if($can_view_profile) { $online = get_online_status($nickname); + App::$profile['online_status'] = $online['result']; } @@ -1965,11 +1972,24 @@ function zat_init() { ); if($r) { $xchan = atoken_xchan($r[0]); - atoken_create_xchan($xchan); + //atoken_create_xchan($xchan); atoken_login($xchan); } } +function atoken_delete_and_sync($channel_id, $atoken_guid) { + $r = q("select * from atoken where atoken_guid = '%s' and atoken_uid = %d", + dbesc($atoken_guid), + intval($channel_id) + ); + + if ($r) { + $atok = $r[0]; + $atok['deleted'] = true; + atoken_delete($atok['atoken_id']); + Libsync::build_sync_packet($channel_id, ['atoken' => [ $atok ]]); + } +} /** * @brief Used from within PCSS themes to set theme parameters. @@ -2060,11 +2080,12 @@ function get_online_status($nick) { return $ret; $r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1", - dbesc(argv(1)) + dbesc($nick) ); + if($r) { - $hide = get_pconfig($r[0]['channel_id'],'system','hide_online_status'); - if($hide) + $show = get_pconfig($r[0]['channel_id'],'system','show_online_status'); + if(!$show) return $ret; $x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1", @@ -2280,7 +2301,7 @@ function auto_channel_create($account_id) { } } if(! $arr['permissions_role']) - $arr['permissions_role'] = 'social'; + $arr['permissions_role'] = 'personal'; if(validate_channelname($arr['name'])) return false; |