aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/permissions.php4
-rw-r--r--include/widgets.php13
-rw-r--r--mod/settings.php224
-rw-r--r--view/css/mod_settings.css4
-rw-r--r--view/js/mod_settings.js16
-rwxr-xr-xview/tpl/settings.tpl46
6 files changed, 157 insertions, 150 deletions
diff --git a/include/permissions.php b/include/permissions.php
index 61ac8aea3..4eead563f 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -734,6 +734,10 @@ function get_role_perms($role) {
function role_selector($current) {
+
+ if(! $current)
+ $current = 'custom';
+
$roles = array(
'social' => array( t('Social Networking'),
array('social' => t('Mostly Public'), 'social_restricted' => t('Restricted'), 'social_private' => t('Private'))),
diff --git a/include/widgets.php b/include/widgets.php
index 8905df59a..2e406aa77 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -430,6 +430,8 @@ function widget_settings_menu($arr) {
// Retrieve the 'self' address book entry for use in the auto-permissions link
+ $role = get_pconfig(local_user(),'system','permissions_role');
+
$abk = q("select abook_id from abook where abook_channel = %d and ( abook_flags & %d ) limit 1",
intval(local_user()),
intval(ABOOK_FLAG_SELF)
@@ -487,14 +489,15 @@ function widget_settings_menu($arr) {
'selected' => ''
),
- array(
+ );
+
+ if($role === false || $role === 'custom') {
+ $tabs[] = array(
'label' => t('Automatic Permissions (Advanced)'),
'url' => $a->get_baseurl(true) . '/connedit/' . $abook_self_id,
'selected' => ''
- ),
-
-
- );
+ );
+ }
if(feature_enabled(local_user(),'premium_channel')) {
$tabs[] = array(
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,
diff --git a/view/css/mod_settings.css b/view/css/mod_settings.css
index 651167b47..d0c970989 100644
--- a/view/css/mod_settings.css
+++ b/view/css/mod_settings.css
@@ -12,6 +12,10 @@ ul#settings-privacy-macros {
margin-top: 15px;
}
+#settings-default-perms {
+ margin-top: 15px;
+}
+
#settings-perm-advanced {
margin-top: 15px;
}
diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js
index 77c9d0ced..87c8c3a2b 100644
--- a/view/js/mod_settings.js
+++ b/view/js/mod_settings.js
@@ -3,10 +3,18 @@ var ispublic = aStr['everybody'] ;
$(document).ready(function() {
- $("a#settings-default-perms-menu").colorbox({
- 'inline' : true,
- 'transition' : 'elastic'
- });
+ $("a#settings-default-perms-menu").colorbox({
+ 'inline' : true,
+ 'transition' : 'elastic'
+ });
+
+ $("#privacy-role-select").change(function() {
+ var role = $("#privacy-role-select").val();
+ if(role == 'custom')
+ $('#advanced-perm').show();
+ else
+ $('#advanced-perm').hide();
+ });
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
var selstr;
diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl
index 07a37f773..4c1b8eb8f 100755
--- a/view/tpl/settings.tpl
+++ b/view/tpl/settings.tpl
@@ -22,37 +22,44 @@
<h3 class="settings-heading">{{$h_prv}}</h3>
-{{include file="field_checkbox.tpl" field=$hide_presence}}
-
-<button type="button" class="btn btn-xs btn-default" data-toggle="collapse" data-target="#settings-permissions-wrapper">{{$lbl_p2macro}}</button>
+<div class="field custom">
+<label for="privacy-role-select">{{$role_lbl}}</label>
+{{$role_select}}
+</div>
+<div id="advanced-perm" style="display:{{if $permissions_set}}none{{else}}block{{/if}};">
+{{include file="field_checkbox.tpl" field=$hide_presence}}
+<button type="button" class="btn btn-default" data-toggle="collapse" data-target="#settings-permissions-wrapper">{{$lbl_p2macro}}</button>
<div class="collapse well" id="settings-permissions-wrapper">
-{{if !$expert}}
- <div class="alert alert-info">{{$hint}}</div>
-{{/if}}
{{foreach $permiss_arr as $permit}}
- {{if $expert}}
- {{include file="field_select.tpl" field=$permit}}
- {{else}}
- {{include file="field_select_disabled.tpl" field=$permit}}
- {{/if}}
+ {{include file="field_select.tpl" field=$permit}}
{{/foreach}}
-
-{{if $expert}}
<div class="settings-submit-wrapper" >
<input type="submit" name="submit" class="settings-submit" value="{{$submit}}" />
</div>
-{{/if}}
+</div>
+<div id="settings-default-perms" class="settings-default-perms" >
+ <button class="btn btn-default" data-toggle="modal" data-target="#aclModal" onclick="return false;">{{$permissions}}</button>
+ {{$aclselect}}
+ <div id="settings-default-perms-menu-end"></div>
</div>
-<div class="settings-common-perms">
+<br/>
+<div id="settings-default-perms-end"></div>
+{{$group_select}}
{{$profile_in_dir}}
+</div>
+
+<div class="settings-common-perms">
+
+
+
{{$suggestme}}
{{include file="field_yesno.tpl" field=$blocktags}}
@@ -62,15 +69,6 @@
</div>
-<div id="settings-default-perms" class="settings-default-perms" >
- <button class="btn btn-default btn-xs" data-toggle="modal" data-target="#aclModal" onclick="return false;">{{$permissions}}</button>
- {{$aclselect}}
- <div id="settings-default-perms-menu-end"></div>
-</div>
-<br/>
-<div id="settings-default-perms-end"></div>
-
-{{$group_select}}
<div class="settings-submit-wrapper" >