Happy New Year
[squirrelmail.git] / include / options / personal.php
index 45e5c5c27ddc2a5355405050f60b61dba3b8e43b..c00004f229ebb83f9b30a7e9858c3d29584c443c 100644 (file)
@@ -5,14 +5,13 @@
  *
  * Displays all options relating to personal information
  *
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright 1999-2018 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  */
 
 /** SquirrelMail required files. */
-require_once(SM_PATH . 'functions/imap.php');
 require_once(SM_PATH . 'include/timezones.php');
 
 /* Define the group constants for the personal options page. */
@@ -35,15 +34,24 @@ define('SMOPT_GRP_TZ', 3);
  * @return array all option information
  */
 function load_optpage_data_personal() {
-    global $data_dir, $username, $edit_identity, $edit_name,
+    global $data_dir, $username, $edit_identity, $edit_name, $edit_reply_to,
            $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
-           $color, $timeZone;
+           $timeZone, $domain;
 
     /* Set the values of some global variables. */
     $full_name = getPref($data_dir, $username, 'full_name');
     $reply_to = getPref($data_dir, $username, 'reply_to');
-    $email_address  = getPref($data_dir, $username, 'email_address');
+    $email_address  = getPref($data_dir, $username, 'email_address',SMPREF_NONE);
     $signature  = getSig($data_dir, $username, 'g');
+    
+    // set email_address to default value, if it is not set in user's preferences
+    if ($email_address == SMPREF_NONE) {
+        if (preg_match("/(.+)@(.+)/",$username)) {
+            $email_address = $username;
+        } else {
+            $email_address = $username . '@' . $domain ;
+        }
+    }
 
     /* Build a simple array into which we will build options. */
     $optgrps = array();
@@ -96,17 +104,30 @@ function load_optpage_data_personal() {
             'caption' => _("E-mail Address"),
             'type'    => SMOPT_TYPE_COMMENT,
             'refresh' => SMOPT_REFRESH_NONE,
-            'comment' => $email_address
+            'comment' => sm_encode_html_special_chars($email_address)
         );
     }
 
-    $optvals[SMOPT_GRP_CONTACT][] = array(
-        'name'    => 'reply_to',
-        'caption' => _("Reply To"),
-        'type'    => SMOPT_TYPE_STRING,
-        'refresh' => SMOPT_REFRESH_NONE,
-        'size'    => SMOPT_SIZE_HUGE
-    );
+    if ($edit_identity || $edit_reply_to) {
+        $optvals[SMOPT_GRP_CONTACT][] = array(
+            'name'    => 'reply_to',
+            'caption' => _("Reply To"),
+            'type'    => SMOPT_TYPE_STRING,
+            'refresh' => SMOPT_REFRESH_NONE,
+            'size'    => SMOPT_SIZE_HUGE
+        );
+    } else {
+//TODO: For many users, this is redundant to the email address above, especially if not editable -- so here instead of a comment, we could just hide it... in fact, that's what we'll do, but keep this code for posterity in case someone decides we shouldn't do this
+/*
+        $optvals[SMOPT_GRP_CONTACT][] = array(
+            'name'    => 'reply_to',
+            'caption' => _("Reply To"),
+            'type'    => SMOPT_TYPE_COMMENT,
+            'refresh' => SMOPT_REFRESH_NONE,
+            'comment' => sm_encode_html_special_chars($reply_to),
+        );
+*/
+    }
 
     $optvals[SMOPT_GRP_CONTACT][] = array(
         'name'    => 'signature',
@@ -131,7 +152,7 @@ function load_optpage_data_personal() {
         );
     }
 
-    if ( $tzChangeAllowed ) {
+    if ( $tzChangeAllowed || function_exists('date_default_timezone_set')) {
         $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
 
         $aTimeZones = sq_get_tz_array();
@@ -171,7 +192,7 @@ function load_optpage_data_personal() {
 
         // TODO: make error user friendly
         if (isset($message)) {
-            plain_error_message($message, $color);
+            plain_error_message($message);
             exit;
         }
 
@@ -257,4 +278,3 @@ function save_option_signature($option) {
     setSig($data_dir, $username, 'g', $option->new_value);
 }
 
-?>
\ No newline at end of file