diff options
author | friendica <info@friendica.com> | 2013-08-18 20:20:03 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-08-18 20:20:03 -0700 |
commit | 20f3d097080fde4315b25523fe29b129cdd7034c (patch) | |
tree | 3f04bbccf15162d83db7951eaa072e479f6b4e38 | |
parent | e094c23f11c8a164224e8a35c77d2cfa089db7ed (diff) | |
download | volse-hubzilla-20f3d097080fde4315b25523fe29b129cdd7034c.tar.gz volse-hubzilla-20f3d097080fde4315b25523fe29b129cdd7034c.tar.bz2 volse-hubzilla-20f3d097080fde4315b25523fe29b129cdd7034c.zip |
some sane permission defaults.
-rw-r--r-- | include/follow.php | 5 | ||||
-rw-r--r-- | include/identity.php | 15 | ||||
-rw-r--r-- | include/permissions.php | 35 | ||||
-rw-r--r-- | mod/settings.php | 31 |
4 files changed, 67 insertions, 19 deletions
diff --git a/include/follow.php b/include/follow.php index 6b192234c..ce550b07f 100644 --- a/include/follow.php +++ b/include/follow.php @@ -145,12 +145,13 @@ function new_contact($uid,$url,$channel,$interactive = false) { ); } else { - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_created, abook_updated ) - values( %d, %d, '%s', %d, '%s', '%s' ) ", + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated ) + values( %d, %d, '%s', %d, %d, '%s', '%s' ) ", intval($aid), intval($uid), dbesc($xchan_hash), intval($their_perms), + intval(PERMS_W_STREAM|PERMS_W_MAIL), dbesc(datetime_convert()), dbesc(datetime_convert()) ); diff --git a/include/identity.php b/include/identity.php index 99b90cc8b..5f210c456 100644 --- a/include/identity.php +++ b/include/identity.php @@ -115,11 +115,19 @@ function create_identity($arr) { if(array_key_exists('primary', $arr)) $primary = intval($arr['primary']); + $perms_sql = ''; + + $defperms = site_default_perms(); + $global_perms = get_perms(); + foreach($defperms as $p => $v) { + $perms_keys .= ', ' . $global_perms[$p][0]; + $perms_vals .= ', ' . intval($v); + } $r = q("insert into channel ( channel_account_id, channel_primary, channel_name, channel_address, channel_guid, channel_guid_sig, - channel_hash, channel_prvkey, channel_pubkey, channel_pageflags ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d ) ", + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags $perms_keys ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d $perms_vals ) ", intval($arr['account_id']), intval($primary), @@ -133,6 +141,9 @@ function create_identity($arr) { intval($pageflags) ); + + + $r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1", intval($arr['account_id']), diff --git a/include/permissions.php b/include/permissions.php index e7f50ceeb..bf50ebdd1 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -328,3 +328,38 @@ function check_list_permissions($uid,$arr,$perm) { return($result); } + + +function site_default_perms() { + + $typical = array( + 'view_stream' => PERMS_PUBLIC, + 'view_profile' => PERMS_PUBLIC, + 'view_photos' => PERMS_PUBLIC, + 'view_contacts' => PERMS_PUBLIC, + 'view_storage' => PERMS_PUBLIC, + 'view_pages' => PERMS_PUBLIC, + 'send_stream' => PERMS_SPECIFIC, + 'post_wall' => PERMS_SPECIFIC, + 'post_comments' => PERMS_SPECIFIC, + 'post_mail' => PERMS_SPECIFIC, + 'post_photos' => 0, + 'tag_deliver' => PERMS_SPECIFIC, + 'chat' => PERMS_SPECIFIC, + 'write_storage' => 0, + 'write_pages' => 0, + 'delegate' => 0, + ); + + + $global_perms = get_perms(); + $ret = array(); + + foreach($global_perms as $perm => $v) { + $x = get_config('default_perms',$perm); + if($x === false) + $x = $typical[$perm]; + $ret[$perm] = $x; + } + return $ret; +} diff --git a/mod/settings.php b/mod/settings.php index 50bb13ea2..36befead1 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -349,22 +349,23 @@ function settings_post(&$a) { $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0); $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0); + $arr = array(); - $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0); - $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0); - $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0); - $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0); - $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0); - $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0); - $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0); - $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0); - $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0); - $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0); - $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0); - $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0); - $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0); - $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0); - $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0); + $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0); + $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0); + $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0); + $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0); + $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0); + $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0); + $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0); + $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0); + $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0); + $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0); + $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0); + $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0); + $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0); + $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0); + $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0); $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0); $defperms = 0; |