aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/diaspora.php19
-rw-r--r--include/follow.php10
-rw-r--r--include/identity.php17
-rw-r--r--include/widgets.php2
-rw-r--r--include/zot.php18
5 files changed, 37 insertions, 29 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index c6d4b7423..d4e8a2802 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -673,16 +673,15 @@ function diaspora_request($importer,$xml) {
return;
}
- $default_perms = 0;
- // look for default permissions to apply in return - e.g. auto-friend
- $z = q("select * from abook where abook_channel = %d and (abook_flags & %d) limit 1",
- intval($importer['channel_id']),
- intval(ABOOK_FLAG_SELF)
- );
-
- if($z)
- $default_perms = intval($z[0]['abook_my_perms']);
-
+ $role = get_pconfig($channel['channel_id'],'system','permissions_role');
+ if($role) {
+ $x = get_role_perms($role);
+ if($x['perms_auto'])
+ $default_perms = $x['perms_accept'];
+ }
+ if(! $default_perms)
+ $default_perms = intval(get_pconfig($channel['channel_id'],'system','autoperms'));
+
$their_perms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK|PERMS_W_STREAM|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT|PERMS_R_STORAGE|PERMS_R_PAGES;
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_my_perms, abook_their_perms, abook_closeness, abook_rating, abook_created, abook_updated, abook_connected, abook_dob, abook_flags) values ( %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d )",
diff --git a/include/follow.php b/include/follow.php
index 20fd7f5fc..b5196834d 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -64,13 +64,9 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$j = json_decode($ret['body'],true);
}
- if($is_red && $j) {
-
+ $my_perms = get_channel_default_perms($uid);
- // fixme - we need to be able to define these somewhere for the custom role
- $my_perms = 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;
+ if($is_red && $j) {
$role = get_pconfig($uid,'system','permissions_role');
if($role) {
@@ -141,7 +137,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
}
}
- $my_perms = 0;
$their_perms = 0;
$xchan_hash = '';
@@ -168,7 +163,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
if($r) {
$xchan_hash = $r[0]['xchan_hash'];
$their_perms = 0;
- $my_perms = PERMS_W_STREAM|PERMS_W_MAIL;
$role = get_pconfig($uid,'system','permissions_role');
if($role) {
$x = get_role_perms($role);
diff --git a/include/identity.php b/include/identity.php
index 9a574ea65..16e3eff0e 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -348,10 +348,13 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}")
);
- $myperms = 0;
if($role_permissions) {
$myperms = ((array_key_exists('perms_auto',$role_permissions) && $role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0);
}
+ 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_flags, abook_my_perms )
values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ",
@@ -1561,4 +1564,16 @@ function notifications_on($channel_id,$value) {
intval($channel_id)
);
return $x;
+}
+
+
+function get_channel_default_perms($uid) {
+
+ $r = q("select abook_my_perms from abook where abook_channel = %d and abook_flags & %d limit 1",
+ intval($uid),
+ intval(ABOOK_FLAG_SELF)
+ );
+ if($r)
+ return $r[0]['abook_my_perms'];
+ return 0;
} \ No newline at end of file
diff --git a/include/widgets.php b/include/widgets.php
index 703bc07a8..f678e40dd 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -506,7 +506,7 @@ function widget_settings_menu($arr) {
if($role === false || $role === 'custom') {
$tabs[] = array(
- 'label' => t('Automatic Permissions (Advanced)'),
+ 'label' => t('Connection Default Permissions'),
'url' => $a->get_baseurl(true) . '/connedit/' . $abook_self_id,
'selected' => ''
);
diff --git a/include/zot.php b/include/zot.php
index f1ff084ac..9f22bc30b 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -439,15 +439,15 @@ function zot_refresh($them,$channel = null, $force = false) {
}
}
else {
- $default_perms = 0;
- // look for default permissions to apply in return - e.g. auto-friend
- $z = q("select * from abook where abook_channel = %d and (abook_flags & %d) limit 1",
- intval($channel['channel_id']),
- intval(ABOOK_FLAG_SELF)
- );
-
- if($z)
- $default_perms = intval($z[0]['abook_my_perms']);
+ $role = get_pconfig($channel['channel_id'],'system','permissions_role');
+ if($role) {
+ $x = get_role_perms($role);
+ if($x['perms_auto'])
+ $default_perms = $x['perms_accept'];
+ }
+ if(! $default_perms)
+ $default_perms = intval(get_pconfig($channel['channel_id'],'system','autoperms'));
+
// Keep original perms to check if we need to notify them
$previous_perms = get_all_perms($channel['channel_id'],$x['hash']);