添加到 trunk

+YUCHENG HU+



git-svn-id: https://svn.code.sf.net/p/hawebs/svn@110 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-10 19:36:10 +00:00
parent 99825fef8a
commit bcc474fefb
63 changed files with 5349 additions and 0 deletions
@@ -0,0 +1,93 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
global $current_user;
require_once('Smarty_setup.php');
require_once('modules/Leads/Leads.php');
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once('data/Tracker.php');
require_once('include/upload_file.php');
require_once('modules/Webmails/Webmails.php');
require_once('modules/Webmails/MailParse.php');
global $log;
global $app_strings;
global $mod_strings;
if($_REQUEST["record"]) {$mailid=vtlib_purify($_REQUEST["record"]);} else {$mailid=vtlib_purify($_REQUEST["mailid"]);}
$mailInfo = getMailServerInfo($current_user);
$temprow = $adb->fetch_array($mailInfo);
$imapServerAddress=$temprow["mail_servername"];
$start_message=vtlib_purify($_REQUEST["start_message"]);
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=vtlib_purify($_REQUEST["mailbox"]);} else {$mailbox="INBOX";}
global $mbox;
$mbox = getImapMbox($mailbox,$temprow);
$email = new Webmails($mbox, $mailid);
$from = $email->from;
$subject=$email->subject;
$date=$email->date;
$to=$email->to;
$cc_list=$email->cc_list;
$reply_to=$email->replyTo;
$block["Leads"]= "";
global $adb;
if($email->relationship != 0 && $email->relationship["type"] == "Leads") {
$q = "SELECT vtiger_leaddetails.firstname, vtiger_leaddetails.lastname, vtiger_leaddetails.email, vtiger_leaddetails.company, vtiger_crmentity.smownerid from vtiger_leaddetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid WHERE vtiger_leaddetails.leadid=?";
$rs = $adb->pquery($q, array($email->relationship["id"]));
$block["Leads"]["header"]= array("0"=>"First Name","1"=>"Last Name","2"=>"Company Name","3"=>"Email Address","4"=>"Assigned To");
$block["Leads"]["entries"]= array("0"=>array($adb->query_result($rs,0,'firstname'),"1"=>$adb->query_result($rs,0,'lastname'),2=>$adb->query_result($rs,0,'company'),3=>$adb->query_result($rs,0,'email'),4=>$adb->query_result($rs,0,'smownerid')));
}
$block["Contacts"]= "";
if($email->relationship != 0 && $email->relationship["type"] == "Contacts") {
$q = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_contactdetails.email, vtiger_contactdetails.title, vtiger_crmentity.smownerid from vtiger_contactdetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid WHERE vtiger_contactdetails.contactid=?";
$rs = $adb->pquery($q, array($email->relationship["id"]));
$block["Contacts"]["header"]= array("0"=>"First Name","1"=>"Last Name","2"=>"Title","3"=>"Email Address","4"=>"Assigned To");
$block["Contacts"]["entries"]= array("0"=>array($adb->query_result($rs,0,'firstname'),"1"=>$adb->query_result($rs,0,'lastname'),2=>$adb->query_result($rs,0,'title'),3=>$adb->query_result($rs,0,'email'),4=>$adb->query_result($rs,0,'smownerid')));
}
$block["Accounts"]= "";
if($email->relationship != 0 && $email->relationship["type"] == "Accounts") {
$q = "SELECT acccount.accountname, vtiger_account.email1, vtiger_account.website, vtiger_account.industry, vtiger_crmentity.smownerid from vtiger_account left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_account.accountid=?";
$rs = $adb->pquery($q, array($email->relationship["id"]));
$block["Accounts"]["header"]= array("0"=>"Account Name","1"=>"Email","2"=>"Web Site","3"=>"Industry","4"=>"Assigned To");
$block["Accounts"]["entries"]= array("0"=>array($adb->query_result($rs,0,'accountname'),"1"=>$adb->query_result($rs,0,'email'),2=>$adb->query_result($rs,0,'website'),3=>$adb->query_result($rs,0,'industry'),4=>$adb->query_result($rs,0,'smownerid')));
}
global $mod_strings;
global $app_strings;
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
$smarty = new vtigerCRM_Smarty;
$smarty->assign("CATEGORY","My Home Page");
$smarty->assign("id",vtlib_purify($_REQUEST["record"]));
$smarty->assign("NAME","From: ".$from);
$smarty->assign("RELATEDLISTS", $block);
$smarty->assign("SINGLE_MOD","Webmails");
$smarty->assign("MODULE", "Webmails");
$smarty->assign("ID",vtlib_purify($_REQUEST["record"]));
$smarty->assign("MOD",$mod_strings);
$smarty->assign("APP",$app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
$smarty->display("RelatedLists.tpl");
?>
@@ -0,0 +1,37 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
require_once('include/utils/UserInfoUtil.php');
require_once("modules/Webmails/Webmails.php");
require_once("modules/Webmails/MailBox.php");
global $app_strings;
global $mod_strings;
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") { $mailbox=vtlib_purify($_REQUEST["mailbox"]);} else { $mailbox = "INBOX";}
if(isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != "") { $mailid=vtlib_purify($_REQUEST["mailid"]);} else { echo "ERROR";flush();exit();}
global $MailBox;
$MailBox = new MailBox($mailbox);
$webmail = new Webmails($MailBox->mbox,$mailid);
$elist = $MailBox->mailList["overview"][($mailid-1)];
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0" class="previewWindow"><tr>';
echo '<td>';
echo '</td></tr>';
$array_tab = Array();
$webmail->loadMail($array_tab);
echo '<tr><td align="center"><iframe src="index.php?module=Webmails&action=body&fullview=true&mailid='.$mailid.'&mailbox='.$mailbox.'" width="100%" height="600" frameborder="0" style="border:1px solid gray">'.$mod_strings['LBL_NO_IFRAMES_SUPPORTED'].'</iframe></td></tr>';
echo '</table>';
?>
@@ -0,0 +1,35 @@
<?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
function get_validate_record_js() {
}
function get_new_record_form () {
$the_form = '<table width="100%" class="leftFormTable" cellpadding="0" cellspacing="0" border="0" align="center"><tbody><tr>';
$the_form .= '<td class="leftFormHeader" align="left" height="20" nowrap="nowrap" valign="middle">Folders</td></tbody></tr></table>';
$the_form .= '<table width="100%" cellpadding="2" cellspacing="0" border="0" align="center" class="leftFormBorder1"><tr> <form><td nowrap>';
$the_boxes=array();
if (is_array($list)) {
foreach ($list as $key => $val) {
$the_boxes[] = $val->name;
}
}
sort($the_boxes);
for($i=0;$i<count($the_boxes);$i++) {
$the_form .= "<a href='index.php?module=Webmails&action=index&mailbox=".preg_replace(array("/\{.*?\}/i"),array(""),$the_boxes[$i])."' id='".$the_boxes[$i]."'>".preg_replace(array("/\{.*?\}/i"),array(""),$the_boxes[$i])."</a><br>";
}
$the_form .= get_left_form_footer();
$the_form .= get_validate_record_js();
return $the_form;
}
?>
@@ -0,0 +1,465 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {
$mailbox=vtlib_purify($_REQUEST["mailbox"]);
} else {
$mailbox="INBOX";
}
if($_REQUEST["start"] && $_REQUEST["start"] != "") {
$start=vtlib_purify($_REQUEST["start"]);
} else {
$start="1";
}
$show_hidden=vtlib_purify($_REQUEST["show_hidden"]);
global $current_user;
//checking the imap support in php
if(!function_exists('imap_open')) {
echo "<strong>".$mod_strings['LBL_ENABLE_IMAP_SUPPORT']."</strong>";
exit();
}
require_once('Smarty_setup.php');
require_once("data/Tracker.php");
require_once('include/logging.php');
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once("modules/Webmails/MailBox.php");
require_once("modules/Webmails/Webmails.php");
require_once("modules/Webmails/MailParse.php");
$MailBox = new MailBox($mailbox);
// Check for a valid mailbox and also make sure the needed php_imap module is installed
$mods = parsePHPModules();
if(!$MailBox->mbox || !isset($mods["imap"]) || $mods["imap"] == "") {
echo "<center><font color='red'><h3>".$mod_strings['LBL_CONFIGURE_MAIL_SETTINGS']."</h3></font></center>";
exit();
}
// Set the system into degraded service mode where needed
$degraded_service='false';
if($MailBox->mail_protocol == "imap" || $MailBox->mail_protocol == "pop3")
$degraded_service='true';
if($_POST["command"] == "check_mbox_all") {
exit();
$boxes = array();
$i=0;
foreach ($_SESSION["mailboxes"] as $key => $val) {
$MailBox = new MailBox($key);
$box = imap_status($MailBox->mbox, "{".$MailBox->imapServerAddress."}".$key, SA_ALL);
$boxes[$i]["name"] = $key;
if($val == $box->unseen)
$boxes[$i]["newmsgs"] = 0;
elseif($val < $box->unseen) {
$boxes[$i]["newmsgs"] = ($box->unseen-$val);
$_SESSION["mailboxes"][$key] = $box->unseen;
} else {
$boxes[$i]["newmsgs"] = 0;
$_SESSION["mailboxes"][$key] = $box->unseen;
}
$i++;
imap_close($MailBox->mbox);
}
$ret = '';
if(count($boxes) > 0) {
$ret = '{"msgs":[';
for($i=0,$num=count($boxes);$i<$num;$i++) {
$ret .= '{"msg":';
$ret .= '{';
$ret .= '"box":"'.$boxes[$i]["name"].'",';
$ret .= '"newmsgs":"'.$boxes[$i]["newmsgs"].'"}';
if(($i+1) == $num)
$ret .= '}';
else
$ret .= '},';
}
$ret .= ']}';
}
echo $ret;
flush();
exit();
}
//This is invoked from Webmails.js as a result of the periodic event function call, checks only for NEW mails; this in turn checks for new mails in all the mailboxes
if($_POST["command"] == "check_mbox") {
$adb->println("Inside check_mbox AJAX command");
$search = imap_search($MailBox->mbox, 'NEW');
//if($search === false) {echo "failed";flush();exit();}
$adb->println("imap_search($MailBox->mbox, $criteria) ===> ");
$adb->println($search);
$data = imap_fetch_overview($MailBox->mbox,implode(',',$search));
$num=sizeof($data);
$adb->println("fetched data using imap_fetch_overview ==>");
$adb->println($data);
$ret = '';
if($num > 0) {
$ret = '{"mails":[';
for($i=0;$i<$num;$i++)
{
//Added condition to avoid show the deleted mails and readed mails
if($data[$i]->deleted == 0)// && $data[$i]->seen == 0)
{
$ret .= '{"mail":';
$ret .= '{';
$ret .= '"mailid":"'.$data[$i]->msgno.'",';
$ret .= '"subject":"'.substr($data[$i]->subject,0,40).'",';
$ret .= '"date":"'.substr($data[$i]->date,0,30).'",';
$ret .= '"from":"'.substr($data[$i]->from,0,20).'",';
$ret .= '"to":"'.$data[$i]->to.'",';
echo ' to field is ' .$data[$i]->to;
$email = new Webmails($MailBox->mbox,$data[$i]->msgno);
if($email->has_attachments)
$ret .= '"attachments":"1"}';
else
$ret .= '"attachments":"0"}';
if(($i+1) == $num)
$ret .= '}';
else
$ret .= '},';
}
}
$ret .= ']}';
$adb->println("Ret Value ==> $ret");
}
echo $ret;
flush();
imap_close($MailBox->mbox);
exit();
}
?>
<script language="JavaScript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript">
// Pass our PHP variables to js.
<?php if($degraded_service == 'true')
{
echo 'var degraded_service="true";';
}
else
{
echo 'var degraded_service="false";';
};
?>
var mailbox = "<?php echo $MailBox->mailbox;?>";
var box_refresh=<?php echo $MailBox->box_refresh;?>;
var webmail = new Array();
var webmail2 = new Array();
var timer;
var command;
var id;
var preview_id='';
var move_mail,change_box,mvmbox;
var theme = "<?php echo $theme;?>";
addOnloadEvent(function() {
window.setTimeout("periodic_event()",box_refresh);
}
);
</script>
<script language="JavaScript" type="text/javascript" src="modules/Webmails/Webmails.js"></script>
<?php
global $displayed_msgs;
// AJAX commands (should be moved)
if($_POST["command"] == "move_msg" && $_POST["ajax"] == "true") {
if(isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != '')
{
$mailids = explode(':',$_REQUEST["mailid"]);
}
foreach($mailids as $mailid)
{
imap_mail_move($MailBox->mbox,$mailid,$_REQUEST["mvbox"]);
}
imap_expunge($MailBox->mbox);
imap_close($MailBox->mbox);
$MailBox = new MailBox($mailbox);
$elist = $MailBox->mailList;
$num_mails = $elist['count'];
$start_page = ceil($num_mails/$MailBox->mails_per_page);
imap_close($MailBox->mbox);
echo "start=".$start_page.";";
echo "id=".$mailid.";";
flush();
exit();
}
// Function to remove directories used for tmp attachment storage
function SureRemoveDir($dir) {
if(!$dh = @opendir($dir)) return;
while (($obj = readdir($dh))) {
if($obj=='.' || $obj=='..') continue;
if (!@unlink($dir.'/'.$obj)) {
SureRemoveDir($dir.'/'.$obj);
} else {
$file_deleted++;
}
}
if (@rmdir($dir)) $dir_deleted++;
}
$save_path=$root_directory.'modules/Webmails/tmp';
$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
// Get the list of mails for this mailbox
$elist = $MailBox->mailList;
$numEmails = $elist["count"];
$headers = $elist["headers"];
$mails_per_page = $MailBox->mails_per_page;
// Calculate paging information ahead before retrieving overviews
if($start == 1 || $start == "") {
$start_message=$numEmails;
if($numEmails > $mails_per_page) $end_message = $start_message - $mails_per_page;
else $end_message = $start_message - $numEmails;
} else {
$start_message=($numEmails-(($start-1)*$mails_per_page));
$end_message = ($numEmails-(($start*2-1)*$mails_per_page));
}
// If in search mode, load overview of all the available emails
if(isset($_REQUEST["search"])) {
// TODO: Navigating when search is used needs to be added
$MailBox->loadOverviewList(1, $numEmails);
} else {
// For normal listview, fetch only required mail overview
$MailBox->loadOverviewList($start_message, $end_message);
}
// Fetch meta-info again after overview is loaded, for further process
$elist = $MailBox->mailList;
$headers = $elist["headers"];
// END
$c=$numEmails;
if(!isset($_REQUEST["search"])) {
$numPages = ceil($numEmails/$MailBox->mails_per_page);
if($numPages > 1) {
if($start != 1){
$navigationOutput = "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',1);\" ><img src='modules/Webmails/images/start.gif' border='0'></a>&nbsp;&nbsp;";
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".($start-1).");\" ><img src='modules/Webmails/images/previous.gif' border='0'></a> &nbsp;";
}
if($start <= ($numPages-1)){
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".($start+1).");\" ><img src='modules/Webmails/images/next.gif' border='0'></a>&nbsp;&nbsp;";
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".$numPages.");\"><img src='modules/Webmails/images/end.gif' border='0'></a> &nbsp;";
}
}
}
if(isPermitted('Contacts','EditView','') == 'yes')
$show_qualify = "yes";
else
$show_qualify = "no";
$overview=$elist["overview"];
?>
<!-- MAIN MSG LIST TABLE -->
<script type="text/javascript">
// Here we are creating a multi-dimension array to store mail info
// these are mainly used in the preview window and could be ajaxified/
// during the preview window load instead.
var msgCount = "<?php echo $numEmails;?>";
var start = "<?php echo vtlib_purify($_REQUEST['start']);?>";
var gselected_mail = '';
var showQualify = "<?php echo $show_qualify;?>";
<?php
$mails = array();
if (is_array($overview))
{
foreach ($overview as $val)
{
$mails[$val->msgno] = $val;
//$hdr = @imap_headerinfo($MailBox->mbox, $val->msgno);
//Added to get the UTF-8 string - 30-11-06 - Mickie
//we have to do this utf8 decode for the fields which may contains special characters -- Mickie - 02-02-07
$val->from = utf8_decode(utf8_encode(imap_utf8(addslashes($val->from))));
$val->to = utf8_decode(utf8_encode(imap_utf8(addslashes($val->to))));
$val->subject = utf8_decode(utf8_encode(imap_utf8($val->subject)));
$to = str_replace("<",":",$val->to);
$to_list = str_replace(">","",$to);
$from = str_replace("<",":",$val->from);
$from_list = str_replace(">","",$from);
//$cc = str_replace("<",":",$hdr->ccaddress);
//$cc_list = str_replace(">","",$cc);
$cc_list = '';
?>
webmail[<?php echo $val->msgno;?>] = new Array();
webmail[<?php echo $val->msgno;?>]["from"]="<?php echo addslashes($from_list);?>";
webmail[<?php echo $val->msgno;?>]["to"]="<?php echo addslashes($to_list);?>";
webmail[<?php echo $val->msgno;?>]["subject"]="<?php echo addslashes($val->subject);?>";
webmail[<?php echo $val->msgno;?>]["date"]="<?php echo addslashes($val->date);?>";
webmail[<?php echo $val->msgno;?>]["cc"]="<?php echo addslashes($cc_list); ?>";
<?php
}
}
echo "</script>";
$search_fields = Array("SUBJECT","BODY","TO","CC","BCC","FROM");
$listview_header = array("<th class='tableHeadBg' width='10%'>".$mod_strings['LBL_INFO']."</th>","<th class='tableHeadBg' width='45%'>".$mod_strings['LBL_LIST_SUBJECT']."</th>","<th class='tableHeadBg' width='25%'>".$mod_strings['LABEL_DATE']."</th>","<th class='tableHeadBg' width='10%'>".$mod_strings['LABEL_FROM']."</th>","<th class='tableHeadBg'>".$mod_strings['LBL_DEL']."</th>");
$listview_entries = array();
$displayed_msgs=0;
$info = imap_mailboxmsginfo($MailBox->mbox);
$unread_msgs = $info->Unread;
//$new_msgs=0;
if(($numEmails) <= 0)
$listview_entries[0][] = '<td colspan="6" width="100%" align="center"><b>'.$mod_strings['LBL_NO_EMAILS'].'</b></td>';
else {
if(isset($_REQUEST["search"]) && trim($_REQUEST["search_input"]) != '') {
$searchstring = vtlib_purify($_REQUEST["search_type"]).' "'.vtlib_purify($_REQUEST["search_input"]).'"';
//echo $searchstring."<br>";
$searchlist = Array();
$searchlist = imap_search($MailBox->mbox,$searchstring);
if(is_array($searchlist))
{
$num_searches = count($searchlist);
$c=$numEmails;
}
$search_count = $num_searches;
while ($i<=$c) {
if(is_array($searchlist)) {
for($l=0;$l<$num_searches;$l++) {
if($mails[$start_message]->msgno == $searchlist[$l])
$listview_entries[] = show_msg($mails,$start_message);
}
}
$i++;
$start_message--;
}
}else
{
$i=1;
while ($i<=$c) {
if($start_message > 0)
{
$listview_entries[] = show_msg($mails,$start_message);
if($displayed_msgs == $MailBox->mails_per_page) {break;}
}
$i++;
$start_message--;
}
}
flush();
// MAIN LOOP
// Main loop to create listview entries
}
$search_html = '<select name="optionSel" class="importBox" id="search_type">';
foreach($search_fields as $searchfield)
{
if($_REQUEST['search_type'] == $searchfield)
$search_html .= '<option selected value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
else
$search_html .= '<option value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
}
$search_html .= '</select>';
// Build folder list and move_to dropdown box
$list = imap_getmailboxes($MailBox->mbox, "{".$MailBox->imapServerAddress."}", "*");
sort($list);
$i=0;
if (is_array($list)) {
$boxes = '<select name="mailbox" id="mailbox_select" onChange="move_messages();">';
$boxes .= '<option value="move_to" SELECTED>'.$mod_strings['LBL_MOVE_TO'].'</option>';
foreach ($list as $key => $val) {
$tmpval = preg_replace(array("/\{.*?\}/i"),array(""),$val->name);
if(preg_match("/trash/i",$tmpval))
$img = "webmail_trash.gif";
elseif($_REQUEST["mailbox"] == $tmpval)
$img = "opened_folder.gif";
else
$img = "folder.gif";
$i++;
if($_REQUEST["mailbox"] == '')
$_REQUEST["mailbox"] = 'INBOX';
if ($_REQUEST["mailbox"] == $tmpval) {
/* if($tmpval != "INBOX")
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
*/
if(!isset($_SESSION["folder_image_path"]))
$_SESSION["folder_image_path"] = $image_path;
$_SESSION["mailboxes"][$tmpval] = $unread_msgs;
if($tmpval[0] != "."){
if($numEmails==0) {$num=$numEmails;} else {$num=($numEmails-1);}
$folders .= '<li style="padding-left:0px;"><img src="themes/images/'.$img.'"align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="small">'.$tmpval.'</a>&nbsp;&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
if($unread_msgs > 0)
$folders .= '(<span id="'.$tmpval.'_unread">'.$unread_msgs.'</span>)</span>&nbsp;&nbsp;<span id="remove_'.$tmpval.'" style="position:relative;display:none">Remove</span></li>';
else
$folders .='</span></li>';
}
} else {
$box = imap_status($MailBox->mbox, "{".$MailBox->imapServerAddress."}".$tmpval, SA_ALL);
$_SESSION["mailboxes"][$tmpval] = $box->unseen;
if($tmpval[0] != ".") {
if($box->messages==0) {$num=$box->messages;} else {$num=($box->messages-1);}
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
$folders .= '<li ><img src="themes/images/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="small">'.$tmpval.'</a>&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
if($box->unseen > 0)
$folders .= '(<span id="'.$tmpval.'_unread">'.$box->unseen.'</span>)</span></li>';
else
$folders .='</span></li>';
}
}
}
$boxes .= '</select>';
}
imap_close($MailBox->mbox);
$smarty = new vtigerCRM_Smarty;
$smarty->assign("SEARCH_VALUE",vtlib_purify($_REQUEST['search_input']));
$smarty->assign("USERID", $current_user->id);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMAGE_PATH",$image_path);
$smarty->assign("LISTENTITY", $listview_entries);
$smarty->assign("LISTHEADER", $listview_header);
$smarty->assign("SEARCH_HTML", $search_html);
$smarty->assign("MODULE","Webmails");
$smarty->assign("SINGLE_MOD",'Webmails');
$smarty->assign("BUTTONS",$other_text);
$smarty->assign("CATEGORY","My Home Page");
$smarty->assign("NAVIGATION", $navigationOutput);
$smarty->assign("FOLDER_SELECT", $boxes);
if(isset($_REQUEST['search']))
$smarty->assign("NUM_EMAILS", $search_count);
else
$smarty->assign("NUM_EMAILS", $numEmails);
$smarty->assign("MAILBOX", $MailBox->mailbox);
$smarty->assign("ACCOUNT", $MailBox->display_name);
$smarty->assign("BOXLIST",$folders);
$smarty->assign("DEGRADED_SERVICE",$degraded_service);
$smarty->assign("THEME",$theme);
$smarty->display("Webmails.tpl");
?>
@@ -0,0 +1,263 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {
$mailbox=$_REQUEST["mailbox"];
} else {
$mailbox="INBOX";
}
if($_REQUEST["start"] && $_REQUEST["start"] != "") {
$start=vtlib_purify($_REQUEST["start"]);
} else {
$start="1";
}
$show_hidden=vtlib_purify($_REQUEST["show_hidden"]);
global $current_user;
require_once('Smarty_setup.php');
require_once("data/Tracker.php");
require_once('include/logging.php');
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once("modules/Webmails/MailBox.php");
require_once("modules/Webmails/Webmails.php");
require_once("modules/Webmails/MailParse.php");
$MailBox = new MailBox($mailbox);
// Check for a valid mailbox and also make sure the needed php_imap module is installed
$mods = parsePHPModules();
if(!$MailBox->mbox || !isset($mods["imap"]) || $mods["imap"] == "") {
echo "<center><font color='red'><h3>".$mod_strings['LBL_CONFIGURE_MAIL_SETTINGS']."</h3></font></center>";
exit();
}
// Set the system into degraded service mode where needed
$degraded_service='false';
if($MailBox->mail_protocol == "imap" || $MailBox->mail_protocol == "pop3")
$degraded_service='true';
$save_path=$root_directory.'modules/Webmails/tmp';
$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
// Get the list of mails for this mailbox
$elist = $MailBox->mailList;
$numEmails = $elist["count"];
$headers = $elist["headers"];
$mails_per_page = $MailBox->mails_per_page;
// Calculate paging information ahead before retrieving overviews
if($start == 1 || $start == "") {
$start_message=$numEmails;
if($numEmails > $mails_per_page) $end_message = $start_message - $mails_per_page;
else $end_message = $start_message - $numEmails;
} else {
$start_message=($numEmails-(($start-1)*$mails_per_page));
$end_message = ($numEmails-(($start)*$mails_per_page));
if($end_message < 0) $end_message = 0;
}
// If in search mode, load overview of all the available emails
if(isset($_REQUEST["search"])) {
// TODO: Navigating when search is used needs to be added
$MailBox->loadOverviewList(1, $numEmails);
} else {
// For normal listview, fetch only required mail overview
$MailBox->loadOverviewList($start_message, $end_message);
}
// Fetch meta-info again after overview is loaded, for further process
$elist = $MailBox->mailList;
$headers = $elist["headers"];
// END
$c=$numEmails;
if(!isset($_REQUEST["search"])) {
$numPages = ceil($numEmails/$MailBox->mails_per_page);
if($numPages > 1) {
if($start != 1){
$navigationOutput = "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',1);\" ><img src='modules/Webmails/images/start.gif' border='0'></a>&nbsp;&nbsp;";
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".($start-1).");\" ><img src='modules/Webmails/images/previous.gif' border='0'></a> &nbsp;";
}
if($start <= ($numPages-1)){
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".($start+1).");\" ><img src='modules/Webmails/images/next.gif' border='0'></a>&nbsp;&nbsp;";
$navigationOutput .= "<a href='javascript:;' onClick=\"cal_navigation('".$mailbox."',".$numPages.");\"><img src='modules/Webmails/images/end.gif' border='0'></a> &nbsp;";
}
}
}
$js_array = "";
$overview=$elist["overview"];
$mails = array();
if (is_array($overview))
{
foreach ($overview as $val)
{
$mails[$val->msgno] = $val;
$hdr = @imap_headerinfo($MailBox->mbox, $val->msgno);
$val->from = utf8_decode(utf8_encode(imap_utf8(addslashes($val->from))));
$val->to = utf8_decode(utf8_encode(imap_utf8(addslashes($val->to))));
$val->subject = utf8_decode(utf8_encode(imap_utf8($val->subject)));
$to = str_replace("<",":",$val->to);
$to_list = str_replace(">","",$to);
$from = str_replace("<",":",$val->from);
$from_list = str_replace(">","",$from);
$cc = str_replace("<",":",$hdr->ccaddress);
$cc_list = str_replace(">","",$cc);
$cc_list = addslashes($cc_list);
/*$js_array .= "webmail2[".$val->msgno."] = new Array();";
$js_array .= "webmail2[".$val->msgno."]['from'] = '".addslashes($from_list)."';";
$js_array .= "webmail2[".$val->msgno."]['to'] = '".addslashes($to_list)."';";
$js_array .= "webmail2[".$val->msgno."]['subject'] = '".addslashes($val->subject)."';";
$js_array .= "webmail2[".$val->msgno."]['date'] = '".addslashes($val->date)."';";
$js_array .= "webmail2[".$val->msgno."]['cc'] = '".$cc_list."';";*/
}
}
$search_fields = Array("SUBJECT","BODY","TO","CC","BCC","FROM");
$listview_header = array("<th class='tableHeadBg' width='10%'>".$mod_strings['LBL_INFO']."</th>","<th class='tableHeadBg' width='45%'>".$mod_strings['LBL_LIST_SUBJECT']."</th>","<th class='tableHeadBg' width='25%'>".$mod_strings['LABEL_DATE']."</th>","<th class='tableHeadBg' width='10%'>".$mod_strings['LABEL_FROM']."</th>","<th class='tableHeadBg' >".$mod_strings['LBL_DEL']."</th>");
$listview_entries = array();
$displayed_msgs=0;
$info = imap_mailboxmsginfo($MailBox->mbox);
$unread_msgs = $info->Unread;
//$new_msgs=0;
if(($numEmails) <= 0)
$listview_entries[0][] = '<td colspan="6" width="100%" align="center"><b>'.$mod_strings['LBL_NO_EMAILS'].'</b></td>';
else {
if(isset($_REQUEST["search"]) && trim($_REQUEST["search_input"]) != '') {
$searchstring = vtlib_purify($_REQUEST["search_type"]).' "'.vtlib_purify($_REQUEST["search_input"]).'"';
//echo $searchstring."<br>";
$searchlist = Array();
$searchlist = imap_search($MailBox->mbox,$searchstring);
if(is_array($searchlist))
{
$num_searches = count($searchlist);
$c=$numEmails;
}
while ($i<=$c) {
if(is_array($searchlist)) {
for($l=0;$l<$num_searches;$l++) {
if($mails[$start_message]->msgno == $searchlist[$l])
$listview_entries[] = show_msg($mails,$start_message);
}
}
$i++;
$start_message--;
}
}else
{
$i=1;
while ($i<=$c) {
if($start_message > 0)
{
$listview_entries[] = show_msg($mails,$start_message);
if($displayed_msgs == $MailBox->mails_per_page) {break;}
}
$i++;
$start_message--;
}
}
flush();
// MAIN LOOP
// Main loop to create listview entries
}
$search_html = '<select name="optionSel" class="importBox" id="search_type">';
foreach($search_fields as $searchfield)
{
if($_REQUEST['search_type'] == $searchfield)
$search_html .= '<option selected value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
else
$search_html .= '<option value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
}
$search_html .= '</select>';
// Build folder list and move_to dropdown box
$list = imap_getmailboxes($MailBox->mbox, "{".$MailBox->imapServerAddress."}", "*");
sort($list);
$i=0;
if (is_array($list)) {
$boxes = '<select name="mailbox" id="mailbox_select" onChange="move_messages();">';
$boxes .= '<option value="move_to" SELECTED>'.$mod_strings['LBL_MOVE_TO'].'</option>';
foreach ($list as $key => $val) {
$tmpval = preg_replace(array("/\{.*?\}/i"),array(""),$val->name);
if(preg_match("/trash/i",$tmpval))
$img = "webmail_trash.gif";
elseif($_REQUEST["mailbox"] == $tmpval)
$img = "opened_folder.gif";
else
$img = "folder.gif";
$i++;
if($_REQUEST["mailbox"] == '')
$_REQUEST["mailbox"] = 'INBOX';
if ($_REQUEST["mailbox"] == $tmpval) {
/* if($tmpval != "INBOX")
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
*/
$_SESSION["mailboxes"][$tmpval] = $new_msgs;
if($tmpval[0] != ".")
{
if($numEmails==0) {$num=$numEmails;} else {$num=($numEmails-1);}
$folders .= '<li style="padding-left:0px;"><img src="themes/images/'.$img.'"align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="small">'.$tmpval.'</a>&nbsp;&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
if($unread_msgs > 0)
$folders .= '(<span id="'.$tmpval.'_unread">'.$unread_msgs.'</span>)</span>&nbsp;&nbsp;<span id="remove_'.$tmpval.'" style="position:relative;display:none">Remove</span></li>';
else
$folders .='</span></li>';
}
} else {
$box = imap_status($MailBox->mbox, "{".$MailBox->imapServerAddress."}".$tmpval, SA_ALL);
$_SESSION["mailboxes"][$tmpval] = $box->unseen;
if($tmpval[0] != ".")
{
if($box->messages==0) {$num=$box->messages;} else {$num=($box->messages-1);}
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
$folders .= '<li ><img src="themes/images/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="small">'.$tmpval.'</a>&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
if($box->unseen > 0)
$folders .= '(<span id="'.$tmpval.'_unread">'.$box->unseen.'</span>)</span></li>';
else
$folders .='</span></li>';
}
}
}
$boxes .= '</select>';
}
imap_close($MailBox->mbox);
//echo '<div id="js_arr" style="display:none">'.$js_array.'</div>';
$smarty = new vtigerCRM_Smarty;
//$smarty->assign("USERID", $current_user->id);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("UNREAD_COUNT",$unread_msgs);
$smarty->assign("LISTENTITY", $listview_entries);
$smarty->assign("LISTHEADER", $listview_header);
$smarty->assign("NAVIGATION", $navigationOutput);
$smarty->assign("FOLDER_SELECT", $boxes);
$smarty->assign("NUM_EMAILS", $numEmails);
$smarty->assign("MAILBOX", $MailBox->mailbox);
$smarty->assign("ACCOUNT", $MailBox->display_name);
$smarty->assign("BOXLIST",$folders);
$smarty->assign("MAIL_INFO",$js_array);
$smarty->display("ListViewAjax.tpl");
?>
@@ -0,0 +1,230 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
include_once('config.php');
require_once('include/logging.php');
require_once('include/utils/utils.php');
class MailBox {
var $mbox;
var $db;
var $boxinfo;
var $readonly='false';
var $enabled;
var $login_username;
var $secretkey;
var $imapServerAddress;
var $ssltype;
var $sslmeth;
var $box_refresh;
var $mails_per_page;
var $mail_protocol;
var $account_name;
var $display_name;
var $mailbox;
var $mailList;
function MailBox($mailbox = '') {
global $current_user;
require_once('include/utils/encryption.php');
$oencrypt = new Encryption();
$this->db = PearDatabase::getInstance();
$this->db->println("Entering MailBox($mailbox)");
$this->mailbox = $mailbox;
$tmp = getMailServerInfo($current_user);
if($this->db->num_rows($tmp) < 1)
$this->enabled = 'false';
else
$this->enabled = 'true';
$this->boxinfo = $this->db->fetch_array($tmp);
$this->login_username=trim($this->boxinfo["mail_username"]);
$this->secretkey=$oencrypt->decrypt(trim($this->boxinfo["mail_password"]));
$this->imapServerAddress=gethostbyname(trim($this->boxinfo["mail_servername"]));
$this->mail_protocol=$this->boxinfo["mail_protocol"];
$this->ssltype=$this->boxinfo["ssltype"];
$this->sslmeth=$this->boxinfo["sslmeth"];
$this->box_refresh=trim($this->boxinfo["box_refresh"]);
$this->mails_per_page=trim($this->boxinfo["mails_per_page"]);
if($this->mails_per_page < 1)
$this->mails_per_page=20;
$this->account_name=$this->boxinfo["account_name"];
$this->display_name=$this->boxinfo["display_name"];
//$this->imapServerAddress=$this->boxinfo["mail_servername"];
$this->db->println("Setting Mailbox Name");
if($this->mailbox != "")
$this->mailbox=$mailbox;
$this->db->println("Opening Mailbox");
if(!$this->mbox && $this->mailbox != "")
$this->getImapMbox();
$this->db->println("Loading mail list");
if($this->mbox)
$this->mailList = $this->fullMailList();
$this->db->println("Exiting MailBox($mailbox)");
}
function loadOverviewList($start, $end) {
if($this->mbox) {
if($end == 0) $end = 1;
$mailOverviews = @imap_fetch_overview($this->mbox, "$start:$end", 0);
$this->mailList['headers'] = Array();
$this->mailList['overview'] = $mailOverviews;
}
}
function fullMailList() {
/*$mailHeaders = @imap_headers($this->mbox);
$numEmails = sizeof($mailHeaders);
$mailOverviews = @imap_fetch_overview($this->mbox, "1:$numEmails", 0);
$out = array("headers"=>$mailHeaders,"overview"=>$mailOverviews,"count"=>$numEmails);& */
$numEmails = @imap_num_msg($this->mbox);
$out = array("count" => $numEmails);
return $out;
}
function isBase64($iVal){
$_tmp=preg_replace("/[^A-Z0-9\+\/\=]/i","",$iVal);
return (strlen($_tmp) % 4 == 0 ) ? "y" : "n";
}
function getImapMbox() {
$this->db->println("Entering getImapMbox()");
$mods = parsePHPModules();
$this->db->println("Parsing PHP Modules");
// first we will try a regular old IMAP connection:
if($this->ssltype == "") {$this->ssltype = "notls";}
if($this->sslmeth == "") {$this->sslmeth = "novalidate-cert";}
if($this->mail_protocol == "pop3")
$port = "110";
else
{
if($mods["imap"]["SSL Support"] == "enabled" && ($this->ssltype == "tls" || $this->ssltype == "ssl"))
$port = "993";
else
$port = "143";
}
$this->db->println("Building connection string");
if(preg_match("/@/",$this->login_username))
{
$mailparts = split("@",$this->login_username);
$user="".trim($mailparts[0])."";
$domain="".trim($mailparts[1])."";
// This section added to fix a bug when connecting as user@domain.com
if($this->readonly == "true")
{
if($mods["imap"]["SSL Support"] == "enabled")
$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}/readonly";
else
$connectString = "/notls/novalidate-cert/user={$user}@{$domain}/readonly";
}
else
{
if($mods["imap"]["SSL Support"] == "enabled")
$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}";
else
$connectString = "/notls/novalidate-cert/user={$user}@{$domain}";
}
}
else
{
if($this->readonly == "true")
{
if($mods["imap"]["SSL Support"] == "enabled")
$connectString = "/".$this->ssltype."/".$this->sslmeth."/readonly";
else
$connectString = "/notls/novalidate-cert/readonly";
}
else
{
if($mods["imap"]["SSL Support"] == "enabled")
$connectString = "/".$this->ssltype."/".$this->sslmeth;
else
$connectString = "/notls/novalidate-cert";
}
}
//$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port.$connectString."}".$this->mailbox;
$connectString = "{".$this->imapServerAddress.":".$port."/".$this->mail_protocol.$connectString."}".$this->mailbox;
//Reference - http://forums.vtiger.com/viewtopic.php?p=33478#33478 - which has no tls or validate-cert
$connectString1 = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."}".$this->mailbox;
$this->db->println("Done Building Connection String.. $connectString Connecting to box");
//checking the imap support in php
if(!function_exists('imap_open'))
{
echo "<strong>".$mod_strings['LBL_ENABLE_IMAP_SUPPORT']."</strong>";
exit();
}
if(!$this->mbox = @imap_open($connectString, $this->login_username, $this->secretkey))
{
//try second string which has no tls or validate-cert
if(!$this->mbox = @imap_open($connectString1, $this->login_username, $this->secretkey))
{
global $current_user,$mod_strings;
$this->db->println("CONNECTION ERROR - Could not be connected to the server using imap_open function through the connection strings $connectString and $connectString1");
echo "<br>&nbsp;<b>".$mod_strings['LBL_MAIL_CONNECT_ERROR']."<a href='index.php?module=Users&action=AddMailAccount&return_module=Webmails&return_action=index&record=".$current_user->id."'> ".$mod_strings['LBL_HERE']."</a>. ".$mod_strings['LBL_PLEASE']." <a href='index.php?module=Emails&action=index&parenttab=".vtlib_purify($_REQUEST['parenttab'])."'>".$mod_strings['LBL_CLICK_HERE']."</a>".$mod_strings['LBL_GOTO_EMAILS_MODULE']." </b>";
exit;
}
}
$this->db->println("Done connecting to box");
}
} // END CLASS
function parsePHPModules() {
ob_start();
phpinfo(INFO_MODULES);
$s = ob_get_contents();
ob_end_clean();
$s = strip_tags($s,'<h2><th><td>');
$s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
$s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
$vTmp = preg_split('/(<h2>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
$vModules = array();
for ($i=1;$i<count($vTmp);$i++) {
if (preg_match('/<h2>([^<]+)<\/h2>/',$vTmp[$i],$vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode("\n",$vTmp[$i+1]);
foreach ($vTmp2 AS $vOne) {
$vPat = '<info>([^<]+)<\/info>';
$vPat3 = "/$vPat\s*$vPat\s*$vPat/";
$vPat2 = "/$vPat\s*$vPat/";
if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
} elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
?>
@@ -0,0 +1,153 @@
<?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
// draw a row for the listview entry
function show_msg($mails,$start_message)
{
global $MailBox,$displayed_msgs,$show_hidden,$new_msgs,$theme;
$num = $mails[$start_message]->msgno;
$msg_ob = new Webmails($MailBox->mbox,$mails[$start_message]->msgno);
// TODO: scan the current db vtiger_tables to find a
// matching email address that will make a good
// candidate for record_id
// this module will also need to be able to associate to any entity type
$record_id='';
if($mails[$start_message]->subject=="")
$mails[$start_message]->subject="(No Subject)";
// Let's pre-build our URL parameters since it's too much of a pain not to
$detailParams = 'record='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
$displayed_msgs++;
if ($mails[$start_message]->deleted && !$show_hidden)
{
$flags = "<tr id='row_".$num."' class='mailSelected' style='display:none' class=\"lvtColData\" bgcolor='#ffffff'><td width='2px'><input type='checkbox' class='msg_check'></td><td colspan='1'>";
$displayed_msgs--;
}
elseif ($mails[$start_message]->deleted && $show_hidden)
{
$flags = "<tr id='row_".$num."' class='mailSelected' class=\"lvtColData\" bgcolor='#ffffff'><td width='2px'><input type='checkbox' class='msg_check'></td><td colspan='1'>";
}
elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent)
{
$flags = "<tr id='row_".$num."' class='mailSelected' class=\"lvtColData\" bgcolor='#ffffff'><td width='2px'><input type='checkbox' name='selected_id' onclick='toggleSelectAll(this.name,\"select_all\")' value='$num' class='msg_check'></td><td colspan='1'>";
$new_msgs++;
}
else
{
$flags = "<tr id='row_".$num."' class=\"lvtColData\" bgcolor='#ffffff'><td width='2px'><input type='checkbox' name='selected_id' value='$num' onclick='toggleSelectAll(this.name,\"select_all\")' class='msg_check'></td><td colspan='1'>";
}
//enable-diable download attachment button
if($msg_ob->has_attachments){
$enableDownlaodAttachment = 'yes';
}else
$enableDownlaodAttachment = 'no';
// Attachment Icons
if($msg_ob->has_attachments)
$flags.='<a href="javascript:;" onclick="displayAttachments('.$num.');"><img src="themes/images/attachment.gif" border="0" width="8px" height="13" title="Attachment"></a>&nbsp;';
else
$flags.='<img src="themes/images/blank.gif" border="0" width="8px" height="14" alt="">&nbsp;';
// read/unread/forwarded/replied
if(!$mails[$start_message]->seen || $mails[$start_message]->recent)
{
$flags.='<span id="unread_img_'.$num.'"><a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="themes/images/newmail.gif" border="0" width="12" height="10" title="Unread"></a></span>&nbsp;';
}
elseif ($mails[$start_message]->in_reply_to || $mails[$start_message]->references || preg_match("/^re:/i",$mails[$start_message]->subject))
{
$flags.='<a href="javascript:;" onclick="OpenComposer(\''.$num.'\',\'reply\');"><img src="themes/images/stock_mail-replied.png" border="0" width="14" height="16" title="Replied" ></a>&nbsp;';
}
elseif (preg_match("/^fw:/i",$mails[$start_message]->subject))
{
$flags.='<a href="javascript:;" onclick="OpenComposer(\''.$num.'\',\'reply\');"><img src="themes/images/stock_mail-forward.png" border="0" width="10" height="13" title="Forward" ></a>&nbsp;';
}
else
{
$flags.='<a href="javascript:;" onclick="OpenComposer(\''.$num.'\',\'reply\');"><img src="themes/images/openmail.gif" border="0" width="12" height="12" title="Read" ></a>&nbsp;';
}
// Set IMAP flag
if($mails[$start_message]->flagged)
{
$flags.='<span id="clear_td_'.$num.'"><a href="javascript:runEmailCommand(\'clear_flag\','.$num.');"><img src="themes/images/important1.gif" border="0" width="11" height="11" id="clear_flag_img_'.$num.'"title="Important"></a></span>';
}
else
{
$flags.='<span id="set_td_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','.$num.');"><img src="themes/images/important2.gif" border="0" width="11" height="11" id="set_flag_img_'.$num.'"title="Important"></a></span>';
}
$tmp=imap_mime_header_decode($mails[$start_message]->from);
$from = $tmp[0]->text;
$listview_entries[$num] = array();
$listview_entries[$num][] = $flags."</td>";
if ($mails[$start_message]->deleted)
{
$listview_entries[$num][] = '<td nowrap align="left" style="cursor:pointer;" id="deleted_subject_'.$num.'" onclick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\'); "><s><a href="javascript:;" >'.substr($mails[$start_message]->subject,0,40).'</a></s></td>';
$listview_entries[$num][] = '<td nowrap align="left" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" nowrap id="deleted_date_'.$num.'"><s>'.substr($mails[$start_message]->date,0,25).'</s></td>';
$listview_entries[$num][] = '<td nowrap align="left" id="deleted_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');"><s>'.substr($from,0,20).'</s></td>';
}
elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent)
{
$listview_entries[$num][] = '<td nowrap align="left" onclick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" style="cursor:pointer;" ><a href="javascript:;" id="ndeleted_subject_'.$num.'"><font id="fnt_subject_'.$num.'" color="green">'.substr($mails[$start_message]->subject,0,40).'</font></a></td>';
$listview_entries[$num][] = '<td nowrap align="left" nowrap id="ndeleted_date_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" ><font id="fnt_date_'.$num.'" color="green">'.substr($mails[$start_message]->date,0,25).' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font></td>';
$listview_entries[$num][] = '<td nowrap align="left" id="ndeleted_from_'.$num.'"><font id="fnt_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" >'.substr($from,0,20).'</font></td>';
}
else
{
//IMPORTANT - This UTF-8 conversion has been done in ListView.php so no need to do again here
//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Starts
//we can use the option 1 or option 2
//Option 1 - Starts
/*
$translated_subject = imap_mime_header_decode($mails[$start_message]->subject);
for($i=0;$i<count($translated_subject);$i++)
{
if($translated_subject[$i]->charset != 'default')
{
$tmp .= $translated_subject[$i]->text;
$mails[$start_message]->subject = utf8_decode($tmp);//$tmp;
}
}
//Option 1 - Ends
*/
//Option 2 - Starts
//$mails[$start_message]->subject = utf8_decode(imap_utf8($mails[$start_message]->subject));//imap_utf8($mails[$start_message]->subject);
//Option 2 - Ends
//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Ends
$listview_entries[$num][] = '<td nowrap align="left" onclick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" style="cursor:pointer;" ><a href="javascript:;" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,40).'</a></td>';
$listview_entries[$num][] = '<td npwrap align="left" nowrap id="ndeleted_date_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" >'.substr($mails[$start_message]->date,0,25).'</td>';
$listview_entries[$num][] = '<td nowrap align="left" id="ndeleted_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\', \''.$enableDownlaodAttachment.'\');" >'.substr($from,0,20).'</td>';
}
if($mails[$start_message]->deleted)
$listview_entries[$num][] = '<td nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="themes/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del" title="Delete"></a></span></td></tr>';
else
$listview_entries[$num][] = '<td nowrap align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="themes/images/no.gif" border="0" width="14" height="14" alt="del" title="Delete"></a></span></td></tr>';
return $listview_entries[$num];
}
?>
+201
View File
@@ -0,0 +1,201 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
require_once('modules/Emails/Emails.php');
require_once('modules/Webmails/Webmails.php');
require_once('include/logging.php');
require_once('include/database/PearDatabase.php');
require_once('include/utils/UserInfoUtil.php');
require_once('include/utils/CommonUtils.php');
require_once('modules/Webmails/MailParse.php');
require_once('modules/Webmails/MailBox.php');
require_once('modules/Documents/Documents.php');
require_once('modules/Settings/MailScanner/core/MailAttachmentMIME.php');
global $current_user;
$local_log =& LoggerManager::getLogger('index');
$focus = new Emails();
$to_address = explode(";",$_REQUEST['to_list']);
$cc_address = explode(";",$_REQUEST['cc_list']);
$bcc_address = explode(";",$_REQUEST['bcc_list']);
$start_message=vtlib_purify($_REQUEST["start_message"]);
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=vtlib_purify($_REQUEST["mailbox"]);} else {$mailbox="INBOX";}
$MailBox = new MailBox($mailbox);
$mail = $MailBox->mbox;
$email = new Webmails($MailBox->mbox, $_REQUEST["mailid"]);
$subject = imap_utf8($email->subject);
$date = $email->date;
$array_tab = Array();
$email->loadMail($array_tab);
$msgData = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',"",$email->body);
$content['attachtab'] = $email->attachtab;
while ($tmp = array_pop($content['attachtab'])){
if ((!eregi('ATTACHMENT', $tmp['disposition'])) && $conf->display_text_attach && (eregi('text/plain', $tmp['mime'])))
$msgData .= '<hr />'.view_part_detail($mail, $mailid, $tmp['number'], $tmp['transfer'], $tmp['charset'], $charset);
}
$focus->column_fields['subject']=$subject;
$focus->column_fields["activitytype"]="Emails";
$ddate = date("Y-m-d",strtotime($date));
$dtime = date("h:m");
$focus->column_fields["assigned_user_id"] = $current_user->id;
$focus->column_fields["date_start"] = $ddate;
$focus->column_fields["time_start"] = $dtime;
//Set the flag as 'Webmails' to show up the sent date
$focus->column_fields["email_flag"] = "WEBMAIL";
//Save the To field information in vtiger_emaildetails
$all_to_ids = $email->to;
$focus->column_fields["saved_toid"] = implode(',',$all_to_ids);
//store the sent date in 'yyyy-mm-dd' format
$user_old_date_format = $current_user->date_format;
$current_user->date_format = 'yyyy-mm-dd';
$focus->column_fields["description"]=$msgData;
//to save the email details in vtiger_emaildetails vtiger_tables
$fieldid = $adb->query_result($adb->pquery('select fieldid from vtiger_field where tablename="vtiger_contactdetails" and fieldname="email" and columnname="email" and vtiger_field.presence in (0,2)', array()),0,'fieldid');
if(count($email->relationship) != 0) {
$focus->column_fields['parent_id']=$email->relationship["id"].'@'.$fieldid.'|';
$focus->save("Emails");
if($email->relationship["type"] == "Contacts")
add_attachment_to_contact($email->relationship["id"],$email,$focus->id);
}else {
//if relationship is not available create a contact and relate the email to the contact
require_once('modules/Contacts/Contacts.php');
$contact_focus = new Contacts();
//Populate the lastname as emailid if email doesn't have from name
if($email->fromname){
$contact_focus->column_fields['lastname'] =$email->fromname;
}else{
$contact_focus->column_fields['lastname'] =$email->from;
}
$contact_focus->column_fields['email'] = $email->from;
$contact_focus->column_fields["assigned_user_id"]=$current_user->id;
$contact_focus->save("Contacts");
$focus->column_fields['parent_id']=$contact_focus->id.'@'.$fieldid.'|';
$focus->save("Emails");
add_attachment_to_contact($contact_focus->id,$email,$focus->id);
}
function add_attachment_to_contact($cid,$email,$emailid) {
// add vtiger_attachments to contact
global $adb,$current_user,$default_charset;
for($j=0;$j<2;$j++) {
if($j==0)
$attachments=$email->downloadAttachments();
else
$attachments=$email->downloadInlineAttachments();
$upload_filepath = decideFilePath();
for($i=0,$num_files=count($attachments);$i<$num_files;$i++)
{
$current_id = $adb->getUniqueID("vtiger_crmentity");
$date_var = $adb->formatDate(date('Y-m-d H:i:s'), true);
$filename = ereg_replace("[ ()-]+", "_",$attachments[$i]["filename"]);
preg_match_all('/=\?([^\?]+)\?([^\?]+)\?([^\?]+)\?=/', $filename, $matches);
$totalmatches = count($matches[0]);
for($index = 0; $index < $totalmatches; ++$index) {
$charset = $matches[1][$index];
$encoding= strtoupper($matches[2][$index]);
$data = $matches[3][$index];
if($encoding == 'B') {
$filename = base64_decode($data);
} else if($encoding == 'Q') {
$filename = quoted_printable_decode($data);
}
$filename = iconv(str_replace('_','-',$charset),$default_charset,$filename);
}
$saveasfile = $upload_filepath.'/'.$current_id.'_'.$filename;
$filetype = MailAttachmentMIME::detect($saveasfile);
$filesize = $attachments[$i]["filesize"];
$query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?,?,?,?,?,?,?)";
$qparams = array($current_id, $current_user->id, $current_user->id, 'Contacts Attachment', 'Uploaded from webmail during qualification', $date_var, $date_var);
$result = $adb->pquery($query, $qparams);
$sql = "insert into vtiger_attachments (attachmentsid,name,description,type,path) values(?,?,?,?,?)";
$params = array($current_id, $filename, 'Uploaded '.$filename.' from webmail', $filetype, $upload_filepath);
$result = $adb->pquery($sql, $params);
if(!empty($result)){
// Create document record
$document = new Documents();
$document->column_fields['notes_title'] = $filename;
$document->column_fields['filename'] = $filename;
$document->column_fields['filesize'] = $filesize;
$document->column_fields['filetype'] = $filetype;
$document->column_fields['filestatus'] = 1;
$document->column_fields['filelocationtype'] = 'I';
$document->column_fields['folderid'] = 1; // Default Folder
$document->column_fields['assigned_user_id'] = $current_user->id;
$document->save('Documents');
$sql1 = "insert into vtiger_senotesrel values(?,?)";
$params1 = array($cid, $document->id);
$result = $adb->pquery($sql1, $params1);
$sql1 = "insert into vtiger_seattachmentsrel values(?,?)";
$params1 = array($document->id, $current_id);
$result = $adb->pquery($sql1, $params1);
$sql1 = "insert into vtiger_seattachmentsrel values(?,?)";
$params1 = array($emailid, $current_id);
$result = $adb->pquery($sql1, $params1);
}
//we have to add attachmentsid_ as prefix for the filename
$move_filename = $upload_filepath.'/'.$current_id.'_'.$filename;
$fp = fopen($move_filename, "w") or die("Can't open file");
fputs($fp, base64_decode($attachments[$i]["filedata"]));
fclose($fp);
}
}
}
//Display the sent date in logged in user date format
$current_user->date_format = $user_old_date_format;
function view_part_detail($mail,$mailid,$part_no, &$transfer, &$msg_charset, &$charset)
{
$text = imap_fetchbody($mail,$mailid,$part_no);
if ($transfer == 'BASE64')
$str = nl2br(imap_base64($text));
elseif($transfer == 'QUOTED-PRINTABLE')
$str = nl2br(quoted_printable_decode($text));
else
$str = nl2br($text);
return ($str);
}
$_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
$return_id = vtlib_purify($_REQUEST["mailid"]);
$return_module='Webmails';
$return_action='ListView';
if($_POST["ajax"] != "true")
header("Location: index.php?action=$return_action&module=$return_module&record=$return_id");
return;
?>
+19
View File
@@ -0,0 +1,19 @@
webmail todos:
--------------
1) Add attachment uploading code for emails added to vtiger -- Done 05-25-06 -- mmbrich
2) Create "Add to Vtiger" link to "Quick View" -- Done 01-30-06 -- mmbrich
3) BCC current_user on all outgoing emails -- Done 01-30-06 -- mmbrich
4) Automatically import threads on mbox refresh
5) Multiple email accounts
6) Fix entity relationships so entites will show up in "Emails" module under "More Information" -- Done 05-24-06 -- vtiger
7) Store the msg-id of the imported emails (for checking the thread and importing) -- not needed
8) Add all needed tab relationships to the DB
9) Generate a related list of some kind for webmails -- Done 01-30-06 -- mmbrich
10) Enable the following relationships with an Emails entity:
a) HelpDesk
b) Vendor
c) Product
d) {Multiple} Other Emails (for thread relationships)
e) ??
11) Enable radio boxes and massdelete funtion
12) Figure out a way to AJAX'ify checks for new messages and automatically insert them in the table? -- Done 05-25-06 -- mmbrich
@@ -0,0 +1,722 @@
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
function load_webmail(mid,hasAttachment) {
var node = $("row_"+mid);
preview_id = mid;
if(typeof($('fnt_subject_'+mid)) != "undefined" && $('fnt_subject_'+mid).color=="green")
{
$('fnt_subject_'+mid).color="";
$('fnt_date_'+mid).color="";
$('fnt_from_'+mid).color="";
}
if(node.className == "mailSelected") {
var unread = parseInt($(mailbox+"_unread").innerHTML);
if(unread != 0)
{
var curUnread;
curUnread = unread -1;
if(curUnread == 0)
$(mailbox+"_count").style.display="none";
else
$(mailbox+"_unread").innerHTML = curUnread;
}
$("unread_img_"+mid).removeChild($("unread_img_"+mid).firstChild);
$("unread_img_"+mid).appendChild(Builder.node('a',
{href: 'javascript:;', onclick: 'OpenComposer('+mid+',\'reply\')'},
[Builder.node('img',{src: 'themes/images/openmail.gif', border: '0', width: '12', height: '12'})]
));
}
node.className='read_email';
//Fix for webmails body display in IE - dartagnanlaf
/*
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=body&mailid=' + mid + '&mailbox='+mailbox,
onComplete: function(response) {
document.getElementById("body_area").innerHTML=response.responseText;
}
}
);
*/
oiframe = $("email_description");
oiframe.src = 'index.php?module=Webmails&action=body&theme='+theme+'&mailid='+mid+'&mailbox='+mailbox;
//$("body_area").appendChild(Builder.node('iframe',{src: 'index.php?module=Webmails&action=body&mailid='+mid+'&mailbox='+mailbox, width: '100%', height: '210', frameborder: '0'},'You must enable iframes'));
tmp = document.getElementsByClassName("previewWindow");
for(var i=0;i<tmp.length;i++) {
if(tmp[i].style.visibility === "hidden") {
tmp[i].style.visibility="visible";
}
}
if($("preview1").style.visibility === "hidden" || $("preview2").style.visibility === "hidden") {
$("preview1").style.visibility="visible";
$("preview2").style.visibility="visible";
}
$("delete_button").removeChild($("delete_button").firstChild);
$("delete_button").appendChild(Builder.node('input',{type: 'button', name: 'Button', value: alert_arr.LBL_DELETE_EMAIL, className: 'buttonok', onclick: 'runEmailCommand(\'delete_msg\','+mid+')'}));
$("reply_button_all").removeChild($("reply_button_all").firstChild);
$("reply_button_all").appendChild(Builder.node('input',{type: 'button', name: 'reply', value: alert_arr.LBL_REPLY_TO_ALL, className: 'buttonok', onclick: 'OpenComposer('+mid+',\'replyall\')'}));
$("reply_button").removeChild($("reply_button").firstChild);
$("reply_button").appendChild(Builder.node('input',{type: 'button', name: 'reply', value: alert_arr.LBL_REPLY_TO_SENDER, className: 'buttonok', onclick: 'OpenComposer('+mid+',\'reply\')'}));
$("forward_button").removeChild($("forward_button").firstChild);
$("forward_button").appendChild(Builder.node('input',{type: 'button', name: 'forward', value: alert_arr.LBL_FORWARD_EMAIL, className: 'buttonok', onclick: 'OpenComposer('+mid+',\'forward\')'}));
$("qualify_button").removeChild($("qualify_button").firstChild);
if(showQualify == 'yes')
$("qualify_button").appendChild(Builder.node('input',{type: 'button', name: 'Qualify2', value: alert_arr.LBL_QUALIFY_EMAIL, className: 'buttonok', onclick: 'showRelationships('+mid+')'}));
else
$("qualify_button").appendChild(Builder.node('input',{type: 'hidden',name: 'hide'}));
$("download_attach_button").removeChild($("download_attach_button").firstChild);
if(hasAttachment == 'yes'){
$("download_attach_button").appendChild(Builder.node('input',{type: 'button', name: 'download', value: alert_arr.LBL_DOWNLOAD_ATTACHMENTS, className: 'buttonok', onclick: 'displayAttachments('+mid+')'}));
}else{
$("download_attach_button").appendChild(Builder.node('input',{type: 'hidden', name: 'download', value: alert_arr.LBL_DOWNLOAD_ATTACHMENTS, className: 'buttonok', onclick: 'displayAttachments('+mid+')'}));
}
$("print_email_button").removeChild($("print_email_button").firstChild);
$("print_email_button").appendChild(Builder.node('input',{type: 'button', name: 'print', value: alert_arr.LBL_PRINT_EMAIL,className: 'buttonok', onclick: 'OpenComposer('+mid+',\'print\')'}));
//$("full_view").removeChild($("full_view").firstChild);
// $("full_view").appendChild(Builder.node('a',{href: 'javascript:;', onclick: 'OpenComposer('+mid+',\'full_view\')'},'Full Email View'));
makeSelected(node.id)
}
function displayAttachments(mid) {
var url = "index.php?module=Webmails&action=dlAttachments&mailid="+mid+"&mailbox="+mailbox;
window.open(url,"DownloadAttachments",'menubar=no,toolbar=no,location=no,status=no,resizable=no,width=450,height=450');
}
function OpenComposer(id,mode)
{
switch(mode)
{
case 'edit':
url = 'index.php?module=Webmails&action=EditView&record='+id;
break;
case 'create':
url = 'index.php?module=Emails&action=EmailsAjax&file=EditView';
break;
case 'forward':
url = 'index.php?module=Emails&action=EmailsAjax&mailid='+id+'&forward=true&webmail=true&file=EditView&mailbox='+mailbox;
break;
case 'reply':
url = 'index.php?module=Emails&action=EmailsAjax&mailid='+id+'&reply=single&webmail=true&file=EditView&mailbox='+mailbox;
break;
case 'replyall':
url = 'index.php?module=Emails&action=EmailsAjax&mailid='+id+'&reply=all&webmail=true&file=EditView&mailbox='+mailbox;
break;
case 'attachments':
url = 'index.php?module=Webmails&action=dlAttachments&mailid='+id+'&mailbox='+mailbox;
break;
case 'full_view':
url = 'index.php?module=Webmails&action=DetailView&record='+id+'&mailid='+id+'&mailbox='+mailbox;
break;
case 'print':
url = 'index.php?module=Emails&action=EmailsAjax&file=PrintEmail&record='+id+'&mailbox='+mailbox+'&print=true';
break;
}
openPopUp('xComposeEmail',this,url,'createemailWin',830,662,'menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes');
}
function makeSelected(rowId)
{
if(gselected_mail != '')
$(gselected_mail).className = '';
$(rowId).className = 'mailSelected_select';
gselected_mail = rowId;
}
function showRelationships(mid) {
// TODO: present the user with a simple DHTML div to
// choose what type of relationship they would like to create
// before creating it.
if(confirm(alert_arr.WISH_TO_QUALIFY_MAIL_AS_CONTACT))
add_to_vtiger(mid);
}
function add_to_vtiger(mid) {
// TODO: update this function to allow you to set what entity type
// you would like to associate to
var rowId = "row_"+mid;
$(rowId).className = "qualify_email";
$("status").style.display="block";
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=Save&mailid='+mid+'&ajax=true'+'&mailbox='+mailbox,
onComplete: function(t) {
setTimeout('makeSelected("'+rowId+'");',500);
$("status").style.display="none";
}
}
);
}
function select_all() {
var els = document.getElementsByClassName("msg_check");
var id='';
for(var i=0;i<els.length;i++) {
id = els[i].name.substr((els[i].name.indexOf("_")+1),els[i].name.length);
var tels = $("row_"+id);
if(tels.className == "deletedRow") {
els[i].checked = false;
} else {
if(els[i].checked)
els[i].checked = false;
else
els[i].checked = true;
}
}
}
function check_in_all_boxes(mymbox) {
// TODO: There is possibly still a bug in the mailbox counting code
// check for NaN
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=WebmailsAjax&command=check_mbox_all&mailbox='+mymbox+'&ajax=true&file=ListView',
onComplete: function(t) {
//alert(t.responseText);
if(t.responseText != "") {
var data = eval('(' + t.responseText + ')');
for (var i=0;i<data.msgs.length;i++) {
var mbox = data.msgs[i].msg.box;
if(mbox != mailbox) {
var numnew = parseInt(data.msgs[i].msg.newmsgs);
var read = parseInt($(mbox+"_read").innerHTML);
$(mbox+"_read").innerHTML = (read+numnew);
var unread = parseInt($(mbox+"_unread").innerHTML);
$(mbox+"_unread").innerHTML = (unread+numnew);
}
}
}
$("status").style.display="none";
}
}
);
}
function check_for_new_mail(mbox) {
//window.location=window.location;
if(degraded_service == 'true') {
return;
}
mailbox = mbox;
runEmailCommand("reload",0);
$("status").style.display="block";
/*
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=WebmailsAjax&mailbox='+mbox+'&command=check_mbox&ajax=true&file=ListView',
onComplete: function(t) {
try {
// TODO: replace this at some point with prototype JSON
// tools
var data = eval('(' + t.responseText + ')');
//var read = parseInt($(mailbox+"_read").innerHTML);
//$(mailbox+"_read").innerHTML = (read+data.mails.length);
var unread = parseInt($(mailbox+"_unread").innerHTML);
$(mailbox+"_unread").innerHTML = (unread+data.mails.length);
for (var i=0;i<data.mails.length;i++) {
var mailid = data.mails[i].mail.mailid;
var date = data.mails[i].mail.date;
var subject=data.mails[i].mail.subject;
var attachments=data.mails[i].mail.attachments;
var from=data.mails[i].mail.from;
webmail[mailid] = new Array();
webmail[mailid]["from"] = from;
webmail[mailid]["to"] = data.mails[i].mail.to;
webmail[mailid]["subject"] = subject;
webmail[mailid]["date"] = date;
// main row
var tr = Builder.node(
'tr',
{id:'row_'+mailid, className: 'unread_email'}
);
// checkbox
var check = Builder.node(
'td',
[ Builder.node(
'input',
{type: 'checkbox', name: 'selected_id', value: mailid, className: 'msg_check'}
)]
);
tr.appendChild(check);
// images
// Attachment
imgtd = Builder.node('td');
if(attachments === "1") {
var attach = Builder.node('a',
{href: 'javascript:;', onclick: 'displayAttachments('+mailid+')'},
[ Builder.node('img',
{src: 'modules/Webmails/images/stock_attach.png', border: '0', width: '14px', height: '14px'}
)]
);
} else {
var attach = Builder.node('a',
{src: 'modules/Webmails/images/blank.png', border: '0', width: '14px', height: '14px'}
);
}
imgtd.appendChild(attach);
imgtd.innerHTML += "&nbsp;";
var unread = Builder.node('span',
{id: 'unread_img_'+mailid},
[ Builder.node('a',
{href: 'javascript:;', onclick: 'OpenCompose('+mailid+',\'reply\')'},
[ Builder.node('img',
{src: 'modules/Webmails/images/stock_mail-unread.png', border: '0', width: '10', height: '14'}
)]
)]
);
imgtd.appendChild(unread);
imgtd.innerHTML += "&nbsp;";
var flag = Builder.node('span',
{id: 'set_td_'+mailid},
[ Builder.node('a',
{href: 'javascript:void(0);', onclick: 'runEmailCommand(\'set_flag\','+mailid+')'},
[ Builder.node('img',
{src: 'modules/Webmails/images/plus.gif', border: '0', width: '11px', height: '11px', id: 'set_flag_img_'+mailid}
)]
)]
);
imgtd.appendChild(flag);
tr.appendChild(imgtd);
// MSG details
tr.appendChild( Builder.node('td',
[ Builder.node('a',
{href: 'javascript:;', onclick: 'load_webmail(\''+mailid+'\')', id: 'ndeleted_subject_'+mailid},
''+subject+''
)]
));
tr.appendChild( Builder.node('td',
{id: 'ndeleted_date_'+mailid},
''+date+''
));
tr.appendChild( Builder.node('td',
{id: 'ndeleted_from_'+mailid},
''+from+''
));
var del = Builder.node('td',
{align: 'center', id:'ndeleted_td_'+mailid},
[ Builder.node('span',
{id: 'del_link_'+mailid},
[ Builder.node('a',
{href: 'javascript:;', onclick: 'runEmailCommand(\'delete_msg\','+mailid+')'},
[ Builder.node('img',
{src: 'modules/Webmails/images/gnome-fs-trash-empty.png', border: '0', width: '14', height: '14', alt: 'del'}
)]
)]
)]
);
tr.appendChild(del);
// TODO: this is ugly, replace using prototype child walker tools
tr.style.display='none';
var tels = $("message_table").childNodes[1].childNodes;
for(var j=0;j<tels.length;j++) {
try {
if(tels[j].id.match(/row_/)) {
//we are deleting the row and add it - AVOID THIS DELTE - MICKIE
//$("message_table").childNodes[1].deleteRow(tr,tels[j]);commented since header does not come when new mails arrive
$("message_table").childNodes[1].insertBefore(tr,tels[j]);
break;
}
}catch(f){}
}
new Effect.Appear("row_"+mailid);
}
}catch(e) {}
check_in_all_boxes(mailbox);
//$("status").style.display="none";
}
}
);
*/
}
function periodic_event() {
// NOTE: any functions you put in here may race. This could probably
// be avoided by executing functions in a 0'ed timeout, or a prototype
// enumerator
check_for_new_mail(mailbox);
window.setTimeout("periodic_event()",box_refresh);
}
function show_hidden() {
// prototype uses enumerable lists to queue events for execution.
// because of this, this function executes and returns imediately and
// the status spinner is never seen. The status spinner below is a hack
// and doesn't even attempt to pretend like it knows the event is finished.
// this cannot be fixed with the scriptaculous beforeStart and afterFinish
// event hooks for some reason, maybe because the event duration is too quick?
window.setTimeout(function() {
$("status").style.display="block";
window.setTimeout(function() {
$("status").style.display="none";
},2000);
},0);
var els = document.getElementsByClassName("deletedRow");
for(var i=0;i<els.length;i++) {
if(els[i].style.display == "none")
new Effect.Appear(els[i],{queue: {position: 'end', scope: 'show'}, duration: 0.2});
else
new Effect.Fade(els[i],{queue: {position: 'end', scope: 'show'}, duration: 0.2});
}
}
function mass_delete()
{
var select_options = document.getElementsByName('selected_id');
var x = select_options.length;
var nids = "";
var nid='';
xx = 0;
for(i = 0; i < x ; i++)
{
if(select_options[i].checked)
{
idvalue= select_options[i].value;
nid += idvalue +":";
xx++;
}
}
if (xx != 0)
nids=nid;
else
{
alert(alert_arr.SELECT_ATLEAST_ONEMSG_TO_DEL);
return false;
}
if(confirm(alert_arr.SURE_TO_DELETE))
runEmailCommand("delete_multi_msg",nids);
}
function move_messages()
{
var nid = '';
var chkname=document.getElementsByName("selected_id");
mvmbox = $("mailbox_select").value;
var nid = Array();
var i=0;
move_mail = 1;
for(var m=0;m<chkname.length;m++)
{
if(chkname[m].checked)
nid[i++] = chkname[m].value;
}
if(nid.length > 0)
{
$("status").style.display="block";
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=WebmailsAjax&mailbox='+mailbox+'&start='+start+'&command=move_msg&ajax=true&mailid='+nid.join(":")+'&mvbox='+mvmbox,
onComplete: function(t) {
sh = $("show_msg");
var leftSide = findPosX(sh);
var topSide = findPosY(sh);
sh.style.left= leftSide + 400+'px';
sh.style.top= topSide + 350 +'px';
sh.innerHTML = "Moving mail(s) from "+mailbox+" folder to "+mvmbox+" folder";
sh.style.display = "block";
sh.classname = "delete_email";
new Effect.Fade(sh,{queue: {position: 'end', scope: 'effect'},duration: '50'});
for(i=0;i<nid.length;i++)
{
var oRow = $('row_'+nid[i]);
new Effect.Fade(oRow,{queue: {position: 'end', scope: 'effect'},duration: '0.5'});
}
$("status").style.display = "none";
start = t.responseText;
runEmailCommand("reload",0);
}
}
);
}else
{
alert(alert_arr.SELECT_MAIL_MOVE);
}
}
/*function move_messages() {
$("status").style.display="block";
var els = document.getElementsByTagName("INPUT");
var cnt = (els.length-1);
for(var i=cnt;i>0;i--) {
if(els[i].type == "checkbox" && els[i].name.indexOf("_")) {
if(els[i].checked) {
var nid = els[i].name.substr((els[i].name.indexOf("_")+1),els[i].name.length);
var mvmbox = $("mailbox_select").value;
var row = $("row_"+nid);
new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '0.5'});
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=WebmailsAjax&file=ListView&mailbox='+gCurrentFolder+'&command=move_msg&ajax=true&mailid='+nid+'&mvbox='+mvmbox,
onComplete: function(t) {
//alert(t.responseText);
}
}
);
}
}
}
$('mailbox_select').selectedIndex=0;
//runEmailCommand('expunge','');
$("status").style.display="none";
}*/
function search_emails() {
// TODO: find a way to search in degraded functionality mode.
var search_query = $("search_input").value;
var search_type = $("search_type").value;
window.location = "index.php?module=Webmails&action=index&search=true&search_type="+search_type+"&search_input="+search_query;
}
function runEmailCommand(com,id) {
command=com;
id=id;
gselected_mail = '';
if(com == 'delete_msg')
{
if(!confirm(alert_arr.DELETE+" "+alert_arr.MAIL+" ?"))
return;
}
if(com=="reload")
var file="ListViewAjax";
else
var file="";
if(move_mail == 1){
var qry_str = "&mvbox="+mvmbox;
move_mail = 0;
}
else
qry_str = "";
$("status").style.display="block";
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=WebmailsAjax&start='+start+'&command='+command+'&mailid='+id+'&file='+file+'&mailbox='+mailbox+qry_str,
onComplete: function(t) {
resp = t.responseText;
id=resp;
if(resp.match(/ajax failed/)) {return;}
switch(command) {
case 'reload':
$("rssScroll").innerHTML = resp;
var unread_count = parseInt($(mailbox+"_tempcount").innerHTML);
if(unread_count > 0) {
$(mailbox+"_unread").innerHTML = unread_count;
}
else{
$(mailbox+"_count").innerHTML = "";
}
$("nav").innerHTML = $("navTemp").innerHTML;
$("box_list").innerHTML = $("temp_boxlist").innerHTML;
$("move_pane").innerHTML = $("temp_movepane").innerHTML;
$("temp_boxlist").innerHTML = "";
$("temp_movepane").innerHTML = "";
$("navTemp").innerHTML = '';
$(mailbox+"_tempcount").innerHTML = "";
break;
case 'expunge':
// NOTE: we either have to reload the page or count up from the messages that
// are deleted and moved or we introduce a bug from invalid mail ids
//window.location = window.location;
start = resp;
runEmailCommand("reload",0);
break;
case 'delete_multi_msg':
var ids;
eval(resp);
var rows = ids.split(":");
for(i=0;i<rows.length;i++) {
var id = rows[i];
var row = $("row_"+id);
if(row.className == "mailSelected") {
var unread = parseInt($(mailbox+"_unread").innerHTML);
$(mailbox+"_unread").innerHTML = (unread-1);
}
row.className = "delete_email";
Try.these (
function() {
$("ndeleted_subject_"+id).innerHTML = "<s>"+$("ndeleted_subject_"+id).innerHTML+"</s>";
$("ndeleted_date_"+id).innerHTML = "<s>"+$("ndeleted_date_"+id).innerHTML+"</s>";
$("ndeleted_from_"+id).innerHTML = "<s>"+$("ndeleted_from_"+id).innerHTML+"</s>";
},
function() {
$("deleted_subject_"+id).innerHTML = "<s>"+$("deleted_subject_"+id).innerHTML+"</s>";
$("deleted_date_"+id).innerHTML = "<s>"+$("deleted_date_"+id).innerHTML+"</s>";
$("deleted_from_"+id).innerHTML = "<s>"+$("deleted_from_"+id).innerHTML+"</s>";
}
);
try {
$("del_link_"+id).innerHTML = '<a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','+id+');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a>';
new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '0.5'});
tmp = document.getElementsByClassName("previewWindow");
// tmp[0].style.visibility="hidden";
}catch(g){}
if(preview_id == id){
// alert(preview_id + id);
$("preview1").style.visibility="hidden";
$("preview2").style.visibility="hidden";
}
/*for(var i=0;i<tmp.length;i++) {
if(tmp[i].style.visibility === "visible") {
tmp[i].style.visibility="hidden";
}
}*/
$("status").style.display="none";
if(i == ((rows.length)-2)){
runEmailCommand("reload",0);
}
}
break;
case 'delete_msg':
//id=resp;
eval(resp);
if($("row_"+id))
{
var row = $("row_"+id);
if(row.className == "unread_email") {
var unread = parseInt($(mailbox+"_unread").innerHTML);
$(mailbox+"_unread").innerHTML = (unread-1);
}
row.className = 'delete_email';
// row.className = "deletedRow";
Try.these (
function() {
$("ndeleted_subject_"+id).innerHTML = "<s>"+$("ndeleted_subject_"+id).innerHTML+"</s>";
$("ndeleted_date_"+id).innerHTML = "<s>"+$("ndeleted_date_"+id).innerHTML+"</s>";
$("ndeleted_from_"+id).innerHTML = "<s>"+$("ndeleted_from_"+id).innerHTML+"</s>";
},
function() {
$("deleted_subject_"+id).innerHTML = "<s>"+$("deleted_subject_"+id).innerHTML+"</s>";
$("deleted_date_"+id).innerHTML = "<s>"+$("deleted_date_"+id).innerHTML+"</s>";
$("deleted_from_"+id).innerHTML = "<s>"+$("deleted_from_"+id).innerHTML+"</s>";
}
);
$("del_link_"+id).innerHTML = '<a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','+id+');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a>';
new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'},duration: '1.0'});
}
if(preview_id == id){
// alert(preview_id + id);
$("preview1").style.visibility="hidden";
$("preview2").style.visibility="hidden";
}
runEmailCommand("reload",0);
break;
case 'undelete_msg':
id=resp;
var node = $("row_"+id);
node.className='';
node.style.display = '';
var newhtml = remove(remove(node.innerHTML,'<s>'),'</s>');
node.innerHTML=newhtml;
$("del_link_"+id).innerHTML = '<a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','+id+');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a>';
$("status").style.display="none";
break;
case 'clear_flag':
var nm = "clear_td_"+id;
var el = $(nm);
var tmp = el.innerHTML;
el.innerHTML ='<a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','+id+');"><img src="themes/images/important2.gif" border="0" width="11" height="11" id="set_flag_img_'+id+'"></a>';
el.id = "set_td_"+id;
break;
case 'set_flag':
var nm = "set_td_"+id;
var el = $(nm);
var tmp = el.innerHTML;
el.innerHTML ='<a href="javascript:void(0);" onclick="runEmailCommand(\'clear_flag\','+id+');"><img src="themes/images/important1.gif" border="0" width="11" height="11" id="clear_flag_img'+id+'"></a>';
el.id = "clear_td_"+id;
break;
}
$("status").style.display="none";
}
}
);
}
function cal_navigation(box,page){
start = page;
mailbox = box;
runEmailCommand("reload",0);
}
function remove(s, t) {
/*
** Remove all occurrences of a token in a string
** s string to be processed
** t token to be removed
** returns new string
*/
i = s.indexOf(t);
r = "";
if (i == -1) return s;
r += s.substring(0,i) + remove(s.substring(i + t.length), t);
return r;
}
function changeMbox(box) {
mailbox=box;
start = 0;
change_box=1;
runEmailCommand("reload",0);
//location.href = "index.php?module=Webmails&action=index&mailbox="+box;
}
// TODO: these two functions should be tied into a mailbox management panel of some kind.
// could be a DHTML div with AJAX calls to execute the commands on the mailbox.
function show_addfolder() {
var fldr = $("folderOpts");
if(fldr.style.display == 'none')
$("folderOpts").style.display="";
else
$("folderOpts").style.display="none";
}
function show_remfolder(mb) {
var fldr = $("remove_"+mb);
if(typeof(fldr) != "undefined")
{
if(fldr.style.display == 'none')
fldr.style.display="";
else
fldr.style.display="none";
}
}
@@ -0,0 +1,986 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
include_once('config.php');
require_once('include/logging.php');
require_once('modules/Webmails/conf.php');
require_once('modules/Webmails/functions.php');
require_once('include/database/PearDatabase.php');
require_once('data/SugarBean.php');
require_once('data/CRMEntity.php');
class result
{
var $text = "";
var $charset = "";
}
class Webmails extends CRMEntity {
var $log;
var $db;
var $headers;
var $mailid;
var $to = array();
var $to_name = array();
var $from;
var $fromname;
var $fromaddr;
var $reply_to = array();
var $reply_to_name = array();
var $cc_list = array();
var $cc_list_name = array();
var $subject;
var $date;
var $body_type;
var $body;
var $attachments = array();
var $inline = array();
var $attachtab = array();
var $mbox;
var $email;
var $relationship = array();
var $has_attachments = false;
function Webmails($mbox='',$mailid='') {
$this->db = PearDatabase::getInstance();
$this->db->println("Entering Webmail($mbox,$mailid)");
$this->log = &LoggerManager::getLogger('WEBMAILS');
$this->mbox=$mbox;
$this->mailid=$mailid;
$this->headers = $this->load_headers();
$this->to = $this->headers["theader"]["to"];
$this->to_name = $this->headers["theader"]["to_name"];
$this->db->println("Webmail TO:");
$this->db->println($this->to);
$this->from = $this->headers["theader"]["from"];
$this->fromname = $this->headers["theader"]["from_name"];
$this->fromaddr = $this->headers["theader"]["fromaddr"];
$this->reply_to = $this->headers["theader"]["reply_to"];
$this->reply_to_name = $this->headers["theader"]["reply_to_name"];
$this->cc_list = $this->headers["cc_list"];
$this->cc_list_name = $this->headers["cc_list_name"];
$this->subject = $this->headers["theader"]["subject"];
$this->date = $this->headers["theader"]["date"];
$this->has_attachments = $this->get_attachments();
$this->db->println("Exiting Webmail($mbox,$mailid)");
$this->relationship = $this->find_relationships(); // Added by Puneeth for 5231
}
function delete() {
imap_delete($this->mbox, $this->mailid);
}
function loadMail($attach_tab) {
$this->email = $this->load_mail($attach_tab);
$this->body = $this->email["body"];
$this->attachtab = $this->email["attachtab"];
$this->att= $this->email["att"];
}
function replyBody() {
$tmpvar = "<br><br><p style='font-weight:bold'>".$mod_strings['IN_REPLY_TO_THE_MESSAGE'].$this->reply_name." on ".$this->date."</p>";
$tmpvar .= "<blockquote style='border-left:1px solid blue;padding-left:5px'>".$this->body."</blockquote>";
return $tmpvar;
}
function unDeleteMsg() {
imap_undelete($this->mbox, $this->mailid);
}
function setFlag() {
$status=imap_setflag_full($this->mbox,$this->mailid,"\\Flagged");
}
function delFlag() {
$status=imap_clearflag_full($this->mbox,$this->mailid,"\\Flagged");
}
function getBodyType() {
return $this->body_type;
}
function downloadInlineAttachments() {
return $this->dl_inline();
}
function downloadAttachments() {
return $this->dl_attachments();
}
function load_headers() {
// get the header info
$mailHeader=Array();
$theader = @imap_headerinfo($this->mbox, $this->mailid);
$tmpvar = imap_mime_header_decode($theader->fromaddress);
for($p=0;$p<count($theader->to);$p++) {
$mailHeader['to'][] = $theader->to[$p]->mailbox.'@'.$theader->to[$p]->host;
$mailHeader['to_name'][] = $theader->to[$p]->personal;
}
$mailHeader['from'] = $theader->from[0]->mailbox.'@'.$theader->from[0]->host;
$mailHeader['from_name'] = $theader->from[0]->personal;
$mailHeader['fromaddr'] = $theader->fromaddress;
$mailHeader['subject'] = strip_tags($theader->subject);
$mailHeader['date'] = $theader->date;
for($p=0;$p<count($theader->reply_to);$p++) {
$mailHeader['reply_to'][] = $theader->reply_to[$p]->mailbox.'@'.$theader->reply_to[$p]->host;
$mailHeader['reply_to_name'][] = $theader->reply_to[$p]->personal;
}
for($p=0;$p<count($theader->cc);$p++) {
$mailHeader['cc_list'][] = $theader->cc[$p]->mailbox.'@'.$theader->cc[$p]->host;
$mailHeader['cc_list_name'][] = $theader->cc[$p]->personal;
}
return $ret = Array("theader"=>$mailHeader);
}
function get_attachments() {
$struct = @imap_fetchstructure($this->mbox, $this->mailid);
$parts = $struct->parts;
$done="false";
$i = 0;
if (!$parts)
return false; // simple message
else {
$stack = array();
$inline = array();
$endwhile = false;
while (!$endwhile) {
if (!$parts[$i]) {
if (count($stack) > 0) {
$parts = $stack[count($stack)-1]["p"];
$i = $stack[count($stack)-1]["i"] + 1;
array_pop($stack);
} else {
$endwhile = true;
}
}
if (!$endwhile) {
$partstring = "";
foreach ($stack as $s) {
$partstring .= ($s["i"]+1) . ".";
}
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "INLINE" || strtoupper($parts[$i]->disposition) == "ATTACHMENT")
return true;
}
if ($parts[$i]->parts) {
$stack[] = array("p" => $parts, "i" => $i);
$parts = $parts[$i]->parts;
$i = 0;
} else {
$i++;
}
}
}
return false;
}
function find_relationships() {
// leads search
$sql = "SELECT * from vtiger_leaddetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid where vtiger_leaddetails.email = ? AND vtiger_crmentity.deleted='0'";
$res = $this->db->pquery($sql,array(trim($this->from)),true,"Error: "."<BR>$query");
$numRows = $this->db->num_rows($res);
if($numRows > 0)
return array('type'=>"Leads",'id'=>$this->db->query_result($res,0,"leadid"),'name'=>$this->db->query_result($res,0,"firstname")." ".$this->db->query_result($res,0,"lastname"));
// contacts search
$sql = "SELECT * from vtiger_contactdetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid where vtiger_contactdetails.email = ? AND vtiger_crmentity.deleted='0'";
$res = $this->db->pquery($sql,array(trim($this->from)),true,"Error: "."<BR>$query");
$numRows = $this->db->num_rows($res);
if($numRows > 0)
return array('type'=>"Contacts",'id'=>$this->db->query_result($res,0,"contactid"),'name'=>$this->db->query_result($res,0,"firstname")." ".$this->db->query_result($res,0,"lastname"));
// vtiger_accounts search
$sql = "SELECT * from vtiger_account left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_account.email1 = ? OR vtiger_account.email1=? AND vtiger_crmentity.deleted='0'";
$res = $this->db->pquery($sql, array(trim($this->from), trim($this->from)), true,"Error: "."<BR>$query");
$numRows = $this->db->num_rows($res);
if($numRows > 0)
return array('type'=>"Accounts",'id'=>$this->db->query_result($res,0,"accountid"),'name'=>$this->db->query_result($res,0,"accountname"));
return array();
}
function dl_inline()
{
$struct = @imap_fetchstructure($this->mbox, $this->mailid);
$parts = $struct->parts;
$i = 0;
if (!$parts)
return;
else
{
$stack = array();
$inline = array();
$endwhile = false;
while (!$endwhile)
{
if (!$parts[$i])
{
if (count($stack) > 0)
{
$parts = $stack[count($stack)-1]["p"];
$i = $stack[count($stack)-1]["i"] + 1;
array_pop($stack);
}
else
{
$endwhile = true;
}
}
if (!$endwhile)
{
$partstring = "";
foreach ($stack as $s)
{
$partstring .= ($s["i"]+1) . ".";
}
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "INLINE")
{
//if the type is JPEG or GIF then call mail_fetchpart else fetchbody
if($parts[$i]->subtype == "JPEG" || $parts[$i]->subtype == "GIF")
$filedata = $this->mail_fetchpart($partstring);
else
$filedata = imap_fetchbody($this->mbox, $this->mailid, $partstring);
//Added to get the UTF-8 string - 30-11-06 - Mickie
$parts[$i]->dparameters[0]->value = utf8_decode(imap_utf8($parts[$i]->dparameters[0]->value));
//Added to get the UTF-8 string - 02-02-06 - Mickie
$filedata = utf8_decode(imap_utf8($filedata));
$inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>$filedata,"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
}
}
if ($parts[$i]->parts)
{
$stack[] = array("p" => $parts, "i" => $i);
$parts = $parts[$i]->parts;
$i = 0;
}
else
{
$i++;
}
}
}
return $inline;
}
function dl_attachments()
{
$struct = @imap_fetchstructure($this->mbox, $this->mailid);
$parts = $struct->parts;
$i = 0;
if (!$parts)
return;
else
{
$stack = array();
$attachment = array();
$endwhile = false;
while (!$endwhile)
{
if (!$parts[$i])
{
if (count($stack) > 0)
{
$parts = $stack[count($stack)-1]["p"];
$i = $stack[count($stack)-1]["i"] + 1;
array_pop($stack);
}
else
{
$endwhile = true;
}
}
if (!$endwhile)
{
$partstring = "";
foreach ($stack as $s)
{
$partstring .= ($s["i"]+1) . ".";
}
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
{
$filedata = imap_fetchbody($this->mbox, $this->mailid, $partstring);
$attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>$filedata,"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
}
}
if ($parts[$i]->parts)
{
$stack[] = array("p" => $parts, "i" => $i);
$parts = $parts[$i]->parts;
$i = 0;
}
else
{
$i++;
}
}
}
return $attachment;
}
function graphicalsmilies($body) {
$user_prefs = $_SESSION['nocc_user_prefs'];
if (isset($user_prefs->graphical_smilies) && $user_prefs->graphical_smilies) {
$body = ereg_replace("\;-?\)","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/wink.png\" alt=\"wink\"/>", $body);
$body = ereg_replace("\;-?D","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/grin.png\" alt=\"grin\"/>", $body);
$body = ereg_replace(":\'\(?","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/cry.png\" alt=\"cry\"/>", $body);
$body = ereg_replace(":-?[xX]","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/confused.png\" alt=\"confused\"/>", $body);
$body = ereg_replace(":-?\[\)","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/embarassed.png\" alt=\"embarassed\"/>", $body);
$body = ereg_replace(":-?\*","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/love.png\" alt=\"love\"/>", $body);
$body = ereg_replace(":-?[pP]","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/tongue.png\" alt=\"tongue\"/>", $body);
$body = ereg_replace(":-?\)","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/happy.png\" alt=\"happy\"/>", $body);
$body = ereg_replace(":-?\(","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/unhappy.png\" alt=\"unhappy\"/>", $body);
$body = ereg_replace(":-[oO]","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/surprised.png\" alt=\"surprised\"/>", $body);
$body = ereg_replace("8-?\)","<img src=\"themes/" . $_SESSION['nocc_theme'] . "/img/smilies/cool.png\" alt=\"cool\"/>", $body);
}
return ($body);
}
// based on a function from matt@bonneau.net
function GetPart(&$attach_tab, &$this_part, $part_no, &$display_rfc822)
{
$att_name = '[unknown]';
if ($this_part->ifdescription == true)
{
$att_name = $this_part->description;
}
for ($i = 0; $i < count($this_part->parameters); $i++)
{
// PHP 5.x doesn't allow to convert a stdClass object to an array
// We sometimes have this issue with Mailer daemon reports
if (!(get_class($this_part->parameters) == "stdClass") &&
!(get_class($this_part->parameters) == "stdclass"))
{
$param = $this_part->parameters[$i];
if ((($param->attribute == 'NAME') || ($param->attribute == 'name')) && ($param->value != ''))
{
$att_name = $param->value;
break;
}
}
}
if (isset($this_part->type))
{
switch ($this_part->type)
{
case 0:
$mime_type = 'text';
break;
case 1:
$mime_type = 'multipart';
for ($i = 0; $i < count($this_part->parts); $i++)
{
if ($part_no != ''){
$len = strlen($part_no);
if(!strpos($part_no,'.',($len-1)))
$part_no = $part_no . '.';
}
// if it's an alternative, we skip the text part to only keep the HTML part
if ($this_part->subtype == 'ALTERNATIVE')// && $read == true)
$this->GetPart($attach_tab, $this_part->parts[++$i], $part_no . ($i + 1), $display_rfc822);
else
$this->GetPart($attach_tab, $this_part->parts[$i], $part_no . ($i + 1), $display_rfc822);
}
break;
case 2:
$mime_type = 'message';
// well it's a message we have to parse it to find attachments or text message
if(isset($this_part->parts[0]->parts))
{
$num_parts = count($this_part->parts[0]->parts);
for ($i = 0; $i < $num_parts; $i++)
{
$this->GetPart($attach_tab, $this_part->parts[0]->parts[$i], $part_no . '.' . ($i + 1), $display_rfc822);
}
}
break;
// Maybe we can do something with the mime types later ??
case 3:
$mime_type = 'application';
break;
case 4:
$mime_type = 'audio';
break;
case 5:
$mime_type = 'image';
break;
case 6:
$mime_type = 'video';
break;
case 7:
$mime_type = 'other';
break;
default:
$mime_type = 'unknown';
}
}
else
{
$mime_type = 'text';
}
$full_mime_type = $mime_type . '/' . $this_part->subtype;
if (isset($this_part->encoding))
{
switch ($this_part->encoding)
{
case 0:
$encoding = '7BIT';
break;
case 1:
$encoding = '8BIT';
break;
case 2:
$encoding = 'BINARY';
break;
case 3:
$encoding = 'BASE64';
break;
case 4:
$encoding = 'QUOTED-PRINTABLE';
break;
case 5:
$encoding = 'OTHER';
break;
default:
$encoding = 'none';
break;
}
}
else
{
$encoding = '7BIT';
}
if (($full_mime_type == 'message/RFC822' && $display_rfc822 == true) || ($mime_type != 'multipart' && $full_mime_type != 'message/RFC822'))
{
$charset = '';
if ($this_part->ifparameters)
while ($obj = array_pop($this_part->parameters))
if (strtolower($obj->attribute) == 'charset')
{
$charset = $obj->value;
break;
}
$tmp = Array(
'number' => ($part_no != '' ? $part_no : 1),
'id' => $this_part->ifid ? $this_part->id : 0,
'name' => $att_name,
'mime' => $full_mime_type,
'transfer' => $encoding,
'disposition' => $this_part->ifdisposition ? $this_part->disposition : '',
'charset' => $charset,
'size' => ($this_part->bytes > 1000) ? ceil($this_part->bytes / 1000) : 1
);
array_unshift($attach_tab, $tmp);
}
}
function GetCodeScoreAll($Data,$beg_charset) {
global $cad_StatsTableWin, $cad_StatsTableKoi;
$PairSize = 2;
$Data=substr($Data,$beg_charset,100);
$Data=preg_replace('/[\n\r]/','',$Data);
setlocale(LC_CTYPE,'ru_RU.KOI8-R');
$Mark_koi=0;
$Mark_win=0;
$cnt=0;
$max_detect_limit=10;
$sp=preg_split('/[\.\,\-\s\:\;\?\!\'\"\(\)\d<>]+/',$Data);
while ( list($key2,$val2) = each($sp) ) {
$rc=preg_match("/(.*)([\x7F-\xFF]+)/x",$val2);
if($rc == 0) {
continue;
}
if($cnt > $max_detect_limit) {
break;
} else {
$cnt++;
}
$dlina=strlen($val2)-$PairSize;
if($dlina < 1) {$cnt--; continue;}
$val3=strtolower($val2);
if (ucfirst($val3) == $val2) {
$scaleK=2;
} else {
$scaleK=1;
}
if(substr($val3,0,1).strtoupper(substr($val2,1,strlen($val2))) == $val2) {
$scaleW=2;
} else {
$scaleW=1;
}
$Cur_mark_koi=0;
$Cur_mark_win=0;
for ($i=0; $i<$dlina; $i++ ) {
$pp=substr ($val3, $i, $PairSize);
if (isset($cad_StatsTableKoi[$pp])) {
$Cur_mark_koi += $cad_StatsTableKoi[$pp];
}
if (isset($cad_StatsTableWin[$pp])) {
$Cur_mark_win += $cad_StatsTableWin[$pp];
}
}
$Mark_koi+=$Cur_mark_koi*$scaleK;
$Mark_win+=$Cur_mark_win*$scaleW;
}
$Mark_list=array($Mark_koi,$Mark_win);
//setlocale(LC_CTYPE,$old_locale);
return $Mark_list;
}
/* lxnt: patched to return charset names that iconv() understands*/
function detect_charset($Data,$dbg_fl = 0) {
/* for many small pices of text - list of sender/subject*/
$rc=preg_match("/(.*)([\x7F-\xFF]+)/xU",$Data,$tst_ar);
if($rc == 0) {
return 'US-ASCII';
} else {
$beg_charset=strpos($Data,$tst_ar[2]);
}
list($KoiMark,$WinMark) = GetCodeScoreAll($Data,$beg_charset);
$Ratio['koi8-r'] = $KoiMark/($WinMark + 1);
$Ratio['windows-1251'] = $WinMark/($KoiMark + 1);
list($MaxRation,$MaxRatioKey)=max_from_ratio($Ratio);
return $MaxRatioKey;
}
function mime_header_decode(&$header)
{
$output_charset = $GLOBALS['charset'];
$source = imap_mime_header_decode($header);
$result[] = new result;
$result[0]->text='';
$result[0]->charset='UTF-8';
for ($j = 0; $j < count($source); $j++ )
{
$element_charset = ($source[$j]->charset == "default") ? $this->detect_charset($source[$j]->text) : $source[$j]->charset;
if ($element_charset == 'x-unknown')
$element_charset = 'UTF-8';
if(empty($output_charset)) $output_charset = $default_charset;
$element_converted = function_exists(iconv) ? @iconv( $element_charset, $output_charset, $source[$j]->text): $source[$j]->text ;
$result[$j]->text = $element_converted;
$result[$j]->charset = $output_charset;
}
return $result;
}
function link_att(&$mail, $attach_tab, &$display_part_no,$ev)
{
sort($attach_tab);
$link = '';
$ct = 0;
while ($tmp = array_shift($attach_tab))
if (!empty($tmp['name']))
{
$mime = str_replace('/', '-', $tmp['mime']);
if ($display_part_no == true)
//$link .= $tmp['number']-1 . '&nbsp;&nbsp;';
unset($att_name);
$att_name_array = imap_mime_header_decode($tmp['name']);
for ($i=0; $i<count($att_name_array); $i++) {
$att_name .= $att_name_array[$i]->text;
}
if(!preg_match("/unknown/",$att_name))
$this->attname[$ct] = $att_name;
$att_name_dl = $att_name;
$att_name = $this->convertLang2Html($att_name);
if(!preg_match("/unknown/",$att_name)){
$link .= ($ct+1).'. <a href="index.php?module=Webmails&action=download&part=' . $tmp['number'] . '&mailid='.$ev.'&transfer=' . $tmp['transfer'] . '&filename=' . base64_encode($att_name_dl) . '&mime=' . $mime . '">' . $att_name . '</a>&nbsp;&nbsp;' . $tmp['mime'] . '&nbsp;&nbsp;' . $tmp['size'] . '<br/>';
$this->anchor_arr[$ct] = '<a href="index.php?module=Webmails&action=download&part=' . $tmp['number'] . '&mailid='.$ev.'&transfer=' . $tmp['transfer'] . '&filename=' . base64_encode($att_name_dl) . '&mime=' . $mime . '">';
$this->att_details[$ct]['name'] = $att_name;
$this->att_details[$ct]['size'] = $tmp['size'];
$this->att_details[$ct]['type'] = $tmp['mime'];
$this->att_details[$ct]['part'] = $tmp['number'];
$this->att_details[$ct]['transfer'] = $tmp['transfer'];
$ct++;
}
}
return ($link);
}
// Convert mail data (from, to, ...) to HTML
function convertMailData2Html($maildata, $cutafter = 0)
{
if (($cutafter > 0) && (strlen($maildata) > $cutafter))
{
return htmlspecialchars(substr($maildata, 0, $cutafter)) . '&hellip;';
}
else
{
return htmlspecialchars($maildata);
}
}
// Convert a language string to HTML
function convertLang2Html($langstring) {
global $charset;
return htmlentities($langstring, 2, $charset);
}
function load_mail($attach_tab)
{
// parse the message
global $default_charset;
$ref_contenu_message = @imap_headerinfo($this->mbox, $this->mailid);
$struct_msg = @imap_fetchstructure($this->mbox, $this->mailid);
$mail = $this->mbox;
$ev = $this->mailid;
$conf->display_rfc822 = true;
if ($struct_msg->type == 3 || (isset($struct_msg->parts) && (sizeof($struct_msg->parts) > 0)))
{
$this->GetPart($attach_tab, $struct_msg, NULL, $conf->display_rfc822);
}
else
{
$pop_fetchheader_mail_ev = @imap_fetchheader($mail, $ev);
$pop_body_mail_ev = @imap_body($mail, $ev);
GetSinglePart($attach_tab, $struct_msg, $pop_fetchheader_mail_ev, $pop_body_mail_ev);
}
$conf->use_verbose = true;
$header = "";
if (($verbose == 1) && ($conf->use_verbose == true)) {
$header = imap_fetchheader($mail, $ev);
}
$tmpvar = array_pop($attach_tab);
if ($struct_msg->type == 3)
{
$body = '';
}
else
{
$body = @imap_fetchbody($mail,$ev,$tmpvar['number']);
}
if (eregi('text/html', $tmpvar['mime']) || eregi('text/plain', $tmpvar['mime']))
{
if ($tmpvar['transfer'] == 'QUOTED-PRINTABLE')
$body = imap_qprint($body);
if ($tmpvar['transfer'] == 'BASE64')
$body = base64_decode($body);
$body = remove_stuff($body, $tmpvar['mime']);
$body_charset = ($tmpvar['charset'] == "default") ? $this->detect_charset($body) : $tmpvar['charset'];
if (strtolower($body_charset) == "us-ascii") {
$body_charset = "UTF-8";
}
if ($body_charset == "" || $body_charset == null) {
if (isset($conf->default_charset) && $conf->default_charset != "") {
$body_charset = $conf->default_charset;
} else {
$body_charset = "UTF-8";
}
}
if (isset($_REQUEST['user_charset']) && $_REQUEST['user_charset'] != '') {
$body_charset = $_REQUEST['user_charset'];
}
$this->charsets = $body_charset;
if(empty($GLOBALS['charset'])) $GLOBALS['charset'] = $default_charset;
$body_converted = function_exists(iconv) ? @iconv( $body_charset, $GLOBALS['charset'], $body) : $body;
$body = ($body_converted===FALSE) ? $body : $body_converted;
$tmpvar['charset'] = ($body_converted===FALSE) ? $body_charset : $GLOBALS['charset'];
}
else
{
array_push($attach_tab, $tmpvar);
}
$link_att = '';
$att_links = '';//variable added to display the attachments in full email view
$conf->display_part_no = true;
if ($struct_msg->subtype != 'ALTERNATIVE' || $struct_msg->subtype != 'RELATED')
{
switch (sizeof($attach_tab))
{
case 0:
$link_att = '<span id="webmail_cont" style="display:none;"><tr><th class="mailHeaderLabel right"></th><td class="mailHeaderData"></td></tr></span>';
break;
case 1:
$link_att = '<span id="webmail_cont" style="display:none;"><tr><th class="mailHeaderLabel right">' . $html_att . ':</th><td class="mailHeaderData">' . $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev) . '</td></tr></span>';
$this->att_links .= $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev)."</br>";
break;
default:
$link_att = '<span id="webmail_cont" style="display:none;"><tr><th class="mailHeaderLabel right">' . $html_atts . ':</th><td class="mailHeaderData">' . $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev) . '</td></tr></span>';
$this->att_links .= $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev)."</br>";
break;
}
}else
{
$link_att = '<span id="webmail_cont" style="display:none;"><tr><th class="mailHeaderLabel right"></th><td class="mailHeaderData"></td></tr></span>';
}
$struct_msg = @imap_fetchstructure($mail, $ev);
$msg_charset = '';
if ($struct_msg->ifparameters) {
while ($obj = array_pop($struct_msg->parameters)) {
if (strtolower($obj->attribute) == 'charset') {
$msg_charset = $obj->value;
break;
}
}
}
if ($msg_charset == '') {
$msg_charset = 'UTF-8';
}
$subject_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->subject);
$subject_array = $this->mime_header_decode($subject_header);
for ($j = 0; $j < count($subject_array); $j++)
$subject .= $subject_array[$j]->text;
$from_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->fromaddress);
$from_array = $this->mime_header_decode($from_header);
for ($j = 0; $j < count($from_array); $j++)
$from .= $from_array[$j]->text;
//fixed the issue #3235
$toheader = @imap_fetchheader($this->mbox, $this->mailid);
$to_arr = explode("To:",$toheader);
if(!stripos($to_arr[1],'mime')){
$to_add = stripos($to_arr[1],"CC:")?explode("CC:",$to_arr[1]):explode("Subject:",$to_arr[1]);
$to_header = trim($to_add[0]);
}
else
$to_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->toaddress);
$to_array = $this->mime_header_decode($to_header);
for ($j = 0; $j < count($to_array); $j++)
$to .= $to_array[$j]->text;
$to = str_replace(',', ', ', $to);
$this->to_header = $to_header;
$cc_header = isset($ref_contenu_message->ccaddress) ? $ref_contenu_message->ccaddress : '';
$cc_header = str_replace('x-unknown', $msg_charset, $cc_header);
$cc_array = isset($ref_contenu_message->ccaddress) ? imap_mime_header_decode($cc_header) :0;
if ($cc_array != 0) {
for ($j = 0; $j < count($cc_array); $j++)
$cc .= $cc_array[$j]->text;
}
$cc = str_replace(',', ', ', $cc);
$this->cc_header = $cc_header;
$reply_to_header = isset($ref_contenu_message->reply_toaddress) ? $ref_contenu_message->reply_toaddress : '';
$reply_to_header = str_replace('x-unknown', $msg_charset, $reply_to_header);
$reply_to_array = isset($ref_contenu_message->reply_toaddress) ? imap_mime_header_decode($reply_to_header) : 0;
if ($reply_to_array != 0) {
for ($j = 0; $j < count($reply_to_array); $j++)
$reply_to .= $reply_to_array[$j]->text;
}
$timestamp = chop($ref_contenu_message->udate);
$date = format_date($timestamp, $lang);
$time = format_time($timestamp, $lang);
$content = Array(
'from' => $from,
'to' => $to,
'cc' => $cc,
'reply_to' => $reply_to,
'subject' => $subject,
'date' => $date,
'time' => $time,
'complete_date' => $date,
'att' => $link_att,
'body' => $this->graphicalsmilies($body),
'body_mime' => $this->convertLang2Html($tmpvar['mime']),
'body_transfer' => $this->convertLang2Html($tmpvar['transfer']),
'header' => $header,
'verbose' => $verbose,
'prev' => $prev_msg,
'next' => $next_msg,
'msgnum' => $mail,
'attachtab' => $attach_tab,
'charset' => $body_charset
);
return ($content);
}
// get the body of a part of a message according to the
// string in $part
function mail_fetchpart($part)
{
$parts = $this->mail_fetchparts();
$partNos = explode(".", $part);
$currentPart = $parts;
while(list ($key, $val) = each($partNos))
{
$currentPart = $currentPart[$val];
}
if ($currentPart != "") return $currentPart;
else return false;
}
// splits a message given in the body if it is
// a mulitpart mime message and returns the parts,
// if no parts are found, returns false
function mail_mimesplit($header, $body)
{
$parts = array();
$PN_EREG_BOUNDARY = "Content-Type:(.*)boundary=\"([^\"]+)\"";
if (eregi ($PN_EREG_BOUNDARY, $header, $regs))
{
$boundary = $regs[2];
$delimiterReg = "([^\r\n]*)$boundary([^\r\n]*)";
if (eregi ($delimiterReg, $body, $results))
{
$delimiter = $results[0];
$parts = explode($delimiter, $body);
$parts = array_slice ($parts, 1, -1);
}
return $parts;
}
else
{
return false;
}
}
// returns an array with all parts that are
// subparts of the given part
// if no subparts are found, return the body of
// the current part
function mail_mimesub($part)
{
$i = 1;
$headDelimiter = "\r\n\r\n";
$delLength = strlen($headDelimiter);
// get head & body of the current part
$endOfHead = strpos( $part, $headDelimiter);
$head = substr($part, 0, $endOfHead);
$body = substr($part, $endOfHead + $delLength, strlen($part));
// check whether it is a message according to rfc822
if (stristr($head, "Content-Type: message/rfc822"))
{
$part = substr($part, $endOfHead + $delLength, strlen($part));
$returnParts[1] = $this->mail_mimesub($part);
return $returnParts;
// if no message, get subparts and call function recursively
}
elseif ($subParts = $this->mail_mimesplit($head, $body))
{
// got more subparts
while (list ($key, $val) = each($subParts))
{
$returnParts[$i] = $this->mail_mimesub($val);
$i++;
}
return $returnParts;
}
else
{
return $body;
}
}
// get an array with the bodies all parts of an email
// the structure of the array corresponds to the
// structure that is available with imap_fetchstructure
function mail_fetchparts()
{
$parts = array();
$header = imap_fetchheader($this->mbox, $this->mailid);
$body = imap_body($this->mbox, $this->mailid, FT_INTERNAL);
$i = 1;
if ($newParts = $this->mail_mimesplit($header, $body))
{
while (list ($key, $val) = each($newParts))
{
$parts[$i] = $this->mail_mimesub($val);
$i++;
}
}
else
{
$parts[$i] = $body;
}
return $parts;
}
}
function decode_header($string)
{
$elements = imap_mime_header_decode($string);
for ($i=0; $i<count($elements); $i++) {
$result .= $elements[$i]->text;
}
return $result;
}
?>
@@ -0,0 +1,158 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
require_once('include/logging.php');
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once('modules/Webmails/MailBox.php');
require_once('modules/Webmails/Webmails.php');
global $adb,$current_user;
if($_POST['config_chk'] == 'true')
{
$MailBox = new MailBox();
if($MailBox->enabled == 'false') {
echo 'FAILED';
exit();
} else {
echo 'SUCCESS';
exit();
}
exit();
}
if(isset($_REQUEST['file']) && $_REQUEST['file']!='' && !isset($_REQUEST['ajax'])){
checkFileAccess("modules/".$_REQUEST['module']."/".$_REQUEST['file'].".php");
require_once("modules/".$_REQUEST['module']."/".$_REQUEST['file'].".php");
exit();
}
$mailid = vtlib_purify($_REQUEST["mailid"]);
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") {$mailbox=vtlib_purify($_REQUEST["mailbox"]);} else {$mailbox="INBOX";}
$adb->println("Inside WebmailsAjax.php");
if(isset($_POST["file"]) && $_POST["ajax"] == "true") {
checkFileAccess("modules/".$_REQUEST["module"]."/".$_POST["file"].".php");
require_once("modules/".$_REQUEST["module"]."/".$_POST["file"].".php");
}
if(isset($_REQUEST["command"]) && $_REQUEST["command"] != "") {
$command = $_REQUEST["command"];
if($command == "expunge") {
$MailBox = new MailBox($mailbox);
imap_expunge($MailBox->mbox);
$MailBox = new MailBox($mailbox);
$elist = $MailBox->mailList;
$num_mails = $elist['count'];
$start_page = cal_start($num_mails,$MailBox->mails_per_page);
imap_close($MailBox->mbox);
echo $start_page;
flush();
exit();
}
if($command == "delete_msg") {
$adb->println("DELETE SINGLE WEBMAIL MESSAGE $mailid");
$MailBox = new MailBox($mailbox);
imap_delete($MailBox->mbox,$mailid);
imap_expunge($MailBox->mbox);
$email = new Webmails($MailBox->mbox,$mailid);
$MailBox = new MailBox($mailbox);
$elist = $MailBox->mailList;
$num_mails = $elist['count'];
$start_page = cal_start($num_mails,$MailBox->mails_per_page);
imap_close($MailBox->mbox);
echo "start=".$start_page.";";
echo "id=".$mailid.";";
flush();
exit();
}
if($command == "delete_multi_msg") {
$MailBox = new MailBox($mailbox);
$tlist = explode(":",$mailid);
foreach($tlist as $id) {
imap_delete($MailBox->mbox,$id);
$adb->println("DELETE MULTI MESSAGE $id");
$email = new Webmails($MailBox->mbox,$id);
$email->delete();
}
imap_expunge($MailBox->mbox);
$MailBox = new MailBox($mailbox);
$elist = $MailBox->mailList;
$num_mails = $elist['count'];
$start_page = cal_start($num_mails,$MailBox->mails_per_page);
imap_close($MailBox->mbox);
echo "start=".$start_page.";";
echo "ids='".$mailid."';";
flush();
exit();
}
if($_POST["command"] == "move_msg" && $_POST["ajax"] == "true") {
$MailBox = new MailBox($mailbox);
if(isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != '') {
$mailids = explode(':',$_REQUEST["mailid"]);
}
foreach($mailids as $mailid) {
imap_mail_move($MailBox->mbox,$mailid,$_REQUEST["mvbox"]);
}
imap_expunge($MailBox->mbox);
imap_close($MailBox->mbox);
$MailBox = new MailBox($mailbox);
$elist = $MailBox->mailList;
$num_mails = $elist['count'];
$start_page = cal_start($num_mails,$MailBox->mails_per_page);
imap_close($MailBox->mbox);
echo $start_page;
flush();
exit();
}
if($command == "undelete_msg") {
$MailBox = new MailBox($mailbox);
$email = new Webmails($MailBox->mbox,$mailid);
$email->unDeleteMsg();
imap_close($MailBox->mbox);
echo $mailid;
flush();
exit();
}
if($command == "set_flag") {
$MailBox = new MailBox($mailbox);
$email = new Webmails($MailBox->mbox,$mailid);
$email->setFlag();
imap_close($MailBox->mbox);
echo $mailid;
flush();
exit();
}
if($command == "clear_flag") {
$MailBox = new MailBox($mailbox);
$email = new Webmails($MailBox->mbox,$mailid);
$email->delFlag();
imap_close($MailBox->mbox);
echo $mailid;
flush();
exit();
}
imap_close($MailBox->mbox);
flush();
exit();
}
function cal_start($num_mails,$mail_per_page) {
if(isset($_REQUEST['start']) && $_REQUEST['start']!=0) {
$pre_start = $_REQUEST['start'];
$cal = (($pre_start-1) * $mail_per_page);
if($num_mails > $cal)
$res = $pre_start;
else
$res = $pre_start - 1;
} else
$res = 0;
return $res;
}
?>
+161
View File
@@ -0,0 +1,161 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
global $current_user;
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once('modules/Webmails/Webmails.php');
require_once('modules/Webmails/MailBox.php');
global $mod_strings;
if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] != $current_user->id) {echo "ajax failed";flush();exit();}
$mailid=vtlib_purify($_REQUEST["mailid"]);
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "")
{
$mailbox=vtlib_purify($_REQUEST["mailbox"]);
}
else
{
$mailbox="INBOX";
}
$MailBox = new MailBox($mailbox);
$mail = $MailBox->mbox;
$email = new Webmails($MailBox->mbox,$mailid);
$status=imap_setflag_full($MailBox->mbox,$mailid,"\\Seen");
$attach_tab=array();
$email->loadMail($attach_tab);
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$email->charsets."\">\n";
$subject = utf8_decode(utf8_encode(imap_utf8($email->subject)));
$from = decode_header($email->from);
$to = decode_header($email->to_header);
$cc = decode_header($email->cc_header);
$date = decode_header($email->date);
for($i=0;$i<count($email->attname);$i++){
$attachment_links .= $email->anchor_arr[$i].decode_header($email->attname[$i])."</a></br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
$content['body'] = $email->body;
$content['attachtab'] = $email->attachtab;
if(!$_REQUEST['fullview'])
$class_str = 'class="tableHeadBg"';
else
$class_str = 'style="font-size:15px"';
?>
<script src="modules/Webmails/Webmails.js" type="text/javascript"></script>
<script src="include/js/general.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="themes/<?php echo vtlib_purify($_REQUEST['theme']);?>/webmail.css">
<!-- Table to display the Header details (From, To, Subject and date) - Starts -->
<table <?php echo $class_str;?> width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="left"><td width="100%" align="left">&nbsp;<b><?php echo $mod_strings['LBL_FROM'];?></b><?php echo $from;?></td></tr>
<tr><td width="100%" align="left">&nbsp;<b><?php echo $mod_strings['LBL_TO'];?></b><?php echo $to;?></td></tr>
<tr><td width="100%" align="left">&nbsp;<b><?php echo $mod_strings['LBL_CC'];?></b><?php echo $cc;?></td></tr>
<tr><td align="left" width="100%">&nbsp;<b><?php echo $mod_strings['LBL_SUBJECT'];?></b><?php echo $subject;?></td></tr>
<tr><td align="left" width="100%">&nbsp;<b><?php echo $mod_strings['LBL_DATE'];?></b><?php echo substr($date,0,25);?>
<?php if(!$_REQUEST['fullview']) {?>
<span style="float:right" colspan="2"><a href="javascript:;" onclick="OpenComposer('<?php echo $mailid;?>','full_view')"><?php echo $mod_strings['LBL_FULL_EMAIL_VIEW'] ?></a></span>
<?php } ?>
</td>
</tr>
<?php if(isset($_REQUEST['fullview']) && $attachment_links != '') {?>
<tr>
<td align="left">&nbsp;<b><?php echo $mod_strings['LBL_ATTACHMENT'];?>:</b><?php echo $attachment_links;?></td>
</tr>
<?php } ?>
<tr><td align="left" style="border-bottom:1px solid #666666;" colspan="3">&nbsp;</td></tr>
</table>
<!-- Table to display the Header details (From, To, Subject and date) - Ends -->
<script type="text/javascript">
mailbox = "<?php echo $mailbox;?>";
function show_inline(num) {
var el = document.getElementById("block_"+num);
if(el.style.display == 'block')
el.style.display='none';
else
el.style.display='block';
}
</script>
<?php
function view_part_detail($mail,$mailid,$part_no, &$transfer, &$msg_charset, &$charset)
{
$text = imap_fetchbody($mail,$mailid,$part_no);
if ($transfer == 'BASE64')
$str = nl2br(imap_base64($text));
elseif($transfer == 'QUOTED-PRINTABLE')
$str = nl2br(quoted_printable_decode($text));
else
$str = nl2br($text);
return ($str);
}
//Need to put this along with the subject block*/
echo $email->att;
if(!$_REQUEST['fullview'])
echo '<div style="overflow:auto;height:386px;width:737px;padding:5;">';
else
echo '<div style="padding:5;">';
echo $content['body'];
//test added by Richie
if (!isset($_REQUEST['display_images']) || $_REQUEST['display_images'] != 1)
{
$content['body'] = eregi_replace('src="[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]"', 'src="none"', $content['body']);
$content['body'] = eregi_replace('src=[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]', 'src="none"', $content['body']);
}
//Display embedded HTML images
$tmp_attach_tab=$content['attachtab'];
$i = 0;
$conf->display_img_attach = true;
$conf->display_text_attach = true;
while ($tmp = array_pop($tmp_attach_tab))
{
if ($conf->display_img_attach && (eregi('image', $tmp['mime']) && ($tmp['number'] != '')))
{
$exploded = explode('/', $tmp['mime']);
$img_type = array_pop($exploded);
if (eregi('JPEG', $img_type) || eregi('JPG', $img_type) || eregi('GIF', $img_type) || eregi ('PNG', $img_type))
{
$new_img_src = 'src="get_img.php?mail=' . $mailid.'&num=' . $tmp['number'] . '&mime=' . $img_type . '&transfer=' . $tmp['transfer'] . '"';
$img_id = str_replace('<', '', $tmp['id']);
$img_id = str_replace('>', '', $img_id);
$content['body'] = str_replace('src="cid:'.$img_id.'"', $new_img_src, $content['body']);
$content['body'] = str_replace('src=cid:'.$img_id, $new_img_src, $content['body']);
}
}
}
while ($tmp = array_pop($content['attachtab']))
{
if ((!eregi('ATTACHMENT', $tmp['disposition'])) && $conf->display_text_attach && (eregi('text/plain', $tmp['mime'])))
echo '<hr />'.view_part_detail($mail, $mailid, $tmp['number'], $tmp['transfer'], $tmp['charset'], $charset);
if ($conf->display_img_attach && (eregi('image', $tmp['mime']) && ($tmp['number'] != '')))
{
$exploded = explode('/', $tmp['mime']);
$img_type = array_pop($exploded);
if (eregi('JPEG', $img_type) || eregi('JPG', $img_type) || eregi('GIF', $img_type) || eregi ('PNG', $img_type))
{
echo '<hr />';
echo '<center>';
echo '<img src="index.php?module=Webmails&action=get_img&mail=' . $mailid.'&mailbox='.$mailbox.'&num=' . $tmp['number'] . '&mime=' . $img_type . '&transfer=' . $tmp['transfer'] . '" />';
echo '</center>';
}
}
}
echo '</div>';
//test ended by Richie
imap_close($MailBox->mbox);
?>
+290
View File
@@ -0,0 +1,290 @@
<?php
/*
* $Header: /cvsroot/nocc/nocc/webmail/conf.php.dist,v 1.150 2006/11/29 19:58:51 goddess_skuld Exp $
*
* Copyright 2001 Nicolas Chalanset <nicocha@free.fr>
* Copyright 2001 Olivier Cahagne <cahagn_o@epita.fr>
* Copyright 2002 Mike Rylander <mrylander@mail.com>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
// ################### This is the main configuration for NOCC ########## //
// ==> Required parameters
// Will be checked by html/*.php file. If it's not available, these files won't
// be loaded.
$conf->loaded = true;
// Default smtp server and smtp_port (default is 25)
// If a domain has no smtp server, this one will be used
// If no smtp server is provided, Nocc will default to the mail() function,
// and try to use Sendmail or any other MTA (Postfix)
$conf->default_smtp_server = 'smtp';
$conf->default_smtp_port = 25;
// List of domains people can log in
// You can have as many domains as you need
// $conf->domains[$i]->domain = 'sourceforge.net';
// domain name e.g 'sourceforge.net'. This field is used when sending message
//
// $conf->domains[$i]->in = 'mail.sourceforge.net:110/pop3';
// imap or pop3 server name + port + protocol (only if not imap)
// [server_name]:[port number]/[protocol]/[options]
// ex for an imap server : mail.sourceforge.net:143
// ex for an imap server with explicit TLS/SSL negociation desactivated : mail.sourceforge.net:143/notls (may be useful for some courier-imap installation).
//(may be useful for some courier-imap installation).
// ex for an ssl imap server : mail.sourceforge.net:993/ssl
// ex for an ssl imap server with a self-signed certificate : mail.sourceforge.net:993/ssl/novalidate-cert
// ex for a pop3 server : mail.sourceforge.net:110/pop3
// ex for a pop3 server with explicit TLS/SSL negociation desactivated : mail.sourceforge.net:110/pop3/notls (may be useful for some courier-imap installation).
// ex for an ssl pop3 server : mail.sourceforge.net:995/pop3/ssl
// ex for an ssl pop3 server with a self-signed certificate : mail.sourceforge.net:995/pop3/ssl/novalidate-cert
// protocol can only be pop3
//
// $conf->domains[$i]->smtp = 'smtp.isp.com';
// Optional: smtp server name or IP address
// Leave empty to send mail via sendmail
//
// $conf->domains[$i]->smtp_port = 25;
// Port number to connect to smtp server (usually 25)
$i = 0;
$conf->domains[$i]->domain = '';
$conf->domains[$i]->in ='' ;
//$conf->domains[$i]->in = '';
$conf->domains[$i]->smtp = 'smtp';
$conf->domains[$i]->smtp_port = 25;
// Uncomment for 'user<char>domain.com' style logins
//$conf->domains[$i]->login_with_domain = 1;
// Uncomment and select character to use for login_with_domain option
//$conf->domains[$i]->login_with_domain_character = '@';
// Fill in if you require login suffixes for your mail server
$conf->domains[$i]->login_suffix = '';
// Uncomment for login aliases and use the following syntax:
// login_aliases = array('alias1' => 'real_login_1','alias2' => 'real_login_2');
// If you want to use an external file, use the following syntax:
// login_aliases = '@/path/to/file/';
// See login_alias.sample file for example.
//$conf->domains[$i]->login_aliases = array();
// Uncomment for allowed logins and use the following syntax:
// login_allowed = array('login_1' => '', 'login_2' => '');
// If you want to use an external file, use the following syntax:
// login_allowed = '@/path/to/file/';
// See login_allowed.sample file for example.
//$conf->domains[$i]->login_allowed = array();
// Select SMTP AUTH method.
// Supported AUTH methods are :
// '' : no authentification method
// 'PLAIN' : AUTH PLAIN method
// 'LOGIN' : AUTH LOGIN method
$conf->domains[$i]->smtp_auth_method = '';
// Select IMAP Namespace
$conf->domains[$i]->imap_namespace = "INBOX.";
// If you want to add more domains, uncomment the following
// lines and fill them in
//$i++;
//$conf->domains[$i]->domain = '';
//$conf->domains[$i]->in = '';
//$conf->domains[$i]->smtp = '';
//$conf->domains[$i]->smtp_port = 25;
//$conf->domains[$i]->login_with_domain = 1;
//$conf->domains[$i]->login_suffix = '';
//$conf->domains[$i]->login_aliases = array();
//$conf->domains[$i]->login_allowed = array();
//$conf->domains[$i]->smtp_auth_method = '';
//$conf->domains[$i]->imap_namespace = "INBOX.";
//$i++;
//$conf->domains[$i]->domain = '';
//$conf->domains[$i]->in = '';
//$conf->domains[$i]->smtp = '';
//$conf->domains[$i]->smtp_port = 25;
//$conf->domains[$i]->login_with_domain = 1;
//$conf->domains[$i]->login_suffix = '';
//$conf->domains[$i]->login_aliases = array();
//$conf->domains[$i]->login_allowed = array();
//$conf->domains[$i]->smtp_auth_method = '';
//$conf->domains[$i]->imap_namespace = "INBOX.";
// If you use many mail domains, the one used will be we one of the HTTP host,
// and the user won't be asked for the domain to connect.
// Set to true to enable.
$conf->vhost_domain_login = false;
// Is the user allowed to change his "From:" address? (true/false)
$conf->allow_address_change = true;
// Default tmp directory (where to store temporary uploaded files)
// This should be something like '/tmp' on Unix System
// And 'c:\\temp' on Win32 (note that we must escape "\")
$conf->tmpdir = '/tmp';
// Preferences and contacts data directory
// IMPORTANT: This directory must exist and be writable by the user
// the webserver is running as (e.g. 'apache', or 'nobody'). For
// Apache, see the User directive in the httpd.conf file.
// See README for more about this.
// This should be something like 'profiles/' on Unix System
// or 'prefs\\' on Win32 (note that we must escape "\").
// You should not use a subfolder within your Nocc installation, as it will
// be readable by everybody, and will contain sensible information as email
// addresses and names.
// If left empty, preferences, contacts and session saving will be disabled.
$conf->prefs_dir = '.';
// Master key for session password encryption. Longer is better.
// It must not be left empty.
$conf->master_key = 'abc';
// Default folder to go first
$conf->default_folder = 'INBOX';
// ===> End of required parameters
// The following parameters can be changed but it's not necessary to
// get a working version of nocc
// if browser has no preferred language, we use the default language
// This is only needed for browsers that don't send any preferred
// language such as W3 Amaya
$conf->default_lang = 'en';
// force default language to be set, rather than browser prefered language
$conf->force_default_lang = false;
// How many messages to display in the inbox (devel only)
$conf->max_msg_num = 1;
// let user see the header of a message
$conf->use_verbose = true;
// the user can logout or not (if nocc is used within your website
// enter 'false' here else leave 'true')
$conf->enable_logout = true;
// the user can change their 'reply leadin' string
$conf->enable_reply_leadin = false;
// Whether or not to display attachment part number
$conf->display_part_no = true;
// Whether or not to display the Message/RFC822 into the attachments
// (the attachments of that part are still available even if false is set
$conf->display_rfc822 = true;
// If you don't want to display images (GIF, JPEG and PNG) sent as attachements
// set it to 'false'
$conf->display_img_attach = true;
// If you don't want to display text/plain attachments set it to 'false'
$conf->display_text_attach = true;
// By default the messages are sorted by date
$conf->default_sort = '1';
// By default the most recent is in top ('1' --> sorting top to bottom,
// '0' --> bottom to top)
$conf->default_sortdir = '1';
// For old UCB POP server, change this setting to 1 to enable
// new mail detection. Recommended: leave it to 0 for any other POP or
// IMAP server.
// See FAQ for more details.
$conf->have_ucb_pop_server = false;
// If you wanna make your own theme and force people to use that one,
// set $conf->use_theme to false and fill in the $conf->default_theme to
// the theme name you want to use
// Theme handling: allows users to choose a theme on the login page
$conf->use_theme = true;
// Default theme
$conf->default_theme = 'standard';
// Error reporting
// Display all errors (including IMAP connection errors, such as
// 'host not found' or 'invalid login')
$conf->debug_level = E_ALL & ~E_NOTICE;
// Base URL where NOCC is hosted (only needed for Xitami servers, see #463390)
// (NOTE: should end in a slash). Leave blank to detect it automagically.
//$conf->base_url = 'http://www.yoursite.com/webmail/';
$conf->base_url = '';
// Another tip for Xitami users, whose $_SERVER['PHP_SELF'] is broken
// (see http://sourceforge.net/tracker/index.php?func=detail&aid=505194&group_id=12177&atid=112177)
//$_SERVER['PHP_SELF'] = 'action.php';
// Use old-style forwarding (quote original message, and attach original attachments).
// This is discouraged, because it mangles the original message, removing important headers etc.
$conf->broken_forwarding = false;
// This sets the number of messages per page to display from a imap folder or pop mailbox
$conf->msg_per_page = '25';
// Set this to '1' to enable the status line for folders at the bottom of the inbox page.
// If you get slow page loads, set it to '0' to disable this (rather slow) function.
$conf->status_line = '1';
//Uncomment this to allow secure typed domain logins
//$conf->typed_domain_login = '1';
// ################### Messages Signature ################### //
// This message is added to every message, the user cannot delete it
// Be careful if you modify this, do not forget to write '\r\n' to switch
// to the next line !
$conf->ad = "___________________________________\r\nNOCC, http://nocc.sourceforge.net";
// PHP error reporting for this application
error_reporting($conf->debug_level);
// Prevent mangling of uploaded attachments
set_magic_quotes_runtime(0);
// Delay between 2 mail send (in second)
$conf->send_delay = 30;
// Number of contacts per user, 0 to disable contacts list
$conf->contact_number_max = 10;
// Allow more memory than default setting in order to handle correctly
// large mails attachments. Try to find correct setting (about 2.5x total
// attachment size)
$conf->memory_limit="20M";
// Allow only specified characters for login. The format of this configuration
// variable is any valid regular expression.
// Example: '^[a-zA-Z0-9_]+$' : login only with letters (upper and lower case),
// numbers and '_' character
// Set to '' to disable
$conf->allowed_char='';
// Select the CRLF to use.
// According to rfc-822 CRLF is "\r\n"
// OS independent, this is a MTA problem
// not ours.
$conf->crlf = "\r\n";
// Enable quota checks.
// Works only with c-client2000 or more recent, and IMAP inbox
$conf->quota_enable=false;
// Quota types.
// Possible values are STORAGE or MESSAGE
$conf->quota_type="STORAGE";
// Default encoding charset to use to display email which does not include one.
$conf->default_charset = 'UTF-8';
/*
################### End of Configuration ####################
*/
?>
@@ -0,0 +1,51 @@
<?php
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is FOSS Labs.
* Portions created by FOSS Labs are Copyright (C) FOSS Labs.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
include('config.php');
require_once('include/utils/UserInfoUtil.php');
require_once('include/utils/utils.php');
require_once('modules/Webmails/Webmails.php');
require_once('modules/Webmails/MailBox.php');
global $MailBox, $mod_strings,$theme;
$theme_path="themes/".$theme."/style.css";
$MailBox = new MailBox($_REQUEST["mailbox"]);
$mailid=vtlib_purify($_REQUEST["mailid"]);
$num=vtlib_purify($_REQUEST["num"]);
$email = new Webmails($MailBox->mbox,$mailid);
$attach_tab = Array();
$email->loadMail($attach_tab);
echo "<html><head><title>".$mod_strings['LBL_ATTACHMENTS']."</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$email->charsets."\">\n";
echo "<script src='modules/Webmails/Webmails.js' type='text/javascript'></script>";
echo "<link REL='SHORTCUT ICON' HREF='include/images/vtigercrm_icon.ico'>";
echo "<style type='text/css'>@import url('$theme_path');</style>";
echo "</head><body>";
echo "<table class='small' width='100%' cellspacing='1' cellpadding='0' border='0' style='font-size:18px'>";
echo "<tr><td><table border=0 cellspacing=0 cellpadding=0 width=100% class='mailClientWriteEmailHeader'><tr><td >".$mod_strings['LBL_ATTACHMENTS']."</td></tr></table></td></tr>";
if(count($email->attname) <= 0)
echo "<tr align='center'><td nowrap>".$mod_strings['LBL_NO_ATTACHMENTS']."</td></tr>";
else{
for($i=0;$i<count($email->attname);$i++){
$attachment_links .= "&nbsp;&nbsp;&nbsp;&nbsp;".$email->anchor_arr[$i].$email->attname[$i]."</a></br>";
}
echo "<tr><td><table class='small' width='100%' cellspacing='1' cellpadding='0' border='0' style='font-size:13px'><tr><td width='90%'>".$mod_strings['LBL_THERE_ARE']." ".count($email->attname)." ".$mod_strings['LBL_ATTACHMENTS_TO_CHOOSE'].":</td></tr><br>";
echo "<tr><td width='100%'>".$attachment_links."</div></td></tr>";
echo "</td></tr></table>";
}
echo "</table>";
?>
@@ -0,0 +1,79 @@
<?php
/*
* $Header: /cvsroot/nocc/nocc/webmail/download.php,v 1.38 2005/12/15 20:10:47 goddess_skuld Exp $
*
* Copyright 2001 Nicolas Chalanset <nicocha@free.fr>
* Copyright 2001 Olivier Cahagne <cahagn_o@epita.fr>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*
* File for downloading the attachments
*/
require_once('modules/Webmails/MailBox.php');
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "")
{
$mailbox=$_REQUEST["mailbox"];
}
else
{
$mailbox="INBOX";
}
$MailBox = new MailBox($mailbox);
$mail = $MailBox->mbox;
if(!isset($HTTP_USER_AGENT))
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
$mailid = $_REQUEST['mailid'];
$mime = $_REQUEST['mime'];
$filename = $_REQUEST['filename'];
$transfer = $_REQUEST['transfer'];
$part = $_REQUEST['part'];
$filename = base64_decode($filename);
$filename = ereg_replace('[\\/:\*\?"<>\|;]', '_', str_replace('&#32;', ' ', $filename));
$isIE = $isIE6 = 0;
// Set correct http headers.
// Thanks to Squirrelmail folks :-)
if (strstr($HTTP_USER_AGENT, 'compatible; MSIE ') !== false &&
strstr($HTTP_USER_AGENT, 'Opera') === false) {
$isIE = 1;
}
if (strstr($HTTP_USER_AGENT, 'compatible; MSIE 6') !== false &&
strstr($HTTP_USER_AGENT, 'Opera') === false) {
$isIE6 = 1;
}
if ($isIE) {
$filename=rawurlencode($filename);
header ("Pragma: public");
header ("Cache-Control: no-store, max-age=0, no-cache, must-revalidate"); // HTTP/1.1
header ("Cache-Control: post-check=0, pre-check=0", false);
header ("Cache-Control: private");
//set the inline header for IE, we'll add the attachment header later if we need it
header ("Content-Disposition: inline; filename=$filename");
}
header ("Content-Type: application/octet-stream; name=\"$filename\"");
header ("Content-Disposition: attachment; filename=\"$filename\"");
if ($isIE && !$isIE6) {
header ("Content-Type: application/download; name=\"$filename\"");
} else {
header ("Content-Type: application/octet-stream; name=\"$filename\"");
}
$file = imap_fetchbody($mail,$mailid,$part);
if ($transfer == 'BASE64')
$file = imap_base64($file);
elseif($transfer == 'QUOTED-PRINTABLE')
$file = imap_qprint($file);
imap_close($mail);
header('Content-Length: ' . strlen($file));
echo ($file);
?>
@@ -0,0 +1,819 @@
<?php
/*
* $Header: /cvsroot/nocc/nocc/webmail/functions.php,v 1.225 2006/12/10 08:47:44 goddess_skuld Exp $
*
* Copyright 2001 Nicolas Chalanset <nicocha@free.fr>
* Copyright 2001 Olivier Cahagne <cahagn_o@epita.fr>
* Copyright 2002 Mike Rylander <mrylander@mail.com>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
/* ----------------------------------------------------- */
function inbox(&$pop, $skip = 0, &$ev)
{
global $conf;
global $charset;
$user_prefs = $_SESSION['nocc_user_prefs'];
$msg_list = array();
$lang = $_SESSION['nocc_lang'];
$sort = $_SESSION['nocc_sort'];
$sortdir = $_SESSION['nocc_sortdir'];
$num_msg = $pop->num_msg();
$per_page = get_per_page();
$start_msg = $skip * $per_page;
$end_msg = $start_msg + $per_page;
$sorted = $pop->sort($sort, $sortdir, $ev, true);
if(NoccException::isException($ev)) return;
$end_msg = ($num_msg > $end_msg) ? $end_msg : $num_msg;
if ($start_msg > $num_msg) {
return $msg_list;
}
for ($i = $start_msg; $i < $end_msg; $i++)
{
$subject = $from = $to = '';
$msgnum = $sorted[$i];
$pop_msgno_msgnum = $pop->msgno($msgnum);
$ref_contenu_message = $pop->headerinfo($pop_msgno_msgnum, $ev);
if(NoccException::isException($ev)) return;
$struct_msg = $pop->fetchstructure($pop_msgno_msgnum, $ev);
if(NoccException::isException($ev)) return;
// Get message charset
$msg_charset = '';
if ($struct_msg->ifparameters) {
while ($obj = array_pop($struct_msg->parameters))
if (strtolower($obj->attribute) == 'charset') {
$msg_charset = $obj->value;
break;
}
}
if ($msg_charset == '') {
$msg_charset = 'UTF-8';
}
// Get subject
$subject_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->subject);
$subject_array = nocc_imap::mime_header_decode($subject_header);
for ($j = 0; $j < count($subject_array); $j++)
$subject .= $subject_array[$j]->text;
// Get from
$from_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->fromaddress);
$from_array = nocc_imap::mime_header_decode($from_header);
for ($j = 0; $j < count($from_array); $j++)
$from .= $from_array[$j]->text;
// Get to
$to_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->toaddress);
$to_array = nocc_imap::mime_header_decode($to_header);
for ($j = 0; $j < count($to_array); $j++) {
$to = $to . $to_array[$j]->text . ", ";
}
$to = substr($to, 0, strlen($to)-2);
$msg_size = 0;
if ($pop->is_imap())
$msg_size = get_mail_size($struct_msg);
else
if(isset($struct_msg->bytes))
$msg_size = ($struct_msg->bytes > 1000) ? ceil($struct_msg->bytes / 1000) : 1;
if (isset($struct_msg->type) && ( $struct_msg->type == 1 || $struct_msg->type == 3))
{
if ($struct_msg->subtype == 'ALTERNATIVE' || $struct_msg->subtype == 'RELATED')
$attach = '&nbsp;';
else
$attach = '<img src="themes/' . $_SESSION['nocc_theme'] . '/img/attach.png" alt="" />';
}
else
$attach = '&nbsp;';
// Check Status Line with UCB POP Server to
// see if this is a new message. This is a
// non-RFC standard line header.
// Set this in conf.php
if ($conf->have_ucb_pop_server)
{
$header_msg = $pop->fetchheader($pop->msgno($msgnum), $ev);
if(NoccException::isException($ev)) return;
$header_lines = explode("\r\n", $header_msg);
while (list($k, $v) = each($header_lines))
{
list ($header_field, $header_value) = explode(':', $v);
if ($header_field == 'Status')
$new_mail_from_header = $header_value;
}
}
else
{
if (($ref_contenu_message->Unseen == 'U') || ($ref_contenu_message->Recent == 'N'))
$new_mail_from_header = '';
else
$new_mail_from_header = '&nbsp;';
}
if ($new_mail_from_header == '')
$newmail = '<img src="themes/' . $_SESSION['nocc_theme'] . '/img/new.png" alt=""/>';
else
$newmail = '&nbsp;';
$timestamp = chop($ref_contenu_message->udate);
$date = format_date($timestamp, $lang);
$time = format_time($timestamp, $lang);
$msg_list[$i] = Array(
'new' => $newmail,
'number' => $pop->msgno($msgnum),
'attach' => $attach,
'to' => $to,
'from' => $from,
'subject' => $subject,
'date' => $date,
'time' => $time,
'complete_date' => $date,
'size' => $msg_size,
'sort' => $sort,
'sortdir' => $sortdir);
}
return ($msg_list);
}
/* ----------------------------------------------------- */
// BUG: returns text/plain when Content-Type: application/x-zip (e.g.)
function GetSinglePart(&$attach_tab, &$this_part, &$header, &$body)
{
if (eregi('text/html', $header))
$full_mime_type = 'text/html';
else
$full_mime_type = 'text/plain';
if (isset($this_part->encoding))
{
switch ($this_part->encoding)
{
case 0:
$encoding = '7BIT';
break;
case 1:
$encoding = '8BIT';
break;
case 2:
$encoding = 'BINARY';
break;
case 3:
$encoding = 'BASE64';
break;
case 4:
$encoding = 'QUOTED-PRINTABLE';
break;
case 5:
$encoding = 'OTHER';
break;
default:
$encoding = 'none';
break;
}
}
else
{
$encoding = '7BIT';
}
$charset = '';
if ($this_part->ifparameters)
while ($obj = array_pop($this_part->parameters))
if (strtolower($obj->attribute) == 'charset')
{
$charset = $obj->value;
break;
}
$tmpvar = Array(
'number' => 1,
'id' => $this_part->ifid ? $this_part->id : 0,
'name' => '',
'mime' => $full_mime_type,
'transfer' => $encoding,
'disposition' => $this_part->ifdisposition ? $this_part->disposition : '',
'charset' => $charset
);
if(isset($this_part->bytes))
$tmpvar['size'] = ($this_part->bytes > 1000) ? ceil($this_part->bytes / 1000) : 1;
array_unshift($attach_tab, $tmpvar);
}
/* ----------------------------------------------------- */
function remove_stuff(&$body, &$mime)
{
$PHP_SELF = $_SERVER['PHP_SELF'];
$lang = $_SESSION['nocc_lang'];
if (eregi('html', $mime))
{
$to_removed_array = array (
"'<html>'si",
"'</html>'si",
"'<body[^>]*>'si",
"'</body>'si",
"'<head[^>]*>.*?</head>'si",
"'<style[^>]*>.*?</style>'si",
"'<script[^>]*>.*?</script>'si",
"'<object[^>]*>.*?</object>'si",
"'<embed[^>]*>.*?</embed>'si",
"'<applet[^>]*>.*?</applet>'si",
"'<mocha[^>]*>.*?</mocha>'si",
"'<meta[^>]*>'si"
);
$body = preg_replace($to_removed_array, '', $body);
//this line is not needed, commented to fix #3245
//$body=preg_replace("/(http:\/\/|ftp:\/\/)([^\s,]*)/i","<a href='$1$2'>$1$2</a> target=_blank",$body );
$body = preg_replace("|href=\"(.*)script:|i", 'href="nocc_removed_script:', $body);
$body = preg_replace("|<([^>]*)java|i", '<nocc_removed_java_tag', $body);
$body = preg_replace("|<([^>]*)&{.*}([^>]*)>|i", "<&{;}\\3>", $body);
//$body = eregi_replace("href=\"mailto:([a-zA-Z0-9+-=%&:_.~?@]+[#a-zA-Z0-9+]*)\"","HREF=\"$PHP_SELF?action=write&amp;mail_to=\\1\"", $body);
$body = eregi_replace("href=\"mailto:([a-zA-Z0-9+-=%&:_.~?@]+[#a-zA-Z0-9+]*)\"","HREF=\"mailto:\\1\"", $body);
$body = eregi_replace("href=mailto:([a-zA-Z0-9+-=%&:_.~?@]+[#a-zA-Z0-9+]*)","HREF=\"$PHP_SELF?action=write&amp;mail_to=\\1\"", $body);
$body = eregi_replace("href=\"([a-zA-Z0-9+-=%&:_.~?]+[#a-zA-Z0-9+]*)\"","href=\"javascript:void(0);\" onclick=\"window.open('\\1');\"", $body);
$body = eregi_replace("href=([a-zA-Z0-9+-=%&:_.~?]+[#a-zA-Z0-9+]*)","href=\"javascript:void(0);\" onclick=\"window.open('\\1');\"", $body);
}
elseif (eregi('plain', $mime))
{
$user_prefs = $_SESSION['nocc_user_prefs'];
$body = htmlspecialchars($body);
$body = eregi_replace("(http|https|ftp)://([a-zA-Z0-9+-=%&:_.~?]+[#a-zA-Z0-9+]*)","<a href=\"javascript:void(0);\" onclick=\"window.open('\\1://\\2');\">\\1://\\2</a>", $body);
// Bug #511302: Comment out following line if you have the 'Invalid Range End' problem
// New rewritten preg_replace should fix the problem, bug #522389
// $body = eregi_replace("([#a-zA-Z0-9+-._]*)@([#a-zA-Z0-9+-_.]*)\.([a-zA-Z]+)","<a href=\"$PHP_SELF?action=write&amp;mail_to=\\1@\\2.\\3\">\\1@\\2.\\3</a>", $body);
//$body = preg_replace("/([0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,})/", "<a href=\"$PHP_SELF?action=write&amp;mail_to=\\1\">\\1</a>", $body);
$body = preg_replace("/([0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,})/", "<a href=\"mailto:\\1\">\\1</a>", $body);
if ( !isset($user_prefs->colored_quotes) || (isset($user_prefs->colored_quotes) && $user_prefs->colored_quotes)) {
$body = preg_replace('/^(&gt; *&gt; *&gt; *&gt; *&gt;)(.*?)(\r?\n)/m', '<span class="quoteLevel5">\\1\\2</span>\\3', $body);
$body = preg_replace('/^(&gt; *&gt; *&gt; *&gt;)(.*?)(\r?\n)/m', '<span class="quoteLevel4">\\1\\2</span>\\3', $body);
$body = preg_replace('/^(&gt; *&gt; *&gt;)(.*?)(\r?\n)/m', '<span class="quoteLevel3">\\1\\2</span>\\3', $body);
$body = preg_replace('/^(&gt; *&gt;)(.*?)(\r?\n)/m', '<span class="quoteLevel2">\\1\\2</span>\\3', $body);
$body = preg_replace('/^(&gt;)(.*?)(\r?\n)/m', '<span class="quoteLevel1">\\1\\2</span>\\3', $body);
}
if (isset($user_prefs->display_struct) && $user_prefs->display_struct) {
$body = preg_replace('/(\s)\+\/-/', '\\1&plusmn;', $body); // +/-
$body = preg_replace('/(\w|\))\^([0-9]+)/', '\\1<sup>\\2</sup>', $body); // 10^6, a^2, (a+b)^2
$body = preg_replace('/(\s)(\*)([^\s\*]+[^\*\r\n]+)(\*)/', '\\1<strong>\\2\\3\\4</strong>', $body); // *strong*
$body = preg_replace('/(\s)(\/)([^\s\/]+[^\/\r\n<>]+)(\/)/', '\\1<em>\\2\\3\\4</em>', $body); // /emphasis/
$body = preg_replace('/(\s)(_)([^\s_]+[^_\r\n]+)(_)/', '\\1<span style="text-decoration:underline">\\2\\3\\4</span>', $body); // _underline_
$body = preg_replace('/(\s)(\|)([^\s\|]+[^\|\r\n]+)(\|)/', '\\1<code>\\2\\3\\4</code>', $body); // |code|
}
$body = nl2br($body);
if (function_exists('wordwrap'))
$body = wordwrap($body, 80, "\n");
}
return ($body);
}
/* ----------------------------------------------------- */
function link_att(&$mail, $attach_tab, &$display_part_no)
{
sort($attach_tab);
$link = '';
while ($tmp = array_shift($attach_tab))
if (!empty($tmp['name']))
{
$mime = str_replace('/', '-', $tmp['mime']);
if ($display_part_no == true)
$link .= $tmp['number'] . '&nbsp;&nbsp;';
unset($att_name);
$att_name_array = imap_mime_header_decode($tmp['name']);
for ($i=0; $i<count($att_name_array); $i++) {
$att_name .= $att_name_array[$i]->text;
}
$att_name_dl = $att_name;
$att_name = convertLang2Html($att_name);
$link .= '<a href="download.php?mail=' . $mail . '&amp;part=' . $tmp['number'] . '&transfer=' . $tmp['transfer'] . '&filename=' . base64_encode($att_name_dl) . '&mime=' . $mime . '">' . $att_name . '</a>&nbsp;&nbsp;' . $tmp['mime'] . '&nbsp;&nbsp;' . $tmp['size'] . '<br/>';
}
return ($link);
}
/* ----------------------------------------------------- */
// Return date formatted as a string, according to locale
function format_date(&$date, &$lang)
{
global $default_date_format;
global $lang_locale;
global $no_locale_date_format;
// handle bad inputs
if (empty($date))
return '';
// if locale can't be set, use default for no locale
if (!setlocale (LC_TIME, $lang_locale))
$default_date_format = $no_locale_date_format;
// format dates
return strftime($default_date_format, $date);
}
function format_time(&$time, &$lang)
{
global $default_time_format;
global $lang_locale;
// handle bad inputs
if (empty($time))
return '';
// if locale can't be set, use default for no locale
setlocale (LC_TIME, $lang_locale);
// format dates
return strftime($default_time_format, $time);
}
/* ----------------------------------------------------- */
// We have to figure out the entire mail size
function get_mail_size(&$this_part)
{
$size = (isset($this_part->bytes) ? $this_part->bytes : 0);
if (isset($this_part->parts))
for ($i = 0; $i < count($this_part->parts); $i++)
$size += (isset($this_part->parts[$i]->bytes) ? $this_part->parts[$i]->bytes : 0);
$size = ($size > 1000) ? ceil($size / 1000) : 1;
return ($size);
}
/* ----------------------------------------------------- */
// this function build an array with all the recipients of the message for later reply or reply all
function get_reply_all(&$from, &$to, &$cc)
{
$login = $_SESSION['nocc_login'];
$domain = $_SESSION['nocc_domain'];
if (!eregi($login.'@'.$domain, $from))
$rcpt = $from.'; ';
$tab = explode(',', $to);
while ($tmpvar = array_shift($tab))
if (!eregi($login.'@'.$domain, $tmpvar))
$rcpt .= $tmpvar.'; ';
$tab = explode(',', $cc);
while ($tmpvar = array_shift($tab))
if (!eregi($login.'@'.$domain, $tmpvar))
$rcpt .= $tmpvar.'; ';
$rcpt = isset($rcpt) ? substr($rcpt, 0, strlen($rcpt) - 2) : $from;
return ($rcpt);
}
/* ----------------------------------------------------- */
// We need that to build a correct list of all the recipient when we send a message
function cut_address(&$addr, &$charset)
{
global $charset;
// Strip slashes from input
$addr = safestrip($addr);
// Break address line into individual addresses, taking
// quoted addresses into account
$addresses = array();
$token = '';
$quote_esc = false;
for ($i = 0; $i < strlen($addr); $i++) {
$c = substr($addr, $i, 1);
// Are we entering/leaving escaped mode
if($c == '"') {
$quote_esc = !$quote_esc;
}
// Is this an address seperator (comma/semicolon)
if($c == ',' || $c == ';') {
if(!$quote_esc) {
$token = trim($token);
if($token != '') {
$addresses[] = $token;
}
$token = '';
continue;
}
}
$token .= $c;
}
if(!$quote_esc) {
$token = trim($token);
if($token != '') {
$addresses[] = $token;
}
}
/* old way
// Replace commas with semicolons as address seperator
$addr = str_replace(',', ';', $addr);
// Break address line into individual addresses
$addresses = explode(';', $addr);
*/
// Loop through addresses
for ($i = 0; $i < sizeof($addresses); $i++)
{
// Wrap address in brackets, if not already
$pos = strrpos($addresses[$i], '<');
if (!is_int($pos))
$addresses[$i] = '<'.$addresses[$i].'>';
else
{
$name = '';
if ($pos != 0)
$name = '=?'.$charset.'?B?'.base64_encode(substr($addresses[$i], 0, $pos - 1)).'?= ';
$addr = substr($addresses[$i], $pos);
$addresses[$i] = '"'.$name.'" '.$addr.'';
}
}
return ($addresses);
}
/* ----------------------------------------------------- */
function view_part(&$pop, &$mail, $part_no, &$transfer, &$msg_charset, &$charset)
{
if(NoccException::isException($ev)) {
return "<p class=\"error\">".$ev->getMessage."</p>";
}
$text = $pop->fetchbody($mail, $part_no, $ev);
if(NoccException::isException($ev)) {
return "<p class=\"error\">".$ev->getMessage."</p>";
}
if ($transfer == 'BASE64')
$str = nl2br(nocc_imap::base64($text));
elseif($transfer == 'QUOTED-PRINTABLE')
$str = nl2br(quoted_printable_decode($text));
else
$str = nl2br($text);
//if (eregi('koi', $transfer) || eregi('windows-1251', $transfer))
// $str = @convert_cyr_string($str, $msg_charset, $charset);
return ($str);
}
/* ----------------------------------------------------- */
function encode_mime(&$string, &$charset)
{
/*$text = '=?' . $charset . '?Q?';
for($i = 0; $i < strlen($string); $i++ )
{
$val = ord($string[$i]);
$val = dechex($val);
$text .= '=' . $val;
}
$text .= '?=';
return ($text);
*/
$string = rawurlencode($string);
$string = str_replace('%', '=', $string);
$string = '=?' . $charset . '?Q?' . $string . '?=';
return ($string);
}
/* ----------------------------------------------------- */
// This function removes temporary attachment files and
// removes any attachment information from the session
function clear_attachments()
{
global $conf;
if (isset($_SESSION['nocc_attach_array']) && is_array($_SESSION['nocc_attach_array']))
while ($tmpvar = array_shift($_SESSION['nocc_attach_array']))
@unlink($conf->tmpdir.'/'.$tmpvar->tmp_file);
unset($_SESSION['nocc_attach_array']);
}
/* ----------------------------------------------------- */
// This function chops the <mail@domain.com> bit from a
// full 'Blah Blah <mail@domain.com>' address, or not
// depending on the 'hide_addresses' preference.
function display_address(&$address)
{
global $html_att_unknown;
// Check for null
if($address == '')
return $html_att_unknown;
// Get preference
$user_prefs = $_SESSION['nocc_user_prefs'];
// If not set, return full address.
if(!isset($user_prefs->hide_addresses))
return $address;
if($user_prefs->hide_addresses!=1 && $user_prefs->hide_addresses!="on")
return $address;
// If no '<', return full address.
$bracketpos = strpos($address, "<");
if($bracketpos === false)
return $address;
// Return up to the first '<', or end of string if not found
//return substr($address, 0, $bracketpos - 1);
$formatted_address = '';
while (!($bracketpos === false)) {
$formatted_address = substr($address, 0, $bracketpos - 1);
$formatted_address .= substr($address, strpos($address, ">")+1);
$address = $formatted_address;
$bracketpos = strpos($address, "<");
}
return $address;
}
/* ----------------------------------------------------- */
function mailquote(&$body, &$from, $html_wrote)
{
$user_prefs = $_SESSION['nocc_user_prefs'];
$crlf = "\r\n";
$from = ucwords(trim(ereg_replace("&lt;.*&gt;", "", str_replace("\"", "", $from))));
if (isset($user_prefs->wrap_msg)) {
$wrap_msg = $user_prefs->wrap_msg;
} else {
$wrap_msg = 0;
}
// If we must wrap the message
if ($wrap_msg)
{
$msg = '';
//Break message in table with "\r\n" as separator
$tbl = explode ("\r\n", $body);
// For each line
for ($i = 0, $buffer = ''; $i < count ($tbl); ++$i)
{
unset($buffer);
// Number of "> "
$q = substr_count($tbl[$i], "> ");
$tbl[$i] = rtrim ($tbl[$i]);
// Erase the "> "
$tbl[$i] = str_replace ("> ", "", $tbl[$i]);
// Erase the break line
$tbl[$i] = str_replace ("\n", " ", $tbl[$i]);
// length of "> > ...."
$length = ($q + 1) * strlen ("> ");
// Add the quote if ligne is not to long
if (strlen ($tbl[$i]) + $length <= $wrap_msg)
$msg .= str_pad($tbl[$i], strlen ($tbl[$i]) + $length, "> ", STR_PAD_LEFT) . $crlf;
// If line is to long, create new line
else
{
$words = explode (" ", $tbl[$i]);
for ($j = 0; $j < count ($words); ++$j)
{
if (strlen ($buffer) + strlen ($words[$j]) + $length <= $wrap_msg)
$buffer .= $words[$j] . " ";
else
{
$msg .= str_pad(rtrim ($buffer), strlen (rtrim ($buffer)) + $length, "> ", STR_PAD_LEFT) . $crlf;
$buffer = $words[$j] . " ";
}
}
//if ($q != substr_count($tbl[$i + 1], "> "))
$msg .= str_pad(rtrim ($buffer), strlen (rtrim ($buffer)) + $length, "> ", STR_PAD_LEFT) . $crlf;
}
}
$body = $msg;
}
else
$body = "> " . ereg_replace("\n", "\n> ", trim($body));
return($from . ' ' . $html_wrote . " :\n\n" . $body);
}
/* ----------------------------------------------------- */
// If running with magic_quotes_gpc (get/post/cookie) set
// in php.ini, we will need to strip slashes from every
// field we receive from a get/post operation.
function safestrip(&$string)
{
if(get_magic_quotes_gpc())
$string = stripslashes($string);
return $string;
}
// Wrap outgoing messages to
function wrap_outgoing_msg ($txt, $length, $newline)
{
$msg = '';
// cut message in segment
$tbl = explode ("\r\n", $txt);
// Clean the end of the line
for ($i = 0, $buffer = ''; $i < count ($tbl); ++$i)
{
$tbl[$i] = rtrim ($tbl[$i]);
if (strlen ($tbl[$i]) <= $length)
$msg .= $tbl[$i] . $newline;
else
{
unset( $buffer);
$words = explode (" ", $tbl[$i]);
for ($j = 0; $j < count ($words); ++$j)
{
if ((strlen ($buffer) + strlen ($words[$j])) <= $length)
$buffer .= $words[$j] . " ";
else
{
$msg .= rtrim ($buffer) . $newline;
$buffer = $words[$j] . " ";
}
}
$msg .= rtrim ($buffer) . $newline;
}
}
return $msg;
}
function strip_tags2(&$string, $allow)
{
$string = eregi_replace('<<', '<nocc_less_than_tag><', $string);
$string = eregi_replace('>>', '><nocc_greater_than_tag>;', $string);
$string = strip_tags($string, $allow . '<nocc_less_than_tag><nocc_greater_than_tag>');
$string = eregi_replace('<nocc_less_than_tag>', '<', $string);
return eregi_replace('<nocc_greater_than_tag>', '>', $string);
}
/* ----------------------------------------------------- */
// Check e-mail address and return TRUE if it looks valid.
function valid_email($email)
{
/* Regex of valid characters */
$regexp = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z0-9][A-Za-z0-9-]{1,62})+$";
if(!ereg($regexp, $email))
return FALSE;
return TRUE;
}
function get_per_page() {
global $conf;
$user_prefs = $_SESSION['nocc_user_prefs'];
$msg_per_page = 0;
if (isset($conf->msg_per_page))
$msg_per_page = $conf->msg_per_page;
if (isset($user_prefs->msg_per_page))
$msg_per_page = $user_prefs->msg_per_page;
// Failsafe
if($msg_per_page < 1)
$msg_per_page = 25;
return $msg_per_page;
}
// ============================ Contact List ==================================
function load_list ($path)
{
$fp = @fopen($path, "r");
if (!$fp)
return array();
// Create the contact list
$contacts = array ();
// Load the contact list
while(!feof ($fp))
{
$buffer = trim(fgets($fp, 4096));
if ($buffer != "")
array_push ($contacts, $buffer);
}
fclose($fp);
// return the list
return $contacts;
}
function save_list ($path, $contacts, $conf, &$ev)
{
include ('lang/' . $_SESSION['nocc_lang'] . '.php');
if(file_exists($path) && !is_writable($path)){
$ev = new NoccException($html_err_file_contacts);
return;
}
if (!is_writeable($conf->prefs_dir)) {
$ev = new NoccException($html_err_file_contacts);
return;
}
$fp = fopen($path, "w");
for ($i = 0; $i < count ($contacts); ++$i)
{
if (trim($contacts[$i]) != "")
fwrite ($fp, $contacts[$i]."\n");
}
fclose($fp);
}
// Convert html entities to normal characters
function unhtmlentities ($string)
{
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
// Convert mail data (from, to, ...) to HTML
function convertMailData2Html($maildata, $cutafter = 0) {
if (($cutafter > 0) && (strlen($maildata) > $cutafter)) {
return htmlspecialchars(substr($maildata, 0, $cutafter)) . '&hellip;';
} else {
return htmlspecialchars($maildata);
}
}
// Save session informations.
function saveSession(&$ev)
{
global $conf;
if (!empty($conf->prefs_dir)) {
// generate string with session information
unset ($cookie_string);
$cookie_string = $_SESSION['nocc_user'];
$cookie_string .= " " . $_SESSION['nocc_passwd'];
$cookie_string .= " " . $_SESSION['nocc_lang'];
$cookie_string .= " " . $_SESSION['nocc_smtp_server'];
$cookie_string .= " " . $_SESSION['nocc_smtp_port'];
$cookie_string .= " " . $_SESSION['nocc_theme'];
$cookie_string .= " " . $_SESSION['nocc_domain'];
$cookie_string .= " " . $_SESSION['imap_namespace'];
$cookie_string .= " " . $_SESSION['nocc_servr'];
$cookie_string .= " " . $_SESSION['nocc_folder'];
$cookie_string .= " " . $_SESSION['smtp_auth'];
// encode cookie string to base64
$cookie_string = base64_encode($cookie_string);
// save string to file
$filename = $conf->prefs_dir . '/' . $_SESSION['nocc_user'].'@'.$_SESSION['nocc_domain'] . '.session';
if (file_exists($filename) && !is_writable($filename)) {
$ev = new NoccException($html_session_file_error);
return;
}
if (!is_writable($conf->prefs_dir)) {
$ev = new NoccException($html_session_file_error);
return;
}
$file = fopen($filename, 'w');
if (!$file) {
$ev = new NoccException($html_session_file_error);
return;
}
fwrite ($file, $cookie_string . "\n");
fclose ($file);
}
}
// Restore session informations.
function loadSession(&$ev, &$key)
{
global $conf;
if (empty($conf->prefs_dir)) {
return '';
}
$filename = $conf->prefs_dir . '/' . $key . '.session';
if (!file_exists($filename)) {
return '';
}
$file = fopen($filename, 'r');
if (!$file) {
$ev = new NoccException("Could not open $filename for reading user session");
return '';
}
$line = trim(fgets($file, 1024));
return $line;
}
// Convert a language string to HTML
function convertLang2Html($langstring) {
global $charset;
return htmlentities($langstring, ENT_COMPAT, $charset);
}
?>
@@ -0,0 +1,35 @@
<?php
/*
* $Header: /cvsroot/nocc/nocc/webmail/get_img.php,v 1.27 2005/05/09 13:32:51 goddess_skuld Exp $
*
* Copyright 2001 Nicolas Chalanset <nicocha@free.fr>
* Copyright 2001 Olivier Cahagne <cahagn_o@epita.fr>
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
require_once('modules/Webmails/MailBox.php');
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "")
{
$mailbox=$_REQUEST["mailbox"];
}
else
{
$mailbox="INBOX";
}
$MailBox = new MailBox($mailbox);
$mail = $MailBox->mbox;
$mailid = $_REQUEST['mail'];
$num = $_REQUEST['num'];
$transfer = $_REQUEST['transfer'];
$mime = $_REQUEST['mime'];
$img = imap_fetchbody($mail,$mailid,$num);
if ($transfer == 'BASE64')
$img = imap_base64($img);
elseif ($transfer == 'QUOTED-PRINTABLE')
$img = imap_qprint($img);
imap_close($mail);
header('Content-type: image/'.$mime);
echo $img;
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

@@ -0,0 +1,23 @@
<?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
/**
** index.php
**
** This file simply takes any attempt to view source vtiger_files
** and sends those people to the login screen. At this
** point no attempt is made to see if the person is logged
** or not.
**/
header("Location:../index.php");
/** pretty impressive huh? **/
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

@@ -0,0 +1,31 @@
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/index.php,v 1.3 2005/03/17 20:01:10 samk Exp $
* Description: TODO: To be written.
********************************************************************************/
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
if(isset($_REQUEST['mailconnect']))
{
echo '<center><font color=red><b>'.$mod_strings['LBL_MAIL_CONNECT_ERROR_INFO'].'</b></color></center><br>';
}
include ('modules/Webmails/ListView.php');
?>
@@ -0,0 +1,91 @@
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
function showhide(argg)
{
var x=document.getElementById(argg).style;
if (x.display=="none")
{
x.display="block"
}
else {
x.display="none"
}
}
function showhideRepeat(argg1,argg2)
{
var x=document.getElementById(argg2).style;
var y=document.getElementById(argg1).checked;
if (y)
{
x.display="block";
}
else {
x.display="none";
}
}
function gshow(argg1)
{
var y=document.getElementById(argg1).style;
if (y.display=="none")
{
y.display="block";
}
}
function ghide(argg2)
{
var z=document.getElementById(argg2).style;
if (z.display=="block" )
{
z.display="none"
}
}
function moveMe(arg1) {
var posx = 0;
var posy = 0;
var e=document.getElementById(arg1);
if (!e) var e = window.event;
if (e.pageX || e.pageY)
{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)
{
posx = e.clientX + document.body.scrollLeft;
posy = e.clientY + document.body.scrollTop;
}
}
function switchClass(myModule,toStatus) {
var x=document.getElementById(myModule);
if (toStatus=="on") {
x.className="dvtSelectedCell";
}
if (toStatus=="off") {
x.className="dvtUnSelectedCell";
}
}
@@ -0,0 +1,181 @@
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/language/en_us.lang.php,v 1.17 2005/03/28 06:31:38 rank Exp $
* Description: Defines the English language pack for the Account module.
********************************************************************************/
$mod_strings = Array(
'LBL_MODULE_NAME'=>'Email',
'LBL_MODULE_TITLE'=>'Email: Home',
'LBL_SEARCH_FORM_TITLE'=>'Email Search',
'LBL_LIST_FORM_TITLE'=>'Email List',
'LBL_NEW_FORM_TITLE'=>'Track Email',
'LBL_LIST_SUBJECT'=>'Subject',
'LBL_LIST_CONTACT'=>'Contact',
'LBL_LIST_RELATED_TO'=>'Related to',
'LBL_LIST_DATE'=>'Date Sent',
'LBL_LIST_TIME'=>'Time Sent',
'LBL_MOVE_TO'=>'Move To',
'LBL_DELETE'=>'Delete',
'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
'LBL_DATE_SENT'=>'Date Sent:',
'LBL_SUBJECT'=>'Subject :',
'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
'LBL_DATE'=>'Date :',
'LBL_TIME'=>'Time Sent:',
'LBL_BODY'=>'Body:',
'LBL_CONTACT_NAME'=>' Contact Name: ',
'LBL_EMAIL'=>'Email:',
'LBL_COLON'=>':',
'LBL_TO'=>'To :',
'LBL_CHK_MAIL'=>'Check Mail',
'LBL_COMPOSE'=>'Compose',
'LBL_SETTINGS'=>'Incoming MailServer Settings',
'LBL_EMAIL_FOLDERS'=>'Email Folders',
'LBL_INBOX'=>'Inbox',
'LBL_SENT_MAILS'=>'Sent Mails',
'LBL_TRASH'=>'Trash',
'LBL_JUNK_MAILS'=>'Junk Mails',
'LBL_TO_LEADS'=>'To Leads',
'LBL_TO_CONTACTS'=>'To Contacts',
'LBL_TO_ACCOUNTS'=>'To Accounts',
'LBL_MY_MAILS'=>'My Mails',
'LBL_QUAL_CONTACT'=>'Qualified Mails (As Contacts)',
'LBL_MAILS'=>'Mails',
'LBL_QUALIFY_BUTTON'=>'Qualify',
'LBL_REPLY_BUTTON'=>'Reply',
'LBL_FORWARD_BUTTON'=>'Forward',
'LBL_DOWNLOAD_ATTCH_BUTTON'=>'Download Attachments',
'LBL_FROM'=>'From :',
'LBL_CC'=>'cc :',
'LBL_REPLY_TO_SENDER'=>'Reply to Sender',
'LBL_REPLY_ALL'=>'Reply All',
'LBL_SHOW_HIDDEN'=>'Show Hidden Mails',
'LBL_EXPUNGE_MAILBOX'=>'Trim Mailbox',
'NTC_REMOVE_INVITEE'=>'Are you sure you want to remove this recipient from the email?',
'LBL_INVITEE'=>'Recipients',
// Added Fields
// Contacts-SubPanelViewContactsAndUsers.php
'LBL_BULK_MAILS'=>'Bulk Mails',
'LBL_ATTACHMENT'=>'Attachment',
'LBL_UPLOAD'=>'Upload',
'LBL_FILE_NAME'=>'File Name',
'LBL_SEND'=>'Send',
'LBL_EMAIL_TEMPLATES'=>'Email Templates',
'LBL_TEMPLATE_NAME'=>'Template Name',
'LBL_DESCRIPTION'=>'Description',
'LBL_EMAIL_TEMPLATES_LIST'=>'Email Templates List',
'LBL_EMAIL_INFORMATION'=>'Email Information',
//for v4 release added
'LBL_NEW_LEAD'=>'New Lead',
'LBL_LEAD_TITLE'=>'Leads',
'LBL_NEW_PRODUCT'=>'New Product',
'LBL_PRODUCT_TITLE'=>'Products',
'LBL_NEW_CONTACT'=>'New Contact',
'LBL_CONTACT_TITLE'=>'Contacts',
'LBL_NEW_ACCOUNT'=>'New Account',
'LBL_ACCOUNT_TITLE'=>'Accounts',
// Added vtiger_fields after vtiger4 - Beta
'LBL_USER_TITLE'=>'Users',
'LBL_NEW_USER'=>'New User',
// Added for 4 GA
'LBL_TOOL_FORM_TITLE'=>'Email Tools',
//Added for 4GA
'Date & Time Sent'=>'Date & Time Sent',
'Sales Enity Module'=>'Sales Enity Module',
'Activtiy Type'=>'Activtiy Type',
'Related To'=>'Related To',
'Assigned To'=>'Assigned To',
'Subject'=>'Subject',
'Attachment'=>'Attachment',
'Description'=>'Description',
'Time Start'=>'Time Start',
'Created Time'=>'Created Time',
'Modified Time'=>'Modified Time',
'MESSAGE_CHECK_MAIL_SERVER_NAME'=>'Please Check the Mail Server Name...',
'MESSAGE_CHECK_MAIL_ID'=>'Please Check the Email Id of "Assigned To" User...',
'MESSAGE_MAIL_HAS_SENT_TO_USERS'=>'Mail has been sent to the following User(s) :',
'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS'=>'Mail has been sent to the following Contact(s) :',
'MESSAGE_MAIL_ID_IS_INCORRECT'=>'Mail Id is incorrect. Please Check this Mail Id...',
'MESSAGE_ADD_USER_OR_CONTACT'=>'Please Add any User(s) or Contact(s)...',
'MESSAGE_MAIL_SENT_SUCCESSFULLY'=>' Mail(s) sent successfully!',
// Added for web mail post 4.0.1 release
'LBL_FETCH_WEBMAIL'=>'Fetch Web Mail',
//Added for 4.2 Release -- CustomView
'LBL_ALL'=>'All',
'MESSAGE_CONTACT_NOT_WANT_MAIL'=>'This Contact does not want to receive mails.',
'LBL_WEBMAILS_TITLE'=>'WebMails',
'LBL_EMAILS_TITLE'=>'Email',
'LBL_MAIL_CONNECT_ERROR_INFO'=>'Error connecting mail server!<br> Check in My Accounts->List Mail Server -> List Mail Account',
// Added for 5.0.3 release
'LBL_MAIL_CONNECT_ERROR'=>'Could not connect to the mail server. Please check the mail server details',
'IN_REPLY_TO_THE_MESSAGE' => 'In reply to the message sent by ',
'LBL_CLICK_HERE' => 'Click Here ',
'LBL_GOTO_EMAILS_MODULE' => ' go to Email module',
'LBL_NO_EMAILS'=>'No Email In This Folder',
'LBL_MOVE_TO'=>'Move To...',
'LBL_DEL'=>'Del ',
'LABEL_FROM'=>'From',
'LBL_INFO'=>'Info',
'LABEL_DATE'=>'Date',
'LBL_NO_IFRAMES_SUPPORTED'=>'No Iframes supported',
'LBL_EMAIL_ATTACHMENTS'=>'Email Attachments:',
'LBL_ALLMAILS'=>'Email',
'LBL_TO_USERS'=>'To Users',
'LBL_TO_GROUPS'=>'To Groups',
'SUBJECT' => 'Subject',
'BODY' => 'Body',
'TO' => 'To:',
'CC' => 'CC:',
'BCC' => 'BCC:',
'FROM' => 'From:',
'IN'=>'in',
'ADD_FOLDER' => 'Add Folder[X]',
//Added for 5.0.3
'LBL_LOADING_IMAGE' => 'Loading Image',
'LBL_ENABLE_IMAP_SUPPORT' => 'Please enable the IMAP support in php to run this module',
// Added/Updated for vtiger CRM 5.0.4
'LBL_CONFIGURE_MAIL_SETTINGS'=>'Please configure your mail settings',
'LBL_PLEASE'=>'Please',
'LBL_HERE'=>'Here',
// Added after 5.0.4 GA
'LBL_FULL_EMAIL_VIEW'=>'Full Email View',
'LBL_MESSAGE'=>'Message',
'LBL_MESSAGES'=>'Messages',
'LBL_NO_ATTACHMENTS'=>'No files to download',
'LBL_THERE_ARE'=>'There are ',
'LBL_ATTACHMENTS_TO_CHOOSE'=>' attachment(s) to choose from',
'LBL_ATTACHMENTS'=>'Attachments',
);
?>
@@ -0,0 +1,168 @@
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/language/en_us.lang.php,v 1.17 2005/03/28 06:31:38 rank Exp $
* Description: Defines the English language pack for the Account module.
********************************************************************************/
$mod_strings = Array(
'LBL_MODULE_NAME' => '电子邮件',
'LBL_MODULE_TITLE' => '电子邮件:首页',
'LBL_SEARCH_FORM_TITLE' => '搜寻电子邮件',
'LBL_LIST_FORM_TITLE' => '电子邮件列表',
'LBL_NEW_FORM_TITLE' => '追踪电子邮件',
'LBL_LIST_SUBJECT' => '主旨',
'LBL_LIST_CONTACT' => '联络人',
'LBL_LIST_RELATED_TO' => '关联',
'LBL_LIST_DATE' => '寄送日期',
'LBL_LIST_TIME' => '寄送时间',
'LBL_MOVE_TO' => '移动',
'LBL_DELETE' => '删除',
'ERR_DELETE_RECORD' => '删除客户数据必须先指定数据编号。',
'LBL_DATE_SENT' => '寄送日期:',
'LBL_SUBJECT' => '主旨:',
'LBL_DATE_AND_TIME' => '寄送日期与时间:',
'LBL_DATE' => '寄送日期:',
'LBL_TIME' => '寄送时间:',
'LBL_BODY' => '内容:',
'LBL_CONTACT_NAME' => '联络人:',
'LBL_EMAIL' => '信箱:',
'LBL_COLON' => '',
'LBL_TO' => '收件人:',
'LBL_CHK_MAIL' => '检查邮件',
'LBL_COMPOSE' => '新增邮件',
'LBL_SETTINGS' => '设定',
'LBL_EMAIL_FOLDERS' => '邮件数据匣',
'LBL_INBOX' => '收件匣',
'LBL_SENT_MAILS' => '寄件备份',
'LBL_TRASH' => '垃圾桶',
'LBL_JUNK_MAILS' => '废弃邮件',
'LBL_TO_LEADS' => '转为准客户',
'LBL_TO_CONTACTS' => '转为联络人',
'LBL_TO_ACCOUNTS' => '转为客户',
'LBL_MY_MAILS' => '我的邮件',
'LBL_QUAL_CONTACT' => '处理过的邮件(转为联络人)',
'LBL_MAILS' => '邮件',
'LBL_QUALIFY_BUTTON' => '转换',
'LBL_REPLY_BUTTON' => '回应',
'LBL_FORWARD_BUTTON' => '转寄',
'LBL_DOWNLOAD_ATTCH_BUTTON' => '下载附加档案',
'LBL_FROM' => '寄件人:',
'LBL_CC' => '副本:',
'LBL_REPLY_TO_SENDER' => '回复寄件人',
'LBL_REPLY_ALL' => '全部回复',
'LBL_SHOW_HIDDEN' => '显示隐藏',
'LBL_EXPUNGE_MAILBOX' => '删除信件匣',
'NTC_REMOVE_INVITEE' => '您确定要从信件中移除这个收件人?',
'LBL_INVITEE' => '收件人',
// Added Fields
// Contacts-SubPanelViewContactsAndUsers.php
'LBL_BULK_MAILS' => '大量邮件',
'LBL_ATTACHMENT' => '附加档案',
'LBL_UPLOAD' => '上传',
'LBL_FILE_NAME' => '檔名',
'LBL_SEND' => '寄送',
'LBL_EMAIL_TEMPLATES' => '邮件样板',
'LBL_TEMPLATE_NAME' => '样板名称',
'LBL_DESCRIPTION'=>'描述',
'LBL_EMAIL_TEMPLATES_LIST' => '邮件样板列表',
'LBL_EMAIL_INFORMATION' => '邮件信息',
//for v4 release added
'LBL_NEW_LEAD' => '新增潜在客户',
'LBL_LEAD_TITLE' => '潜在客户',
'LBL_NEW_PRODUCT' => '新增商品',
'LBL_PRODUCT_TITLE' => '商品',
'LBL_NEW_CONTACT' => '新增联络人',
'LBL_CONTACT_TITLE' => '联络人',
'LBL_NEW_ACCOUNT' => '新增客户',
'LBL_ACCOUNT_TITLE' => '客户',
// Added vtiger_fields after vtiger4 - Beta
'LBL_USER_TITLE' => '使用者',
'LBL_NEW_USER' => '新增使用者',
// Added for 4 GA
'LBL_TOOL_FORM_TITLE' => '邮件工具',
//Added for 4GA
'Date & Time Sent' => '寄送日期与时间',
'Sales Enity Module' => '销售实体模块',
'Activtiy Type' => '活动类型',
'Related To' => '关联',
'Assigned To' => '负责人',
'Subject' => '主旨',
'Attachment' => '附加档案',
'Description' => '说明',
'Time Start' => '寄送时间',
'Created Time' => '建立时间',
'Modified Time' => '更新时间',
'MESSAGE_CHECK_MAIL_SERVER_NAME' => '请检查邮件服务器名称',
'MESSAGE_CHECK_MAIL_ID' => '请检查负责人的邮件编号',
'MESSAGE_MAIL_HAS_SENT_TO_USERS' => '邮件已经寄送到下面使用者:',
'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS' => '邮件已经寄送到下面联络人:',
'MESSAGE_MAIL_ID_IS_INCORRECT' => '邮件编号错误,请检查',
'MESSAGE_ADD_USER_OR_CONTACT' => '请新增使用者或是联络人',
'MESSAGE_MAIL_SENT_SUCCESSFULLY' => '邮件寄送成功!',
// Added for web mail post 4.0.1 release
'LBL_FETCH_WEBMAIL' => '取得网页邮件',
//Added for 4.2 Release -- CustomView
'LBL_ALL' => '全部',
'MESSAGE_CONTACT_NOT_WANT_MAIL' => '这个联络人不希望收到邮件打扰。',
'LBL_WEBMAILS_TITLE' => '网页邮件',
'LBL_EMAILS_TITLE' => '电子邮件',
'LBL_MAIL_CONNECT_ERROR_INFO' => '邮件服务器联机失败!<br> 检查我的账号->邮件服务器列表 -> 账号列表',
// Added for 5.0.3 release
'LBL_MAIL_CONNECT_ERROR'=>'无法连接到邮件服务器。请检查邮件服务器的细节',
'IN_REPLY_TO_THE_MESSAGE' => '在回答发出的信息 ',
'LBL_CLICK_HERE' => '点击这里 ',
'LBL_GOTO_EMAILS_MODULE' => ' 电子邮件模块',
'LBL_NO_EMAILS'=>'没有邮件在这个文件夹',
'LBL_MOVE_TO'=>'移除...',
'LBL_DEL'=>'删除 ',
'LABEL_FROM'=>'来自',
'LBL_INFO'=>'信息',
'LABEL_DATE'=>'日期',
'LBL_NO_IFRAMES_SUPPORTED'=>'没有隐藏支持',
'LBL_EMAIL_ATTACHMENTS'=>'邮件附件:',
'LBL_ALLMAILS'=>'邮件',
'LBL_TO_USERS'=>'至使用者',
'LBL_TO_GROUPS'=>'至用户组',
'SUBJECT' => '提交',
'BODY' => 'Body',
'TO' => 'To:',
'CC' => 'CC:',
'BCC' => 'BCC:',
'FROM' => 'From:',
'IN'=>'in',
'ADD_FOLDER' => '添加文件夹[X]',
//Added for 5.0.3
'LBL_LOADING_IMAGE' => '等待图像',
'LBL_ENABLE_IMAP_SUPPORT' => '请在PHP里开通IMAP模块',
'LBL_CONFIGURE_MAIL_SETTINGS'=>'请配置你的邮件设置',
'LBL_PLEASE'=>'请',
'LBL_HERE'=>'这',
);
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

@@ -0,0 +1,29 @@
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Yahoo/language/en_us.lang.php,v 1.3 2005/01/25 06:23:32 jack Exp $
* Description: Defines the English language pack for the Account module.
********************************************************************************/
$mod_strings = Array(
'LBL_MODULE_NAME'=>'Accounts',
'LBL_MODULE_TITLE'=>'Accounts: Home',
'LBL_SEARCH_FORM_TITLE'=>'Account Search',
'LBL_LIST_FORM_TITLE'=>'Account List',
'LBL_NEW_FORM_TITLE'=>'New Account',
'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
);
?>
@@ -0,0 +1,29 @@
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version 1.1.2
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
/*********************************************************************************
* $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Yahoo/language/en_us.lang.php,v 1.3 2005/01/25 06:23:32 jack Exp $
* Description: Defines the English language pack for the Account module.
********************************************************************************/
$mod_strings = Array(
'LBL_MODULE_NAME' => '客户',
'LBL_MODULE_TITLE' => '客户:首页',
'LBL_SEARCH_FORM_TITLE' => '搜寻客户',
'LBL_LIST_FORM_TITLE' => '客户列表',
'LBL_NEW_FORM_TITLE' => '新增客户',
'ERR_DELETE_RECORD' => '必须指定记录编号才能删除客户。',
);
?>