diff options
author | friendica <info@friendica.com> | 2014-11-04 17:11:02 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-11-04 17:11:02 -0800 |
commit | d5d6158973ecb83b63d42c57c96dce849842c83b (patch) | |
tree | 354abb2b3fefcb4c61fd1a87f7c37e82ae8c70f8 | |
parent | 7a92157187c59ae68eb585e5bd0ae1d7c9aa6162 (diff) | |
download | volse-hubzilla-d5d6158973ecb83b63d42c57c96dce849842c83b.tar.gz volse-hubzilla-d5d6158973ecb83b63d42c57c96dce849842c83b.tar.bz2 volse-hubzilla-d5d6158973ecb83b63d42c57c96dce849842c83b.zip |
ok heads up - potentially destabilising change. I've tried to sort out all the default connection permissions for those who don't have a predefined (or therefore have a "custom") permissions role. Unfortunately this includes most people that were using this software more than a month ago. The real changes are that the SELF address book entry no longer holds "auto-permissions" but instead holds your "default permissions" (if you have a pre-defined role, the defaults will be pulled from the role table).
The auto permissions have moved to a pconfig (uid.system.autoperms). A DB update will move these settings into their new homes.
What used to be the "Auto-permissions settings" page is now the "default permissions settings" page and a checkbox therein decides whether or not to apply the permissions automatically. A link to this page will only be shown when you have the "custom" role selected.
With luck nobody will notice anything wrong. But at least for the next few days, please review permissions that have been assigned to new connections (either automatically or manually) and make sure they make sense (e.g. they aren't "nothing"). You still need to take action when seeing a message "permissions have changed but not yet submitted" as we always let you review and perhaps adjust the settings _before_ a connection is established (unless you have autoperms turned on).
-rwxr-xr-x | boot.php | 2 | ||||
-rwxr-xr-x | include/diaspora.php | 19 | ||||
-rw-r--r-- | include/follow.php | 10 | ||||
-rw-r--r-- | include/identity.php | 17 | ||||
-rw-r--r-- | include/widgets.php | 2 | ||||
-rw-r--r-- | include/zot.php | 18 | ||||
-rw-r--r-- | install/update.php | 22 | ||||
-rw-r--r-- | mod/connedit.php | 28 | ||||
-rw-r--r-- | view/css/mod_connedit.css | 2 | ||||
-rwxr-xr-x | view/tpl/abook_edit.tpl | 3 |
10 files changed, 81 insertions, 42 deletions
@@ -48,7 +48,7 @@ define ( 'RED_PLATFORM', 'redmatrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1130 ); +define ( 'DB_UPDATE_VERSION', 1131 ); define ( 'EOL', '<br />' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); 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']); diff --git a/install/update.php b/install/update.php index c36864908..d6953cdbc 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1130 ); +define( 'UPDATE_VERSION' , 1131 ); /** * @@ -1464,3 +1464,23 @@ function update_r1129() { return UPDATE_FAILED; } +function update_r1130() { + $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("select abook_channel, abook_my_perms from abook where (abook_flags & %d) and abook_my_perms != 0", + intval(ABOOK_FLAG_SELF) + ); + if($r) { + foreach($r as $rr) { + set_pconfig($rr['abook_channel'],'system','autoperms',$rr['abook_my_perms']); + } + } + $r = q("update abook set abook_my_perms = %d where (abook_flags & %d) and abook_my_perms = 0", + intval($myperms), + intval(ABOOK_FLAG_SELF) + ); + + return UPDATE_SUCCESS; +}
\ No newline at end of file diff --git a/mod/connedit.php b/mod/connedit.php index b10d9f3b8..0e129e32d 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -68,6 +68,14 @@ function connedit_post(&$a) { call_hooks('contact_edit_post', $_POST); + if($orig_record['abook_flags'] & ABOOK_FLAG_SELF) { + $autoperms = intval($_POST['autoperms']); + } + else { + $autoperms = null; + } + + $profile_id = $_POST['profile_assign']; if($profile_id) { $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1", @@ -121,7 +129,7 @@ function connedit_post(&$a) { if($orig_record[0]['abook_profile'] != $profile_id) { //Update profile photo permissions - logger('As a new profile was assigned updating profile photos'); + logger('A new profile was assigned - updating profile photos'); require_once('mod/profile_photo.php'); profile_photo_set_profile_perms($profile_id); @@ -209,6 +217,9 @@ function connedit_post(&$a) { call_hooks('accept_follow', $arr); } + if(! is_null($autoperms)) + set_pconfig(local_user(),'system','autoperms',(($autoperms) ? $abook_my_perms : 0)); + connedit_clone($a); return; @@ -261,12 +272,8 @@ function connedit_content(&$a) { $x = get_role_perms($role); if($x['perms_accept']) $my_perms = $x['perms_accept']; - else { - // 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; - } + else + $my_perms = get_channel_default_perms(local_user()); } if($my_perms) { $o .= "<script>function connectDefaultShare() { @@ -522,16 +529,17 @@ function connedit_content(&$a) { if((! $self) && ($existing[$k])) $thisperm = "1"; - $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]); + $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC || $self) ? '' : '1'), $v[4]); } $o .= replace_macros($tpl,array( - '$header' => (($self) ? t('Automatic Permissions Settings') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])), + '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])), + '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_user(),'system','autoperms')) ? 1 : 0), ''), '$addr' => $contact['xchan_addr'], '$notself' => (($self) ? '' : '1'), '$self' => (($self) ? '1' : ''), - '$autolbl' => t('When receiving a channel introduction, any permissions provided here will be applied to the new connection automatically and the introduction approved. Leave this page if you do not wish to use this feature.'), + '$autolbl' => t('Apply the permissions indicated on this page to all new connections.'), '$viewprof' => t('View Profile'), '$lbl_slider' => t('Slide to adjust your degree of friendship'), '$slide' => $slide, diff --git a/view/css/mod_connedit.css b/view/css/mod_connedit.css index 5bf598062..e7b93a088 100644 --- a/view/css/mod_connedit.css +++ b/view/css/mod_connedit.css @@ -14,7 +14,7 @@ margin-bottom: 5px !important; } -.abook-pending-contact, .abook-permschange { +.abook-pending-contact, .abook-permschange, .abook-autotext { background: orange; font-weight: bold; margin: 10px; diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl index 078eb4df4..0f91d6024 100755 --- a/view/tpl/abook_edit.tpl +++ b/view/tpl/abook_edit.tpl @@ -10,7 +10,10 @@ {{/if}} {{if $self}} +<div class="abook-autotext"> <div id="autoperm-desc" class="descriptive-paragraph">{{$autolbl}}</div> +{{include file="field_checkbox.tpl" field=$autoperms}} +</div> {{/if}} |