Fix get_identities() for the case where the user has not set an email
[squirrelmail.git] / functions / identity.php
1 <?php
2
3 /**
4 * identity.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains utility functions for dealing with multiple identities
10 *
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /** Used to simplify includes */
16 if (!defined('SM_PATH')) {
17 define('SM_PATH','../');
18 }
19
20 include_once(SM_PATH . 'include/load_prefs.php');
21
22 /**
23 * Returns an array of all the identities.
24 * Array is keyed: full_name, reply_to, email_address, index, signature
25 * @return array full_name,reply_to,email_address,index,signature
26 */
27 function get_identities() {
28
29 global $username, $data_dir, $domain;
30
31 $em = getPref($data_dir,$username,'email_address');
32 if ( ! $em ) $em = $username.'@'.$domain;
33
34 $identities = array();
35 /* We always have this one, even if the user doesn't use multiple identities */
36 $identities[] = array('full_name' => getPref($data_dir,$username,'full_name'),
37 'email_address' => $em,
38 'reply_to' => getPref($data_dir,$username,'reply_to'),
39 'signature' => getSig($data_dir,$username,'g'),
40 'index' => 0 );
41
42 $num_ids = getPref($data_dir,$username,'identities');
43 /* If there are any others, add them to the array */
44 if (!empty($num_ids) && $num_ids > 1) {
45 for ($i=1;$i<$num_ids;$i++) {
46 $identities[] = array('full_name' => getPref($data_dir,$username,'full_name' . $i),
47 'email_address' => getPref($data_dir,$username,'email_address' . $i),
48 'reply_to' => getPref($data_dir,$username,'reply_to' . $i),
49 'signature' => getSig($data_dir,$username,$i),
50 'index' => $i );
51 }
52 }
53
54 return $identities;
55 }
56
57 ?>