- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / intranet_email / intra-email-addrbook.php
blob330012679994d84ab039ad9d45d7ae40b0f30558
1 <?php
2 error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
3 require('./roots.php');
4 require($root_path.'include/inc_environment_global.php');
5 /**
6 * CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
7 * GNU General Public License
8 * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
9 * elpidio@care2x.org,
11 * See the file "copy_notice.txt" for the licence notice
13 define('LANG_FILE','intramail.php');
14 $local_user='ck_intra_email_user';
15 require_once($root_path.'include/inc_front_chain_lang.php');
17 /**
18 * check the info params for completeness
20 if(!isset($addr)) $addr='';
21 if(!isset($mode)) $mode='';
22 if(!isset($task)) $task='';
24 $addr=trim($addr);
25 if(($mode=='saveadd')&&($addr=='')) { header('location:intra-email-addrbook.php'.URL_REDIRECT_APPEND); exit;}
27 require_once($root_path.'include/inc_config_color.php'); // load color preferences
29 $thisfile=basename(__FILE__);
30 $breakfile='intra-email.php'.URL_APPEND.'&mode=listmail';
31 $dbtable='care_mail_private_users';
33 $linecount=0;
34 $modetypes=array('sendmail','listmail');
36 $sql="SELECT addr_book, lastcheck FROM $dbtable WHERE email='".$HTTP_COOKIE_VARS[$local_user.$sid]."'";
37 if($ergebnis=$db->Execute($sql))
39 if($rows=$ergebnis->RecordCount())
41 $content=$ergebnis->FetchRow();
42 switch($task)
45 // if new address save new address
46 case 'saveadd':
48 $buf="n=$name&a=$alias&e=$addr@$dept\r\n";
49 // $content[addr_book]=trim($content[addr_book]);
50 if($content['addr_book']=="") $content['addr_book']=$buf;
51 else $content[addr_book].="_".$buf;
52 $sql="UPDATE $dbtable SET addr_book='".$content['addr_book']."' , lastcheck='".$content['lastcheck']."'
53 WHERE email='".$HTTP_COOKIE_VARS[$local_user.$sid]."'";
54 $db->BeginTrans();
55 $ok=$db->Execute($sql);
56 if($ok&&$db->CommitTrans())
58 header("location:intra-email-addrbook.php".URL_REDIRECT_APPEND."&l2h=$l2h&folder=$folder&mode=$mode");
59 exit;
60 } else {
61 $db->RollbackTrans();
62 echo "$LDDbNoUpdate<br>$sql";
64 break;
66 // if mode is delete entry
67 case 'delete':
68 { //$content[addr_book]=strtolower($content[addr_book]);
69 $inb=explode("_",trim($content[addr_book]));
70 for($i=0;$i<sizeof($inb);$i++)
72 for($n=0;$n<$maxrow;$n++)
74 $delbuf="del$n";
75 if(!$$delbuf) continue;
76 $delbuf2=trim(strtr($$delbuf,"+"," "));
77 //echo "$delbuf2<br>$inb[$i]<br>";
78 //echo "vor comp $delbuf2<br>$inb[$i]<br>";
79 if(!strcmp($delbuf2,strtolower(trim($inb[$i]))))
81 //echo "nach comp $delbuf2<br>$inb[$i]<br>";
82 $trash=array_splice($inb,$i,1);//echo "trash <br>";
83 $i--;
84 break;
88 $content['addr_book']=implode('_',$inb);
89 $sql="UPDATE $dbtable SET addr_book='".trim($content['addr_book'])."', lastcheck='".$content['lastcheck']."'
90 WHERE email='".$HTTP_COOKIE_VARS[$local_user.$sid]."'";
91 $db->BeginTrans();
92 $ok=$db->Execute($sql);
93 if($ok&&$db->CommitTrans()) {
94 header("location:intra-email-addrbook.php".URL_REDIRECT_APPEND."&l2h=$l2h&folder=$folder&mode=$mode");
95 exit;
96 } else {
97 $db->RollbackTrans();
98 echo "$LDDbNoUpdate<br>$sql";
100 break;
102 } // end of switch mode
104 } //end of if rows
105 }else { echo "$LDDbNoRead<br>$sql"; }
107 # Start Smarty templating here
109 * LOAD Smarty
112 # Note: it is advisable to load this after the inc_front_chain_lang.php so
113 # that the smarty script can use the user configured template theme
115 require_once($root_path.'gui/smarty_template/smarty_care.class.php');
116 $smarty = new smarty_care('common');
118 # Title in toolbar
119 $smarty->assign('sToolbarTitle',"$LDIntraEmail - $LDAddrBook");
121 # href for help button
122 $smarty->assign('pbHelp',"javascript:gethelp('intramail.php','address','$mode','$folder')");
124 # href for close button
125 $smarty->assign('breakfile',$breakfile);
127 # Window bar title
128 $smarty->assign('title',"$LDIntraEmail - $LDAddrBook");
130 # Set body onLoad javascript
131 if($task=="newadd") $smarty->assign('sOnLoadJs','onLoad="document.newform.name.focus();"');
133 # Collect extra javascript code
135 ob_start();
139 <script language="javascript" >
140 <!--
142 function newAddr()
144 document.addrlist.task.value="newadd";
145 document.addrlist.submit();
148 function chkAddress(d)
150 if(d.addr.value=="")
152 alert("<?php echo $LDNoEmailAddress; ?>");
153 d.addr.focus();
154 return false;
156 return true;
159 function chkDelete(d,m)
161 for (i=0;i<m;i++){
162 if(eval("d.del"+i+".checked"))
163 if(confirm("<?php echo $LDConfirmDeleteAddr ?>")) return true;
164 else {
165 for (i=0;i<m;i++) if(eval("d.del"+i+".checked")) eval("d.del"+i+".checked=false");
166 d.sel_all.checked=false;
167 break;
170 return false;
173 function selectAll(s,m)
175 if(s.checked) v="true"; else v="false";
176 d=document.addrlist;
177 for(i=0;i<m;i++) eval("d.del"+i+".checked="+v);
180 // -->
181 </script>
183 <?php
185 $sTemp = ob_get_contents();
186 ob_end_clean();
188 $smarty->append('JavaScript',$sTemp);
190 # Start buffering page output
192 ob_start();
194 echo '
195 &nbsp; <b><a href="intra-email.php'.URL_APPEND.'&mode=listmail">'.$LDInbox.'</a> |
196 <a href="intra-email.php'.URL_APPEND.'&mode=compose">'.$LDNewEmail.'</a> | '.$LDAddrBook.' |
197 <a href="javascript:gethelp(\'intramail.php\',\'address\',\''.$mode.'\',\''.$folder.'\')">'.$LDHelp.'</a>|
198 <a href="intra-email-pass.php'.URL_APPEND.'">'.$LDLogout.'</a></b>
199 <hr color=#000080>
200 &nbsp; <FONT color="#800000">'.$HTTP_COOKIE_VARS[$local_user.$sid].'</font>';
203 <?php if($task=="newadd") : ?>
204 <p><ul>
205 <form name=newform action="<?php echo $thisfile ?>" method=post onSubmit="return chkAddress(this)">
206 <FONT face="Verdana,Helvetica,Arial" size=2 color="#000080"><b><?php echo $LDSaveNewAddr ?></b></font>
207 <table border=0>
208 <tr bgcolor=#f9f9f9>
209 <td>&nbsp;<?php echo "$LDName, $LDFirstName" ?>:</td>
210 <td colspan=2><input type="text" name="name" size=25 maxlength=40 value="<?php echo $name ?>">
211 </td>
212 </tr>
213 <tr bgcolor=#f9f9f9>
214 <td>&nbsp;<?php echo "$LDAlias/$LDShortName" ?>:</td>
215 <td colspan=2><input type="text" name="alias" size=25 maxlength=40 value="<?php echo $alias ?>" ></td>
216 </tr>
217 <tr bgcolor=#f9f9f9>
218 <td>&nbsp;<?php echo $LDEmailAddr ?>:<br></td>
219 <td><input type="text" name="addr" size=25 maxlength=40 value="<?php echo $addr ?>"></td>
220 <td><FONT face="Verdana,Helvetica,Arial" size=2 color="#800000"><b>@</b>
221 <select name="dept" size=1>
223 <?php require($root_path."include/inc_email_domains_options.php");
224 for ($j=0;$j<sizeof($email_domains);$j++)
226 echo '
227 <option value="'.$email_domains[$j].'"';
228 if ($dept==$email_domains[$j]) echo "selected";
229 echo '>'.$email_domains[$j].'</option>';
232 </select>
233 </td>
234 </tr>
235 <tr >
236 <td><input type="submit" value="<?php echo $LDSave ?>"></td>
237 <td colspan=2><input type="reset" value="<?php echo $LDJustReset ?>">
238 <input type="button" value="<?php echo $LDCancel ?>" onClick="window.location.replace('intra-email-addrbook.php?sid=<?php echo "$sid&lang=$lang&mode=$mode&l2h=$l2h&folder=$folder" ?>')"></td>
239 </tr>
240 </table>
241 <input type="hidden" name="sid" value="<?php echo $sid ?>">
242 <input type="hidden" name="lang" value="<?php echo $lang ?>">
243 <input type="hidden" name="task" value="saveadd">
244 <input type="hidden" name="l2h" value="<?php echo $l2h ?>">
245 <input type="hidden" name="folder" value="<?php echo $folder ?>">
246 <input type="hidden" name="mode" value="<?php echo $mode ?>">
248 </form>
249 </ul>
250 <hr color=#000080>
251 <?php endif; ?>
253 <?php
254 // ******************************** show address book***************************************
256 $arrlist=explode("_",strtolower($content[addr_book]));
257 if($l2h) rsort($arrlist); else sort($arrlist);
258 reset($arrlist);
259 $maxrow=sizeof($arrlist);
260 if(($maxrow==1)&&($arrlist[0]=="")) $maxrow=0;
262 echo '</b></font>
263 <form name="addrlist" action="intra-email-addrbook.php" method="post" onSubmit="return chkDelete(this,'.sizeof($arrlist).')">
265 if ($maxrow>6) echo '
266 <input type="submit" value="'.$LDDelete.'"> &nbsp; &nbsp; <input type="button" value="'.$LDAddNewAddr.'" onClick="newAddr()">
267 <br>';
268 echo ' <table border=0 cellspacing=0 width=100% cellpadding=0>
269 <tr ><td colspan=6 height=1><img src="'.$root_path.'gui/img/common/default/pixel.gif" border=0 height=3 width=1></td></tr>
270 <tr class="adm_list_titlebar">
271 <td>&nbsp;</td>
272 <td> <input type="checkbox" name="sel_all" value="1" onClick="selectAll(this,'.$maxrow.')"><br>
273 </td>
274 <td>';
275 if($l2h) echo '<a href="'.$thisfile.''.URL_APPEND.'&l2h=0&mode='.$mode.'&folder='.$folder.'" title="'.$LDSortName.'"><img src="'.$root_path.'gui/img/common/default/arw_down.gif" '; else echo '<a href="'.$thisfile.''.URL_APPEND.'&l2h=1&mode='.$mode.'&folder='.$folder.'" title="'.$LDSortName.'"><img src="'.$root_path.'gui/img/common/default/arw_up.gif" ';
276 echo '
277 width=12 height=20 border=0 align=absmiddle alt="'.$LDSortName.'">&nbsp;'.$LDName.','.$LDFirstName.':</td>
278 <td>&nbsp;&nbsp;'.$LDAlias.'/'.$LDShortName.':
279 </td>
280 <td>'.$LDEmailAddr.':</font></a></td>
281 </tr>';
282 for($i=0;$i<sizeof($arrlist);$i++)
284 parse_str(trim($arrlist[$i]),$minfo);
285 if(!isset($minfo['e'])) continue;
286 //$buf="intra-email-read.php?sid=$sid&ua=$ck_intra_email_user&s_stamp=$minfo[t]&read=$minfo[r]&from=$minfo[f]&subj=".strtr($minfo[s]," ","+")."&date=".strtr($minfo[d]," ","+")."&size=$minfo[z]&l2h=$l2h&folder=$folder";
287 $delbuf="n=$minfo[n]&a=$minfo[a]&e=$minfo[e]";
288 echo ' <tr bgcolor="#ffffff">
289 <td>&nbsp;</td>
290 <td> <input type="checkbox" name="del'.$i.'" value="'.strtr($delbuf," ","+").'"><br>
291 </td>
292 <td>&nbsp; &nbsp; &nbsp; <a href="#" title="'.$LDMoreInfo.'">'.ucwords($minfo[n]).'</a></td>
293 <td>&nbsp;&nbsp;'.$minfo[a].'</td>
294 <td>&nbsp;&nbsp;'.$minfo[e].'</td>
295 </tr>
296 <tr ><td bgcolor="#66aace" colspan=6 height=1><img src="'.$root_path.'gui/img/common/default/pixel.gif" border=0 height=1 width=1></td></tr>';
298 echo '
299 <tr ><td colspan=6 height=1><img src="'.$root_path.'gui/img/common/default/pixel.gif" border=0 height=3 width=1></td></tr>
300 </table>';
301 if($maxrow) echo '
302 <input type="submit" value="'.$LDDelete.'"> ';
303 echo '&nbsp; &nbsp; <input type="button" value="'.$LDAddNewAddr.'" onClick=newAddr()>
304 <br><input type="hidden" name="task" value="delete">
305 <input type="hidden" name="maxrow" value="'.$maxrow.'">
306 <input type="hidden" name="sid" value="'.$sid.'">
307 <input type="hidden" name="lang" value="'.$lang.'">
308 <input type="hidden" name="l2h" value="'.$l2h.'">
309 <input type="hidden" name="folder" value="'.$folder.'">
310 <input type="hidden" name="mode" value="'.$mode.'">
311 </form>
313 echo ' &nbsp; &nbsp;
314 <font size=1><a href="intra-email.php'.URL_APPEND.'&mode='.$mode.'&l2h='.$l2h.'&folder='.$folder.'">
315 <img '.createComIcon($root_path,'l_arrowgrnsm.gif','0','middle').'> '.$LDBack2.' ';
316 if($mode=="compose") echo $LDWriteEmail;
317 else
318 switch($folder)
320 case "inbox": echo $LDInbox; break;
321 case "sent": echo $LDSent; break;
322 case "drafts": echo $LDDrafts; break;
323 case "trash": echo $LDRecycle; break;
325 echo '</a></font>';
328 $sTemp = ob_get_contents();
329 ob_end_clean();
331 # Assign to main template object
332 $smarty->assign('sMainFrameBlockData',$sTemp);
335 * show Template
337 $smarty->display('common/mainframe.tpl');