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.

1191 lines
43 KiB

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