Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1170 lines
43 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
7 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <?php
  2. function get_theme_config_file($theme){
  3. $a = get_app();
  4. $base_theme = $a->theme_info['extends'];
  5. if (file_exists("view/theme/$theme/config.php")){
  6. return "view/theme/$theme/config.php";
  7. }
  8. if (file_exists("view/theme/$base_theme/config.php")){
  9. return "view/theme/$base_theme/config.php";
  10. }
  11. return null;
  12. }
  13. function settings_init(&$a) {
  14. if (function_exists("apc_delete")) {
  15. $toDelete = new APCIterator('user', APC_ITER_VALUE);
  16. apc_delete($toDelete);
  17. }
  18. // These lines provide the javascript needed by the acl selector
  19. $tpl = get_markup_template("settings-head.tpl");
  20. $a->page['htmlhead'] .= replace_macros($tpl,array(
  21. '$ispublic' => t('everybody')
  22. ));
  23. $tabs = array(
  24. array(
  25. 'label' => t('Account settings'),
  26. 'url' => $a->get_baseurl(true).'/settings',
  27. 'selected' => (($a->argc == 1)?'active':''),
  28. ),
  29. array(
  30. 'label' => t('Additional features'),
  31. 'url' => $a->get_baseurl(true).'/settings/features',
  32. 'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''),
  33. ),
  34. array(
  35. 'label' => t('Display settings'),
  36. 'url' => $a->get_baseurl(true).'/settings/display',
  37. 'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
  38. ),
  39. array(
  40. 'label' => t('Connector settings'),
  41. 'url' => $a->get_baseurl(true).'/settings/connectors',
  42. 'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
  43. ),
  44. array(
  45. 'label' => t('Plugin settings'),
  46. 'url' => $a->get_baseurl(true).'/settings/addon',
  47. 'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
  48. ),
  49. array(
  50. 'label' => t('Connected apps'),
  51. 'url' => $a->get_baseurl(true) . '/settings/oauth',
  52. 'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
  53. ),
  54. array(
  55. 'label' => t('Export personal data'),
  56. 'url' => $a->get_baseurl(true) . '/uexport',
  57. 'selected' => ''
  58. ),
  59. array(
  60. 'label' => t('Remove account'),
  61. 'url' => $a->get_baseurl(true) . '/removeme',
  62. 'selected' => ''
  63. )
  64. );
  65. $tabtpl = get_markup_template("generic_links_widget.tpl");
  66. $a->page['aside'] = replace_macros($tabtpl, array(
  67. '$title' => t('Settings'),
  68. '$class' => 'settings-widget',
  69. '$items' => $tabs,
  70. ));
  71. }
  72. function settings_post(&$a) {
  73. if(! local_user())
  74. return;
  75. if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
  76. return;
  77. if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
  78. notice( t('Permission denied.') . EOL);
  79. return;
  80. }
  81. $old_page_flags = $a->user['page-flags'];
  82. if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){
  83. check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
  84. $key = $_POST['remove'];
  85. q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
  86. dbesc($key),
  87. local_user());
  88. goaway($a->get_baseurl(true)."/settings/oauth/");
  89. return;
  90. }
  91. if(($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
  92. check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
  93. $name = ((x($_POST,'name')) ? $_POST['name'] : '');
  94. $key = ((x($_POST,'key')) ? $_POST['key'] : '');
  95. $secret = ((x($_POST,'secret')) ? $_POST['secret'] : '');
  96. $redirect = ((x($_POST,'redirect')) ? $_POST['redirect'] : '');
  97. $icon = ((x($_POST,'icon')) ? $_POST['icon'] : '');
  98. if ($name=="" || $key=="" || $secret==""){
  99. notice(t("Missing some important data!"));
  100. } else {
  101. if ($_POST['submit']==t("Update")){
  102. $r = q("UPDATE clients SET
  103. client_id='%s',
  104. pw='%s',
  105. name='%s',
  106. redirect_uri='%s',
  107. icon='%s',
  108. uid=%d
  109. WHERE client_id='%s'",
  110. dbesc($key),
  111. dbesc($secret),
  112. dbesc($name),
  113. dbesc($redirect),
  114. dbesc($icon),
  115. local_user(),
  116. dbesc($key));
  117. } else {
  118. $r = q("INSERT INTO clients
  119. (client_id, pw, name, redirect_uri, icon, uid)
  120. VALUES ('%s','%s','%s','%s','%s',%d)",
  121. dbesc($key),
  122. dbesc($secret),
  123. dbesc($name),
  124. dbesc($redirect),
  125. dbesc($icon),
  126. local_user());
  127. }
  128. }
  129. goaway($a->get_baseurl(true)."/settings/oauth/");
  130. return;
  131. }
  132. if(($a->argc > 1) && ($a->argv[1] == 'addon')) {
  133. check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon');
  134. call_hooks('plugin_settings_post', $_POST);
  135. return;
  136. }
  137. if(($a->argc > 1) && ($a->argv[1] == 'connectors')) {
  138. check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
  139. if(x($_POST, 'imap-submit')) {
  140. $mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
  141. $mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
  142. $mail_ssl = ((x($_POST,'mail_ssl')) ? strtolower(trim($_POST['mail_ssl'])) : '');
  143. $mail_user = ((x($_POST,'mail_user')) ? $_POST['mail_user'] : '');
  144. $mail_pass = ((x($_POST,'mail_pass')) ? trim($_POST['mail_pass']) : '');
  145. $mail_action = ((x($_POST,'mail_action')) ? trim($_POST['mail_action']) : '');
  146. $mail_movetofolder = ((x($_POST,'mail_movetofolder')) ? trim($_POST['mail_movetofolder']) : '');
  147. $mail_replyto = ((x($_POST,'mail_replyto')) ? $_POST['mail_replyto'] : '');
  148. $mail_pubmail = ((x($_POST,'mail_pubmail')) ? $_POST['mail_pubmail'] : '');
  149. $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
  150. if(get_config('system','dfrn_only'))
  151. $mail_disabled = 1;
  152. if(! $mail_disabled) {
  153. $failed = false;
  154. $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
  155. intval(local_user())
  156. );
  157. if(! count($r)) {
  158. q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
  159. intval(local_user())
  160. );
  161. }
  162. if(strlen($mail_pass)) {
  163. $pass = '';
  164. openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
  165. q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1",
  166. dbesc(bin2hex($pass)),
  167. intval(local_user())
  168. );
  169. }
  170. $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
  171. `action` = %d, `movetofolder` = '%s',
  172. `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1",
  173. dbesc($mail_server),
  174. intval($mail_port),
  175. dbesc($mail_ssl),
  176. dbesc($mail_user),
  177. intval($mail_action),
  178. dbesc($mail_movetofolder),
  179. dbesc($mail_replyto),
  180. intval($mail_pubmail),
  181. intval(local_user())
  182. );
  183. logger("mail: updating mailaccount. Response: ".print_r($r, true));
  184. $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
  185. intval(local_user())
  186. );
  187. if(count($r)) {
  188. $eacct = $r[0];
  189. require_once('include/email.php');
  190. $mb = construct_mailbox_name($eacct);
  191. if(strlen($eacct['server'])) {
  192. $dcrpass = '';
  193. openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
  194. $mbox = email_connect($mb,$mail_user,$dcrpass);
  195. unset($dcrpass);
  196. if(! $mbox) {
  197. $failed = true;
  198. notice( t('Failed to connect with email account using the settings provided.') . EOL);
  199. }
  200. }
  201. }
  202. if(! $failed)
  203. info( t('Email settings updated.') . EOL);
  204. }
  205. }
  206. call_hooks('connector_settings_post', $_POST);
  207. return;
  208. }
  209. if(($a->argc > 1) && ($a->argv[1] === 'features')) {
  210. check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
  211. foreach($_POST as $k => $v) {
  212. if(strpos($k,'feature_') === 0) {
  213. set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0));
  214. }
  215. }
  216. info( t('Features updated') . EOL);
  217. return;
  218. }
  219. if(($a->argc > 1) && ($a->argv[1] === 'display')) {
  220. check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
  221. $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['theme']);
  222. $mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : '');
  223. $nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0);
  224. $infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0);
  225. $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
  226. $browser_update = $browser_update * 1000;
  227. if($browser_update < 10000)
  228. $browser_update = 10000;
  229. $itemspage_network = ((x($_POST,'itemspage_network')) ? intval($_POST['itemspage_network']) : 40);
  230. if($itemspage_network > 100)
  231. $itemspage_network = 100;
  232. $itemspage_mobile_network = ((x($_POST,'itemspage_mobile_network')) ? intval($_POST['itemspage_mobile_network']) : 20);
  233. if($itemspage_mobile_network > 100)
  234. $itemspage_mobile_network = 100;
  235. if($mobile_theme !== '') {
  236. set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
  237. }
  238. set_pconfig(local_user(),'system','update_interval', $browser_update);
  239. set_pconfig(local_user(),'system','itemspage_network', $itemspage_network);
  240. set_pconfig(local_user(),'system','itemspage_mobile_network', $itemspage_mobile_network);
  241. set_pconfig(local_user(),'system','no_smilies',$nosmile);
  242. set_pconfig(local_user(),'system','infinite_scroll',$infinite_scroll);
  243. if ($theme == $a->user['theme']){
  244. // call theme_post only if theme has not been changed
  245. if( ($themeconfigfile = get_theme_config_file($theme)) != null){
  246. require_once($themeconfigfile);
  247. theme_post($a);
  248. }
  249. }
  250. $r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d LIMIT 1",
  251. dbesc($theme),
  252. intval(local_user())
  253. );
  254. call_hooks('display_settings_post', $_POST);
  255. goaway($a->get_baseurl(true) . '/settings/display' );
  256. return; // NOTREACHED
  257. }
  258. check_form_security_token_redirectOnErr('/settings', 'settings');
  259. if (x($_POST,'resend_relocate')) {
  260. proc_run('php', 'include/notifier.php', 'relocate', local_user());
  261. info(t("Relocate message has been send to your contacts"));
  262. goaway($a->get_baseurl(true) . '/settings');
  263. }
  264. call_hooks('settings_post', $_POST);
  265. if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
  266. $newpass = $_POST['npassword'];
  267. $confirm = $_POST['confirm'];
  268. $oldpass = hash('whirlpool', $_POST['opassword']);
  269. $err = false;
  270. if($newpass != $confirm ) {
  271. notice( t('Passwords do not match. Password unchanged.') . EOL);
  272. $err = true;
  273. }
  274. if((! x($newpass)) || (! x($confirm))) {
  275. notice( t('Empty passwords are not allowed. Password unchanged.') . EOL);
  276. $err = true;
  277. }
  278. // check if the old password was supplied correctly before
  279. // changing it to the new value
  280. $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
  281. if( $oldpass != $r[0]['password'] ) {
  282. notice( t('Wrong password.') . EOL);
  283. $err = true;
  284. }
  285. if(! $err) {
  286. $password = hash('whirlpool',$newpass);
  287. $r = q("UPDATE `user` SET `password` = '%s' WHERE `uid` = %d LIMIT 1",
  288. dbesc($password),
  289. intval(local_user())
  290. );
  291. if($r)
  292. info( t('Password changed.') . EOL);
  293. else
  294. notice( t('Password update failed. Please try again.') . EOL);
  295. }
  296. }
  297. $username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
  298. $email = ((x($_POST,'email')) ? notags(trim($_POST['email'])) : '');
  299. $timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
  300. $defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
  301. $openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
  302. $maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
  303. $expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0);
  304. $def_gid = ((x($_POST,'group-selection')) ? intval($_POST['group-selection']) : 0);
  305. $expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0);
  306. $expire_notes = ((x($_POST,'expire_notes')) ? intval($_POST['expire_notes']) : 0);
  307. $expire_starred = ((x($_POST,'expire_starred')) ? intval($_POST['expire_starred']) : 0);
  308. $expire_photos = ((x($_POST,'expire_photos'))? intval($_POST['expire_photos']) : 0);
  309. $expire_network_only = ((x($_POST,'expire_network_only'))? intval($_POST['expire_network_only']) : 0);
  310. $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
  311. $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
  312. $net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0);
  313. $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0);
  314. $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
  315. $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
  316. $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
  317. $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0);
  318. $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0);
  319. $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
  320. $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
  321. $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
  322. $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
  323. $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
  324. $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
  325. $notify = 0;
  326. if(x($_POST,'notify1'))
  327. $notify += intval($_POST['notify1']);
  328. if(x($_POST,'notify2'))
  329. $notify += intval($_POST['notify2']);
  330. if(x($_POST,'notify3'))
  331. $notify += intval($_POST['notify3']);
  332. if(x($_POST,'notify4'))
  333. $notify += intval($_POST['notify4']);
  334. if(x($_POST,'notify5'))
  335. $notify += intval($_POST['notify5']);
  336. if(x($_POST,'notify6'))
  337. $notify += intval($_POST['notify6']);
  338. if(x($_POST,'notify7'))
  339. $notify += intval($_POST['notify7']);
  340. if(x($_POST,'notify8'))
  341. $notify += intval($_POST['notify8']);
  342. $email_changed = false;
  343. $err = '';
  344. $name_change = false;
  345. if($username != $a->user['username']) {
  346. $name_change = true;
  347. if(strlen($username) > 40)
  348. $err .= t(' Please use a shorter name.');
  349. if(strlen($username) < 3)
  350. $err .= t(' Name too short.');
  351. }
  352. if($email != $a->user['email']) {
  353. $email_changed = true;
  354. // check for the correct password
  355. $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
  356. $password = hash('whirlpool', $_POST['password']);
  357. if ($password != $r[0]['password']) {
  358. $err .= t('Wrong Password') . EOL;
  359. $email = $a->user['email'];
  360. }
  361. // check the email is valid
  362. if(! valid_email($email))
  363. $err .= t(' Not valid email.');
  364. // ensure new email is not the admin mail
  365. if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
  366. $err .= t(' Cannot change to that email.');
  367. $email = $a->user['email'];
  368. }
  369. }
  370. if(strlen($err)) {
  371. notice($err . EOL);
  372. return;
  373. }
  374. if($timezone != $a->user['timezone']) {
  375. if(strlen($timezone))
  376. date_default_timezone_set($timezone);
  377. }
  378. $str_group_allow = perms2str($_POST['group_allow']);
  379. $str_contact_allow = perms2str($_POST['contact_allow']);
  380. $str_group_deny = perms2str($_POST['group_deny']);
  381. $str_contact_deny = perms2str($_POST['contact_deny']);
  382. $openidserver = $a->user['openidserver'];
  383. $openid = normalise_openid($openid);
  384. // If openid has changed or if there's an openid but no openidserver, try and discover it.
  385. if($openid != $a->user['openid'] || (strlen($openid) && (! strlen($openidserver)))) {
  386. $tmp_str = $openid;
  387. if(strlen($tmp_str) && validate_url($tmp_str)) {
  388. logger('updating openidserver');
  389. require_once('library/openid.php');
  390. $open_id_obj = new LightOpenID;
  391. $open_id_obj->identity = $openid;
  392. $openidserver = $open_id_obj->discover($open_id_obj->identity);
  393. }
  394. else
  395. $openidserver = '';
  396. }
  397. set_pconfig(local_user(),'expire','items', $expire_items);
  398. set_pconfig(local_user(),'expire','notes', $expire_notes);
  399. set_pconfig(local_user(),'expire','starred', $expire_starred);
  400. set_pconfig(local_user(),'expire','photos', $expire_photos);
  401. set_pconfig(local_user(),'expire','network_only', $expire_network_only);
  402. set_pconfig(local_user(),'system','suggestme', $suggestme);
  403. set_pconfig(local_user(),'system','post_newfriend', $post_newfriend);
  404. set_pconfig(local_user(),'system','post_joingroup', $post_joingroup);
  405. set_pconfig(local_user(),'system','post_profilechange', $post_profilechange);
  406. if($page_flags == PAGE_PRVGROUP) {
  407. $hidewall = 1;
  408. if((! $str_contact_allow) && (! $str_group_allow) && (! $str_contact_deny) && (! $str_group_deny)) {
  409. if($def_gid) {
  410. info( t('Private forum has no privacy permissions. Using default privacy group.'). EOL);
  411. $str_group_allow = '<' . $def_gid . '>';
  412. }
  413. else {
  414. notice( t('Private forum has no privacy permissions and no default privacy group.') . EOL);
  415. }
  416. }
  417. }
  418. $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, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d LIMIT 1",
  419. dbesc($username),
  420. dbesc($email),
  421. dbesc($openid),
  422. dbesc($timezone),
  423. dbesc($str_contact_allow),
  424. dbesc($str_group_allow),
  425. dbesc($str_contact_deny),
  426. dbesc($str_group_deny),
  427. intval($notify),
  428. intval($page_flags),
  429. dbesc($defloc),
  430. intval($allow_location),
  431. intval($maxreq),
  432. intval($expire),
  433. dbesc($openidserver),
  434. intval($def_gid),
  435. intval($blockwall),
  436. intval($hidewall),
  437. intval($blocktags),
  438. intval($unkmail),
  439. intval($cntunkmail),
  440. intval(local_user())
  441. );
  442. if($r)
  443. info( t('Settings updated.') . EOL);
  444. $r = q("UPDATE `profile`
  445. SET `publish` = %d,
  446. `name` = '%s',
  447. `net-publish` = %d,
  448. `hide-friends` = %d
  449. WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
  450. intval($publish),
  451. dbesc($username),
  452. intval($net_publish),
  453. intval($hide_friends),
  454. intval(local_user())
  455. );
  456. if($name_change) {
  457. q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
  458. dbesc($username),
  459. dbesc(datetime_convert()),
  460. intval(local_user())
  461. );
  462. }
  463. if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
  464. // Update global directory in background
  465. $url = $_SESSION['my_url'];
  466. if($url && strlen(get_config('system','directory_submit_url')))
  467. proc_run('php',"include/directory.php","$url");
  468. }
  469. require_once('include/profile_update.php');
  470. profile_change();
  471. //$_SESSION['theme'] = $theme;
  472. if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
  473. // FIXME - set to un-verified, blocked and redirect to logout
  474. // Why? Are we verifying people or email addresses?
  475. }
  476. goaway($a->get_baseurl(true) . '/settings' );
  477. return; // NOTREACHED
  478. }
  479. if(! function_exists('settings_content')) {
  480. function settings_content(&$a) {
  481. $o = '';
  482. nav_set_selected('settings');
  483. if(! local_user()) {
  484. notice( t('Permission denied.') . EOL );
  485. return;
  486. }
  487. if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
  488. notice( t('Permission denied.') . EOL );
  489. return;
  490. }
  491. if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
  492. if(($a->argc > 2) && ($a->argv[2] === 'add')) {
  493. $tpl = get_markup_template("settings_oauth_edit.tpl");
  494. $o .= replace_macros($tpl, array(
  495. '$form_security_token' => get_form_security_token("settings_oauth"),
  496. '$title' => t('Add application'),
  497. '$submit' => t('Save Settings'),
  498. '$cancel' => t('Cancel'),
  499. '$name' => array('name', t('Name'), '', ''),
  500. '$key' => array('key', t('Consumer Key'), '', ''),
  501. '$secret' => array('secret', t('Consumer Secret'), '', ''),
  502. '$redirect' => array('redirect', t('Redirect'), '', ''),
  503. '$icon' => array('icon', t('Icon url'), '', ''),
  504. ));
  505. return $o;
  506. }
  507. if(($a->argc > 3) && ($a->argv[2] === 'edit')) {
  508. $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
  509. dbesc($a->argv[3]),
  510. local_user());
  511. if (!count($r)){
  512. notice(t("You can't edit this application."));
  513. return;
  514. }
  515. $app = $r[0];
  516. $tpl = get_markup_template("settings_oauth_edit.tpl");
  517. $o .= replace_macros($tpl, array(
  518. '$form_security_token' => get_form_security_token("settings_oauth"),
  519. '$title' => t('Add application'),
  520. '$submit' => t('Update'),
  521. '$cancel' => t('Cancel'),
  522. '$name' => array('name', t('Name'), $app['name'] , ''),
  523. '$key' => array('key', t('Consumer Key'), $app['client_id'], ''),
  524. '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''),
  525. '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''),
  526. '$icon' => array('icon', t('Icon url'), $app['icon'], ''),
  527. ));
  528. return $o;
  529. }
  530. if(($a->argc > 3) && ($a->argv[2] === 'delete')) {
  531. check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
  532. $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
  533. dbesc($a->argv[3]),
  534. local_user());
  535. goaway($a->get_baseurl(true)."/settings/oauth/");
  536. return;
  537. }
  538. $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
  539. FROM clients
  540. LEFT JOIN tokens ON clients.client_id=tokens.client_id
  541. WHERE clients.uid IN (%d,0)",
  542. local_user(),
  543. local_user());
  544. $tpl = get_markup_template("settings_oauth.tpl");
  545. $o .= replace_macros($tpl, array(
  546. '$form_security_token' => get_form_security_token("settings_oauth"),
  547. '$baseurl' => $a->get_baseurl(true),
  548. '$title' => t('Connected Apps'),
  549. '$add' => t('Add application'),
  550. '$edit' => t('Edit'),
  551. '$delete' => t('Delete'),
  552. '$consumerkey' => t('Client key starts with'),
  553. '$noname' => t('No name'),
  554. '$remove' => t('Remove authorization'),
  555. '$apps' => $r,
  556. ));
  557. return $o;
  558. }
  559. if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
  560. $settings_addons = "";
  561. $r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
  562. if(! count($r))
  563. $settings_addons = t('No Plugin settings configured');
  564. call_hooks('plugin_settings', $settings_addons);
  565. $tpl = get_markup_template("settings_addons.tpl");
  566. $o .= replace_macros($tpl, array(
  567. '$form_security_token' => get_form_security_token("settings_addon"),
  568. '$title' => t('Plugin Settings'),
  569. '$settings_addons' => $settings_addons
  570. ));
  571. return $o;
  572. }
  573. if(($a->argc > 1) && ($a->argv[1] === 'features')) {
  574. $arr = array();
  575. $features = get_features();
  576. foreach($features as $fname => $fdata) {
  577. $arr[$fname] = array();
  578. $arr[$fname][0] = $fdata[0];
  579. foreach(array_slice($fdata,1) as $f) {
  580. $arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(get_pconfig(local_user(),'feature',$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
  581. }
  582. }
  583. $tpl = get_markup_template("settings_features.tpl");
  584. $o .= replace_macros($tpl, array(
  585. '$form_security_token' => get_form_security_token("settings_features"),
  586. '$title' => t('Additional Features'),
  587. '$features' => $arr,
  588. '$submit' => t('Save Settings'),
  589. ));
  590. return $o;
  591. }
  592. if(($a->argc > 1) && ($a->argv[1] === 'connectors')) {
  593. $settings_connectors = "";
  594. call_hooks('connector_settings', $settings_connectors);
  595. $diasp_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('Diaspora'), ((get_config('system','diaspora_enabled')) ? t('enabled') : t('disabled')));
  596. $ostat_enabled = sprintf( t('Built-in support for %s connectivity is %s'), t('StatusNet'), ((get_config('system','ostatus_disabled')) ? t('disabled') : t('enabled')));
  597. $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
  598. if(get_config('system','dfrn_only'))
  599. $mail_disabled = 1;
  600. if(! $mail_disabled) {
  601. $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
  602. local_user()
  603. );
  604. }
  605. else {
  606. $r = null;
  607. }
  608. $mail_server = ((count($r)) ? $r[0]['server'] : '');
  609. $mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : '');
  610. $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : '');
  611. $mail_user = ((count($r)) ? $r[0]['user'] : '');
  612. $mail_replyto = ((count($r)) ? $r[0]['reply_to'] : '');
  613. $mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0);
  614. $mail_action = ((count($r)) ? $r[0]['action'] : 0);
  615. $mail_movetofolder = ((count($r)) ? $r[0]['movetofolder'] : '');
  616. $mail_chk = ((count($r)) ? $r[0]['last_check'] : '0000-00-00 00:00:00');
  617. $tpl = get_markup_template("settings_connectors.tpl");
  618. if(! service_class_allows(local_user(),'email_connect')) {
  619. $mail_disabled_message = upgrade_bool_message();
  620. }
  621. else {
  622. $mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
  623. }
  624. $o .= replace_macros($tpl, array(
  625. '$form_security_token' => get_form_security_token("settings_connectors"),
  626. '$title' => t('Connector Settings'),
  627. '$diasp_enabled' => $diasp_enabled,
  628. '$ostat_enabled' => $ostat_enabled,
  629. '$h_imap' => t('Email/Mailbox Setup'),
  630. '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."),
  631. '$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk,''),
  632. '$mail_disabled' => $mail_disabled_message,
  633. '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''),
  634. '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''),
  635. '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( 'notls'=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')),
  636. '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''),
  637. '$mail_pass' => array('mail_pass', t('Email password:'), '', ''),
  638. '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), $mail_replyto, 'Optional'),
  639. '$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''),
  640. '$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'))),
  641. '$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''),
  642. '$submit' => t('Save Settings'),
  643. '$settings_connectors' => $settings_connectors
  644. ));
  645. call_hooks('display_settings', $o);
  646. return $o;
  647. }
  648. /*
  649. * DISPLAY SETTINGS
  650. */
  651. if(($a->argc > 1) && ($a->argv[1] === 'display')) {
  652. $default_theme = get_config('system','theme');
  653. if(! $default_theme)
  654. $default_theme = 'default';
  655. $default_mobile_theme = get_config('system','mobile-theme');
  656. if(! $mobile_default_theme)
  657. $mobile_default_theme = 'none';
  658. $allowed_themes_str = get_config('system','allowed_themes');
  659. $allowed_themes_raw = explode(',',$allowed_themes_str);
  660. $allowed_themes = array();
  661. if(count($allowed_themes_raw))
  662. foreach($allowed_themes_raw as $x)
  663. if(strlen(trim($x)) && is_dir("view/theme/$x"))
  664. $allowed_themes[] = trim($x);
  665. $themes = array();
  666. $mobile_themes = array("---" => t('No special theme for mobile devices'));
  667. $files = glob('view/theme/*');
  668. if($allowed_themes) {
  669. foreach($allowed_themes as $th) {
  670. $f = $th;
  671. $is_experimental = file_exists('view/theme/' . $th . '/experimental');
  672. $unsupported = file_exists('view/theme/' . $th . '/unsupported');
  673. $is_mobile = file_exists('view/theme/' . $th . '/mobile');
  674. if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
  675. $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
  676. if($is_mobile) {
  677. $mobile_themes[$f]=$theme_name;
  678. }
  679. else {
  680. $themes[$f]=$theme_name;
  681. }
  682. }
  683. }
  684. }
  685. $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']);
  686. $mobile_theme_selected = (!x($_SESSION,'mobile-theme')? $default_mobile_theme : $_SESSION['mobile-theme']);
  687. $browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
  688. $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
  689. $itemspage_network = intval(get_pconfig(local_user(), 'system','itemspage_network'));
  690. $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
  691. $itemspage_mobile_network = intval(get_pconfig(local_user(), 'system','itemspage_mobile_network'));
  692. $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : 20); // default if not set: 20 items
  693. $nosmile = get_pconfig(local_user(),'system','no_smilies');
  694. $nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0
  695. $infinite_scroll = get_pconfig(local_user(),'system','infinite_scroll');
  696. $infinite_scroll = (($infinite_scroll===false)? '0': $infinite_scroll); // default if not set: 0
  697. $theme_config = "";
  698. if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){
  699. require_once($themeconfigfile);
  700. $theme_config = theme_content($a);
  701. }
  702. $tpl = get_markup_template("settings_display.tpl");
  703. $o = replace_macros($tpl, array(
  704. '$ptitle' => t('Display Settings'),
  705. '$form_security_token' => get_form_security_token("settings_display"),
  706. '$submit' => t('Save Settings'),
  707. '$baseurl' => $a->get_baseurl(true),
  708. '$uid' => local_user(),
  709. '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true),
  710. '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false),
  711. '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
  712. '$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')),
  713. '$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')),
  714. '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''),
  715. '$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
  716. '$theme_config' => $theme_config,
  717. ));
  718. $tpl = get_markup_template("settings_display_end.tpl");
  719. $a->page['end'] .= replace_macros($tpl, array(
  720. '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes)
  721. ));
  722. return $o;
  723. }
  724. /*
  725. * ACCOUNT SETTINGS
  726. */
  727. require_once('include/acl_selectors.php');
  728. $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
  729. intval(local_user())
  730. );
  731. if(count($p))
  732. $profile = $p[0];
  733. $username = $a->user['username'];
  734. $email = $a->user['email'];
  735. $nickname = $a->user['nickname'];
  736. $timezone = $a->user['timezone'];
  737. $notify = $a->user['notify-flags'];
  738. $defloc = $a->user['default-location'];
  739. $openid = $a->user['openid'];
  740. $maxreq = $a->user['maxreq'];
  741. $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
  742. $blockwall = $a->user['blockwall'];
  743. $blocktags = $a->user['blocktags'];
  744. $unkmail = $a->user['unkmail'];
  745. $cntunkmail = $a->user['cntunkmail'];
  746. $expire_items = get_pconfig(local_user(), 'expire','items');
  747. $expire_items = (($expire_items===false)? '1' : $expire_items); // default if not set: 1
  748. $expire_notes = get_pconfig(local_user(), 'expire','notes');
  749. $expire_notes = (($expire_notes===false)? '1' : $expire_notes); // default if not set: 1
  750. $expire_starred = get_pconfig(local_user(), 'expire','starred');
  751. $expire_starred = (($expire_starred===false)? '1' : $expire_starred); // default if not set: 1
  752. $expire_photos = get_pconfig(local_user(), 'expire','photos');
  753. $expire_photos = (($expire_photos===false)? '0' : $expire_photos); // default if not set: 0
  754. $expire_network_only = get_pconfig(local_user(), 'expire','network_only');
  755. $expire_network_only = (($expire_network_only===false)? '0' : $expire_network_only); // default if not set: 0
  756. $suggestme = get_pconfig(local_user(), 'system','suggestme');
  757. $suggestme = (($suggestme===false)? '0': $suggestme); // default if not set: 0
  758. $post_newfriend = get_pconfig(local_user(), 'system','post_newfriend');
  759. $post_newfriend = (($post_newfriend===false)? '0': $post_newfriend); // default if not set: 0
  760. $post_joingroup = get_pconfig(local_user(), 'system','post_joingroup');
  761. $post_joingroup = (($post_joingroup===false)? '0': $post_joingroup); // default if not set: 0
  762. $post_profilechange = get_pconfig(local_user(), 'system','post_profilechange');
  763. $post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0
  764. if(! strlen($a->user['timezone']))
  765. $timezone = date_default_timezone_get();
  766. $pageset_tpl = get_markup_template('pagetypes.tpl');
  767. $pagetype = replace_macros($pageset_tpl, array(
  768. '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL,
  769. t('This account is a normal personal profile'),
  770. ($a->user['page-flags'] == PAGE_NORMAL)),
  771. '$page_soapbox' => array('page-flags', t('Soapbox Page'), PAGE_SOAPBOX,
  772. t('Automatically approve all connection/friend requests as read-only fans'),
  773. ($a->user['page-flags'] == PAGE_SOAPBOX)),
  774. '$page_community' => array('page-flags', t('Community Forum/Celebrity Account'), PAGE_COMMUNITY,
  775. t('Automatically approve all connection/friend requests as read-write fans'),
  776. ($a->user['page-flags'] == PAGE_COMMUNITY)),
  777. '$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE,
  778. t('Automatically approve all connection/friend requests as friends'),
  779. ($a->user['page-flags'] == PAGE_FREELOVE)),
  780. '$page_prvgroup' => array('page-flags', t('Private Forum [Experimental]'), PAGE_PRVGROUP,
  781. t('Private forum - approved members only'),
  782. ($a->user['page-flags'] == PAGE_PRVGROUP)),
  783. ));
  784. $noid = get_config('system','no_openid');
  785. if($noid) {
  786. $openid_field = false;
  787. }
  788. else {
  789. $openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."));
  790. }
  791. $opt_tpl = get_markup_template("field_yesno.tpl");
  792. if(get_config('system','publish_all')) {
  793. $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
  794. }
  795. else {
  796. $profile_in_dir = replace_macros($opt_tpl,array(
  797. '$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
  798. ));
  799. }
  800. if(strlen(get_config('system','directory_submit_url'))) {
  801. $profile_in_net_dir = replace_macros($opt_tpl,array(
  802. '$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
  803. ));
  804. }
  805. else
  806. $profile_in_net_dir = '';
  807. $hide_friends = replace_macros($opt_tpl,array(
  808. '$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))),
  809. ));
  810. $hide_wall = replace_macros($opt_tpl,array(
  811. '$field' => array('hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], '', array(t('No'),t('Yes'))),
  812. ));
  813. $blockwall = replace_macros($opt_tpl,array(
  814. '$field' => array('blockwall', t('Allow friends to post to your profile page?'), (intval($a->user['blockwall']) ? '0' : '1'), '', array(t('No'),t('Yes'))),
  815. ));
  816. $blocktags = replace_macros($opt_tpl,array(
  817. '$field' => array('blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', array(t('No'),t('Yes'))),
  818. ));
  819. $suggestme = replace_macros($opt_tpl,array(
  820. '$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))),
  821. ));
  822. $unkmail = replace_macros($opt_tpl,array(
  823. '$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))),
  824. ));
  825. $invisible = (((! $profile['publish']) && (! $profile['net-publish']))
  826. ? true : false);
  827. if($invisible)
  828. info( t('Profile is <strong>not published</strong>.') . EOL );
  829. $subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/profile/' . $nickname : '');
  830. $tpl_addr = get_markup_template("settings_nick_set.tpl");
  831. $prof_addr = replace_macros($tpl_addr,array(
  832. '$desc' => t('Your Identity Address is'),
  833. '$nickname' => $nickname,
  834. '$subdir' => $subdir,
  835. '$basepath' => $a->get_hostname()
  836. ));
  837. $stpl = get_markup_template('settings.tpl');
  838. $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
  839. $expire_arr = array(
  840. 'days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')),
  841. 'advanced' => t('Advanced expiration settings'),
  842. 'label' => t('Advanced Expiration'),
  843. 'items' => array('expire_items', t("Expire posts:"), $expire_items, '', array(t('No'),t('Yes'))),
  844. 'notes' => array('expire_notes', t("Expire personal notes:"), $expire_notes, '', array(t('No'),t('Yes'))),
  845. 'starred' => array('expire_starred', t("Expire starred posts:"), $expire_starred, '', array(t('No'),t('Yes'))),
  846. 'photos' => array('expire_photos', t("Expire photos:"), $expire_photos, '', array(t('No'),t('Yes'))),
  847. 'network_only' => array('expire_network_only', t("Only expire posts by others:"), $expire_network_only, '', array(t('No'),t('Yes'))),
  848. );
  849. require_once('include/group.php');
  850. $group_select = mini_group_select(local_user(),$a->user['def_gid']);
  851. // Private/public post links for the non-JS ACL form
  852. $private_post = 1;
  853. if($_REQUEST['public'])
  854. $private_post = 0;
  855. $query_str = $a->query_string;
  856. if(strpos($query_str, 'public=1') !== false)
  857. $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
  858. // I think $a->query_string may never have ? in it, but I could be wrong
  859. // It looks like it's from the index.php?q=[etc] rewrite that the web
  860. // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
  861. if(strpos($query_str, '?') === false)
  862. $public_post_link = '?public=1';
  863. else
  864. $public_post_link = '&public=1';
  865. $o .= replace_macros($stpl, array(
  866. '$ptitle' => t('Account Settings'),
  867. '$submit' => t('Save Settings'),
  868. '$baseurl' => $a->get_baseurl(true),
  869. '$uid' => local_user(),
  870. '$form_security_token' => get_form_security_token("settings"),
  871. '$nickname_block' => $prof_addr,
  872. '$h_pass' => t('Password Settings'),
  873. '$password1'=> array('npassword', t('New Password:'), '', ''),
  874. '$password2'=> array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')),
  875. '$password3'=> array('opassword', t('Current Password:'), '', t('Your current password to confirm the changes')),
  876. '$password4'=> array('password', t('Password:'), '', t('Your current password to confirm the changes')),
  877. '$oid_enable' => (! get_config('system','no_openid')),
  878. '$openid' => $openid_field,
  879. '$h_basic' => t('Basic Settings'),
  880. '$username' => array('username', t('Full Name:'), $username,''),
  881. '$email' => array('email', t('Email Address:'), $email, ''),
  882. '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''),
  883. '$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''),
  884. '$allowloc' => array('allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''),
  885. '$h_prv' => t('Security and Privacy Settings'),
  886. '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), $maxreq ,t("\x28to prevent spam abuse\x29")),
  887. '$permissions' => t('Default Post Permissions'),
  888. '$permdesc' => t("\x28click to open/close\x29"),
  889. '$visibility' => $profile['net-publish'],
  890. '$aclselect' => populate_acl($a->user,$celeb),
  891. '$suggestme' => $suggestme,
  892. '$blockwall'=> $blockwall, // array('blockwall', t('Allow friends to post to your profile page:'), !$blockwall, ''),
  893. '$blocktags'=> $blocktags, // array('blocktags', t('Allow friends to tag your posts:'), !$blocktags, ''),
  894. // ACL permissions box
  895. '$acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
  896. '$group_perms' => t('Show to Groups'),
  897. '$contact_perms' => t('Show to Contacts'),
  898. '$private' => t('Default Private Post'),
  899. '$public' => t('Default Public Post'),
  900. '$is_private' => $private_post,
  901. '$return_path' => $query_str,
  902. '$public_link' => $public_post_link,
  903. '$settings_perms' => t('Default Permissions for New Posts'),
  904. '$group_select' => $group_select,
  905. '$expire' => $expire_arr,
  906. '$profile_in_dir' => $profile_in_dir,
  907. '$profile_in_net_dir' => $profile_in_net_dir,
  908. '$hide_friends' => $hide_friends,
  909. '$hide_wall' => $hide_wall,
  910. '$unkmail' => $unkmail,
  911. '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail ,t("\x28to prevent spam abuse\x29")),
  912. '$h_not' => t('Notification Settings'),
  913. '$activity_options' => t('By default post a status message when:'),
  914. '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, ''),
  915. '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, ''),
  916. '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, ''),
  917. '$lbl_not' => t('Send a notification email when:'),
  918. '$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''),
  919. '$notify2' => array('notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''),
  920. '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''),
  921. '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
  922. '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
  923. '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),
  924. '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
  925. '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),
  926. '$h_advn' => t('Advanced Account/Page Type Settings'),
  927. '$h_descadvn' => t('Change the behaviour of this account for special situations'),
  928. '$pagetype' => $pagetype,
  929. '$relocate' => t('Relocate'),
  930. '$relocate_text' => t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."),
  931. '$relocate_button' => t("Resend relocate message to contacts"),
  932. ));
  933. call_hooks('settings_form',$o);
  934. $o .= '</form>' . "\r\n";
  935. return $o;
  936. }}