aboutsummaryrefslogtreecommitdiffstats
path: root/mod/settings.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-10-26 19:32:12 -0700
committerfriendica <info@friendica.com>2014-10-26 19:32:12 -0700
commit655c3e1b4784f4bc37af1e1db0d7bcf313e71e66 (patch)
tree83b8d1029a9c0b0191120f6b5bf5e71b65b493a9 /mod/settings.php
parentd2af45d2066565a5eab31b5105b874ee98f10364 (diff)
downloadvolse-hubzilla-655c3e1b4784f4bc37af1e1db0d7bcf313e71e66.tar.gz
volse-hubzilla-655c3e1b4784f4bc37af1e1db0d7bcf313e71e66.tar.bz2
volse-hubzilla-655c3e1b4784f4bc37af1e1db0d7bcf313e71e66.zip
put privacy role selector in settings page. Change visibility of various permissions items accordingly.
Diffstat (limited to 'mod/settings.php')
-rw-r--r--mod/settings.php224
1 files changed, 107 insertions, 117 deletions
diff --git a/mod/settings.php b/mod/settings.php
index 876216871..2027012ad 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -39,7 +39,9 @@ function settings_post(&$a) {
if(! local_user())
return;
- // logger('mod_settings: ' . print_r($_REQUEST,true));
+ $channel = $a->get_channel();
+
+ logger('mod_settings: ' . print_r($_REQUEST,true));
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return;
@@ -152,14 +154,11 @@ function settings_post(&$a) {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
}
-// $chanview_full = ((x($_POST,'chanview_full')) ? intval($_POST['chanview_full']) : 0);
set_pconfig(local_user(),'system','user_scalable',$user_scalable);
set_pconfig(local_user(),'system','update_interval', $browser_update);
set_pconfig(local_user(),'system','itemspage', $itemspage);
set_pconfig(local_user(),'system','no_smilies',$nosmile);
set_pconfig(local_user(),'system','title_tosource',$title_tosource);
-// set_pconfig(local_user(),'system','chanview_full',$chanview_full);
-
if ($theme == $a->channel['channel_theme']){
// call theme_post only if theme has not been changed
@@ -257,14 +256,103 @@ function settings_post(&$a) {
call_hooks('settings_post', $_POST);
-
+ $set_perms = '';
+
+ $role = ((x($_POST,'permissions_role')) ? notags(trim($_POST['permissions_role'])) : '');
+ $oldrole = get_pconfig(local_user(),'system','permissions_role');
+
+ if(($role != $oldrole) || ($role === 'custom')) {
+
+ if($role === 'custom') {
+ $hide_presence = (((x($_POST,'hide_presence')) && (intval($_POST['hide_presence']) == 1)) ? 1: 0);
+ $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
+ $def_group = ((x($_POST,'group-selection')) ? notags(trim($_POST['group-selection'])) : '');
+ $r = q("update channel set channel_default_group = '%s' where channel_id = %d limit 1",
+ dbesc($def_group),
+ intval(local_user())
+ );
+
+ $global_perms = get_perms();
+
+ foreach($global_perms as $k => $v) {
+ $set_perms .= ', ' . $v[0] . ' = ' . intval($_POST[$k]) . ' ';
+ }
+
+ $str_group_allow = perms2str($_POST['group_allow']);
+ $str_contact_allow = perms2str($_POST['contact_allow']);
+ $str_group_deny = perms2str($_POST['group_deny']);
+ $str_contact_deny = perms2str($_POST['contact_deny']);
+ $r = q("update channel set channel_allow_cid = '%s', channel_allow_gid = '%s', channel_deny_cid = '%s', channel_deny_gid = '%s'
+ where channel_id = %d limit 1",
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
+ intval(local_user())
+ );
+ }
+ else {
+ $role_permissions = get_role_perms($_POST['permissions_role']);
+ if(! $role_permissions) {
+ notice('Permissions category could not be found.');
+ return;
+ }
+ $hide_presence = 1 - (intval($role_permissions['online']));
+ if($role_permissions['default_collection']) {
+ $r = q("select hash from groups where uid = %d and name = '%s' limit 1",
+ intval(local_user()),
+ dbesc( t('Friends') )
+ );
+ if(! $r) {
+ require_once('include/group.php');
+ group_add(local_user(), t('Friends'));
+ group_add_member(local_user(),t('Friends'),$channel['channel_hash']);
+ $r = q("select hash from groups where uid = %d and name = '%s' limit 1",
+ intval(local_user()),
+ dbesc( t('Friends') )
+ );
+ }
+ if($r) {
+ q("update channel set channel_default_group = '%s', channel_allow_gid = '%s' where channel_id = %d limit 1",
+ dbesc($r[0]['hash']),
+ dbesc('<' . $r[0]['hash'] . '>'),
+ intval(local_user())
+ );
+ }
+ else {
+ notice( sprintf('Default privacy collection \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
+ return;
+ }
+ }
+
+ if($role_permissions['perms_auto']) {
+ $r = q("update abook set abook_my_perms = %d where abook_channel = %d and (abook_flags & %d) limit 1",
+ intval($role_permissions['perms_accept']),
+ intval(local_user()),
+ intval(ABOOK_FLAG_SELF)
+ );
+ }
+
+ foreach($role_permissions as $p => $v) {
+ if(strpos($p,'channel_') !== false) {
+ $set_perms .= ', ' . $p . ' = ' . intval($v) . ' ';
+ }
+ if($p === 'directory_publish') {
+ $publish = intval($v);
+ }
+ }
+ }
+
+ set_pconfig(local_user(),'system','hide_online_status',$hide_presence);
+ set_pconfig(local_user(),'system','permissions_role',$role);
+ }
+
$username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
$timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
$defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
$openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
$maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
$expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0);
- $def_group = ((x($_POST,'group-selection')) ? notags(trim($_POST['group-selection'])) : '');
$channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu']),ENT_QUOTES) : '');
$expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0);
@@ -273,17 +361,13 @@ function settings_post(&$a) {
$expire_network_only = ((x($_POST,'expire_network_only'))? intval($_POST['expire_network_only']) : 0);
$allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
- $hide_presence = (((x($_POST,'hide_presence')) && (intval($_POST['hide_presence']) == 1)) ? 1: 0);
- $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
- $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
- $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
+
$blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
$unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0);
$cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0);
$suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
- $hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0);
- $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
+
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
@@ -295,63 +379,6 @@ function settings_post(&$a) {
if($adult != $existing_adult)
$pageflags = ($pageflags ^ PAGE_ADULT);
- $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_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0);
- $arr['channel_a_republish'] = (($_POST['republish']) ? $_POST['republish'] : 0);
- $arr['channel_w_like'] = (($_POST['post_like']) ? $_POST['post_like'] : 0);
-
- $defperms = 0;
- if(x($_POST['def_view_stream']))
- $defperms += $_POST['def_view_stream'];
- if(x($_POST['def_view_profile']))
- $defperms += $_POST['def_view_profile'];
- if(x($_POST['def_view_photos']))
- $defperms += $_POST['def_view_photos'];
- if(x($_POST['def_view_contacts']))
- $defperms += $_POST['def_view_contacts'];
- if(x($_POST['def_send_stream']))
- $defperms += $_POST['def_send_stream'];
- if(x($_POST['def_post_wall']))
- $defperms += $_POST['def_post_wall'];
- if(x($_POST['def_tag_deliver']))
- $defperms += $_POST['def_tag_deliver'];
- if(x($_POST['def_post_comments']))
- $defperms += $_POST['def_post_comments'];
- if(x($_POST['def_post_mail']))
- $defperms += $_POST['def_post_mail'];
- if(x($_POST['def_post_photos']))
- $defperms += $_POST['def_post_photos'];
- if(x($_POST['def_chat']))
- $defperms += $_POST['def_chat'];
- if(x($_POST['def_delegate']))
- $defperms += $_POST['def_delegate'];
- if(x($_POST['def_view_storage']))
- $defperms += $_POST['def_view_storage'];
- if(x($_POST['def_write_storage']))
- $defperms += $_POST['def_write_storage'];
- if(x($_POST['def_view_pages']))
- $defperms += $_POST['def_view_pages'];
- if(x($_POST['def_write_pages']))
- $defperms += $_POST['def_write_pages'];
- if(x($_POST['def_republish']))
- $defperms += $_POST['def_republish'];
- if(x($_POST['def_post_like']))
- $defperms += $_POST['def_post_like'];
$notify = 0;
@@ -372,7 +399,6 @@ function settings_post(&$a) {
if(x($_POST,'notify8'))
$notify += intval($_POST['notify8']);
-
$channel = $a->get_channel();
$err = '';
@@ -389,27 +415,20 @@ function settings_post(&$a) {
}
}
-
if($timezone != $channel['channel_timezone']) {
if(strlen($timezone))
date_default_timezone_set($timezone);
}
- $str_group_allow = perms2str($_POST['group_allow']);
- $str_contact_allow = perms2str($_POST['contact_allow']);
- $str_group_deny = perms2str($_POST['group_deny']);
- $str_contact_deny = perms2str($_POST['contact_deny']);
-
set_pconfig(local_user(),'system','use_browser_location',$allow_location);
set_pconfig(local_user(),'system','suggestme', $suggestme);
set_pconfig(local_user(),'system','post_newfriend', $post_newfriend);
set_pconfig(local_user(),'system','post_joingroup', $post_joingroup);
set_pconfig(local_user(),'system','post_profilechange', $post_profilechange);
set_pconfig(local_user(),'system','blocktags',$blocktags);
- set_pconfig(local_user(),'system','hide_online_status',$hide_presence);
set_pconfig(local_user(),'system','channel_menu',$channel_menu);
- $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_default_group = '%s', channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d, channel_a_republish = %d, channel_w_like = %d, channel_allow_cid = '%s', channel_allow_gid = '%s', channel_deny_cid = '%s', channel_deny_gid = '%s' where channel_id = %d limit 1",
+ $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d limit 1",
dbesc($username),
intval($pageflags),
dbesc($timezone),
@@ -418,42 +437,17 @@ function settings_post(&$a) {
intval($unkmail),
intval($maxreq),
intval($expire),
- dbesc($def_group),
- intval($arr['channel_r_stream']),
- intval($arr['channel_r_profile']),
- intval($arr['channel_r_photos']),
- intval($arr['channel_r_abook']),
- intval($arr['channel_w_stream']),
- intval($arr['channel_w_wall']),
- intval($arr['channel_w_tagwall']),
- intval($arr['channel_w_comment']),
- intval($arr['channel_w_mail']),
- intval($arr['channel_w_photos']),
- intval($arr['channel_w_chat']),
- intval($arr['channel_a_delegate']),
- intval($arr['channel_r_storage']),
- intval($arr['channel_w_storage']),
- intval($arr['channel_r_pages']),
- intval($arr['channel_w_pages']),
- intval($arr['channel_a_republish']),
- intval($arr['channel_w_like']),
- dbesc($str_contact_allow),
- dbesc($str_group_allow),
- dbesc($str_contact_deny),
- dbesc($str_group_deny),
intval(local_user())
);
if($r)
info( t('Settings updated.') . EOL);
- $r = q("UPDATE `profile`
- SET `publish` = %d,
- `hide_friends` = %d
- WHERE `is_default` = 1 AND `uid` = %d LIMIT 1",
- intval($publish),
- intval($hide_friends),
- intval(local_user())
- );
+ if(! is_null($publish)) {
+ $r = q("UPDATE profile SET publish = %d WHERE is_default = 1 AND uid = %d LIMIT 1",
+ intval($publish),
+ intval(local_user())
+ );
+ }
if($name_change) {
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s' limit 1",
@@ -786,8 +780,6 @@ function settings_content(&$a) {
require_once('include/permissions.php');
-
-
$p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user())
);
@@ -840,9 +832,8 @@ function settings_content(&$a) {
$expire = $channel['channel_expire_days'];
$adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
- $blockwall = $a->user['blockwall'];
- $unkmail = $a->user['unkmail'];
- $cntunkmail = $a->user['cntunkmail'];
+// $unkmail = $a->user['unkmail'];
+// $cntunkmail = $a->user['cntunkmail'];
$hide_presence = intval(get_pconfig(local_user(), 'system','hide_online_status'));
@@ -880,8 +871,6 @@ function settings_content(&$a) {
$timezone = date_default_timezone_get();
-
-
$opt_tpl = get_markup_template("field_yesno.tpl");
if(get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
@@ -980,9 +969,10 @@ function settings_content(&$a) {
'$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($perm_defaults,false),
'$suggestme' => $suggestme,
-
'$group_select' => $group_select,
+ '$role_lbl' => t('Channel permissions category:'),
+ '$role_select' => role_selector($permissions_role),
'$profile_in_dir' => $profile_in_dir,
'$hide_friends' => $hide_friends,