4 function settings_init(&$a) {
6 profile_load($a,$a->user['nickname']);
9 // These lines provide the javascript needed by the acl selector
11 $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ;
13 $a->page['htmlhead'] .= <<< EOT
15 $(document).ready(function() {
17 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
19 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
20 selstr = $(this).text();
21 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
22 $('#jot-public').hide();
25 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
26 $('#jot-public').show();
40 function settings_post(&$a) {
45 if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
48 if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
49 notice( t('Permission denied.') . EOL);
53 $old_page_flags = $a->user['page-flags'];
55 if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){
56 $key = $_POST['remove'];
57 q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
60 goaway($a->get_baseurl()."/settings/oauth/");
64 if(($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
66 $name = ((x($_POST,'name')) ? $_POST['name'] : '');
67 $key = ((x($_POST,'key')) ? $_POST['key'] : '');
68 $secret = ((x($_POST,'secret')) ? $_POST['secret'] : '');
69 $redirect = ((x($_POST,'redirect')) ? $_POST['redirect'] : '');
70 $icon = ((x($_POST,'icon')) ? $_POST['icon'] : '');
71 if ($name=="" || $key=="" || $secret==""){
72 notice(t("Missing some important data!"));
75 if ($_POST['submit']==t("Update")){
76 $r = q("UPDATE clients SET
83 WHERE client_id='%s'",
92 $r = q("INSERT INTO clients
93 (client_id, pw, name, redirect_uri, icon, uid)
94 VALUES ('%s','%s','%s','%s','%s',%d)",
103 goaway($a->get_baseurl()."/settings/oauth/");
107 if(($a->argc > 1) && ($a->argv[1] == 'addon')) {
108 call_hooks('plugin_settings_post', $_POST);
112 if(($a->argc > 1) && ($a->argv[1] == 'connectors')) {
114 if(x($_POST['imap-submit'])) {
115 $mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
116 $mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
117 $mail_ssl = ((x($_POST,'mail_ssl')) ? strtolower(trim($_POST['mail_ssl'])) : '');
118 $mail_user = ((x($_POST,'mail_user')) ? $_POST['mail_user'] : '');
119 $mail_pass = ((x($_POST,'mail_pass')) ? trim($_POST['mail_pass']) : '');
120 $mail_action = ((x($_POST,'mail_action')) ? trim($_POST['mail_action']) : '');
121 $mail_movetofolder = ((x($_POST,'mail_movetofolder')) ? trim($_POST['mail_movetofolder']) : '');
122 $mail_replyto = ((x($_POST,'mail_replyto')) ? $_POST['mail_replyto'] : '');
123 $mail_pubmail = ((x($_POST,'mail_pubmail')) ? $_POST['mail_pubmail'] : '');
126 $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
127 if(get_config('system','dfrn_only'))
130 if(! $mail_disabled) {
132 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
136 q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
140 if(strlen($mail_pass)) {
142 openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
143 q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1",
144 dbesc(bin2hex($pass)),
148 $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
149 `action` = %d, `movetofolder` = '%s',
150 `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1",
155 intval($mail_action),
156 dbesc($mail_movetofolder),
157 dbesc($mail_replyto),
158 intval($mail_pubmail),
161 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
166 require_once('include/email.php');
167 $mb = construct_mailbox_name($eacct);
168 if(strlen($eacct['server'])) {
170 openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
171 $mbox = email_connect($mb,$mail_user,$dcrpass);
175 notice( t('Failed to connect with email account using the settings provided.') . EOL);
180 info( t('Email settings updated.') . EOL);
184 call_hooks('connector_settings_post', $_POST);
189 call_hooks('settings_post', $_POST);
191 if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
193 $newpass = $_POST['npassword'];
194 $confirm = $_POST['confirm'];
197 if($newpass != $confirm ) {
198 notice( t('Passwords do not match. Password unchanged.') . EOL);
202 if((! x($newpass)) || (! x($confirm))) {
203 notice( t('Empty passwords are not allowed. Password unchanged.') . EOL);
208 $password = hash('whirlpool',$newpass);
209 $r = q("UPDATE `user` SET `password` = '%s' WHERE `uid` = %d LIMIT 1",
214 info( t('Password changed.') . EOL);
216 notice( t('Password update failed. Please try again.') . EOL);
220 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['theme']);
221 $username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
222 $email = ((x($_POST,'email')) ? notags(trim($_POST['email'])) : '');
223 $timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
224 $defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
225 $openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
226 $maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
227 $expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0);
230 $expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0);
231 $expire_notes = ((x($_POST,'expire_notes')) ? intval($_POST['expire_notes']) : 0);
232 $expire_starred = ((x($_POST,'expire_starred')) ? intval($_POST['expire_starred']) : 0);
233 $expire_photos = ((x($_POST,'expire_photos'))? intval($_POST['expire_photos']) : 0);
235 $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
236 $browser_update = $browser_update * 1000;
237 if($browser_update < 10000)
238 $browser_update = 40000;
241 $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
242 $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
243 $net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0);
244 $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0);
245 $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
246 $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
247 $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
249 $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
250 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
251 $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
256 if(x($_POST,'notify1'))
257 $notify += intval($_POST['notify1']);
258 if(x($_POST,'notify2'))
259 $notify += intval($_POST['notify2']);
260 if(x($_POST,'notify3'))
261 $notify += intval($_POST['notify3']);
262 if(x($_POST,'notify4'))
263 $notify += intval($_POST['notify4']);
264 if(x($_POST,'notify5'))
265 $notify += intval($_POST['notify5']);
266 if(x($_POST,'notify6'))
267 $notify += intval($_POST['notify6']);
268 if(x($_POST,'notify7'))
269 $notify += intval($_POST['notify7']);
271 $email_changed = false;
275 $name_change = false;
277 if($username != $a->user['username']) {
279 if(strlen($username) > 40)
280 $err .= t(' Please use a shorter name.');
281 if(strlen($username) < 3)
282 $err .= t(' Name too short.');
285 if($email != $a->user['email']) {
286 $email_changed = true;
287 if(! valid_email($email))
288 $err .= t(' Not valid email.');
289 if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
290 $err .= t(' Cannot change to that email.');
291 $email = $a->user['email'];
300 if($timezone != $a->user['timezone']) {
301 if(strlen($timezone))
302 date_default_timezone_set($timezone);
305 $str_group_allow = perms2str($_POST['group_allow']);
306 $str_contact_allow = perms2str($_POST['contact_allow']);
307 $str_group_deny = perms2str($_POST['group_deny']);
308 $str_contact_deny = perms2str($_POST['contact_deny']);
310 $openidserver = $a->user['openidserver'];
312 // If openid has changed or if there's an openid but no openidserver, try and discover it.
314 if($openid != $a->user['openid'] || (strlen($openid) && (! strlen($openidserver)))) {
316 if(strlen($tmp_str) && validate_url($tmp_str)) {
317 logger('updating openidserver');
318 require_once('library/openid.php');
319 $open_id_obj = new LightOpenID;
320 $open_id_obj->identity = $openid;
321 $openidserver = $open_id_obj->discover($open_id_obj->identity);
327 set_pconfig(local_user(),'expire','items', $expire_items);
328 set_pconfig(local_user(),'expire','notes', $expire_notes);
329 set_pconfig(local_user(),'expire','starred', $expire_starred);
330 set_pconfig(local_user(),'expire','photos', $expire_photos);
332 set_pconfig(local_user(),'system','suggestme', $suggestme);
333 set_pconfig(local_user(),'system','update_interval', $browser_update);
335 $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d WHERE `uid` = %d LIMIT 1",
340 dbesc($str_contact_allow),
341 dbesc($str_group_allow),
342 dbesc($str_contact_deny),
343 dbesc($str_group_deny),
347 intval($allow_location),
351 dbesc($openidserver),
358 info( t('Settings updated.') . EOL);
360 $r = q("UPDATE `profile`
364 WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
366 intval($net_publish),
367 intval($hide_friends),
373 q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
375 dbesc(datetime_convert()),
380 if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
381 // Update global directory in background
382 $url = $_SESSION['my_url'];
383 if($url && strlen(get_config('system','directory_submit_url')))
384 proc_run('php',"include/directory.php","$url");
389 require_once('include/profile_update.php');
392 $_SESSION['theme'] = $theme;
393 if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
395 // FIXME - set to un-verified, blocked and redirect to logout
399 goaway($a->get_baseurl() . '/settings' );
400 return; // NOTREACHED
404 if(! function_exists('settings_content')) {
405 function settings_content(&$a) {
408 nav_set_selected('settings');
411 notice( t('Permission denied.') . EOL );
415 if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
416 notice( t('Permission denied.') . EOL );
422 'label' => t('Account settings'),
423 'url' => $a->get_baseurl().'/settings',
424 'sel' => (($a->argc == 1)?'active':''),
427 'label' => t('Connector settings'),
428 'url' => $a->get_baseurl().'/settings/connectors',
429 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
432 'label' => t('Plugin settings'),
433 'url' => $a->get_baseurl().'/settings/addon',
434 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
437 'label' => t('Connections'),
438 'url' => $a->get_baseurl() . '/settings/oauth',
439 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
442 'label' => t('Export personal data'),
443 'url' => $a->get_baseurl() . '/uexport',
448 $tabtpl = get_markup_template("common_tabs.tpl");
449 $tabs = replace_macros($tabtpl, array(
453 if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
455 if(($a->argc > 2) && ($a->argv[2] === 'add')) {
456 $tpl = get_markup_template("settings_oauth_edit.tpl");
457 $o .= replace_macros($tpl, array(
459 '$title' => t('Add application'),
460 '$submit' => t('Submit'),
461 '$cancel' => t('Cancel'),
462 '$name' => array('name', t('Name'), '', ''),
463 '$key' => array('key', t('Consumer Key'), '', ''),
464 '$secret' => array('secret', t('Consumer Secret'), '', ''),
465 '$redirect' => array('redirect', t('Redirect'), '', ''),
466 '$icon' => array('icon', t('Icon url'), '', ''),
471 if(($a->argc > 3) && ($a->argv[2] === 'edit')) {
472 $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
477 notice(t("You can't edit this application."));
482 $tpl = get_markup_template("settings_oauth_edit.tpl");
483 $o .= replace_macros($tpl, array(
485 '$title' => t('Add application'),
486 '$submit' => t('Update'),
487 '$cancel' => t('Cancel'),
488 '$name' => array('name', t('Name'), $app['name'] , ''),
489 '$key' => array('key', t('Consumer Key'), $app['client_id'], ''),
490 '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''),
491 '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''),
492 '$icon' => array('icon', t('Icon url'), $app['icon'], ''),
497 if(($a->argc > 3) && ($a->argv[2] === 'delete')) {
498 $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
501 goaway($a->get_baseurl()."/settings/oauth/");
506 $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
508 LEFT JOIN tokens ON clients.client_id=tokens.client_id
509 WHERE clients.uid IN (%d,0)",
514 $tpl = get_markup_template("settings_oauth.tpl");
515 $o .= replace_macros($tpl, array(
516 '$baseurl' => $a->get_baseurl(),
517 '$title' => t('Connected Apps'),
518 '$add' => t('Add application'),
519 '$edit' => t('Edit'),
520 '$delete' => t('Delete'),
521 '$consumerkey' => t('Client key starts with'),
522 '$noname' => t('No name'),
523 '$remove' => t('Remove authorization'),
530 if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
531 $settings_addons = "";
533 $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
535 $settings_addons = t('No Plugin settings configured');
537 call_hooks('plugin_settings', $settings_addons);
540 $tpl = get_markup_template("settings_addons.tpl");
541 $o .= replace_macros($tpl, array(
542 '$title' => t('Plugin Settings'),
544 '$settings_addons' => $settings_addons
549 if(($a->argc > 1) && ($a->argv[1] === 'connectors')) {
551 $settings_connectors = "";
553 call_hooks('connector_settings', $settings_connectors);
555 $diasp_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('Diaspora'), ((get_config('system','diaspora_enabled')) ? t('enabled') : t('disabled')));
556 $ostat_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('StatusNet'), ((get_config('system','ostatus_disabled')) ? t('disabled') : t('enabled')));
558 $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
559 if(get_config('system','dfrn_only'))
562 if(! $mail_disabled) {
563 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
571 $mail_server = ((count($r)) ? $r[0]['server'] : '');
572 $mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
573 $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : '');
574 $mail_user = ((count($r)) ? $r[0]['user'] : '');
575 $mail_replyto = ((count($r)) ? $r[0]['reply_to'] : '');
576 $mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0);
577 $mail_action = ((count($r)) ? $r[0]['action'] : 0);
578 $mail_movetofolder = ((count($r)) ? $r[0]['movetofolder'] : '');
579 $mail_chk = ((count($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
582 $tpl = get_markup_template("settings_connectors.tpl");
583 $o .= replace_macros($tpl, array(
584 '$title' => t('Connector Settings'),
587 '$diasp_enabled' => $diasp_enabled,
588 '$ostat_enabled' => $ostat_enabled,
590 '$h_imap' => t('Email/Mailbox Setup'),
591 '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."),
592 '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk,''),
593 '$mail_disabled' => (($mail_disabled) ? t('Email access is disabled on this site.') : ''),
594 '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''),
595 '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''),
596 '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')),
597 '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''),
598 '$mail_pass' => array('mail_pass', t('Email password:'), '', ''),
599 '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), '', 'Optional'),
600 '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''),
601 '$mail_action' => array('mail_action', t('Action after import:'), $mail_action, '', array(0=>t('None'), 1=>t('Delete'), 2=>t('Mark as seen'), 3=>t('Move to folder'))),
602 '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''),
603 '$submit' => t('Submit'),
607 '$settings_connectors' => $settings_connectors
613 require_once('include/acl_selectors.php');
615 $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
621 $username = $a->user['username'];
622 $email = $a->user['email'];
623 $nickname = $a->user['nickname'];
624 $timezone = $a->user['timezone'];
625 $notify = $a->user['notify-flags'];
626 $defloc = $a->user['default-location'];
627 $openid = $a->user['openid'];
628 $maxreq = $a->user['maxreq'];
629 $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
630 $blockwall = $a->user['blockwall'];
631 $blocktags = $a->user['blocktags'];
633 $expire_items = get_pconfig(local_user(), 'expire','items');
634 $expire_items = (($expire_items===false)?1:$expire_items); // default if not set: 1
636 $expire_notes = get_pconfig(local_user(), 'expire','notes');
637 $expire_notes = (($expire_notes===false)?1:$expire_notes); // default if not set: 1
639 $expire_starred = get_pconfig(local_user(), 'expire','starred');
640 $expire_starred = (($expire_starred===false)?1:$expire_starred); // default if not set: 1
642 $expire_photos = get_pconfig(local_user(), 'expire','photos');
643 $expire_photos = (($expire_photos===false)?0:$expire_photos); // default if not set: 0
646 $suggestme = get_pconfig(local_user(), 'system','suggestme');
647 $suggestme = (($suggestme===false)?0:$suggestme); // default if not set: 0
649 $browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
650 $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
652 if(! strlen($a->user['timezone']))
653 $timezone = date_default_timezone_get();
657 $pageset_tpl = get_markup_template('pagetypes.tpl');
658 $pagetype = replace_macros($pageset_tpl,array(
659 '$page_normal' => array('page-flags', t('Normal Account'), PAGE_NORMAL,
660 t('This account is a normal personal profile'),
661 ($a->user['page-flags'] == PAGE_NORMAL)),
663 '$page_soapbox' => array('page-flags', t('Soapbox Account'), PAGE_SOAPBOX,
664 t('Automatically approve all connection/friend requests as read-only fans'),
665 ($a->user['page-flags'] == PAGE_SOAPBOX)),
667 '$page_community' => array('page-flags', t('Community/Celebrity Account'), PAGE_COMMUNITY,
668 t('Automatically approve all connection/friend requests as read-write fans'),
669 ($a->user['page-flags'] == PAGE_COMMUNITY)),
671 '$page_freelove' => array('page-flags', t('Automatic Friend Account'), PAGE_FREELOVE,
672 t('Automatically approve all connection/friend requests as friends'),
673 ($a->user['page-flags'] == PAGE_FREELOVE)),
676 $noid = get_config('system','no_openid');
679 $openid_field = false;
682 $openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."));
686 $opt_tpl = get_markup_template("field_yesno.tpl");
687 if(get_config('system','publish_all')) {
688 $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
691 $profile_in_dir = replace_macros($opt_tpl,array(
692 '$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
696 if(strlen(get_config('system','directory_submit_url'))) {
697 $profile_in_net_dir = replace_macros($opt_tpl,array(
698 '$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
702 $profile_in_net_dir = '';
705 $hide_friends = replace_macros($opt_tpl,array(
706 '$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))),
709 $hide_wall = replace_macros($opt_tpl,array(
710 '$field' => array('hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], '', array(t('No'),t('Yes'))),
714 $blockwall = replace_macros($opt_tpl,array(
715 '$field' => array('blockwall', t('Allow friends to post to your profile page?'), ! $a->user['blockwall'], '', array(t('No'),t('Yes'))),
720 $blocktags = replace_macros($opt_tpl,array(
721 '$field' => array('blocktags', t('Allow friends to tag your posts?'), ! $a->user['blocktags'], '', array(t('No'),t('Yes'))),
726 $suggestme = replace_macros($opt_tpl,array(
727 '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))),
732 $invisible = (((! $profile['publish']) && (! $profile['net-publish']))
736 info( t('Profile is <strong>not published</strong>.') . EOL );
739 $default_theme = get_config('system','theme');
741 $default_theme = 'default';
743 $allowed_themes_str = get_config('system','allowed_themes');
744 $allowed_themes_raw = explode(',',$allowed_themes_str);
745 $allowed_themes = array();
746 if(count($allowed_themes_raw))
747 foreach($allowed_themes_raw as $x)
749 $allowed_themes[] = trim($x);
753 $files = glob('view/theme/*');
754 if($allowed_themes) {
755 foreach($allowed_themes as $th) {
757 $is_experimental = file_exists('view/theme/' . $th . '/experimental');
758 $unsupported = file_exists('view/theme/' . $th . '/unsupported');
759 if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
760 $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
761 $themes[$f]=$theme_name;
765 $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
768 $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl() . '/profile/' . $nickname : '');
770 $tpl_addr = get_markup_template("settings_nick_set.tpl");
772 $prof_addr = replace_macros($tpl_addr,array(
773 '$desc' => t('Your Identity Address is'),
774 '$nickname' => $nickname,
775 '$subdir' => $subdir,
776 '$basepath' => $a->get_hostname()
779 $stpl = get_markup_template('settings.tpl');
781 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
784 'days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')),
785 'advanced' => t('Advanced expiration settings'),
786 'label' => t('Advanced Expiration'),
787 'items' => array('expire_items', t("Expire posts:"), $expire_items, '', array(t('No'),t('Yes'))),
788 'notes' => array('expire_notes', t("Expire personal notes:"), $expire_notes, '', array(t('No'),t('Yes'))),
789 'starred' => array('expire_starred', t("Expire starred posts:"), $expire_starred, '', array(t('No'),t('Yes'))),
790 'photos' => array('expire_photos', t("Expire photos:"), $expire_photos, '', array(t('No'),t('Yes'))),
793 $o .= replace_macros($stpl,array(
795 '$ptitle' => t('Account Settings'),
797 '$submit' => t('Submit'),
798 '$baseurl' => $a->get_baseurl(),
799 '$uid' => local_user(),
801 '$nickname_block' => $prof_addr,
803 '$h_pass' => t('Password Settings'),
804 '$password1'=> array('npassword', t('New Password:'), '', ''),
805 '$password2'=> array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')),
806 '$oid_enable' => (! get_config('system','no_openid')),
807 '$openid' => $openid_field,
809 '$h_basic' => t('Basic Settings'),
810 '$username' => array('username', t('Full Name:'), $username,''),
811 '$email' => array('email', t('Email Address:'), $email, ''),
812 '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''),
813 '$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''),
814 '$allowloc' => array('allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''),
815 '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes),
816 '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
818 '$h_prv' => t('Security and Privacy Settings'),
820 '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), $maxreq ,t("\x28to prevent spam abuse\x29")),
821 '$permissions' => t('Default Post Permissions'),
822 '$permdesc' => t("\x28click to open/close\x29"),
823 '$visibility' => $profile['net-publish'],
824 '$aclselect' => populate_acl($a->user,$celeb),
825 '$suggestme' => $suggestme,
826 '$blockwall'=> $blockwall, // array('blockwall', t('Allow friends to post to your profile page:'), !$blockwall, ''),
827 '$blocktags'=> $blocktags, // array('blocktags', t('Allow friends to tag your posts:'), !$blocktags, ''),
828 '$expire' => $expire_arr,
830 '$profile_in_dir' => $profile_in_dir,
831 '$profile_in_net_dir' => $profile_in_net_dir,
832 '$hide_friends' => $hide_friends,
833 '$hide_wall' => $hide_wall,
837 '$h_not' => t('Notification Settings'),
838 '$lbl_not' => t('Send a notification email when:'),
839 '$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''),
840 '$notify2' => array('notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''),
841 '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''),
842 '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
843 '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
844 '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),
845 '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
848 '$h_advn' => t('Advanced Page Settings'),
849 '$pagetype' => $pagetype,
864 call_hooks('settings_form',$o);
866 $o .= '</form>' . "\r\n";