aboutsummaryrefslogtreecommitdiffstats
path: root/mod/settings.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/settings.php')
-rw-r--r--mod/settings.php290
1 files changed, 169 insertions, 121 deletions
diff --git a/mod/settings.php b/mod/settings.php
index 876216871..396bb2972 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
@@ -169,7 +168,7 @@ function settings_post(&$a) {
}
}
- $r = q("UPDATE channel SET channel_theme = '%s' WHERE channel_id = %d LIMIT 1",
+ $r = q("UPDATE channel SET channel_theme = '%s' WHERE channel_id = %d",
dbesc($theme),
intval(local_user())
);
@@ -206,7 +205,7 @@ function settings_post(&$a) {
$salt = random_string(32);
$password_encoded = hash('whirlpool', $salt . $newpass);
$r = q("update account set account_salt = '%s', account_password = '%s', account_password_changed = '%s'
- where account_id = %d limit 1",
+ where account_id = %d",
dbesc($salt),
dbesc($password_encoded),
dbesc(datetime_convert()),
@@ -236,7 +235,7 @@ function settings_post(&$a) {
$email = $a->user['email'];
}
if(! $errs) {
- $r = q("update account set account_email = '%s' where account_id = %d limit 1",
+ $r = q("update account set account_email = '%s' where account_id = %d",
dbesc($email),
intval($account['account_id'])
);
@@ -257,14 +256,111 @@ 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",
+ 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",
+ 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', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d",
+ 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;
+ }
+ }
+ // no default collection
+ else {
+ q("update channel set channel_default_group = '', channel_allow_gid = '', channel_allow_cid = '', channel_deny_gid = '',
+ channel_deny_cid = '' where channel_id = %d",
+ intval(local_user())
+ );
+ }
+
+ $r = q("update abook set abook_my_perms = %d where abook_channel = %d and (abook_flags & %d)>0",
+ intval(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0),
+ intval(local_user()),
+ intval(ABOOK_FLAG_SELF)
+ );
+ set_pconfig(local_user(),'system','autoperms',(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0));
+
+ 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'])) : '');
+ $evdays = ((x($_POST,'evdays')) ? intval($_POST['evdays']) : 3);
+
$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 +369,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 +387,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;
@@ -373,6 +408,31 @@ function settings_post(&$a) {
$notify += intval($_POST['notify8']);
+ $vnotify = 0;
+
+ if(x($_POST,'vnotify1'))
+ $vnotify += intval($_POST['vnotify1']);
+ if(x($_POST,'vnotify2'))
+ $vnotify += intval($_POST['vnotify2']);
+ if(x($_POST,'vnotify3'))
+ $vnotify += intval($_POST['vnotify3']);
+ if(x($_POST,'vnotify4'))
+ $vnotify += intval($_POST['vnotify4']);
+ if(x($_POST,'vnotify5'))
+ $vnotify += intval($_POST['vnotify5']);
+ if(x($_POST,'vnotify6'))
+ $vnotify += intval($_POST['vnotify6']);
+ if(x($_POST,'vnotify7'))
+ $vnotify += intval($_POST['vnotify7']);
+ if(x($_POST,'vnotify8'))
+ $vnotify += intval($_POST['vnotify8']);
+ if(x($_POST,'vnotify9'))
+ $vnotify += intval($_POST['vnotify9']);
+ if(x($_POST,'vnotify10'))
+ $vnotify += intval($_POST['vnotify10']);
+ if(x($_POST,'vnotify11'))
+ $vnotify += intval($_POST['vnotify11']);
+
$channel = $a->get_channel();
$err = '';
@@ -389,27 +449,22 @@ 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);
+ set_pconfig(local_user(),'system','vnotify',$vnotify);
+ set_pconfig(local_user(),'system','evdays',$evdays);
- $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",
dbesc($username),
intval($pageflags),
dbesc($timezone),
@@ -418,45 +473,20 @@ 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",
+ 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",
+ $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s'",
dbesc($username),
dbesc(datetime_convert()),
dbesc($channel['channel_hash'])
@@ -786,8 +816,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 +868,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 +907,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" />';
@@ -935,9 +960,15 @@ function settings_content(&$a) {
}
}
+ $evdays = get_pconfig(local_user(),'system','evdays');
+ if(! $evdays)
+ $evdays = 3;
$permissions_role = get_pconfig(local_user(),'system','permissions_role');
$permissions_set = (($permissions_role && $permissions_role != 'custom') ? true : false);
+ $vnotify = get_pconfig(local_user(),'system','vnotify');
+ if($vnotify === false)
+ $vnotify = (-1);
$o .= replace_macros($stpl,array(
'$ptitle' => t('Channel Settings'),
@@ -980,9 +1011,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,
@@ -1006,7 +1038,23 @@ function settings_content(&$a) {
'$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
'$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),
-
+
+ '$lbl_vnot' => t('Show visual notifications including:'),
+
+ '$vnotify1' => array('vnotify1', t('Unseen matrix activity'), ($vnotify & VNOTIFY_NETWORK), VNOTIFY_NETWORK, ''),
+ '$vnotify2' => array('vnotify2', t('Unseen channel activity'), ($vnotify & VNOTIFY_CHANNEL), VNOTIFY_CHANNEL, ''),
+ '$vnotify3' => array('vnotify3', t('Unseen private messages'), ($vnotify & VNOTIFY_MAIL), VNOTIFY_MAIL, t('Recommended')),
+ '$vnotify4' => array('vnotify4', t('Upcoming events'), ($vnotify & VNOTIFY_EVENT), VNOTIFY_EVENT, ''),
+ '$vnotify5' => array('vnotify5', t('Events today'), ($vnotify & VNOTIFY_EVENTTODAY), VNOTIFY_EVENTTODAY, ''),
+ '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), ($vnotify & VNOTIFY_BIRTHDAY), VNOTIFY_BIRTHDAY, t('Not available in all themes')),
+ '$vnotify7' => array('vnotify7', t('System (personal) notifications'), ($vnotify & VNOTIFY_SYSTEM), VNOTIFY_SYSTEM, ''),
+ '$vnotify8' => array('vnotify8', t('System info messages'), ($vnotify & VNOTIFY_INFO), VNOTIFY_INFO, t('Recommended')),
+ '$vnotify9' => array('vnotify9', t('System critical alerts'), ($vnotify & VNOTIFY_ALERT), VNOTIFY_ALERT, t('Recommended')),
+ '$vnotify10' => array('vnotify10', t('New connections'), ($vnotify & VNOTIFY_INTRO), VNOTIFY_INTRO, t('Recommended')),
+ '$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, ''),
+
+ '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')),
+
'$h_advn' => t('Advanced Account/Page Type Settings'),
'$h_descadvn' => t('Change the behaviour of this account for special situations'),
'$pagetype' => $pagetype,