From b4b1055b502c317513bf5c57794c004ced43a0de Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Mar 2012 00:57:59 -0700 Subject: [PATCH] settings for unknown private mail acceptance --- boot.php | 2 +- database.sql | 10 ++++++++-- mod/settings.php | 40 ++++++++++++++++++++++++++-------------- update.php | 7 ++++++- view/settings.tpl | 4 ++++ 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/boot.php b/boot.php index 2a8dc3d047..ec1ffbbf48 100755 --- a/boot.php +++ b/boot.php @@ -11,7 +11,7 @@ require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '2.3.1297' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1133 ); +define ( 'DB_UPDATE_VERSION', 1134 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 327b482c06..a271e5491c 100755 --- a/database.sql +++ b/database.sql @@ -289,9 +289,10 @@ CREATE TABLE IF NOT EXISTS `mail` ( `convid` int(10) unsigned NOT NULL, `title` char(255) NOT NULL, `body` mediumtext NOT NULL, - `seen` tinyint(1) NOT NULL, + `seen` tinyint(1) NOT NULL DEFAULT '0', `reply` tinyint(1) NOT NULL DEFAULT '0', - `replied` tinyint(1) NOT NULL, + `replied` tinyint(1) NOT NULL DEFAULT '0', + `unknown` tinyint(1) NOT NULL DEFAULT '0', `uri` char(255) NOT NULL, `parent-uri` char(255) NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -300,6 +301,7 @@ CREATE TABLE IF NOT EXISTS `mail` ( KEY `guid` (`guid`), KEY `convid` (`convid`), KEY `reply` (`reply`), + KEY `unknown` (`unknown`), KEY `uri` (`uri`), KEY `parent-uri` (`parent-uri`), KEY `created` (`created`) @@ -453,6 +455,8 @@ CREATE TABLE IF NOT EXISTS `user` ( `blockwall` tinyint(1) unsigned NOT NULL DEFAULT '0', `hidewall` tinyint(1) unsigned NOT NULL DEFAULT '0', `blocktags` tinyint(1) unsigned NOT NULL DEFAULT '0', + `unkmail` tinyint(1) unsigned NOT NULL DEFAULT '0', + `cntunkmail` int(11) unsigned NOT NULL DEFAULT '10', `notify-flags` int(11) unsigned NOT NULL DEFAULT '65535', `page-flags` int(11) unsigned NOT NULL DEFAULT '0', `prvnets` tinyint(1) NOT NULL DEFAULT '0', @@ -472,6 +476,8 @@ CREATE TABLE IF NOT EXISTS `user` ( KEY `account_expired` (`account_expired`), KEY `hidewall` (`hidewall`), KEY `blockwall` (`blockwall`), + KEY `unkmail` (`unkmail`), + KEY `cntunkmail` (`cntunkmail`), KEY `blocked` (`blocked`), KEY `verified` (`verified`), KEY `login_date` (`login_date`) diff --git a/mod/settings.php b/mod/settings.php index ce5ceea825..ce2d64851b 100755 --- a/mod/settings.php +++ b/mod/settings.php @@ -303,7 +303,8 @@ function settings_post(&$a) { $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted! - + $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0); + $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0); $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0); $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); @@ -391,7 +392,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','suggestme', $suggestme); - $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', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d WHERE `uid` = %d LIMIT 1", + $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', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($openid), @@ -410,6 +411,8 @@ function settings_post(&$a) { intval($blockwall), intval($hidewall), intval($blocktags), + intval($unkmail), + intval($cntunkmail), intval(local_user()) ); if($r) @@ -760,17 +763,19 @@ function settings_content(&$a) { if(count($p)) $profile = $p[0]; - $username = $a->user['username']; - $email = $a->user['email']; - $nickname = $a->user['nickname']; - $timezone = $a->user['timezone']; - $notify = $a->user['notify-flags']; - $defloc = $a->user['default-location']; - $openid = $a->user['openid']; - $maxreq = $a->user['maxreq']; - $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); - $blockwall = $a->user['blockwall']; - $blocktags = $a->user['blocktags']; + $username = $a->user['username']; + $email = $a->user['email']; + $nickname = $a->user['nickname']; + $timezone = $a->user['timezone']; + $notify = $a->user['notify-flags']; + $defloc = $a->user['default-location']; + $openid = $a->user['openid']; + $maxreq = $a->user['maxreq']; + $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); + $blockwall = $a->user['blockwall']; + $blocktags = $a->user['blocktags']; + $unkmail = $a->user['unkmail']; + $cntunkmail = $a->user['cntunkmail']; $expire_items = get_pconfig(local_user(), 'expire','items'); $expire_items = (($expire_items===false)? '1' : $expire_items); // default if not set: 1 @@ -870,6 +875,12 @@ function settings_content(&$a) { )); + $unkmail = replace_macros($opt_tpl,array( + '$field' => array('unkmail', t('Permit unknown people to send you private messages?'), $unkmail, '', array(t('No'),t('Yes'))), + + )); + + $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) ? true : false); @@ -946,7 +957,8 @@ function settings_content(&$a) { '$profile_in_net_dir' => $profile_in_net_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, - + '$unkmail' => $unkmail, + '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail ,t("\x28to prevent spam abuse\x29")), '$h_not' => t('Notification Settings'), diff --git a/update.php b/update.php index a69742a949..d38e39f8b1 100755 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ $expire.label