aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-11 17:02:49 -0700
committerredmatrix <git@macgirvin.com>2016-07-11 17:02:49 -0700
commit71b001fdb7f4c900f6e7ff15a29952d6dc82c1fc (patch)
treefaa3dd9fa2192995757a261451a2c4e969dad181
parentcc83983ae5cb4675f631b0fb4bc61b800f183dae (diff)
downloadvolse-hubzilla-71b001fdb7f4c900f6e7ff15a29952d6dc82c1fc.tar.gz
volse-hubzilla-71b001fdb7f4c900f6e7ff15a29952d6dc82c1fc.tar.bz2
volse-hubzilla-71b001fdb7f4c900f6e7ff15a29952d6dc82c1fc.zip
more perms work - notably the stuff in public_perms
-rw-r--r--Zotlabs/Module/Connedit.php20
-rw-r--r--include/zot.php72
2 files changed, 30 insertions, 62 deletions
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index 445219894..8aecfca4c 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -129,14 +129,21 @@ class Connedit extends \Zotlabs\Web\Controller {
$abook_my_perms = 0;
- foreach($_POST as $k => $v) {
- if(strpos($k,'perms_') === 0) {
- $perm = substr($k,6);
- set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,(($v) ? 1 : 0));
- $abook_my_perms += $v;
+ $all_perms = \Zotlabs\Access\Permissions::Perms();
+
+ if($all_perms) {
+ foreach($all_perms as $perm => $desc) {
+ 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);
+ }
}
}
-
+
$new_friend = false;
if(! $is_self) {
@@ -686,7 +693,6 @@ class Connedit extends \Zotlabs\Web\Controller {
$their_perms[$t['k']] = $t['v'];
}
}
-logger('theris: ' . print_r($their_perms,true));
foreach($global_perms as $k => $v) {
$thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
diff --git a/include/zot.php b/include/zot.php
index 339ea7a16..f0e4d31db 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -462,7 +462,7 @@ function zot_refresh($them, $channel = null, $force = false) {
$default_perms = $xx['perms_connect'];
}
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
@@ -505,9 +505,9 @@ function zot_refresh($them, $channel = null, $force = false) {
'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'],
));
- if(intval($permissions['view_stream']))) {
- if(intval(get_pconfig($channel['channel_id'],'perms_limit','send_stream')) & PERMS_PENDING)
- || (! intval($new_connection[0]['abook_pending'])) )
+ if(intval($permissions['view_stream'])) {
+ if(intval(get_pconfig($channel['channel_id'],'perms_limit','send_stream') & PERMS_PENDING)
+ || (! intval($new_connection[0]['abook_pending'])))
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'))
$include_sys = true;
$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'])) {
// check mention recipient permissions on top level posts only
$check_mentions = true;
@@ -1378,67 +1377,30 @@ function public_recips($msg) {
// contains the tag. we'll solve that further below.
if($msg['notify']['sender']['guid_sig'] != $msg['message']['owner']['guid_sig']) {
- $perm = 'post_comment';
- $col = 'channel_w_comment';
- $field = PERMS_W_COMMENT;
+ $perm = 'post_comments';
}
}
}
- elseif($msg['message']['type'] === 'mail') {
+ elseif($msg['message']['type'] === '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 = array();
+
+ $c = q("select channel_id, channel_hash from channel where channel_removed = 0");
+ if($c) {
+ foreach($c as $cc) {
+ if(perm_is_allowed($cc['channel_id'],$msg['notify']['sender']['hash'],$perm)) {
+ $r[] = [ 'hash' => $cc['channel_hash'] ];
+ }
+ }
}
- $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();
-
- // Now we have to get a bit dirty. Find every channel that has the sender in their connections (abook)
- // and is allowing this sender at least at a high level.
-
- $x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id
- where abook_xchan = '%s' and channel_removed = 0
- 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));
if($include_sys && array_key_exists('public_scope',$msg['message']) && $msg['message']['public_scope'] === 'public') {
$sys = get_sys_channel();
if($sys)
- $r[] = array('hash' => $sys['channel_hash']);
+ $r[] = [ 'hash' => $sys['channel_hash'] ];
}
// look for any public mentions on this site