From: kink Date: Sun, 18 Feb 2007 18:47:48 +0000 (+0000) Subject: Add option to ask users for personal information on first login. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=209e24bb063cb116e8564e226e0a2687276cb9d5;p=squirrelmail.git Add option to ask users for personal information on first login. Many users start sending out mail without a decent or even correct "From" header. Defaults to on. Admin can disable if he has a retrieve_user_info plugin or the guessed defaults are ok. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12274 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index 84074c93..ca100720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -179,6 +179,7 @@ Version 1.5.2 - SVN - Update for switch from CVS to Subversion. - Default provider URI link fixed (was broken when on plugin options pages, etc) - Fix URL to send read receipts from read_body (#1637572). + - Add option to ask users for personal information on first login. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/config/conf.pl b/config/conf.pl index 031d316f..52099666 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -472,6 +472,7 @@ $icon_theme_def = '' if ( !$icon_theme_def ); $disable_plugins = 'false' if ( !$disable_plugins ); $disable_plugins_user = '' if ( !$disable_plugins_user ); $only_secure_cookies = 'true' if ( !$only_secure_cookies ); +$ask_user_info = 'true' if ( !$ask_user_info ); if ( $ARGV[0] eq '--install-plugin' ) { print "Activating plugin " . $ARGV[1] . "\n"; @@ -790,6 +791,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { } elsif ( $menu == 11 ) { print $WHT. "Interface tweaks\n" . $NRM; print "1. Display html mails in iframe : $WHT$use_iframe$NRM\n"; + print "2. Ask user info on first login : $WHT$ask_user_info$NRM\n"; print "\n"; print $WHT. "PHP tweaks\n" . $NRM; print "4. Use php recode functions : $WHT$use_php_recode$NRM\n"; @@ -965,6 +967,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { elsif ( $command == 5 ) { $lossy_encoding = commandA5(); } } elsif ( $menu == 11 ) { if ( $command == 1 ) { $use_iframe = commandB2(); } + elsif ( $command == 2 ) { $ask_user_info = command_ask_user_info(); } elsif ( $command == 4 ) { $use_php_recode = commandB4(); } elsif ( $command == 5 ) { $use_php_iconv = commandB5(); } elsif ( $command == 6 ) { $allow_remote_configtest = commandB6(); } @@ -4156,6 +4159,30 @@ sub commandB2 { } return $use_iframe; } + +# display html emails in iframe +sub command_ask_user_info { + print "New users need to supply their real name and email address to\n"; + print "send out proper mails. When this option is enabled, a user that\n"; + print "logs in for the first time will be redirected to the Personal\n"; + print "Options screen and asked to supply their personal data.\n"; + print "\n"; + + if ( lc($ask_user_info) eq 'true' ) { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Ask user info? (y/n) [$WHT$default_value$NRM]: $WHT"; + $ask_user_info = ; + if ( ( $ask_user_info =~ /^y\n/i ) || ( ( $ask_user_info =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { + $ask_user_info = 'true'; + } else { + $ask_user_info = 'false'; + } + return $ask_user_info; +} + # use icons sub commandB3 { print "Enabling this option will cause icons to be used instead of text\n"; @@ -4661,13 +4688,13 @@ sub save_data { # boolean print CF "\$use_iframe = $use_iframe;\n"; - print CF "\n"; + # boolean + print CF "\$ask_user_info = $ask_user_info;\n"; # boolean print CF "\$use_icons = $use_icons;\n"; print CF "\n"; # boolean print CF "\$use_php_recode = $use_php_recode;\n"; - print CF "\n"; # boolean print CF "\$use_php_iconv = $use_php_iconv;\n"; print CF "\n"; diff --git a/config/config_default.php b/config/config_default.php index 0ede1844..43f4125e 100644 --- a/config/config_default.php +++ b/config/config_default.php @@ -1151,3 +1151,15 @@ $no_list_for_subscribe = false; * @global integer $config_use_color */ $config_use_color = 2; + +/** + * Ask User for Personal Information on login + * + * When a user logs in that doesn't have an email address configured, + * redirect him/her to the options page with a request to fill in their + * personal information. + * + * @global bool $ask_user_info + */ +$ask_user_info = true; + diff --git a/include/options/personal.php b/include/options/personal.php index b84a3749..9e390baa 100644 --- a/include/options/personal.php +++ b/include/options/personal.php @@ -264,3 +264,4 @@ function save_option_signature($option) { global $data_dir, $username; setSig($data_dir, $username, 'g', $option->new_value); } + diff --git a/src/options.php b/src/options.php index 7dd666ff..d4bb822f 100644 --- a/src/options.php +++ b/src/options.php @@ -44,9 +44,20 @@ function process_optionmode_submit($optpage, $optpage_data) { /* Initialize the maximum option refresh level. */ $max_refresh = SMOPT_REFRESH_NONE; + + /* Save each option in each option group. */ foreach ($optpage_data['options'] as $option_grp) { foreach ($option_grp['options'] as $option) { + + /* Special case: need to make sure emailaddress + * is saved if we use it as a test for ask_user_info */ + global $ask_user_info; + if ( $optpage = SMOPT_PAGE_PERSONAL && $ask_user_info && + $option->name == 'email_address' ) { + $option->setValue(''); + } + /* Remove Debug Mode Until Needed echo "name = '$option->name', " . "value = '$option->value', " @@ -415,6 +426,13 @@ if ($optpage == SMOPT_PAGE_MAIN) { // This is the only variable that is needed by *just* the template. $oTemplate->assign('options', $optpage_data['options']); + global $ask_user_info; + if ( $optpage = SMOPT_PAGE_PERSONAL && $ask_user_info + && getPref($data_dir, $username,'email_address') == "" ) { + $oTemplate->assign('topmessage', + _("Welcome to SquirrelMail. Please supply your full name and email address.") ); + } + /** * The variables below should not be needed by the template since all plugin * hooks are called here, not in the template. If we find otherwise, these @@ -456,4 +474,3 @@ if ($optpage == SMOPT_PAGE_MAIN) { } $oTemplate->display('footer.tpl'); -?> diff --git a/src/right_main.php b/src/right_main.php index 513647f5..7d24ede6 100644 --- a/src/right_main.php +++ b/src/right_main.php @@ -20,6 +20,13 @@ */ include('../include/init.php'); +/* If email_address not set and admin wants us to ask user for it, + * redirect to options page. */ +if ( $ask_user_info && getPref($data_dir, $username,'email_address') == "" ) { + header("Location: " . get_location() . "/options.php?optpage=personal"); + exit; +} + /* SquirrelMail required files. */ require_once(SM_PATH . 'functions/imap_asearch.php'); require_once(SM_PATH . 'functions/imap_general.php'); @@ -29,7 +36,6 @@ require_once(SM_PATH . 'functions/mime.php'); require_once(SM_PATH . 'functions/mailbox_display.php'); require_once(SM_PATH . 'functions/compose.php'); - /* lets get the global vars we may need */ sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION); diff --git a/templates/default/css/options.css b/templates/default/css/options.css index c397e6e4..d8d3df79 100644 --- a/templates/default/css/options.css +++ b/templates/default/css/options.css @@ -154,4 +154,10 @@ margin-left: auto; margin-right: auto; } - +#optionMessage { + text-align: center; + width: 100%; + font-size: larger; + color: red; + font-weight: bold; +} diff --git a/templates/default/options.tpl b/templates/default/options.tpl index 31e317c2..2ec51085 100644 --- a/templates/default/options.tpl +++ b/templates/default/options.tpl @@ -21,7 +21,13 @@ /** extract variables */ extract($t); + + +if ( !empty($topmessage) ) { + echo "
\n$topmessage\n
\n\n"; +} ?> +