diff --git a/oss/vtiger/trunk/modules/Webmails/CallRelatedList.php b/oss/vtiger/trunk/modules/Webmails/CallRelatedList.php new file mode 100644 index 00000000..0173a9fa --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/CallRelatedList.php @@ -0,0 +1,93 @@ +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"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/DetailView.php b/oss/vtiger/trunk/modules/Webmails/DetailView.php new file mode 100644 index 00000000..c25ed395 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/DetailView.php @@ -0,0 +1,37 @@ +mbox,$mailid); +$elist = $MailBox->mailList["overview"][($mailid-1)]; + +echo ''; + +echo ''; +$array_tab = Array(); +$webmail->loadMail($array_tab); + +echo ''; + +echo '
'; + +echo '
'; +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/Forms.php b/oss/vtiger/trunk/modules/Webmails/Forms.php new file mode 100644 index 00000000..7de52287 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/Forms.php @@ -0,0 +1,35 @@ +'; + $the_form .= 'Folders'; + $the_form .= '","","","",""); +$listview_entries = array(); + +$displayed_msgs=0; +$info = imap_mailboxmsginfo($MailBox->mbox); +$unread_msgs = $info->Unread; +//$new_msgs=0; +if(($numEmails) <= 0) + $listview_entries[0][] = ''; +else { + + if(isset($_REQUEST["search"]) && trim($_REQUEST["search_input"]) != '') { + $searchstring = vtlib_purify($_REQUEST["search_type"]).' "'.vtlib_purify($_REQUEST["search_input"]).'"'; + //echo $searchstring."
"; + $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 = ''; + +// Build folder list and move_to dropdown box +$list = imap_getmailboxes($MailBox->mbox, "{".$MailBox->imapServerAddress."}", "*"); +sort($list); +$i=0; +if (is_array($list)) { + $boxes = ''; +} + +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"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/ListViewAjax.php b/oss/vtiger/trunk/modules/Webmails/ListViewAjax.php new file mode 100644 index 00000000..429a1394 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/ListViewAjax.php @@ -0,0 +1,263 @@ +mbox || !isset($mods["imap"]) || $mods["imap"] == "") { + echo "

".$mod_strings['LBL_CONFIGURE_MAIL_SETTINGS']."

"; + 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 = "  "; + $navigationOutput .= "  "; + } + if($start <= ($numPages-1)){ + $navigationOutput .= "  "; + $navigationOutput .= "  "; + } + } +} +$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("","","","",""); +$listview_entries = array(); + +$displayed_msgs=0; +$info = imap_mailboxmsginfo($MailBox->mbox); +$unread_msgs = $info->Unread; +//$new_msgs=0; +if(($numEmails) <= 0) + $listview_entries[0][] = ''; +else { + + if(isset($_REQUEST["search"]) && trim($_REQUEST["search_input"]) != '') { + $searchstring = vtlib_purify($_REQUEST["search_type"]).' "'.vtlib_purify($_REQUEST["search_input"]).'"'; + //echo $searchstring."
"; + $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 = ''; + +// Build folder list and move_to dropdown box +$list = imap_getmailboxes($MailBox->mbox, "{".$MailBox->imapServerAddress."}", "*"); +sort($list); +$i=0; +if (is_array($list)) { + $boxes = ''; +} +imap_close($MailBox->mbox); +//echo ''; +$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"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/MailBox.php b/oss/vtiger/trunk/modules/Webmails/MailBox.php new file mode 100644 index 00000000..3bc8542e --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/MailBox.php @@ -0,0 +1,230 @@ +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 "".$mod_strings['LBL_ENABLE_IMAP_SUPPORT'].""; + 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 "
 ".$mod_strings['LBL_MAIL_CONNECT_ERROR']." ".$mod_strings['LBL_HERE'].". ".$mod_strings['LBL_PLEASE']." ".$mod_strings['LBL_CLICK_HERE']."".$mod_strings['LBL_GOTO_EMAILS_MODULE']." "; + 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,'

"; + + if ($mails[$start_message]->deleted) + { + $listview_entries[$num][] = ''; + $listview_entries[$num][] = ''; + $listview_entries[$num][] = ''; + } + elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent) + { + $listview_entries[$num][] = ''; + $listview_entries[$num][] = ''; + $listview_entries[$num][] = ''; + } + 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;$icharset != '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][] = ''; + $listview_entries[$num][] = ''; + $listview_entries[$num][] = ''; + } + + + + if($mails[$start_message]->deleted) + $listview_entries[$num][] = ''; + else + $listview_entries[$num][] = ''; + + + return $listview_entries[$num]; +} + +?> diff --git a/oss/vtiger/trunk/modules/Webmails/Save.php b/oss/vtiger/trunk/modules/Webmails/Save.php new file mode 100644 index 00000000..6b90f0ec --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/Save.php @@ -0,0 +1,201 @@ +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('',"",$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 .= '
'.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; +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/TODO b/oss/vtiger/trunk/modules/Webmails/TODO new file mode 100644 index 00000000..2e3144c5 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/TODO @@ -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 diff --git a/oss/vtiger/trunk/modules/Webmails/Webmails.js b/oss/vtiger/trunk/modules/Webmails/Webmails.js new file mode 100644 index 00000000..7b971a5a --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/Webmails.js @@ -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 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;i0;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"; + $("ndeleted_date_"+id).innerHTML = ""+$("ndeleted_date_"+id).innerHTML+""; + $("ndeleted_from_"+id).innerHTML = ""+$("ndeleted_from_"+id).innerHTML+""; + }, + function() { + $("deleted_subject_"+id).innerHTML = ""+$("deleted_subject_"+id).innerHTML+""; + $("deleted_date_"+id).innerHTML = ""+$("deleted_date_"+id).innerHTML+""; + $("deleted_from_"+id).innerHTML = ""+$("deleted_from_"+id).innerHTML+""; + } + ); + + try { + $("del_link_"+id).innerHTML = 'del'; + + 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"; + $("ndeleted_date_"+id).innerHTML = ""+$("ndeleted_date_"+id).innerHTML+""; + $("ndeleted_from_"+id).innerHTML = ""+$("ndeleted_from_"+id).innerHTML+""; + }, + function() { + $("deleted_subject_"+id).innerHTML = ""+$("deleted_subject_"+id).innerHTML+""; + $("deleted_date_"+id).innerHTML = ""+$("deleted_date_"+id).innerHTML+""; + $("deleted_from_"+id).innerHTML = ""+$("deleted_from_"+id).innerHTML+""; + } + ); + + $("del_link_"+id).innerHTML = 'del'; + 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,''),''); + node.innerHTML=newhtml; + $("del_link_"+id).innerHTML = 'del'; + $("status").style.display="none"; + break; + case 'clear_flag': + var nm = "clear_td_"+id; + var el = $(nm); + var tmp = el.innerHTML; + el.innerHTML =''; + el.id = "set_td_"+id; + break; + case 'set_flag': + var nm = "set_td_"+id; + var el = $(nm); + var tmp = el.innerHTML; + el.innerHTML =''; + 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"; +} +} diff --git a/oss/vtiger/trunk/modules/Webmails/Webmails.php b/oss/vtiger/trunk/modules/Webmails/Webmails.php new file mode 100644 index 00000000..b0e9c422 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/Webmails.php @@ -0,0 +1,986 @@ +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 = "

".$mod_strings['IN_REPLY_TO_THE_MESSAGE'].$this->reply_name." on ".$this->date."

"; + $tmpvar .= "
".$this->body."
"; + 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;$pto);$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;$preply_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;$pcc);$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: "."
$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: "."
$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: "."
$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("\;-?\)","\"wink\"/", $body); + $body = ereg_replace("\;-?D","\"grin\"/", $body); + $body = ereg_replace(":\'\(?","\"cry\"/", $body); + $body = ereg_replace(":-?[xX]","\"confused\"/", $body); + $body = ereg_replace(":-?\[\)","\"embarassed\"/", $body); + $body = ereg_replace(":-?\*","\"love\"/", $body); + $body = ereg_replace(":-?[pP]","\"tongue\"/", $body); + $body = ereg_replace(":-?\)","\"happy\"/", $body); + $body = ereg_replace(":-?\(","\"unhappy\"/", $body); + $body = ereg_replace(":-[oO]","\"surprised\"/", $body); + $body = ereg_replace("8-?\)","\"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 . '  '; + unset($att_name); + $att_name_array = imap_mime_header_decode($tmp['name']); + for ($i=0; $itext; + } + 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).'. ' . $att_name . '  ' . $tmp['mime'] . '  ' . $tmp['size'] . '
'; + $this->anchor_arr[$ct] = ''; + $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)) . '…'; + } + 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 = '
'; + break; + case 1: + $link_att = ''; + $this->att_links .= $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev)."
"; + break; + default: + $link_att = '
'; + $this->att_links .= $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev)."
"; + break; + } + }else + { + $link_att = '
'; + } + + $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; $itext; + } + return $result; +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/WebmailsAjax.php b/oss/vtiger/trunk/modules/Webmails/WebmailsAjax.php new file mode 100644 index 00000000..944ef6e5 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/WebmailsAjax.php @@ -0,0 +1,158 @@ +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; +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/body.php b/oss/vtiger/trunk/modules/Webmails/body.php new file mode 100644 index 00000000..81c1f327 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/body.php @@ -0,0 +1,161 @@ +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 "\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;$iattname);$i++){ + $attachment_links .= $email->anchor_arr[$i].decode_header($email->attname[$i])."
                     "; +} +$content['body'] = $email->body; +$content['attachtab'] = $email->attachtab; +if(!$_REQUEST['fullview']) + $class_str = 'class="tableHeadBg"'; +else + $class_str = 'style="font-size:15px"'; + +?> + + + + + +
'; + $the_boxes=array(); + if (is_array($list)) { + foreach ($list as $key => $val) { + $the_boxes[] = $val->name; + } + } + sort($the_boxes); + for($i=0;$i".preg_replace(array("/\{.*?\}/i"),array(""),$the_boxes[$i])."
"; + } + + $the_form .= get_left_form_footer(); + $the_form .= get_validate_record_js(); + +return $the_form; +} +?> diff --git a/oss/vtiger/trunk/modules/Webmails/ListView.php b/oss/vtiger/trunk/modules/Webmails/ListView.php new file mode 100644 index 00000000..153a3859 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/ListView.php @@ -0,0 +1,465 @@ +".$mod_strings['LBL_ENABLE_IMAP_SUPPORT'].""; + 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 "

".$mod_strings['LBL_CONFIGURE_MAIL_SETTINGS']."

"; + 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(); +} + +?> + + + + +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 = "  "; + $navigationOutput .= "  "; + } + if($start <= ($numPages-1)){ + $navigationOutput .= "  "; + $navigationOutput .= "  "; + } + } +} +if(isPermitted('Contacts','EditView','') == 'yes') + $show_qualify = "yes"; +else + $show_qualify = "no"; +$overview=$elist["overview"]; +?> + +"; + +$search_fields = Array("SUBJECT","BODY","TO","CC","BCC","FROM"); +$listview_header = array("
".$mod_strings['LBL_INFO']."".$mod_strings['LBL_LIST_SUBJECT']."".$mod_strings['LABEL_DATE']."".$mod_strings['LABEL_FROM']."".$mod_strings['LBL_DEL']."'.$mod_strings['LBL_NO_EMAILS'].'".$mod_strings['LBL_INFO']."".$mod_strings['LBL_LIST_SUBJECT']."".$mod_strings['LABEL_DATE']."".$mod_strings['LABEL_FROM']."".$mod_strings['LBL_DEL']."'.$mod_strings['LBL_NO_EMAILS'].''); + $s = preg_replace('/]*>([^<]+)<\/th>/',"\\1",$s); + $s = preg_replace('/]*>([^<]+)<\/td>/',"\\1",$s); + $vTmp = preg_split('/(

[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE); + $vModules = array(); + for ($i=1;$i([^<]+)<\/h2>/',$vTmp[$i],$vMat)) { + $vName = trim($vMat[1]); + $vTmp2 = explode("\n",$vTmp[$i+1]); + foreach ($vTmp2 AS $vOne) { + $vPat = '([^<]+)<\/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; +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/MailParse.php b/oss/vtiger/trunk/modules/Webmails/MailParse.php new file mode 100644 index 00000000..96c3c72c --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/MailParse.php @@ -0,0 +1,153 @@ +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 = "

"; + } + elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent) + { + $flags = "
"; + $new_msgs++; + } + else + { + $flags = "
"; + + } + + //enable-diable download attachment button + if($msg_ob->has_attachments){ + $enableDownlaodAttachment = 'yes'; + }else + $enableDownlaodAttachment = 'no'; + + // Attachment Icons + if($msg_ob->has_attachments) + $flags.=' '; + else + $flags.=' '; + + + + // read/unread/forwarded/replied + if(!$mails[$start_message]->seen || $mails[$start_message]->recent) + { + $flags.=' '; + } + elseif ($mails[$start_message]->in_reply_to || $mails[$start_message]->references || preg_match("/^re:/i",$mails[$start_message]->subject)) + { + $flags.=' '; + } + elseif (preg_match("/^fw:/i",$mails[$start_message]->subject)) + { + $flags.=' '; + } + else + { + $flags.=' '; + } + + // Set IMAP flag + if($mails[$start_message]->flagged) + { + $flags.=''; + } + else + { + $flags.=''; + + } + + $tmp=imap_mime_header_decode($mails[$start_message]->from); + $from = $tmp[0]->text; + $listview_entries[$num] = array(); + + $listview_entries[$num][] = $flags."'.substr($mails[$start_message]->subject,0,40).''.substr($mails[$start_message]->date,0,25).''.substr($from,0,20).''.substr($mails[$start_message]->subject,0,40).''.substr($mails[$start_message]->date,0,25).'            '.substr($from,0,20).''.substr($mails[$start_message]->subject,0,40).''.substr($mails[$start_message]->date,0,25).''.substr($from,0,20).'del
del
' . $html_att . ':' . $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev) . '
' . $html_atts . ':' . $this->link_att($mail, $attach_tab, $conf->display_part_no,$ev) . '
width="100%" border="0" cellpadding="0" cellspacing="0"> + + + + + + + + + + + + + + +
 
 
 
 
  + + + +
 :
 
+ + + +att; +if(!$_REQUEST['fullview']) + echo '
'; +else + echo '
'; +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 '
'.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 '
'; + echo '
'; + echo ''; + echo '
'; + } +} +} + + +echo '
'; +//test ended by Richie + +imap_close($MailBox->mbox); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/conf.php b/oss/vtiger/trunk/modules/Webmails/conf.php new file mode 100644 index 00000000..4ce7b5f4 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/conf.php @@ -0,0 +1,290 @@ + + * Copyright 2001 Olivier Cahagne + * Copyright 2002 Mike Rylander + * + * 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 'userdomain.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 #################### +*/ + +?> diff --git a/oss/vtiger/trunk/modules/Webmails/dlAttachments.php b/oss/vtiger/trunk/modules/Webmails/dlAttachments.php new file mode 100644 index 00000000..42b6e833 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/dlAttachments.php @@ -0,0 +1,51 @@ +mbox,$mailid); +$attach_tab = Array(); +$email->loadMail($attach_tab); +echo "".$mod_strings['LBL_ATTACHMENTS'].""; +echo "\n"; +echo ""; +echo ""; +echo ""; +echo ""; + +echo ""; +echo ""; + +if(count($email->attname) <= 0) + echo ""; +else{ + for($i=0;$iattname);$i++){ + $attachment_links .= "    ".$email->anchor_arr[$i].$email->attname[$i]."
"; + } + echo "
".$mod_strings['LBL_ATTACHMENTS']."
".$mod_strings['LBL_NO_ATTACHMENTS']."

"; + echo ""; + echo "
".$mod_strings['LBL_THERE_ARE']." ".count($email->attname)." ".$mod_strings['LBL_ATTACHMENTS_TO_CHOOSE'].":
".$attachment_links."
"; +} + +echo "
"; + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/download.php b/oss/vtiger/trunk/modules/Webmails/download.php new file mode 100644 index 00000000..a6569b3d --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/download.php @@ -0,0 +1,79 @@ + + * Copyright 2001 Olivier Cahagne + * + * 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(' ', ' ', $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); +?> diff --git a/oss/vtiger/trunk/modules/Webmails/functions.php b/oss/vtiger/trunk/modules/Webmails/functions.php new file mode 100644 index 00000000..614d8a3a --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/functions.php @@ -0,0 +1,819 @@ + + * Copyright 2001 Olivier Cahagne + * Copyright 2002 Mike Rylander + * + * 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 = ' '; + else + $attach = ''; + } + else + $attach = ' '; + // 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 = ' '; + } + if ($new_mail_from_header == '') + $newmail = ''; + else + $newmail = ' '; + $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 ( + "''si", + "''si", + "']*>'si", + "''si", + "']*>.*?'si", + "']*>.*?'si", + "']*>.*?'si", + "']*>.*?'si", + "']*>.*?'si", + "']*>.*?'si", + "']*>.*?'si", + "']*>'si" + ); + $body = preg_replace($to_removed_array, '', $body); + //this line is not needed, commented to fix #3245 + //$body=preg_replace("/(http:\/\/|ftp:\/\/)([^\s,]*)/i","$1$2 target=_blank",$body ); + $body = preg_replace("|href=\"(.*)script:|i", 'href="nocc_removed_script:', $body); + $body = preg_replace("|<([^>]*)java|i", ']*)&{.*}([^>]*)>|i", "<&{;}\\3>", $body); + //$body = eregi_replace("href=\"mailto:([a-zA-Z0-9+-=%&:_.~?@]+[#a-zA-Z0-9+]*)\"","HREF=\"$PHP_SELF?action=write&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&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+]*)","\\1://\\2", $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]+)","\\1@\\2.\\3", $body); + //$body = preg_replace("/([0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,})/", "\\1", $body); + $body = preg_replace("/([0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,})/", "\\1", $body); + if ( !isset($user_prefs->colored_quotes) || (isset($user_prefs->colored_quotes) && $user_prefs->colored_quotes)) { + $body = preg_replace('/^(> *> *> *> *>)(.*?)(\r?\n)/m', '\\1\\2\\3', $body); + $body = preg_replace('/^(> *> *> *>)(.*?)(\r?\n)/m', '\\1\\2\\3', $body); + $body = preg_replace('/^(> *> *>)(.*?)(\r?\n)/m', '\\1\\2\\3', $body); + $body = preg_replace('/^(> *>)(.*?)(\r?\n)/m', '\\1\\2\\3', $body); + $body = preg_replace('/^(>)(.*?)(\r?\n)/m', '\\1\\2\\3', $body); + } + if (isset($user_prefs->display_struct) && $user_prefs->display_struct) { + $body = preg_replace('/(\s)\+\/-/', '\\1±', $body); // +/- + $body = preg_replace('/(\w|\))\^([0-9]+)/', '\\1\\2', $body); // 10^6, a^2, (a+b)^2 + $body = preg_replace('/(\s)(\*)([^\s\*]+[^\*\r\n]+)(\*)/', '\\1\\2\\3\\4', $body); // *strong* + $body = preg_replace('/(\s)(\/)([^\s\/]+[^\/\r\n<>]+)(\/)/', '\\1\\2\\3\\4', $body); // /emphasis/ + $body = preg_replace('/(\s)(_)([^\s_]+[^_\r\n]+)(_)/', '\\1\\2\\3\\4', $body); // _underline_ + $body = preg_replace('/(\s)(\|)([^\s\|]+[^\|\r\n]+)(\|)/', '\\1\\2\\3\\4', $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'] . '  '; + unset($att_name); + $att_name_array = imap_mime_header_decode($tmp['name']); + for ($i=0; $itext; + } + $att_name_dl = $att_name; + $att_name = convertLang2Html($att_name); + $link .= '' . $att_name . '  ' . $tmp['mime'] . '  ' . $tmp['size'] . '
'; + } + 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 "

".$ev->getMessage."

"; + } + $text = $pop->fetchbody($mail, $part_no, $ev); + if(NoccException::isException($ev)) { + return "

".$ev->getMessage."

"; + } + 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 bit from a +// full 'Blah Blah ' 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("<.*>", "", 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('<<', '<', $string); + $string = eregi_replace('>>', '>;', $string); + $string = strip_tags($string, $allow . ''); + $string = eregi_replace('', '<', $string); + return eregi_replace('', '>', $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)) . '…'; + } 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); +} +?> diff --git a/oss/vtiger/trunk/modules/Webmails/get_img.php b/oss/vtiger/trunk/modules/Webmails/get_img.php new file mode 100644 index 00000000..8b7dbc85 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/get_img.php @@ -0,0 +1,35 @@ + + * Copyright 2001 Olivier Cahagne + * + * 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; +?> diff --git a/oss/vtiger/trunk/modules/Webmails/images/delitem.png b/oss/vtiger/trunk/modules/Webmails/images/delitem.png new file mode 100644 index 00000000..1b4bd3b6 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/delitem.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/down_pointer.png b/oss/vtiger/trunk/modules/Webmails/images/down_pointer.png new file mode 100644 index 00000000..8494f5c0 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/down_pointer.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/draft.png b/oss/vtiger/trunk/modules/Webmails/images/draft.png new file mode 100644 index 00000000..32531b05 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/draft.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/end.gif b/oss/vtiger/trunk/modules/Webmails/images/end.gif new file mode 100644 index 00000000..4ade99f4 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/end.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/flag.png b/oss/vtiger/trunk/modules/Webmails/images/flag.png new file mode 100644 index 00000000..3240b29d Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/flag.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/folder.png b/oss/vtiger/trunk/modules/Webmails/images/folder.png new file mode 100644 index 00000000..0495d879 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/folder.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-empty.png b/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-empty.png new file mode 100644 index 00000000..8562d265 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-empty.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-full.png b/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-full.png new file mode 100644 index 00000000..e8ef5e8f Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/gnome-fs-trash-full.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/inbox.png b/oss/vtiger/trunk/modules/Webmails/images/inbox.png new file mode 100644 index 00000000..72159b13 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/inbox.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/index.php b/oss/vtiger/trunk/modules/Webmails/images/index.php new file mode 100644 index 00000000..8e261fa4 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/images/index.php @@ -0,0 +1,23 @@ + diff --git a/oss/vtiger/trunk/modules/Webmails/images/mail_reply.png b/oss/vtiger/trunk/modules/Webmails/images/mail_reply.png new file mode 100644 index 00000000..7bb70b96 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/mail_reply.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/minus.png b/oss/vtiger/trunk/modules/Webmails/images/minus.png new file mode 100644 index 00000000..3d78a57f Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/minus.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/next.gif b/oss/vtiger/trunk/modules/Webmails/images/next.gif new file mode 100644 index 00000000..e480c5bf Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/next.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/no.gif b/oss/vtiger/trunk/modules/Webmails/images/no.gif new file mode 100644 index 00000000..44130138 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/no.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/plus.gif b/oss/vtiger/trunk/modules/Webmails/images/plus.gif new file mode 100644 index 00000000..e0a1a6ae Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/plus.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/plus.png b/oss/vtiger/trunk/modules/Webmails/images/plus.png new file mode 100644 index 00000000..9bc47365 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/plus.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/previous.gif b/oss/vtiger/trunk/modules/Webmails/images/previous.gif new file mode 100644 index 00000000..e740aa7e Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/previous.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/sec_remove_eng.png b/oss/vtiger/trunk/modules/Webmails/images/sec_remove_eng.png new file mode 100644 index 00000000..5798a2bf Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/sec_remove_eng.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/senti.png b/oss/vtiger/trunk/modules/Webmails/images/senti.png new file mode 100644 index 00000000..d2f814c9 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/senti.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/sm_logo.png b/oss/vtiger/trunk/modules/Webmails/images/sm_logo.png new file mode 100644 index 00000000..da454b16 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/sm_logo.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/sort_none.png b/oss/vtiger/trunk/modules/Webmails/images/sort_none.png new file mode 100644 index 00000000..152faf19 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/sort_none.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/start.gif b/oss/vtiger/trunk/modules/Webmails/images/start.gif new file mode 100644 index 00000000..53efba64 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/start.gif differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_attach.png b/oss/vtiger/trunk/modules/Webmails/images/stock_attach.png new file mode 100644 index 00000000..9023807d Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_attach.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_macro-jump-back.png b/oss/vtiger/trunk/modules/Webmails/images/stock_macro-jump-back.png new file mode 100644 index 00000000..8dc0809d Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_macro-jump-back.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup-done.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup-done.png new file mode 100644 index 00000000..c21a3881 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup-done.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup.png new file mode 100644 index 00000000..08e5e6dc Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-flag-for-followup.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-forward.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-forward.png new file mode 100644 index 00000000..b3ea97e1 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-forward.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-hide-read.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-hide-read.png new file mode 100644 index 00000000..4edb84bd Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-hide-read.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-open.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-open.png new file mode 100644 index 00000000..a3378851 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-open.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-priority-high.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-priority-high.png new file mode 100644 index 00000000..17860f64 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-priority-high.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-read.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-read.png new file mode 100644 index 00000000..75bdd3e6 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-read.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-replied.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-replied.png new file mode 100644 index 00000000..9ddc5fbe Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-replied.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-reply.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-reply.png new file mode 100644 index 00000000..6996ade8 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-reply.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail-unread.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-unread.png new file mode 100644 index 00000000..e8af6685 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail-unread.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_mail.png b/oss/vtiger/trunk/modules/Webmails/images/stock_mail.png new file mode 100644 index 00000000..bb6bf86a Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_mail.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/stock_trash_full.png b/oss/vtiger/trunk/modules/Webmails/images/stock_trash_full.png new file mode 100644 index 00000000..40f722a2 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/stock_trash_full.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/trashcan_empty.png b/oss/vtiger/trunk/modules/Webmails/images/trashcan_empty.png new file mode 100644 index 00000000..f5cb2b8b Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/trashcan_empty.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/images/up_pointer.png b/oss/vtiger/trunk/modules/Webmails/images/up_pointer.png new file mode 100644 index 00000000..871ef0e3 Binary files /dev/null and b/oss/vtiger/trunk/modules/Webmails/images/up_pointer.png differ diff --git a/oss/vtiger/trunk/modules/Webmails/index.php b/oss/vtiger/trunk/modules/Webmails/index.php new file mode 100644 index 00000000..b36ec508 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/index.php @@ -0,0 +1,31 @@ +'.$mod_strings['LBL_MAIL_CONNECT_ERROR_INFO'].'
'; +} + +include ('modules/Webmails/ListView.php'); + +?> diff --git a/oss/vtiger/trunk/modules/Webmails/js/script.js b/oss/vtiger/trunk/modules/Webmails/js/script.js new file mode 100644 index 00000000..6056db23 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/js/script.js @@ -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"; + } + +} diff --git a/oss/vtiger/trunk/modules/Webmails/language/en_us.lang.php b/oss/vtiger/trunk/modules/Webmails/language/en_us.lang.php new file mode 100644 index 00000000..f7284205 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/language/en_us.lang.php @@ -0,0 +1,181 @@ +'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!
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', + +); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Webmails/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Webmails/language/zh_cn.lang.php new file mode 100644 index 00000000..03f80767 --- /dev/null +++ b/oss/vtiger/trunk/modules/Webmails/language/zh_cn.lang.php @@ -0,0 +1,168 @@ + '电子邮件', + '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' => '邮件服务器联机失败!
检查我的账号->邮件服务器列表 -> 账号列表', +// 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'=>'这', +); +?> diff --git a/oss/vtiger/trunk/modules/Yahoo/images/ym.gif b/oss/vtiger/trunk/modules/Yahoo/images/ym.gif new file mode 100644 index 00000000..6d6e2550 Binary files /dev/null and b/oss/vtiger/trunk/modules/Yahoo/images/ym.gif differ diff --git a/oss/vtiger/trunk/modules/Yahoo/language/en_us.lang.php b/oss/vtiger/trunk/modules/Yahoo/language/en_us.lang.php new file mode 100644 index 00000000..782337b0 --- /dev/null +++ b/oss/vtiger/trunk/modules/Yahoo/language/en_us.lang.php @@ -0,0 +1,29 @@ +'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.", +); + +?> diff --git a/oss/vtiger/trunk/modules/Yahoo/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Yahoo/language/zh_cn.lang.php new file mode 100644 index 00000000..717c2bab --- /dev/null +++ b/oss/vtiger/trunk/modules/Yahoo/language/zh_cn.lang.php @@ -0,0 +1,29 @@ + '客户', + 'LBL_MODULE_TITLE' => '客户:首页', + 'LBL_SEARCH_FORM_TITLE' => '搜寻客户', + 'LBL_LIST_FORM_TITLE' => '客户列表', + 'LBL_NEW_FORM_TITLE' => '新增客户', + 'ERR_DELETE_RECORD' => '必须指定记录编号才能删除客户。', +); + +?>