more perms work - notably the stuff in public_perms
This commit is contained in:
parent
cc83983ae5
commit
71b001fdb7
@ -129,11 +129,18 @@ class Connedit extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$abook_my_perms = 0;
|
$abook_my_perms = 0;
|
||||||
|
|
||||||
foreach($_POST as $k => $v) {
|
$all_perms = \Zotlabs\Access\Permissions::Perms();
|
||||||
if(strpos($k,'perms_') === 0) {
|
|
||||||
$perm = substr($k,6);
|
if($all_perms) {
|
||||||
set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,(($v) ? 1 : 0));
|
foreach($all_perms as $perm => $desc) {
|
||||||
$abook_my_perms += $v;
|
if(in_array('perms_' . $perm, $_POST)) {
|
||||||
|
set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,
|
||||||
|
intval($_POST['perms_' . $perm]));
|
||||||
|
$abook_my_perms ++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,7 +693,6 @@ class Connedit extends \Zotlabs\Web\Controller {
|
|||||||
$their_perms[$t['k']] = $t['v'];
|
$their_perms[$t['k']] = $t['v'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger('theris: ' . print_r($their_perms,true));
|
|
||||||
|
|
||||||
foreach($global_perms as $k => $v) {
|
foreach($global_perms as $k => $v) {
|
||||||
$thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
|
$thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
|
||||||
|
@ -462,7 +462,7 @@ function zot_refresh($them, $channel = null, $force = false) {
|
|||||||
$default_perms = $xx['perms_connect'];
|
$default_perms = $xx['perms_connect'];
|
||||||
}
|
}
|
||||||
if(! $default_perms)
|
if(! $default_perms)
|
||||||
$default_perms = get_pconfig($channel['channel_id'],'system','autoperms'));
|
$default_perms = get_pconfig($channel['channel_id'],'system','autoperms');
|
||||||
|
|
||||||
|
|
||||||
// Keep original perms to check if we need to notify them
|
// Keep original perms to check if we need to notify them
|
||||||
@ -505,9 +505,9 @@ function zot_refresh($them, $channel = null, $force = false) {
|
|||||||
'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'],
|
'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'],
|
||||||
));
|
));
|
||||||
|
|
||||||
if(intval($permissions['view_stream']))) {
|
if(intval($permissions['view_stream'])) {
|
||||||
if(intval(get_pconfig($channel['channel_id'],'perms_limit','send_stream')) & PERMS_PENDING)
|
if(intval(get_pconfig($channel['channel_id'],'perms_limit','send_stream') & PERMS_PENDING)
|
||||||
|| (! intval($new_connection[0]['abook_pending'])) )
|
|| (! intval($new_connection[0]['abook_pending'])))
|
||||||
Zotlabs\Daemon\Master::Summon(array('Onepoll',$new_connection[0]['abook_id']));
|
Zotlabs\Daemon\Master::Summon(array('Onepoll',$new_connection[0]['abook_id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1345,8 +1345,7 @@ function public_recips($msg) {
|
|||||||
if(! get_config('system','disable_discover_tab'))
|
if(! get_config('system','disable_discover_tab'))
|
||||||
$include_sys = true;
|
$include_sys = true;
|
||||||
$perm = 'send_stream';
|
$perm = 'send_stream';
|
||||||
$col = 'channel_w_stream';
|
|
||||||
$field = PERMS_W_STREAM;
|
|
||||||
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
|
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
|
||||||
// check mention recipient permissions on top level posts only
|
// check mention recipient permissions on top level posts only
|
||||||
$check_mentions = true;
|
$check_mentions = true;
|
||||||
@ -1378,67 +1377,30 @@ function public_recips($msg) {
|
|||||||
// contains the tag. we'll solve that further below.
|
// contains the tag. we'll solve that further below.
|
||||||
|
|
||||||
if($msg['notify']['sender']['guid_sig'] != $msg['message']['owner']['guid_sig']) {
|
if($msg['notify']['sender']['guid_sig'] != $msg['message']['owner']['guid_sig']) {
|
||||||
$perm = 'post_comment';
|
$perm = 'post_comments';
|
||||||
$col = 'channel_w_comment';
|
|
||||||
$field = PERMS_W_COMMENT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($msg['message']['type'] === 'mail') {
|
elseif($msg['message']['type'] === 'mail')
|
||||||
$perm = 'post_mail';
|
$perm = 'post_mail';
|
||||||
$col = 'channel_w_mail';
|
|
||||||
$field = PERMS_W_MAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(! $col)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
$col = dbesc($col);
|
|
||||||
|
|
||||||
// First find those channels who are accepting posts from anybody, or at least
|
|
||||||
// something greater than just their connections.
|
|
||||||
|
|
||||||
if($msg['notify']['sender']['url'] === z_root()) {
|
|
||||||
$sql = " where (( " . $col . " & " . intval(PERMS_NETWORK) . " ) > 0
|
|
||||||
or ( " . $col . " & " . intval(PERMS_SITE) . " ) > 0
|
|
||||||
or ( " . $col . " & " . intval(PERMS_PUBLIC) . ") > 0
|
|
||||||
or ( " . $col . " & " . intval(PERMS_AUTHED) . ") > 0 ) ";
|
|
||||||
} else {
|
|
||||||
$sql = " where ( " . $col . " = " . intval(PERMS_NETWORK) . "
|
|
||||||
or " . $col . " = " . intval(PERMS_PUBLIC) . "
|
|
||||||
or " . $col . " = " . intval(PERMS_AUTHED) . " ) ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = q("select channel_hash as hash from channel $sql or channel_hash = '%s'
|
|
||||||
and channel_removed = 0 ",
|
|
||||||
dbesc($msg['notify']['sender']['hash'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if(! $r)
|
|
||||||
$r = array();
|
$r = array();
|
||||||
|
|
||||||
// Now we have to get a bit dirty. Find every channel that has the sender in their connections (abook)
|
$c = q("select channel_id, channel_hash from channel where channel_removed = 0");
|
||||||
// and is allowing this sender at least at a high level.
|
if($c) {
|
||||||
|
foreach($c as $cc) {
|
||||||
$x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id
|
if(perm_is_allowed($cc['channel_id'],$msg['notify']['sender']['hash'],$perm)) {
|
||||||
where abook_xchan = '%s' and channel_removed = 0
|
$r[] = [ 'hash' => $cc['channel_hash'] ];
|
||||||
and (( " . $col . " = " . intval(PERMS_SPECIFIC) . " and ( abook_my_perms & " . intval($field) . " ) > 0 )
|
}
|
||||||
OR " . $col . " = " . intval(PERMS_PENDING) . "
|
}
|
||||||
OR ( " . $col . " = " . intval(PERMS_CONTACTS) . " and abook_pending = 0 )) ",
|
}
|
||||||
dbesc($msg['notify']['sender']['hash'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if(! $x)
|
|
||||||
$x = array();
|
|
||||||
|
|
||||||
$r = array_merge($r,$x);
|
|
||||||
|
|
||||||
//logger('message: ' . print_r($msg['message'],true));
|
//logger('message: ' . print_r($msg['message'],true));
|
||||||
|
|
||||||
if($include_sys && array_key_exists('public_scope',$msg['message']) && $msg['message']['public_scope'] === 'public') {
|
if($include_sys && array_key_exists('public_scope',$msg['message']) && $msg['message']['public_scope'] === 'public') {
|
||||||
$sys = get_sys_channel();
|
$sys = get_sys_channel();
|
||||||
if($sys)
|
if($sys)
|
||||||
$r[] = array('hash' => $sys['channel_hash']);
|
$r[] = [ 'hash' => $sys['channel_hash'] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for any public mentions on this site
|
// look for any public mentions on this site
|
||||||
|
Reference in New Issue
Block a user