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.
 
 
 
 
 
 

1301 lines
50 KiB

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