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;
240 $itemspage_network = ((x($_POST,'itemspage_network')) ? intval($_POST['itemspage_network']) : 40);
241 if($itemspage_network > 100)
242 $itemspage_network = 40;
245 $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
246 $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
247 $net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0);
248 $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0);
249 $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
250 $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
251 $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
253 $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
254 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
255 $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
260 if(x($_POST,'notify1'))
261 $notify += intval($_POST['notify1']);
262 if(x($_POST,'notify2'))
263 $notify += intval($_POST['notify2']);
264 if(x($_POST,'notify3'))
265 $notify += intval($_POST['notify3']);
266 if(x($_POST,'notify4'))
267 $notify += intval($_POST['notify4']);
268 if(x($_POST,'notify5'))
269 $notify += intval($_POST['notify5']);
270 if(x($_POST,'notify6'))
271 $notify += intval($_POST['notify6']);
272 if(x($_POST,'notify7'))
273 $notify += intval($_POST['notify7']);
275 $email_changed = false;
279 $name_change = false;
281 if($username != $a->user['username']) {
283 if(strlen($username) > 40)
284 $err .= t(' Please use a shorter name.');
285 if(strlen($username) < 3)
286 $err .= t(' Name too short.');
289 if($email != $a->user['email']) {
290 $email_changed = true;
291 if(! valid_email($email))
292 $err .= t(' Not valid email.');
293 if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
294 $err .= t(' Cannot change to that email.');
295 $email = $a->user['email'];
304 if($timezone != $a->user['timezone']) {
305 if(strlen($timezone))
306 date_default_timezone_set($timezone);
309 $str_group_allow = perms2str($_POST['group_allow']);
310 $str_contact_allow = perms2str($_POST['contact_allow']);
311 $str_group_deny = perms2str($_POST['group_deny']);
312 $str_contact_deny = perms2str($_POST['contact_deny']);
314 $openidserver = $a->user['openidserver'];
316 // If openid has changed or if there's an openid but no openidserver, try and discover it.
318 if($openid != $a->user['openid'] || (strlen($openid) && (! strlen($openidserver)))) {
320 if(strlen($tmp_str) && validate_url($tmp_str)) {
321 logger('updating openidserver');
322 require_once('library/openid.php');
323 $open_id_obj = new LightOpenID;
324 $open_id_obj->identity = $openid;
325 $openidserver = $open_id_obj->discover($open_id_obj->identity);
331 set_pconfig(local_user(),'expire','items', $expire_items);
332 set_pconfig(local_user(),'expire','notes', $expire_notes);
333 set_pconfig(local_user(),'expire','starred', $expire_starred);
334 set_pconfig(local_user(),'expire','photos', $expire_photos);
336 set_pconfig(local_user(),'system','suggestme', $suggestme);
337 set_pconfig(local_user(),'system','update_interval', $browser_update);
338 set_pconfig(local_user(),'system','itemspage_network', $itemspage_network);
340 $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",
345 dbesc($str_contact_allow),
346 dbesc($str_group_allow),
347 dbesc($str_contact_deny),
348 dbesc($str_group_deny),
352 intval($allow_location),
356 dbesc($openidserver),
363 info( t('Settings updated.') . EOL);
365 $r = q("UPDATE `profile`
369 WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
371 intval($net_publish),
372 intval($hide_friends),
378 q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
380 dbesc(datetime_convert()),
385 if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
386 // Update global directory in background
387 $url = $_SESSION['my_url'];
388 if($url && strlen(get_config('system','directory_submit_url')))
389 proc_run('php',"include/directory.php","$url");
394 require_once('include/profile_update.php');
397 $_SESSION['theme'] = $theme;
398 if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
400 // FIXME - set to un-verified, blocked and redirect to logout
404 goaway($a->get_baseurl() . '/settings' );
405 return; // NOTREACHED
409 if(! function_exists('settings_content')) {
410 function settings_content(&$a) {
413 nav_set_selected('settings');
416 notice( t('Permission denied.') . EOL );
420 if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
421 notice( t('Permission denied.') . EOL );
427 'label' => t('Account settings'),
428 'url' => $a->get_baseurl().'/settings',
429 'sel' => (($a->argc == 1)?'active':''),
432 'label' => t('Connector settings'),
433 'url' => $a->get_baseurl().'/settings/connectors',
434 'sel' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
437 'label' => t('Plugin settings'),
438 'url' => $a->get_baseurl().'/settings/addon',
439 'sel' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
442 'label' => t('Connections'),
443 'url' => $a->get_baseurl() . '/settings/oauth',
444 'sel' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
447 'label' => t('Export personal data'),
448 'url' => $a->get_baseurl() . '/uexport',
453 $tabtpl = get_markup_template("common_tabs.tpl");
454 $tabs = replace_macros($tabtpl, array(
458 if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
460 if(($a->argc > 2) && ($a->argv[2] === 'add')) {
461 $tpl = get_markup_template("settings_oauth_edit.tpl");
462 $o .= replace_macros($tpl, array(
464 '$title' => t('Add application'),
465 '$submit' => t('Submit'),
466 '$cancel' => t('Cancel'),
467 '$name' => array('name', t('Name'), '', ''),
468 '$key' => array('key', t('Consumer Key'), '', ''),
469 '$secret' => array('secret', t('Consumer Secret'), '', ''),
470 '$redirect' => array('redirect', t('Redirect'), '', ''),
471 '$icon' => array('icon', t('Icon url'), '', ''),
476 if(($a->argc > 3) && ($a->argv[2] === 'edit')) {
477 $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
482 notice(t("You can't edit this application."));
487 $tpl = get_markup_template("settings_oauth_edit.tpl");
488 $o .= replace_macros($tpl, array(
490 '$title' => t('Add application'),
491 '$submit' => t('Update'),
492 '$cancel' => t('Cancel'),
493 '$name' => array('name', t('Name'), $app['name'] , ''),
494 '$key' => array('key', t('Consumer Key'), $app['client_id'], ''),
495 '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''),
496 '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''),
497 '$icon' => array('icon', t('Icon url'), $app['icon'], ''),
502 if(($a->argc > 3) && ($a->argv[2] === 'delete')) {
503 $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
506 goaway($a->get_baseurl()."/settings/oauth/");
511 $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
513 LEFT JOIN tokens ON clients.client_id=tokens.client_id
514 WHERE clients.uid IN (%d,0)",
519 $tpl = get_markup_template("settings_oauth.tpl");
520 $o .= replace_macros($tpl, array(
521 '$baseurl' => $a->get_baseurl(),
522 '$title' => t('Connected Apps'),
523 '$add' => t('Add application'),
524 '$edit' => t('Edit'),
525 '$delete' => t('Delete'),
526 '$consumerkey' => t('Client key starts with'),
527 '$noname' => t('No name'),
528 '$remove' => t('Remove authorization'),
535 if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
536 $settings_addons = "";
538 $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
540 $settings_addons = t('No Plugin settings configured');
542 call_hooks('plugin_settings', $settings_addons);
545 $tpl = get_markup_template("settings_addons.tpl");
546 $o .= replace_macros($tpl, array(
547 '$title' => t('Plugin Settings'),
549 '$settings_addons' => $settings_addons
554 if(($a->argc > 1) && ($a->argv[1] === 'connectors')) {
556 $settings_connectors = "";
558 call_hooks('connector_settings', $settings_connectors);
560 $diasp_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('Diaspora'), ((get_config('system','diaspora_enabled')) ? t('enabled') : t('disabled')));
561 $ostat_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('StatusNet'), ((get_config('system','ostatus_disabled')) ? t('disabled') : t('enabled')));
563 $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
564 if(get_config('system','dfrn_only'))
567 if(! $mail_disabled) {
568 $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
576 $mail_server = ((count($r)) ? $r[0]['server'] : '');
577 $mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
578 $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : '');
579 $mail_user = ((count($r)) ? $r[0]['user'] : '');
580 $mail_replyto = ((count($r)) ? $r[0]['reply_to'] : '');
581 $mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0);
582 $mail_action = ((count($r)) ? $r[0]['action'] : 0);
583 $mail_movetofolder = ((count($r)) ? $r[0]['movetofolder'] : '');
584 $mail_chk = ((count($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
587 $tpl = get_markup_template("settings_connectors.tpl");
588 $o .= replace_macros($tpl, array(
589 '$title' => t('Connector Settings'),
592 '$diasp_enabled' => $diasp_enabled,
593 '$ostat_enabled' => $ostat_enabled,
595 '$h_imap' => t('Email/Mailbox Setup'),
596 '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."),
597 '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk,''),
598 '$mail_disabled' => (($mail_disabled) ? t('Email access is disabled on this site.') : ''),
599 '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''),
600 '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''),
601 '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')),
602 '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''),
603 '$mail_pass' => array('mail_pass', t('Email password:'), '', ''),
604 '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), '', 'Optional'),
605 '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''),
606 '$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'))),
607 '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''),
608 '$submit' => t('Submit'),
612 '$settings_connectors' => $settings_connectors
618 require_once('include/acl_selectors.php');
620 $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
626 $username = $a->user['username'];
627 $email = $a->user['email'];
628 $nickname = $a->user['nickname'];
629 $timezone = $a->user['timezone'];
630 $notify = $a->user['notify-flags'];
631 $defloc = $a->user['default-location'];
632 $openid = $a->user['openid'];
633 $maxreq = $a->user['maxreq'];
634 $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
635 $blockwall = $a->user['blockwall'];
636 $blocktags = $a->user['blocktags'];
638 $expire_items = get_pconfig(local_user(), 'expire','items');
639 $expire_items = (($expire_items===false)?1:$expire_items); // default if not set: 1
641 $expire_notes = get_pconfig(local_user(), 'expire','notes');
642 $expire_notes = (($expire_notes===false)?1:$expire_notes); // default if not set: 1
644 $expire_starred = get_pconfig(local_user(), 'expire','starred');
645 $expire_starred = (($expire_starred===false)?1:$expire_starred); // default if not set: 1
647 $expire_photos = get_pconfig(local_user(), 'expire','photos');
648 $expire_photos = (($expire_photos===false)?0:$expire_photos); // default if not set: 0
651 $suggestme = get_pconfig(local_user(), 'system','suggestme');
652 $suggestme = (($suggestme===false)?0:$suggestme); // default if not set: 0
654 $browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
655 $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
657 $itemspage_network = intval(get_pconfig(local_user(), 'system','itemspage_network'));
658 $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
660 if(! strlen($a->user['timezone']))
661 $timezone = date_default_timezone_get();
665 $pageset_tpl = get_markup_template('pagetypes.tpl');
666 $pagetype = replace_macros($pageset_tpl,array(
667 '$page_normal' => array('page-flags', t('Normal Account'), PAGE_NORMAL,
668 t('This account is a normal personal profile'),
669 ($a->user['page-flags'] == PAGE_NORMAL)),
671 '$page_soapbox' => array('page-flags', t('Soapbox Account'), PAGE_SOAPBOX,
672 t('Automatically approve all connection/friend requests as read-only fans'),
673 ($a->user['page-flags'] == PAGE_SOAPBOX)),
675 '$page_community' => array('page-flags', t('Community/Celebrity Account'), PAGE_COMMUNITY,
676 t('Automatically approve all connection/friend requests as read-write fans'),
677 ($a->user['page-flags'] == PAGE_COMMUNITY)),
679 '$page_freelove' => array('page-flags', t('Automatic Friend Account'), PAGE_FREELOVE,
680 t('Automatically approve all connection/friend requests as friends'),
681 ($a->user['page-flags'] == PAGE_FREELOVE)),
684 $noid = get_config('system','no_openid');
687 $openid_field = false;
690 $openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."));
694 $opt_tpl = get_markup_template("field_yesno.tpl");
695 if(get_config('system','publish_all')) {
696 $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
699 $profile_in_dir = replace_macros($opt_tpl,array(
700 '$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
704 if(strlen(get_config('system','directory_submit_url'))) {
705 $profile_in_net_dir = replace_macros($opt_tpl,array(
706 '$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
710 $profile_in_net_dir = '';
713 $hide_friends = replace_macros($opt_tpl,array(
714 '$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))),
717 $hide_wall = replace_macros($opt_tpl,array(
718 '$field' => array('hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], '', array(t('No'),t('Yes'))),
722 $blockwall = replace_macros($opt_tpl,array(
723 '$field' => array('blockwall', t('Allow friends to post to your profile page?'), ! $a->user['blockwall'], '', array(t('No'),t('Yes'))),
728 $blocktags = replace_macros($opt_tpl,array(
729 '$field' => array('blocktags', t('Allow friends to tag your posts?'), ! $a->user['blocktags'], '', array(t('No'),t('Yes'))),
734 $suggestme = replace_macros($opt_tpl,array(
735 '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))),
740 $invisible = (((! $profile['publish']) && (! $profile['net-publish']))
744 info( t('Profile is <strong>not published</strong>.') . EOL );
747 $default_theme = get_config('system','theme');
749 $default_theme = 'default';
751 $allowed_themes_str = get_config('system','allowed_themes');
752 $allowed_themes_raw = explode(',',$allowed_themes_str);
753 $allowed_themes = array();
754 if(count($allowed_themes_raw))
755 foreach($allowed_themes_raw as $x)
757 $allowed_themes[] = trim($x);
761 $files = glob('view/theme/*');
762 if($allowed_themes) {
763 foreach($allowed_themes as $th) {
765 $is_experimental = file_exists('view/theme/' . $th . '/experimental');
766 $unsupported = file_exists('view/theme/' . $th . '/unsupported');
767 if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
768 $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
769 $themes[$f]=$theme_name;
773 $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
776 $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl() . '/profile/' . $nickname : '');
778 $tpl_addr = get_markup_template("settings_nick_set.tpl");
780 $prof_addr = replace_macros($tpl_addr,array(
781 '$desc' => t('Your Identity Address is'),
782 '$nickname' => $nickname,
783 '$subdir' => $subdir,
784 '$basepath' => $a->get_hostname()
787 $stpl = get_markup_template('settings.tpl');
789 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
792 'days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')),
793 'advanced' => t('Advanced expiration settings'),
794 'label' => t('Advanced Expiration'),
795 'items' => array('expire_items', t("Expire posts:"), $expire_items, '', array(t('No'),t('Yes'))),
796 'notes' => array('expire_notes', t("Expire personal notes:"), $expire_notes, '', array(t('No'),t('Yes'))),
797 'starred' => array('expire_starred', t("Expire starred posts:"), $expire_starred, '', array(t('No'),t('Yes'))),
798 'photos' => array('expire_photos', t("Expire photos:"), $expire_photos, '', array(t('No'),t('Yes'))),
801 $o .= replace_macros($stpl,array(
803 '$ptitle' => t('Account Settings'),
805 '$submit' => t('Submit'),
806 '$baseurl' => $a->get_baseurl(),
807 '$uid' => local_user(),
809 '$nickname_block' => $prof_addr,
811 '$h_pass' => t('Password Settings'),
812 '$password1'=> array('npassword', t('New Password:'), '', ''),
813 '$password2'=> array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')),
814 '$oid_enable' => (! get_config('system','no_openid')),
815 '$openid' => $openid_field,
817 '$h_basic' => t('Basic Settings'),
818 '$username' => array('username', t('Full Name:'), $username,''),
819 '$email' => array('email', t('Email Address:'), $email, ''),
820 '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''),
821 '$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''),
822 '$allowloc' => array('allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''),
823 '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes),
824 '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
825 '$itemspage_network' => array('itemspage_network', t("Number of items to display on the network page:"), $itemspage_network, t('Maximum of 100 items')),
827 '$h_prv' => t('Security and Privacy Settings'),
829 '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), $maxreq ,t("\x28to prevent spam abuse\x29")),
830 '$permissions' => t('Default Post Permissions'),
831 '$permdesc' => t("\x28click to open/close\x29"),
832 '$visibility' => $profile['net-publish'],
833 '$aclselect' => populate_acl($a->user,$celeb),
834 '$suggestme' => $suggestme,
835 '$blockwall'=> $blockwall, // array('blockwall', t('Allow friends to post to your profile page:'), !$blockwall, ''),
836 '$blocktags'=> $blocktags, // array('blocktags', t('Allow friends to tag your posts:'), !$blocktags, ''),
837 '$expire' => $expire_arr,
839 '$profile_in_dir' => $profile_in_dir,
840 '$profile_in_net_dir' => $profile_in_net_dir,
841 '$hide_friends' => $hide_friends,
842 '$hide_wall' => $hide_wall,
846 '$h_not' => t('Notification Settings'),
847 '$lbl_not' => t('Send a notification email when:'),
848 '$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''),
849 '$notify2' => array('notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''),
850 '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''),
851 '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
852 '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
853 '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),
854 '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
857 '$h_advn' => t('Advanced Page Settings'),
858 '$pagetype' => $pagetype,
873 call_hooks('settings_form',$o);
875 $o .= '</form>' . "\r\n";