2
/////////////////////////////////////////////////////////
4
// source/pref_identities.php
6
// (C)Copyright 2000-2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
8
// This file is part of IlohaMail.
9
// IlohaMail is free software released under the GPL
10
// license. See enclosed file COPYING for details,
11
// or see http://www.fsf.org/copyleft/gpl.html
13
/////////////////////////////////////////////////////////
15
/********************************************************
17
AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
18
FILE: source/pref_identities.php
20
Create/edit/delete identities
24
********************************************************/
26
include("../include/super2global.inc");
27
include("../include/header_main.inc");
28
include("../include/langs.inc");
29
include("../include/icl.inc");
30
include("../lang/".$my_prefs["lang"]."prefs.inc");
31
include("../lang/".$my_prefs["lang"]."pref_identities.inc");
32
//include("../conf/defaults.inc");
33
include("../include/identities.inc");
34
include("../include/data_manager.inc");
35
include("../include/pref_header.inc");
39
$conn=iil_Connect($host, $loginID, $password, $AUTH_MODE);
41
if ($ICL_CAPABILITY["folders"]){
42
if ($my_prefs["hideUnsubscribed"]){
43
$mailboxes = iil_C_ListSubscribed($conn, $my_prefs["rootdir"], "*");
45
$mailboxes = iil_C_ListMailboxes($conn, $my_prefs["rootdir"], "*");
51
echo "Authentication failed.";
52
echo "</body></html>\n";
57
$dm = new DataManager_obj;
58
if ($dm->initialize($loginID, $host, $DB_IDENTITIES_TABLE, $DB_TYPE)){
60
echo "Data Manager initialization failed:<br>\n";
66
if ((empty($new_name)) || (empty($new_email))) $error .= $piError[1];
68
$new_email = eregi_replace('[^a-zA-Z0-9@_.-]', '', $new_email);
69
$new_replyto = eregi_replace('[^a-zA-Z0-9@_.-]', '', $new_replyto);
71
$new_ident["name"] = $new_name;
72
$new_ident["email"] = $new_email;
73
$new_ident["replyto"] = $new_replyto;
74
$new_ident["sig"] = $new_sig;
76
if ($dm->insert($new_ident)) echo "<!-- Inserted //-->";
77
else echo "<!-- Not inserted //-->";
80
$my_prefs["user_name"] = $new_name;
81
$my_prefs["email_address"] = $new_email;
82
$my_prefs["signature1"] = $new_sig;
83
include("../include/save_prefs.inc");
86
$new_name = $new_email = $new_replyto = $new_sig = "";
89
if (isset($edit) && ($edit_id > 0)){
91
$edit_email = eregi_replace('[^a-zA-Z0-9@_.-]', '', $edit_email);
92
$edit_replyto = eregi_replace('[^a-zA-Z0-9@_.-]', '', $edit_replyto);
94
$new_ident["name"] = $edit_name;
95
$new_ident["email"] = $edit_email;
96
$new_ident["replyto"] = $edit_replyto;
97
$new_ident["sig"] = $edit_sig;
99
if ($dm->update($edit_id, $new_ident)) echo "<!-- Updated! //-->";
100
else echo "<!-- Not updated //-->";
103
$my_prefs["user_name"] = $edit_name;
104
$my_prefs["email_address"] = $edit_email;
105
$my_prefs["signature1"] = $edit_sig;
106
include("../include/save_prefs.inc");
111
if (isset($delete) && ($edit_id > 0)){
113
if ($dm->delete($edit_id)){
116
//if default, clear it
117
if (strcmp($edit_name, $my_prefs["user_name"])==0
118
&& strcmp($edit_email, $my_prefs["email_address"])==0
119
&& strcmp($edit_sig, $my_prefs["signature1"])==0
121
$my_prefs["user_name"] = "";
122
$my_prefs["email_address"] = "";
123
$my_prefs["signature1"] = "";
124
include("../include/save_prefs.inc");
127
}else $error .= "Deletion failed<br>\n";
130
$identities_a = $dm->read();
132
$error .= $dm->error;
135
if (is_array($identities_a) && count($identities_a)>0){
136
echo '<p><table border="0" cellspacing="1" cellpadding="4" bgcolor="'.$my_colors["main_hilite"].'" width="95%">';
137
echo '<tr bgcolor="'.$my_colors["main_head_bg"].'">';
138
echo '<td colspan=5><span class="tblheader">'.$piStrings["identities"].'</span>';
139
echo '<span class="mainHeading">';
140
echo ' [<a href="pref_identities.php?user='.$user.'" class="mainHeading">'.$piStrings["new"].'</a>]';
143
echo '<tr bgcolor="'.$my_colors["main_head_bg"].'">';
145
echo "<td valign=\"top\"><span class=tblheader>".$piStrings["name"]."</span></td>";
146
echo "<td valign=\"top\"><span class=tblheader>".$piStrings["email"]."</span></td>";
147
echo "<td valign=\"top\"><span class=tblheader>".$piStrings["replyto"]."</span></td>";
148
echo "<td valign=\"top\"><span class=tblheader>".$piStrings["sig"]."</span></td>";
151
if ($my_prefs["compose_inside"]) $target="list2";
152
else $target="_blank";
154
reset($identities_a);
155
while ( list($k, $v) = each($identities_a) ){
156
$v = $identities_a[$k];
157
if ($my_prefs["user_name"]==$v["name"]
158
&& $my_prefs["email_address"]==$v["email"]
159
&& $my_prefs["signature1"]==$v["sig"])
160
$v["default"] = true;
161
echo '<tr bgcolor="'.$my_colors["main_bg"].'">';
162
echo "<td valign=\"middle\"><a href=\"pref_identities.php?user=$user&edit_id=".$v["id"]."\">".$piStrings["edit"]."</a></td>";
163
$url = "compose2.php?user=$user&sender_identity_id=".$v["id"];
164
echo "<td valign=\"middle\"><nobr><a href=\"$url\" target=\"$target\">";
165
echo $v["name"]." ".($v["default"]?$piStrings["isdef"]:"");
166
echo "</a></nobr></td>";
167
echo "<td valign=\"middle\">".$v["email"]."</td>";
168
echo "<td valign=\"middle\">".$v["replyto"]."</td>";
169
echo "<td valign=\"middle\">".nl2br(stripslashes($v["sig"]))."</td>";
177
<font color="red"><?php echo $error?></font>
182
reset($identities_a);
183
while ( list($k,$foo) = each($identities_a) ){
184
if ($identities_a[$k]["id"]==$edit_id){
185
$v = $identities_a[$k];
189
if ($my_prefs["user_name"]==$v["name"]
190
&& $my_prefs["email_address"]==$v["email"]
191
&& $my_prefs["signature1"]==$v["sig"])
192
$v["default"] = true;
194
<form method="post" action="pref_identities.php">
195
<input type="hidden" name="user" value="<?php echo $user ?>">
196
<input type="hidden" name="edit_id" value="<?php echo $edit_id ?>">
197
<table border="0" cellspacing="1" cellpadding="1" bgcolor="<?php echo $my_colors["main_hilite"]?>" width="95%">
198
<tr bgcolor="<?php echo $my_colors["main_head_bg"]?>">
200
<span class="tblheader">
201
<?php echo $piStrings["edit_ident"]?>
204
</tr><tr bgcolor="<?php echo $my_colors["main_bg"]?>">
208
<td align="right"><?php echo $piStrings["name"]?>:</td>
209
<td><input type="text" name="edit_name" value="<?php echo $v["name"]?>" size="45"></td>
212
<td align="right"><?php echo $piStrings["email"]?>:</td>
213
<td><input type="text" name="edit_email" value="<?php echo $v["email"] ?>" size="45"></td>
216
<td align="right"><?php echo $piStrings["replyto"]?>:</td>
217
<td><input type="text" name="edit_replyto" value="<?php echo $v["replyto"] ?>" size="45"></td>
220
<td align="right" valign="top"><?php echo $piStrings["sig"]?>:</td><td><textarea name="edit_sig" cols=50 rows=5><?php echo htmlspecialchars(stripslashes($v["sig"]))?></textarea></td>
223
<td align="right" valign="top"></td>
225
<input type="checkbox" name="new_default" value="1" <?php echo ($v["default"]?"checked":"") ?>>
226
<?php echo $piStrings["setdef"]?>
230
<input type="submit" name="edit" value="<?php echo $piStrings["edit"]?>">
231
<input type="submit" name="delete" value="<?php echo $piStrings["delete"]?>">
239
<form method="post" action="pref_identities.php">
240
<input type="hidden" name="user" value="<?php echo $user?>">
241
<input type="hidden" name="session" value="<?php echo $user?>">
242
<table border="0" cellspacing="1" cellpadding="1" bgcolor="<?php echo $my_colors["main_hilite"]?>" width="95%">
243
<tr bgcolor="<?php echo $my_colors["main_head_bg"]?>">
244
<td align="center"><span class="tblheader"><?php echo $piStrings["new"]?></span></td>
245
</tr><tr bgcolor="<?php echo $my_colors["main_bg"]?>">
249
<td align="right"><?php echo $piStrings["name"]?>:</td>
250
<td><input type="text" name="new_name" value="<?php echo stripslashes($new_name)?>" size="45"></td>
253
<td align="right"><?php echo $piStrings["email"]?>:</td>
254
<td><input type="text" name="new_email" value="<?php echo $new_email ?>" size="45"></td>
257
<td align="right"><?php echo $piStrings["replyto"]?>:</td>
258
<td><input type="text" name="new_replyto" value="<?php echo $new_replyto ?>" size="45"></td>
261
<td align="right" valign="top"><?php echo $piStrings["sig"]?>:</td><td><textarea name="new_sig" cols=50 rows=5><?php echo htmlspecialchars(stripslashes($new_sig))?></textarea></td>
264
<td align="right" valign="top"></td>
266
<input type="checkbox" name="new_default" value="1"> <?php echo $piStrings["setdef"]?>
270
<input type="submit" name="add" value="<?php echo $piStrings["add"]?>">