This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $current_user;
$dashletData['MyEcmEmailsDashlet']['searchFields'] = array(
'ie_id' => array('default' => ''),
);
$dashletData['MyEcmEmailsDashlet']['columns'] = array(
'SUBJECT' => array(
'label' => 'LBL_LIST_SUBJECT',
'default' => true,
'sortable' => true,
'width' => 30,
),
'FROMADDR' => array(
'label' => 'LBL_LIST_FROM_ADDR',
'default' => true,
'sortable' => true,
),
'TOADDR' => array(
'label' => 'LBL_LIST_TO_ADDR',
'default' => true,
'sortable' => true,
),
'SENDDATE' => array(
'label' => 'LBL_SEND_DATE',
'default' => true,
'sortable' => true,
),
'QUICK_REPLY' => array(
'label' => 'LBL_QUICK_REPLY',
'default' => true,
),
'CREATE_RELATED' => array(
'label' => 'LBL_QUICK_CREATE',
'default' => true,
),
/*
'attachment_image' => array(
'label' => '<img src="themes/default/images/attachment.gif" border="0" />',
'default' => true,
'sortable' => false,
),
'status' => array(
'label' => 'LBL_LIST_STATUS',
'default' => true,
),
'name' => array(
'label' => 'LBL_LIST_SUBJECT',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '30%',
'parent_info' => true,
'default' => true,
),
'contact_name'=>array(
'widget_class' => 'SubPanelDetailViewLink',
'target_record_key' => 'contact_id',
'target_module' => 'Contacts',
'module' => 'Contacts',
'label' => 'LBL_LIST_CONTACT',
'width' => '11%',
'sortable' => false,
'force_exists' => true,
'default' => false,
),
'date_modified' => array(
'default' => false,
'label' => 'LBL_DATE_MODIFIED',
),
'date_entered' => array(
'default' => false,
'label' => 'LBL_LIST_CREATED',
),
'date_sent' => array(
'default' => true,
'label' => 'LBL_LIST_DATE_SENT',
),
'type' => array(
'default' => false,
'label' => 'LBL_LIST_TYPE',
),
'assigned_user_name' => array (
'name' => 'assigned_user_name',
'label' => 'LBL_LIST_ASSIGNED_TO_NAME',
'default' => false,
),
'to_addr_list' => array(
'label' => 'LBL_LIST_TO_ADDR',
'default' => true,
),
'quick_reply' => array(
'label' => 'LBL_QUICK_REPLY',
'default' => true,
),
'create_related' => array(
'label' => 'LBL_QUICK_CREATE',
'default' => true,
),
*/
);
?>

View File

@@ -0,0 +1,47 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $app_strings;
$dashletMeta['MyEcmEmailsDashlet'] = array('module' => 'EmailCaches',
'title' => translate('LBL_DASHLET_MY_EMAILS', 'Emails'),
'description' => 'A customizable view into Tasks',
'category' => 'Module Views',
'hidden' => true);
?>

View File

@@ -0,0 +1,182 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
require_once('include/Dashlets/DashletGeneric.php');
require_once('modules/EmailCaches/EmailCache.php');
class MyEcmEmailsDashlet extends DashletGeneric {
var $ie_id = '';
function MyEcmEmailsDashlet($id, $def = null) {
global $current_user, $app_strings;
require('modules/EcmEmails/Dashlets/MyEcmEmailsDashlet/MyEcmEmailsDashlet.data.php');
parent::DashletGeneric($id, $def);
if(empty($def['title'])) $this->title = translate('LBL_DASHLET_MY_EMAILS', 'Emails');
if(isset($def['ie_id'])) $this->ie_id = $def['ie_id']; else $this->ie_id = array_keys($this->getInbounds());
$this->searchFields = $dashletData['MyEcmEmailsDashlet']['searchFields'];
$this->columns = $dashletData['MyEcmEmailsDashlet']['columns'];
$this->configureTpl = 'modules/EcmEmails/Dashlets/MyEcmEmailsDashlet/MyEcmEmailsDashletGenericConfigure.tpl';
$this->seedBean = new EmailCache();
$this->myItemsOnly = true;
$this->checkEmails();
}
function getTitle($text) {
global $image_path, $app_strings, $sugar_config;
$this->checkEmails();
if($this->isConfigurable)
$additionalTitle = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%">' . $text
. '</td><td nowrap width="1%"><div style="width: 100%;text-align:right"><a href="#" onclick="SUGAR.mySugar.configureDashlet(\''
. $this->id . '\'); return false;" class="chartToolsLink">'
. get_image($image_path.'edit','title="' . translate('LBL_DASHLET_EDIT', 'Home') . '" alt="' . translate('LBL_DASHLET_EDIT', 'Home') . '" border="0" align="absmiddle"').'</a> '
. '';
else
$additionalTitle = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%">' . $text
. '</td><td nowrap width="1%"><div style="width: 100%;text-align:right">';
if($this->isRefreshable)
$additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.retrieveDashlet(\''
. $this->id . '\'); return false;"><img width="13" height="13" border="0" align="absmiddle" title="' . translate('LBL_DASHLET_REFRESH', 'Home') . '" alt="' . translate('LBL_DASHLET_REFRESH', 'Home') . '" src="'
. $image_path . 'refresh.gif"/></a> ';
$additionalTitle .= '<a href="#" onclick="SUGAR.mySugar.deleteDashlet(\''
. $this->id . '\'); return false;"><img width="13" height="13" border="0" align="absmiddle" title="' . translate('LBL_DASHLET_DELETE', 'Home') . '" alt="' . translate('LBL_DASHLET_DELETE', 'Home') . '" src="'
. $image_path . 'close_dashboard.gif"/></a></div></td></tr></table>';
if(!function_exists('get_form_header')) {
global $theme;
require_once('themes/'.$theme.'/layout_utils.php');
}
$str = '<div ';
if(empty($sugar_config['lock_homepage']) || $sugar_config['lock_homepage'] == false) $str .= ' onmouseover="this.style.cursor = \'move\';"';
$str .= 'id="dashlet_header_' . $this->id . '">' . get_form_header($this->title, $additionalTitle, false) . '</div>';
global $current_language;
$str .= "<script type=\"text/javascript\" src=\"cache/jsLanguage/Emails/".$current_language.".js\"></script><script type=\"text/javascript\" src=\"modules/Emails/javascript/Email.js\"></script>";
return $str;
}
function checkEmails() {
if(isset($this->ie_id) && is_array($this->ie_id)) {
foreach($this->ie_id as $key => $ie_id) $this->checkEmail($ie_id);
}
}
function checkEmail($ie_id) {
/*
$post_tmp = $_POST;
$get_tmp = $_GET;
$request_tmp = $_REQUEST;
ob_start();
$arr_tmp = array();
$arr_tmp['module'] = "Emails";
$arr_tmp['action'] = "EmailUIAjax";
$arr_tmp['emailUIAction'] = "checkEmailProgress";
$arr_tmp['currentCount'] = "0";
$arr_tmp['ieId'] = $ie_id;
$arr_tmp['sugar_body_only'] = "true";
$arr_tmp['to_pdf'] = "true";
$_POST = $arr_tmp;
$_REQUEST = $arr_tmp;
global $current_user;
include('index.php');
$out2 = ob_get_contents();
ob_end_clean();
$_POST = $post_tmp;
$_GET = $get_tmp;
$_REQUEST = $request_tmp;
*/
}
function buildWhere() {
$where = array();
$where[] = "`ie_id` IN ('".implode("', '", $this->ie_id)."')";
$where[] = "`mbox` != 'INBOX.Trash'";
return $where;
}
function getInbounds() {
global $current_user;
$GLOBALS['db'] = new MysqlManager();
$GLOBALS['db']->connect();
$query = "SELECT `id`, `name` FROM `inbound_email` WHERE `deleted`=0 AND `group_id` = '$current_user->id' ORDER BY `name`";
$results = $GLOBALS['db']->query($query);
$arr = array();
if(is_resource($results))
while($row = $GLOBALS['db']->fetchByAssoc($results)) $arr[$row['id']] = $row['name'];
return $arr;
}
function displayOptions() {
$this->processDisplayOptions();
global $app_list_strings;
$arr = $this->getInbounds();
$this->currentSearchFields['ie_id']['input'] = '<select id="ie_id" name="ie_id[]" multiple="multiple" size="4" style="width:150px;">'.get_select_options_with_id($arr,(empty($this->ie_id) ? '' : $this->ie_id)).'</select>';
$this->configureSS->assign('searchFields', $this->currentSearchFields);
return $this->configureSS->fetch($this->configureTpl);
}
function saveOptions($req) {
$options = parent::saveOptions($req);
$options['ie_id'] = !is_array($req['ie_id']) ? array('') : $req['ie_id'];
return $options;
}
}
?>

View File

@@ -0,0 +1,132 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<div>
<form action='index.php' id='configure_{$id}' method='post' onSubmit='SUGAR.mySugar.setChooser(); return SUGAR.dashlets.postForm("configure_{$id}", SUGAR.mySugar.uncoverPage);'>
<input type='hidden' name='id' value='{$id}'>
<input type='hidden' name='module' value='Home'>
<input type='hidden' name='action' value='ConfigureDashlet'>
<input type='hidden' name='configure' value='true'>
<input type='hidden' name='to_pdf' value='true'>
<input type='hidden' id='displayColumnsDef' name='displayColumnsDef' value=''>
<input type='hidden' id='hideTabsDef' name='hideTabsDef' value=''>
<input type='hidden' id='dashletType' name='dashletType' value='' />
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="tabForm">
<tr>
<td class='dataLabel' colspan='4' align='left'>
<h2>{$strings.general}</h2>
</td>
</tr>
<tr>
<td class='dataLabel'>
{$strings.title}
</td>
<td class='dataField' colspan='3'>
<input type='text' name='dashletTitle' value='{$dashletTitle}'>
</td>
</tr>
<tr>
<td class='dataLabel'>
{$strings.displayRows}
</td>
<td class='dataField'>
<select name='displayRows'>
{html_options values=$displayRowOptions output=$displayRowOptions selected=$displayRowSelect}
</select>
</td>
<td colspan='2'>
<table cellpading='0' cellspacing='0'>
<tr>
<td class='dataLabel'>
{$strings.maxHeight_}
</td>
<td class='dataField'>
<input type="text" name='maxHeight' id='maxHeight' value='{$maxHeight}' style="width:40px;" />
</td>
</tr>
</table>
</tr>
<tr>
<td colspan='4' align='center'>
<table border='0' cellpadding='0' cellspacing='0'>
<tr><td>
{$columnChooser}
</td>
</tr></table>
</td>
</tr>
<tr>
<td class='dataLabel' colspan='4' align='left'>
<br>
<h2>{$strings.filters}</h2>
</td>
</tr>
<tr>
<td class='dataLabel'>
</td>
<td class='dataField'>
</td>
</tr>
<tr>
{foreach name=searchIteration from=$searchFields key=name item=params}
<td class='dataLabel' valign='top'>
{$params.label}
</td>
<td class='dataField' valign='top' style='padding-bottom: 5px'>
{$params.input}
</td>
{if ($smarty.foreach.searchIteration.iteration is even) and $smarty.foreach.searchIteration.iteration != $smarty.foreach.searchIteration.last}
</tr><tr>
{/if}
{/foreach}
</tr>
<tr>
<td colspan='4' align='right'>
<input type='submit' class='button' value='{$strings.save}'>
</td>
</tr>
</table>
</form>
</div>

View File

@@ -0,0 +1,34 @@
<?
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
require_once('modules/EcmEmails/EcmEmail.php');
require_once('modules/EcmEmails/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmEmail();
if(isset($_REQUEST['record']))$focus->retrieve($_REQUEST['record']);
require_once('include/MVC/View/SugarView.php');
if(file_exists('modules/EcmEmails/views/view.detail.php')) {
require_once('modules/EcmEmails/views/view.detail.php');
$detail = new EcmEmail();
}
else{
require_once('include/MVC/View/views/view.detail.php');
$detail = new ViewDetail();
}
global $app_list_strings;
$detail->bean = $focus;
$detail->preDisplay();
echo $detail->display();
?>

160
modules/EcmEmails/EcmEmail.php Executable file
View File

@@ -0,0 +1,160 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('data/SugarBean.php');
require_once('include/utils.php');
class EcmEmail extends SugarBean {
var $field_name_map = array();
var $id;
var $date_entered;
var $date_modified;
var $modified_user_id;
var $assigned_user_id;
var $name;
var $module_dir = 'EcmEmails';
var $table_name = "ecmemails";
var $object_name = "EcmEmail";
var $new_schema = true;
var $additional_column_fields = array('assigned_user_name', 'assigned_user_id');
function EcmEmail() {
parent::SugarBean();
$this->setupCustomFields('EcmEmails');
foreach($this->field_defs as $field){
$this->field_name_map[$field['name']] = $field;
}
}
function get_summary_text(){
return $this->name;
}
function create_list_query($order_by, $where, $show_deleted = 0){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmemails.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmemails ";
$query.="LEFT JOIN users ON ecmemails.assigned_user_id=users.id";
$query.=" ";
if($custom_join)$query.=$custom_join['join'];
$where_auto='1=1';
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
if($where!="")$query.="where $where AND ".$where_auto;
else $query.="where ".$where_auto;
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmemails.name";
return $query;
}
function create_export_query($order_by,$where){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmemails.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmemails ";
$query.="LEFT JOIN users ON ecmemails.assigned_user_id=users.id";
$query.=" ";
if($custom_join)$query.=$custom_join['join'];
$where_auto='1=1';
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
if($where!="")$query.="where $where AND ".$where_auto;
else $query.="where ".$where_auto;
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmemails.name";
return $query;
}
function fill_in_additional_list_fields(){
}
function fill_in_additional_detail_fields(){
parent::fill_in_additional_detail_fields();
}
function get_list_view_data(){
global $current_language;
$the_array=parent::get_list_view_data();
$app_list_strings=return_app_list_strings_language($current_language);
$mod_strings=return_module_language($current_language,'EcmEmails');
$the_array['NAME']=(($this->name == "") ? "<em>blank</em>" : $this->name);
$the_array['ENCODED_NAME']=$this->name;
return $the_array;
}
function build_generic_where_clause($the_query_string){
$where_clauses=array();
$the_query_string=PearDatabase::quote(from_html($the_query_string));
array_push($where_clauses,"ecmemails.name like '$the_query_string%'");
$the_where="";
foreach($where_clauses as $clause){
if($the_where!="")$the_where.=" or ";
$the_where.=$clause;
}
return $the_where;
}
function set_notification_body($xtpl,$ecmemail)
{
global $mod_strings,$app_list_strings;
$xtpl->assign("ECMEMAIL_SUBJECT",$ecmemail->name);
return $xtpl;
}
function bean_implements($interface){
switch($interface){
case 'ACL':return true;
}
return false;
}
function save($check_notify=FALSE){
return parent::save($check_notify);
}
}
?>

View File

@@ -0,0 +1,75 @@
<?php
class EcmEmailsDataCreator {
var $data;
function EcmEmailsDataCreator() {
$this->data = array();
}
function setAssignedUser($id, $name) {
$this->data['assigned_user']['id'] = $id;
$this->data['assigned_user']['name'] = $name;
}
function addToModule($module, $id) {
$this->data['to'][] = array($module, $id);
}
function addTo($name, $email) {
if(strlen($name) > 0)
$to = $name.' <'.$email.'>; ';
else
$to = '<'.$email.'>; ';
$this->data['to'][] = $to;
}
function setFromModule($module, $id) {
$this->data['from'][0] = array($module, $id);
}
function setFrom($name, $email) {
$this->data['from'][0] = $name.' <'.$email.'>; ';
}
function addAttachmentByLink($name, $link, $mime_type = 'application/pdf') {
$this->data['attachments']['links'][] = array($name, $link, $mime_type);
}
function addAttachmentBySugar($name, $module, $action, $getData, $previewData, $mime_type = 'application/pdf') {
$this->data['attachments']['sugar'][] = array($name, $module, $action, $getData, $previewData, $mime_type);
}
function addAssigned($module, $id) {
$this->data['assigned_ids'][$module] = $id;
}
function getLinkData() {
return base64_encode(serialize($this->data));
}
function createJavaScriptAction($link = 'index.php?module=EcmEmails&action=EditView&to_pdf=1') {
return "EcmPreviewPDF('".$link.'&data='.$this->getLinkData()."');";
}
function setEmailTemplateId($id) {
$this->data['template_id'] = $id;
}
function getBean($module, $id) {
global $beanList, $beanFiles;
$file = $beanFiles[$beanList[$module]];
if(file_exists($file)) {
require_once($file);
$focus = new $beanList[$module]();
$focus->retrieve($id);
$focus->format_all_fields();
return $focus;
}
return null;
}
}
?>

View File

@@ -0,0 +1,372 @@
<?php
class EcmEmailsDataFormatter {
var $data;
function EcmEmailsDataFormatter($data) {
$this->data = $data;
}
function from_addrs() {
return '';
}
function from() {
if(isset($this->data['from']))
return $this->formatAddr($this->data['from']);
return '';
}
function formatAddr($addr) {
if(is_array($addr)) {
$str = '';
foreach($addr as $key => $value) {
if(is_array($value)) {
$focus = $this->getBean($value[0], $value[1]);
if($focus != null) {
if($value[0] == "Accounts")
$str .= $focus->name.' <'.$focus->email1.'>; ';
else
if($value[0] == "Contacts" || $value[0] == "Users" || $value[0] == "Employees" || $value[0] == "Leads")
$str .= $focus->full_name.' <'.$focus->email1.'>; ';
}
} else {
$str .= $value;
}
}
return $str;
}
return '';
}
function to_addrs() {
if(isset($this->data['to'])) {
return $this->formatAddr($this->data['to']);
}
return '';
}
function to_addrs_ids() {
return '';
}
function to_addrs_names() {
return '';
}
function to_addrs_emails() {
return '';
}
function cc_addrs() {
if(isset($this->data['cc'])) {
return $this->formatAddr($this->data['cc']);
}
return '';
}
function cc_addrs_ids() {
return '';
}
function cc_addrs_names() {
return '';
}
function cc_addrs_emails() {
return '';
}
function bcc_addrs() {
if(isset($this->data['bcc'])) {
return $this->parseEmails($this->data['bcc']);
}
return '';
}
function bcc_addrs_ids() {
return '';
}
function bcc_addrs_names() {
return '';
}
function bcc_addrs_emails() {
return '';
}
function subject() {
if(isset($this->data['subject'])) {
return $this->data['subject'];
}
return '';
}
function parseEmails($e, $glue_before = "<", $glue_after =">; ", $el = 0) {
$str = '';
for($i = 0; $i < count($e); $i ++) {
if(!is_array($e[$i])) {
$str .= $glue_before.$e[$i].$glue_after;
} else {
$str .= $glue_before.$e[$i][$el].$glue_after;
}
}
return $str;
}
function parseEmail($e) {
return '';
}
function descriptionHTML() {
if(isset($this->data['body_html'])) {
return $this->data['body_html'];
}
return '';
}
function description() {
if(isset($this->data['body'])) {
return $this->data['body'];
}
return '';
}
function parentType() {
if(isset($this->data['parent']) && isset($this->data['parent']['type'])) {
return $this->data['parent']['type'];
}
return '';
}
function saveEmailRelationToAssignedIds($email_id) {
if(isset($this->data['assigned_ids'])) {
foreach($this->data['assigned_ids'] as $key => $value) {
if($key != "EcmDocumentTemplates" && $key != "Users") {
$focus = $this->getBean($key, $value);
$focus->load_relationship("emails");
if(isset($focus->emails)) {
$focus->emails->add($email_id);
}
}
}
}
}
function assignedUserId() {
if(isset($this->data['assigned_user']) && isset($this->data['assigned_user']['id'])) {
return $this->data['assigned_user']['id'];
}
global $current_user;
return $current_user->id;
}
function assignedUserName() {
if(isset($this->data['assigned_user']) && isset($this->data['assigned_user']['name'])) {
return $this->data['assigned_user']['name'];
}
global $current_user;
return $current_user->user_name;
}
function templateId() {
if(isset($this->data['template_id'])) {
return $this->data['template_id'];
}
return '';
}
function loadMFP($fill_focus = true) {
if(isset($this->data['assigned_ids'])) {
require_once('modules/EcmDocumentTemplates/ModuleFieldsParser/ModuleFieldsParser.php');
$mfp = new ModuleFieldsParser();
$mfp->clear();
global $app_list_strings;
global $beanList;
foreach($this->data['assigned_ids'] as $key => $value) {
if($key == "Users" && (!isset($value) || $value == '')) $value = $this->assignedUserId();
$focus = $fill_focus ? $this->getBean($key, $value) : null;
$mfp->add($key, str_replace("ecm", "", strtolower($beanList[$key])).'_', $focus, $app_list_strings['moduleList'][$key]);
}
return $mfp;
}
return null;
}
function getBean($module, $id) {
global $beanList, $beanFiles;
$file = $beanFiles[$beanList[$module]];
if(file_exists($file)) {
require_once($file);
$focus = new $beanList[$module]();
$focus->retrieve($id);
$focus->format_all_fields();
return $focus;
}
return null;
}
function loadParserArray($name = '') {
if(isset($this->data['assigned_ids'])) {
$mfp = $this->loadMFP(false);
$mfp_arr = $mfp->getFormHTML(false,$name);
return $mfp_arr;
}
return '';
}
function getModuleName($module) {
global $app_list_strings;
return $app_list_strings['moduleList'][$module];
}
function beanName($module, $id) {
if($module == "Users") return $this->assignedUserName();
$focus = $this->getBean($module, $id);
if($focus != null)
return $focus->get_summary_text();
return '';
}
function extraAssigned() {
if(isset($this->data) && is_array($this->data['assigned_ids'])) {
$ea = '';
foreach($this->data['assigned_ids'] as $key => $value) {
if($key == "Users" && (!isset($value) || $value == '')) {
$value = $this->assignedUserId();
}
if(isset($value) && $value != '')
$ea .= $this->getModuleName($key).',&nbsp;&nbsp;'.$this->beanName($key, $value).
'
<input type="hidden" name="assigned_ids[]" value="'.$key.":|:".$value.'" />
<br />
';
}
return $ea;
}
return '';
}
function getAttachments() {
$arr = array();
if(isset($this->data['attachments']['links']) && is_array($this->data['attachments']['links']))
$arr = array_merge($arr, $this->data['attachments']['links']);
if(isset($this->data['attachments']['sugar']) && is_array($this->data['attachments']['sugar'])) {
$tmp = array();
foreach($this->data['attachments']['sugar'] as $att) {
$link = "index.php?module=".$att[1]."&action=".$att[2];
$att[3] = array_merge($att[3], $att[4]);
if(is_array($att[3])) {
foreach($att[3] as $key => $value) {
$link .= "&".$key."=".$value;
}
}
$tmp[] = array($att[0], $link);
}
$arr = array_merge($arr, $tmp);
}
foreach($arr as $key => $value)
$arr[$key]['md5'] = md5($value[0].$value[1]);
return $arr;
}
function getAttachmentsNotes($ids, $parent_name, $parent_module, $parent_id) {
$notes = array();
if(isset($this->data['attachments']['links']) && is_array($this->data['attachments']['links']))
foreach($this->data['attachments']['links'] as $att)
if(in_array(md5($att[0].$att[1]), $ids))
$notes[] = $this->createNoteFromLink($att[0], $att[2], $att[1], $parent_name, $parent_module, $parent_id);
if(isset($this->data['attachments']['sugar']) && is_array($this->data['attachments']['sugar'])) {
foreach($this->data['attachments']['sugar'] as $att) {
$link = "index.php?module=".$att[1]."&action=".$att[2];
$attt = array_merge($att[3], $att[4]);
if(is_array($attt)) {
foreach($attt as $key => $value) {
$link .= "&".$key."=".$value;
}
}
if(in_array(md5($att[0].$link), $ids)) {
$tmp = array('module' => $att[1], 'action' => $att[2]);
if(is_array($att[3]))
$tmp = array_merge($tmp, $att[3]);
$notes[] = $this->createNoteFromSugarFile($att[0], $att[5], $tmp, $parent_name, $parent_module, $parent_id);
}
}
}
return $notes;
}
function createNoteFromSugarFile($name, $mime_type, $data, $parent_name, $parent_module, $parent_id) {
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = translate('LBL_EMAIL_ATTACHMENT', "Emails").': '.$name;
$n->filename = $name;
$n->file_mime_type = $mime_type;
$n->parent_id = $parent_id;
$n->parent_type = $parent_module;
$n->parent_name = $parent_name;
$nid = $n->save();
$post = $_POST;
$get = $_GET;
$request = $_REQUEST;
$_GET = array_merge($_GET, $data);
$_REQUEST = array_merge($_REQUEST, $data);
$_POST = array();
ob_start();
include("modules/".$data['module']."/".$data['action'].".php");
$file_data = ob_get_contents();
ob_end_clean();
global $sugar_config;
$f=fopen($sugar_config['upload_dir'].$nid,'wb');
if($f) {
fwrite($f,$file_data,strlen($file_data));
}
fclose($f);
$_POST = $post;
$_GET = $get;
$_REQUEST = $request;
return $n;
}
function createNoteFromLink($name, $mime_type, $link, $parent_name, $parent_module, $parent_id) {
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = translate('LBL_EMAIL_ATTACHMENT', "Emails").': '.$name;
$n->filename = $name;
$n->file_mime_type = $mime_type;
$n->parent_id = $parent_id;
$n->parent_type = $parent_module;
$n->parent_name = $parent_name;
$nid = $n->save();
global $sugar_config;
if(!copy($link, $sugar_config['upload_dir'].$nid)) {
//$errors= error_get_last(); echo "COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message'];
}
return $n;
}
}
?>

View File

@@ -0,0 +1,73 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/EditView/QuickCreate.php');
require_once('modules/EcmEmails/EcmEmail.php');
require_once('include/javascript/javascript.php');
class EcmEmailsQuickCreate extends QuickCreate {
var $javascript;
function process() {
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'EcmEmails');
parent::process();
$this->ss->assign("PRIORITY_OPTIONS", get_select_options_with_id($app_list_strings['ecmemail_priority_dom'], $app_list_strings['ecmemail_priority_default_key']));
$this->ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['ecmemail_status_dom'], $app_list_strings['ecmemail_status_default_key']));
$this->ss->assign("TYPE_OPTIONS", get_select_options_with_id($app_list_strings['ecmemail_type_dom'],$app_list_strings['ecmemail_type_default_key']));
if($this->viaAJAX) { // override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"ecmemailsQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmemails\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmemails\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('ecmemailsQuickCreate');
$focus = new EcmEmail();
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
}
}
?>

453
modules/EcmEmails/EditView.html Executable file
View File

@@ -0,0 +1,453 @@
<!--
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
-->
<!-- BEGIN: main -->
<script type="text/javascript" language="Javascript">
{JS_VARS}
</script>
{HEADER}
{MESSAGE}
<script type="text/javascript" language="javascript">
YAHOO.util.Event.addListener(window, "load",
function() {
var template_select = document.forms.EditView.email_template;
if(typeof(template_select) == "object") {
fill_email(template_select.value);
}
}
);
</script>
<form action="index.php" method="post" name="EditView" enctype="multipart/form-data">
<input type="hidden" name="module" value="EcmEmails" />
<input type="hidden" name="action" value="Save" />
<input type="hidden" name="contact_id" value="{CONTACT_ID}" />
<input type="hidden" name="user_id" value="{USER_ID}" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="send" value="" />
<input type="hidden" name="type" value="out" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}" />
<input type="hidden" name="assigned_user_id" value="{ASSIGNED_USER_ID}" />
<input type="hidden" name="object_type" value="{OBJECT_TYPE}" />
<input type="hidden" name="object_id" value="{OBJECT_ID}" />
<input type="hidden" name="group" value="{GROUP}" />
<input type="hidden" name="origType" value="{TYPE}" />
<input type="hidden" name="data" value="{DATA}" />
{TO_PDF}
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<tr>
<td style="padding-bottom: 2px;">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL} mm" onclick="prepSave();this.form.action.value='Save';this.form.send.value='1';this.form.type.value='out';return fill_form('out', '{MOD.ERR_NOT_ADDRESSED}');" />
<input type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="this.form.action.value='Save';this.form.send.value='0';this.form.type.value='draft';fill_form('draft', '{MOD.ERR_NOT_ADDRESSED}');" />
<input type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" />
</td>
<td align="right" nowrap>
</td>
<td align='right'>
{ADMIN_EDIT}
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
<!-- END: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
Powiązane z: </slot> </td>
<td class="dataField">
<slot>
<input class="sqsEnabled" tabindex='1' id="assigned_user_name" name='assigned_user_name' type="text" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" tabindex='1' class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1" onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' />
</slot> </td>
<td nowrap>
<slot> </slot> </td>
<td class="dataLabel" valign="top" align="right">
<slot>
<select tabindex='2' name='parent_type' onchange=" document.EditView.parent_name.value='';
changeQS();
checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);">
{TYPE_OPTIONS}</select>&nbsp; </slot> </td>
<td class="dataField" nowrap>
<slot>
<input id='parent_id' name='parent_id' type="hidden" value='{PARENT_ID}'>
<input class="sqsEnabled" id='parent_name' name='parent_name' tabindex='2' type='text' value="{PARENT_NAME}">
&nbsp;{CHANGE_PARENT_BUTTON} </slot> </td>
</tr>
<tr>
<td class="dataLabel">
<slot> </slot> </td>
<td class="dataField">
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
<td class="dataLabel" colspan="2" valign="top" align="right">
<slot>
{EXTRA_ASSIGNED} </slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td colspan="1">&nbsp; </td>
<td colspan="4">
{MOD.LBL_NOTE_SEMICOLON} </td>
<td colspan="2">&nbsp; </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>{MOD.LBL_TO_GROUP}</slot></td>
<td colspan="4" nowrap="NOWRAP" class="dataField">
<slot></slot> <table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><select style="width: 443px;" name="group" id="group">
{GROUPS}
</select></td>
<td style="padding-left: 4px;">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td class="dataLabel"><slot>{MOD.LBL_TO} </slot></td>
<td colspan="4" nowrap="NOWRAP" class="dataField"><table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><textarea id="to_addrs_field" name='to_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{TO_ADDRS}">{TO_ADDRS}</textarea>
<input type="hidden" id="to_addrs_ids" name="to_addrs_ids" value="{TO_ADDRS_IDS}" />
<input type="hidden" id="to_addrs_emails" name="to_addrs_emails" value="{TO_ADDRS_EMAILS}" />
<input type="hidden" id="to_addrs_names" name="to_addrs_names" value="{TO_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;"> {CHANGE_TO_ADDRS_BUTTON} </td>
</tr>
</table></td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_CC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="cc_addrs_field" name='cc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{CC_ADDRS}">{CC_ADDRS}</textarea>
<input type="hidden" id="cc_addrs_ids" name="cc_addrs_ids" value="{CC_ADDRS_IDS}" />
<input type="hidden" id="cc_addrs_emails" name="cc_addrs_emails" value="{CC_ADDRS_EMAILS}" />
<input type="hidden" id="cc_addrs_names" name="cc_addrs_names" value="{CC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_CC_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_BCC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="bcc_addrs_field" name='bcc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{BCC_ADDRS}">{BCC_ADDRS}</textarea>
<input type="hidden" id="bcc_addrs_ids" name="bcc_addrs_ids" value="{BCC_ADDRS_IDS}" />
<input type="hidden" id="bcc_addrs_emails" name="bcc_addrs_emails" value="{BCC_ADDRS_EMAILS}" />
<input type="hidden" id="bcc_addrs_names" name="bcc_addrs_names" value="{BCC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_BCC_ADDRS_BUTTON} </td>
</tr>
</table> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_FROM} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="from_addr_field" name='from_addr' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{FROM_ADDR}">{FROM_ADDR}</textarea> {FROM_ADDR_GROUP}
<input type="hidden" id="from_addr_email" name="from_addr_email" />
<input type="hidden" id="from_addr_name" name="from_addr_name" /> </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_SUBJECT} </slot> </td>
<td colspan='4' class="dataField">
<slot>
<textarea name='name' tabindex='4' cols="100" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" id="subjectfield">{NAME}</textarea>
</slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_BODY} </td>
<!-- BEGIN: htmlarea -->
<td colspan="4" class="dataLabel" valign="top" style="width:auto;">
<slot>
{MOD.LBL_USE_TEMPLATE}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select tabindex='2' name='email_template' onchange="fill_email(this.options[this.selectedIndex].value);">
{EMAIL_TEMPLATE_OPTIONS}
</select>
&nbsp;&nbsp;
<input type="button" class="button" name="clear" id="clear" value="Clear" onClick="fill_email('');">
&nbsp;&nbsp;
<input type="button" class="button" name="new_template" id="new_template" value="Template Fields" onClick="document.getElementById('template_fields').style.display='';" />
</slot> </td>
</tr>
<tr>
<td></td>
<td colspan="4">
<div id="template_fields" style="display:none">
<table>
<tr>
<td valign="top" class="dataLabel">
Templatate Fields: </td>
<td colspan="5" class="dataField">
<slot>
{MFP}
<input type="button" class="button" name="cancel_template_fields" id="cancel_template_fields" value="Hide" onClick="document.getElementById('template_fields').style.display='none';">
</slot> </td>
</tr>
</table>
</div> </td>
</tr>
<tr>
<td valign="top" class="dataLabel"> </td>
<td colspan="2" class="dataField">
<slot>
<div id="editor_select">
<input id="setEditor" name="setEditor" value="1" {EMAIL_EDITOR_OPTION} type="checkbox" onclick="toggle_textonly();">
{MOD.LBL_EMAIL_EDITOR_OPTION} </div>
</slot> </td>
<td class="dataLabel" valign="top">
<slot> </slot> </td>
<td class="dataField" nowrap width="1">
<slot> </slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">&nbsp; </td>
<td colspan="4" class="dataField">
{TINY}
<slot>
<div id="html_div">
<textarea id="description_html" name="description_html" onblur="">{DESCRIPTION_HTML}</textarea>
</div>
<div id="alt_text_div">
<input id="toggle_textarea_elem" onclick="toggle_textarea();" type="checkbox" name="toggle_html">
{MOD.LBL_EDIT_ALT_TEXT} </div>
<div id="text_div" style="display: none;">
<textarea tabindex='5' id="description" name='description' cols="100" rows="20">{DESCRIPTION}</textarea>
</div>
</slot> </td>
<!-- END: htmlarea -->
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_ATTACHMENTS} </td>
<td colspan="4">
{ATTACHMENTS_JAVASCRIPT} {ATTACHMENTS}
<div id="user_attachments">
{USER_ATTACHMENTS} </div>
<div id="template_attachments"> </div>
<div id="uploads_div">
<div style="display: none" id="file0">
<input id='email_attachment0' name='email_attachment0' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file1">
<input id='email_attachment1' name='email_attachment1' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file2">
<input id='email_attachment2' name='email_attachment2' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file3">
<input id='email_attachment3' name='email_attachment3' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file4">
<input id='email_attachment4' name='email_attachment4' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file5">
<input id='email_attachment5' name='email_attachment5' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file6">
<input id='email_attachment6' name='email_attachment6' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file7">
<input id='email_attachment7' name='email_attachment7' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file8">
<input id='email_attachment8' name='email_attachment8' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file9">
<input id='email_attachment9' name='email_attachment9' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document0">
<input name='documentId0' id='documentId0' tabindex='0' type='hidden' />
<input name='documentName0' id='documentName0' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('0');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document1">
<input name='documentId1' id='documentId1' tabindex='1' type='hidden' />
<input name='documentName1' id='documentName1' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('1');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document2">
<input name='documentId2' id='documentId2' tabindex='2' type='hidden' />
<input name='documentName2' id='documentName2' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('2');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document3">
<input name='documentId3' id='documentId3' tabindex='3' type='hidden' />
<input name='documentName3' id='documentName3' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('3');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document4">
<input name='documentId4' id='documentId4' tabindex='4' type='hidden' />
<input name='documentName4' id='documentName4' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('4');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document5">
<input name='documentId5' id='documentId5' tabindex='5' type='hidden' />
<input name='documentName5' id='documentName5' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('5');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document6">
<input name='documentId6' id='documentId6' tabindex='6' type='hidden' />
<input name='documentName6' id='documentName6' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('6');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document7">
<input name='documentId7' id='documentId7' tabindex='7' type='hidden' />
<input name='documentName7' id='documentName7' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('7');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document8">
<input name='documentId8' id='documentId8' tabindex='8' type='hidden' />
<input name='documentName8' id='documentName8' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('8');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document9">
<input name='documentId9' id='documentId9' tabindex='9' type='hidden' />
<input name='documentName9' id='documentName9' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('9');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
</div>
<input type="button" name="add_file_button" onclick="addFile();" value="{MOD.LBL_ADD_FILE}" class="button" />
<input type="button" name="add_document_button" onclick="addDocument();" value="{MOD.LBL_ADD_DOCUMENT}" class="button" /> </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
{JAVASCRIPT}
<script type="text/javascript" language="Javascript">
var old_load=window.onload; window.onload = function() {
old_load();
setEditor();
// cn: bug 5845 - use Group Inbox From info
if(window.switchEmail) {
switchEmail();
}
}
</script>
<!-- END: main -->

952
modules/EcmEmails/EditView.php Executable file
View File

@@ -0,0 +1,952 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$GLOBALS['log']->info("Email edit view");
require_once('include/SugarTinyMCE.php');
require_once('modules/Emails/Email.php');
require_once('modules/EmailTemplates/EmailTemplate.php');
require_once('XTemplate/xtpl.php');
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once($theme_path.'layout_utils.php');
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $current_user;
global $sugar_version, $sugar_config;
global $timedate, $current_language;
$mod_strings = return_module_language($current_language, 'Emails');
$mod_strings['LBL_RELATED_TO'] = translate("LBL_RELATED_TO", "EcmEmails");
$_REQUEST['return_module'] = "EcmEmails";
/*
$data_tmp = array(
//'assigned_user' => array('id' => '', 'name' => ''),
'parent' => array('type' => '', 'id' => '', 'name' => ''),
'to' => array('dk@more7.com'),
'cc' => array(),
'bcc' => array(),
'from' => array('Dawid Karlowicz', 'd.karlowicz@more7.com'),
// 'subject' => 'Jakis tam temat testowy',
// 'body' => "Testowe Body",
// 'body_html' => "Testowe<br />Body",
'template_id' => '121d9a5d-d9d1-2375-7e33-485ba913018f',
'assigned_ids' => array(
'Accounts' => 'c0db0ce9-2418-9eb1-1db4-487d7f256035',
'Contacts' => 'b4ec0d61-9161-5b53-e250-49648dbccee0',
'EcmDocumentTemplates' => '11f9083b-4514-db45-92eb-482029bad899',
'Users' => '',
),
'attachments' => array(
'links' => array(
array("Quote_AN_2009011402.pdf", "http://test.voip2crm.com/index.php?module=EcmQuotes&action=previewPDF&method=I&record=5a4febe3-9a2e-dde0-937d-496df1176aa1&to_pdf=1"),
array("WorkReport_WR_2008090501.pdf", "http://test.voip2crm.com/index.php?module=EcmWorkReports&action=previewPDF&method=I&record=c3adf682-666a-14d3-7dde-48c18f4e675f&to_pdf=1")
),
)
);
if(!isset($_REQUEST['data']) || $_REQUEST['data'] == '') {
$data_tmp = base64_encode(serialize($data_tmp));
$_GET['data'] = $data_tmp;
$_REQUEST['data'] = $data_tmp;
}
*/
$data = array();
if(isset($_REQUEST['data']) && $_REQUEST['data'] != '') {
$data = unserialize(base64_decode($_REQUEST['data']));
}
require_once('modules/EcmEmails/EcmEmailsDataFormatter.php');
$eedf = new EcmEmailsDataFormatter($data);
///////////////////////////////////////////////////////////////////////////////
//// PREPROCESS BEAN DATA FOR DISPLAY
$focus = new Email();
$email_type = 'archived';
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
if(!empty($_REQUEST['type'])) {
$email_type = $_REQUEST['type'];
} elseif(!empty($focus->id)) {
$email_type = $focus->type;
}
$focus->type = $email_type;
require_once('include/MVC/View/SugarView.php');
$sw = new SugarView($focus);
echo '<link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/yui.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1" /><link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/deprecated.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1" /><link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/style.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1" />
';
$sw->displayJavascript();
//needed when creating a new email with default values passed in
if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
$focus->contact_name = $_REQUEST['contact_name'];
}
if(!empty($_REQUEST['load_id']) && !empty($beanList[$_REQUEST['load_module']])) {
$class_name = $beanList[$_REQUEST['load_module']];
require_once($beanFiles[$class_name]);
$contact = new $class_name();
if($contact->retrieve($_REQUEST['load_id'])) {
$link_id = $class_name . '_id';
$focus->$link_id = $_REQUEST['load_id'];
$focus->contact_name = (isset($contact->full_name)) ? $contact->full_name : $contact->name;
$focus->to_addrs_names = $focus->contact_name;
$focus->to_addrs_ids = $_REQUEST['load_id'];
//Retrieve the email address.
//If Opportunity or Case then Oppurtinity/Case->Accounts->(email_addr_bean_rel->email_addresses)
//If Contacts, Leads etc.. then Contact->(email_addr_bean_rel->email_addresses)
$sugarEmailAddress = new SugarEmailAddress();
if($class_name == 'Opportunity' || $class_name == 'aCase'){
$account = new Account();
if($contact->account_id != null && $account->retrieve($contact->account_id)){
$sugarEmailAddress->handleLegacyRetrieve($account);
if(isset($account->email1)){
$focus->to_addrs_emails = $account->email1;
$focus->to_addrs = "$focus->contact_name <$account->email1>";
}
}
}
else{
$sugarEmailAddress->handleLegacyRetrieve($contact);
if(isset($contact->email1)){
$focus->to_addrs_emails = $contact->email1;
$focus->to_addrs = "$focus->contact_name <$contact->email1>";
}
}
if(!empty($_REQUEST['parent_type']) && empty($app_list_strings['record_type_display'][$_REQUEST['parent_type']])){
if(!empty($app_list_strings['record_type_display'][$_REQUEST['load_module']])){
$_REQUEST['parent_type'] = $_REQUEST['load_module'];
$_REQUEST['parent_id'] = $focus->contact_id;
$_REQUEST['parent_name'] = $focus->to_addrs_names;
} else {
unset($_REQUEST['parent_type']);
unset($_REQUEST['parent_id']);
unset($_REQUEST['parent_name']);
}
}
}
}
if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
$focus->contact_id = $_REQUEST['contact_id'];
}
if(isset($_REQUEST['parent_name'])) {
$focus->parent_name = $_REQUEST['parent_name'];
}
if(isset($_REQUEST['parent_id'])) {
$focus->parent_id = $_REQUEST['parent_id'];
}
if(isset($_REQUEST['parent_type'])) {
$focus->parent_type = $_REQUEST['parent_type'];
}
elseif(is_null($focus->parent_type)) {
$focus->parent_type = $app_list_strings['record_type_default_key'];
}
if(isset($_REQUEST['to_email_addrs'])) {
$focus->to_addrs = $_REQUEST['to_email_addrs'];
}
// needed when clicking through a Contacts detail view:
if(isset($_REQUEST['to_addrs_ids'])) {
$focus->to_addrs_ids = $_REQUEST['to_addrs_ids'];
}
if(isset($_REQUEST['to_addrs_emails'])) {
$focus->to_addrs_emails = $_REQUEST['to_addrs_emails'];
}
if(isset($_REQUEST['to_addrs_names'])) {
$focus->to_addrs_names = $_REQUEST['to_addrs_names'];
}
// user's email, go through 3 levels of precedence:
$from = $current_user->getEmailInfo();
//// END PREPROCESSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// XTEMPLATE ASSIGNMENT
$email_type = '';
if($email_type == 'archived') {
echo get_module_title('Emails', $mod_strings['LBL_ARCHIVED_MODULE_NAME'].":", true);
echo "\n</p>\n";
$xtpl=new XTemplate('modules/Emails/EditViewArchive.html');
} else {
if($_REQUEST['to_pdf'] == '1' || $_REQUEST['to_pdf'] == 'true') {
$xtpl = new XTemplate('modules/EcmEmails/EditViewSame.html');
$xtpl->assign('HEADER', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":");
}
else {
$xtpl = new XTemplate('modules/EcmEmails/EditView.html');
$xtpl->assign('HEADER', get_module_title('Emails', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":", true));
}
}
// CHECK USER'S EMAIL SETTINGS TO ENABLE/DISABLE 'SEND' BUTTON
if(!$focus->check_email_settings() &&($email_type == 'out' || $email_type == 'draft')) {
print "<font color='red'>".$mod_strings['WARNING_SETTINGS_NOT_CONF']." <a href='index.php?module=Users&action=EditView&record=".$current_user->id."&return_module=Emails&type=out&return_action=EditView'>".$mod_strings['LBL_EDIT_MY_SETTINGS']."</a></font>";
$xtpl->assign("DISABLE_SEND", 'DISABLED');
}
// CHECK THAT SERVER HAS A PLACE TO PUT UPLOADED TEMP FILES SO THAT ATTACHMENTS WILL WORK
// cn: Bug 5995
$tmpUploadDir = ini_get('upload_tmp_dir');
if(!empty($tmpUploadDir)) {
if(!is_writable($tmpUploadDir)) {
echo "<font color='red'>{$mod_strings['WARNING_UPLOAD_DIR_NOT_WRITABLE']}</font>";
}
} else {
//echo "<font color='red'>{$mod_strings['WARNING_NO_UPLOAD_DIR']}</font>";
}
///////////////////////////////////////////////////////////////////////////////
//// INBOUND EMAIL HANDLING
if(isset($_REQUEST['email_name'])) {
$name = str_replace('_',' ',$_REQUEST['email_name']);
}
if(isset($_REQUEST['inbound_email_id'])) {
$ieMail = new Email();
$ieMail->retrieve($_REQUEST['inbound_email_id']);
$quoted = '';
// cn: bug 9725: replies/forwards lose real content
$quotedHtml = $ieMail->quoteHtmlEmail($ieMail->description_html);
// plain-text
$desc = nl2br(trim($ieMail->description));
$exDesc = explode('<br />', $desc);
foreach($exDesc as $k => $line) {
$quoted .= '> '.trim($line)."\r";
}
// prefill empties with the other's contents
if(empty($quotedHtml) && !empty($quoted)) {
$quotedHtml = nl2br($quoted);
}
if(empty($quoted) && !empty($quotedHtml)) {
$quoted = strip_tags(br2nl($quotedHtml));
}
// forwards have special text
if($_REQUEST['type'] == 'forward') {
$header = $ieMail->getForwardHeader();
// subject is handled in Subject line handling below
} else {
// we have a reply in focus
$header = $ieMail->getReplyHeader();
}
$quoted = br2nl($header.$quoted);
$quotedHtml = $header.$quotedHtml;
// if not a forward: it's a reply
if($_REQUEST['type'] != 'forward') {
$ieMailName = 'RE: '.$ieMail->name;
} else {
$ieMailName = $ieMail->name;
}
$focus->id = null; // nulling this to prevent overwriting a replied email(we're basically doing a "Duplicate" function)
$focus->to_addrs = $ieMail->from_addr;
$focus->description = $quoted; // don't know what i was thinking: ''; // this will be filled on save/send
$focus->description_html = $quotedHtml; // cn: bug 7357 - htmlentities() breaks FCKEditor
$focus->parent_type = $ieMail->parent_type;
$focus->parent_id = $ieMail->parent_id;
$focus->parent_name = $ieMail->parent_name;
$focus->name = $ieMailName;
$xtpl->assign('INBOUND_EMAIL_ID',$_REQUEST['inbound_email_id']);
// un/READ flags
if(!empty($ieMail->status)) {
// "Read" flag for InboundEmail
if($ieMail->status == 'unread') {
// creating a new instance here to avoid data corruption below
$e = new Email();
$e->retrieve($ieMail->id);
$e->status = 'read';
$e->save();
$email_type = $e->status;
}
}
///////////////////////////////////////////////////////////////////////////
//// PRIMARY PARENT LINKING
if(empty($focus->parent_type) && empty($focus->parent_id)) {
$focus->fillPrimaryParentFields();
}
//// END PRIMARY PARENT LINKING
///////////////////////////////////////////////////////////////////////////
// setup for my/mailbox email switcher
$mbox = $ieMail->getMailboxDefaultEmail();
$user = $current_user->getPreferredEmail();
$useGroup = '&nbsp;<input id="use_mbox" name="use_mbox" type="checkbox" CHECKED onClick="switchEmail()" >
<script type="text/javascript">
function switchEmail() {
var mboxName = "'.$mbox['name'].'";
var mboxAddr = "'.$mbox['email'].'";
var userName = "'.$user['name'].'";
var userAddr = "'.$user['email'].'";
if(document.getElementById("use_mbox").checked) {
document.getElementById("from_addr_field").value = mboxName + " <" + mboxAddr + ">";
document.getElementById("from_addr_name").value = mboxName;
document.getElementById("from_addr_email").value = mboxAddr;
} else {
document.getElementById("from_addr_field").value = userName + " <" + userAddr + ">";
document.getElementById("from_addr_name").value = userName;
document.getElementById("from_addr_email").value = userAddr;
}
}
</script>';
$useGroup .= $mod_strings['LBL_USE_MAILBOX_INFO'];
$xtpl->assign('FROM_ADDR_GROUP', $useGroup);
}
//// END INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////////////////
/*
$user_attachments = '';
if(isset($data) && isset($data['attachments']) && isset($data['attachments']['links']) && is_array($data['attachments']['links'])) {
foreach($data['attachments']['links'] as $value) {
$guid = create_guid();
$user_attachments .= '
<input name="user_attachment[]" value="'.$guid.'" type="hidden">
<input name="user_remove_attachment[]" value="'.$guid.'" type="checkbox"> '.$app_strings['LNK_REMOVE'].'&nbsp;&nbsp;
<input name="'.$guid.'_name" value="'.$value[0].'" type="hidden">
<input name="'.$guid.'_link" value="'.$value[1].'" type="hidden">
<a href="'.$value[1].'" target="_blank">'.$value[0].'</a><br>
';
}
$user_attachments .= "<br>";
}
*/
$user_attachments = '';
if(isset($data)) {
$att = $eedf->getAttachments();
foreach($att as $value) {
$guid = create_guid();
$user_attachments .= '
<input name="user_attachment[]" value="'.$value['md5'].'" type="hidden">
<input name="user_remove_attachment[]" value="'.$value['md5'].'" type="checkbox"> '.$app_strings['LNK_REMOVE'].'&nbsp;&nbsp;
<a href="'.$value[1].'" target="_blank">'.$value[0].'</a><br>
';
}
$user_attachments .= "<br>";
}
$xtpl->assign("USER_ATTACHMENTS", $user_attachments);
///////////////////////////////////////////////////////////////////////////////
//// SUBJECT FIELD MANIPULATION
$name = '';
if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
$focus->parent_id = $_REQUEST['parent_id'];
$focus->parent_type = $_REQUEST['parent_type'];
}
if(!empty($focus->parent_id) && !empty($focus->parent_type)) {
if($focus->parent_type == 'Cases') {
require_once('modules/Cases/Case.php');
$myCase = new aCase();
$myCase->retrieve($focus->parent_id);
$myCaseMacro = $myCase->getEmailSubjectMacro();
if(isset($ieMail->name) && !empty($ieMail->name)) { // if replying directly to an InboundEmail
$oldEmailSubj = $ieMail->name;
} elseif(isset($_REQUEST['parent_name']) && !empty($_REQUEST['parent_name'])) {
$oldEmailSubj = $_REQUEST['parent_name'];
} else {
$oldEmailSubj = $focus->name; // replying to an email using old subject
}
if(!preg_match('/^re:/i', $oldEmailSubj)) {
$oldEmailSubj = 'RE: '.$oldEmailSubj;
}
$focus->name = $oldEmailSubj;
if(strpos($focus->name, str_replace('%1',$myCase->case_number,$myCaseMacro))) {
$name = $focus->name;
} else {
$name = $focus->name.' '.str_replace('%1',$myCase->case_number,$myCaseMacro);
}
} else {
$name = $focus->name;
}
} else {
if(empty($focus->name)) {
$name = '';
} else {
$name = $focus->name;
}
}
if($email_type == 'forward') {
$name = 'FW: '.$name;
}
//// END SUBJECT FIELD MANIPULATION
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// GENERAL TEMPLATE ASSIGNMENTS
$xtpl->assign('MOD', $mod_strings);
$xtpl->assign('APP', $app_strings);
$xtpl->assign("LBL_RELATED_TO", translate("LBL_RELATED_TO", "EcmEmails"));
if(!isset($focus->id)) $xtpl->assign('USER_ID', $current_user->id);
if(!isset($focus->id) && isset($_REQUEST['contact_id'])) $xtpl->assign('CONTACT_ID', $_REQUEST['contact_id']);
if(isset($_REQUEST['return_module']) && !empty($_REQUEST['return_module'])) {
$xtpl->assign('RETURN_MODULE', $_REQUEST['return_module']);
} else {
$xtpl->assign('RETURN_MODULE', 'Emails');
}
if(isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action']) && ($_REQUEST['return_action'] != 'SubPanelViewer')) {
$xtpl->assign('RETURN_ACTION', $_REQUEST['return_action']);
} else {
$xtpl->assign('RETURN_ACTION', 'DetailView');
}
if(isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
$xtpl->assign('RETURN_ID', $_REQUEST['return_id']);
}
// handle Create $module then Cancel
if(empty($_REQUEST['return_id']) && !isset($_REQUEST['type'])) {
$xtpl->assign('RETURN_ACTION', 'index');
}
$xtpl->assign('THEME', $theme);
$xtpl->assign('IMAGE_PATH', $image_path);$xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
if(isset($data))
$xtpl->assign("MFP", $eedf->loadParserArray());
///////////////////////////////////////////////////////////////////////////////
//// QUICKSEARCH CODE
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
);
$json = getJSONobj();
$quicksearch_js = $qsd->getQSScripts();
$sqs_objects_encoded = $json->encode($sqs_objects);
$quicksearch_js .= <<<EOQ
<script type="text/javascript" language="javascript">sqs_objects = $sqs_objects_encoded;
function changeQS() {
//new_module = document.getElementById('parent_type').value;
new_module = document.EditView.parent_type.value;
if(new_module == 'Contacts' || new_module == 'Leads' || typeof(disabledModules[new_module]) != 'undefined') {
sqs_objects['parent_name']['disable'] = true;
document.getElementById('parent_name').readOnly = true;
}
else {
sqs_objects['parent_name']['disable'] = false;
document.getElementById('parent_name').readOnly = false;
}
sqs_objects['parent_name']['module'] = new_module;
}
changeQS();
</script>
EOQ;
$xtpl->assign('JAVASCRIPT', get_set_focus_js().$quicksearch_js);
//// END QUICKSEARCH CODE
///////////////////////////////////////////////////////////////////////////////
// cn: bug 14191 - duping archive emails overwrites the original
if(!isset($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] != 'true') {
$xtpl->assign('ID', $focus->id);
}
if(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
$xtpl->assign('OBJECT_ID', $_REQUEST['parent_id']);
$xtpl->assign('OBJECT_TYPE', $_REQUEST['parent_type']);
}
$xtpl->assign('FROM_ADDR', $focus->from_addr);
//// prevent TO: prefill when type is 'forward'
if($email_type != 'forward') {
$xtpl->assign('TO_ADDRS', $focus->to_addrs);
$xtpl->assign('TO_ADDRS_IDS', $focus->to_addrs_ids);
$xtpl->assign('TO_ADDRS_NAMES', $focus->to_addrs_names);
$xtpl->assign('TO_ADDRS_EMAILS', $focus->to_addrs_emails);
$xtpl->assign('CC_ADDRS', $focus->cc_addrs);
$xtpl->assign('CC_ADDRS_IDS', $focus->cc_addrs_ids);
$xtpl->assign('CC_ADDRS_NAMES', $focus->cc_addrs_names);
$xtpl->assign('CC_ADDRS_EMAILS', $focus->cc_addrs_emails);
$xtpl->assign('BCC_ADDRS', $focus->bcc_addrs);
$xtpl->assign('BCC_ADDRS_IDS', $focus->bcc_addrs_ids);
$xtpl->assign('BCC_ADDRS_NAMES', $focus->bcc_addrs_names);
$xtpl->assign('BCC_ADDRS_EMAILS', $focus->bcc_addrs_emails);
}
//$xtpl->assign('FROM_ADDR', $from['name'].' <'.$from['email'].'>');
$xtpl->assign('FROM_ADDR_NAME', $from['name']);
$xtpl->assign('FROM_ADDR_EMAIL', $from['email']);
$xtpl->assign('NAME', from_html($name));
//$xtpl->assign('DESCRIPTION_HTML', from_html($focus->description_html));
$xtpl->assign('DESCRIPTION', $focus->description);
$xtpl->assign('TYPE',$email_type);
// Unimplemented until jscalendar language files are fixed
// $xtpl->assign('CALENDAR_LANG',((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
$xtpl->assign('CALENDAR_LANG', 'en');
$xtpl->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
$xtpl->assign('DATE_START', $focus->date_start);
$xtpl->assign('TIME_FORMAT', '('. $timedate->get_user_time_format().')');
$xtpl->assign('TIME_START', substr($focus->time_start,0,5));
$xtpl->assign('TIME_MERIDIEM', $timedate->AMPMMenu('',$focus->time_start));
$parent_types = $app_list_strings['record_type_display'];
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
foreach($disabled_parent_types as $disabled_parent_type){
if($disabled_parent_type != $focus->parent_type){
unset($parent_types[$disabled_parent_type]);
}
}
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign('USER_DATEFORMAT', '('. $timedate->get_user_date_format().')');
$xtpl->assign('PARENT_NAME', $focus->parent_name);
$xtpl->assign('PARENT_ID', $focus->parent_id);
if(empty($focus->parent_type)) {
$xtpl->assign('PARENT_RECORD_TYPE', '');
} else {
$xtpl->assign('PARENT_RECORD_TYPE', $focus->parent_type);
}
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
$record = '';
if(!empty($_REQUEST['record'])){
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
//// END GENERAL TEMPLATE ASSIGNMENTS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
///
/// SETUP PARENT POPUP
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'parent_id',
'name' => 'parent_name',
),
);
$encoded_popup_request_data = $json->encode($popup_request_data);
/// Users Popup
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'assigned_user_id',
'user_name' => 'assigned_user_name',
),
);
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'account_id',
'name' => 'account_name',
),
);
$encoded_acc_popup_request_data = $json->encode($popup_request_data);
//
///////////////////////////////////////
$change_parent_button = '<input type="button" name="button" tabindex="2" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" '
. "onclick='open_popup(document.EditView.parent_type.value,600,400,\"&tree=ProductsProd\",true,false,$encoded_popup_request_data);' />\n";
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
$button_attr = '';
if(!ACLController::checkAccess('Contacts', 'list', true)){
$button_attr = 'disabled="disabled"';
}
$change_acc_addrs_button = '<input type="button" name="acc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='open_popup_emails(\"Accounts\",600,400,\"&tree=ProductsProd\",true,false,$encoded_acc_popup_request_data);' $button_attr />\n";
$xtpl->assign("CHANGE_ACC_ADDRS_BUTTON", $change_acc_addrs_button);
$change_to_addrs_button = '<input type="button" name="to_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_TO_ADDRS_BUTTON", $change_to_addrs_button);
$change_cc_addrs_button = '<input type="button" name="cc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_CC_ADDRS_BUTTON", $change_cc_addrs_button);
$change_bcc_addrs_button = '<input type="button" name="bcc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_BCC_ADDRS_BUTTON", $change_bcc_addrs_button);
///////////////////////////////////////
//// USER ASSIGNMENT
global $current_user;
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
$record = '';
if(!empty($_REQUEST['record'])) {
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
if(empty($focus->assigned_user_id) && empty($focus->id))
$focus->assigned_user_id = $current_user->id;
if(empty($focus->assigned_name) && empty($focus->id))
$focus->assigned_user_name = $current_user->user_name;
$xtpl->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $focus->assigned_user_id), $focus->assigned_user_id));
$xtpl->assign('ASSIGNED_USER_NAME', $focus->assigned_user_name);
$xtpl->assign('ASSIGNED_USER_ID', $focus->assigned_user_id);
$xtpl->assign('DURATION_HOURS', $focus->duration_hours);
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
if(isset($focus->duration_minutes)) {
$xtpl->assign('DURATION_MINUTES_OPTIONS', get_select_options_with_id($focus->minutes_values,$focus->duration_minutes));
}
//// END USER ASSIGNMENT
///////////////////////////////////////
//Add Custom Fields
require_once('modules/DynamicFields/templates/Files/EditView.php');
require_once("modules/Notes/Note.php");
///////////////////////////////////////
//// ATTACHMENTS
$attachments = '';
if(!empty($focus->id) || (!empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward')) {
$attachments = "<input type='hidden' name='removeAttachment' id='removeAttachment' value=''>\n";
$ids = '';
$focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
$note = new Note();
$where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
$notes_list = $note->get_full_list("", $where,true);
if(!isset($notes_list)) {
$notes_list = array();
}
for($i = 0;$i < count($notes_list);$i++) {
$the_note = $notes_list[$i];
if(empty($the_note->filename)) {
continue;
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
if(!empty($ids)) {
$ids .= ",";
}
$ids .= $the_note->id;
$attachments .= "
<div id='noteDiv{$the_note->id}'>
<img onclick='deletePriorAttachment(\"{$the_note->id}\");' src='themes/{$theme}/images/delete_inline.gif' value='{$the_note->id}'>&nbsp;";
$attachments .= '<a href="'.UploadFile::get_url($the_note->filename,$the_note->id).'" target="_blank">'. $the_note->filename .'</a></div>';
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
$attachments .= "<input type='hidden' name='prior_attachments' value='{$ids}'>";
// workaround $mod_strings being overriden by Note object instantiation above.
global $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'Emails');
}
$attJs = '<script type="text/javascript">';
$attJs .= 'var file_path = "'.$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].'";';
$attJs .= 'var lnk_remove = "'.$app_strings['LNK_REMOVE'].'";';
$attJs .= '</script>';
$xtpl->assign('ATTACHMENTS', $attachments);
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
//// END ATTACHMENTS
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// DOCUMENTS
$popup_request_data = array(
'call_back_function' => 'document_set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'related_doc_id',
'document_name' => 'related_document_name',
),
);
$json = getJSONobj();
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
//// END DOCUMENTS
///////////////////////////////////////////////////////////////////////////////
$parse_open = true;
if($parse_open) {
$xtpl->parse('main.open_source_1');
}
///////////////////////////////////////////////////////////////////////////////
//// EMAIL TEMPLATES
if(ACLController::checkAccess('EmailTemplates', 'list', true) && ACLController::checkAccess('EmailTemplates', 'view', true)) {
$et = new EmailTemplate();
$etResult = $focus->db->query($et->create_new_list_query('','',''));
$email_templates_arr[] = '';
while($etA = $focus->db->fetchByAssoc($etResult)) {
$email_templates_arr[$etA['id']] = $etA['name'];
}
} else {
$email_templates_arr = array('' => $app_strings['LBL_NONE']);
}
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, ''));
if(isset($data)) {
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, $eedf->templateId()));
}
//// END EMAIL TEMPLATES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
//// TEXT EDITOR
// cascade from User to Sys Default
$editor = $focus->getUserEditorPreference();
if($editor != 'plain') {
// this box is checked by Javascript on-load.
$xtpl->assign('EMAIL_EDITOR_OPTION', 'CHECKED');
}
$description_html = from_html($focus->description_html);
$description = $focus->description;
/////////////////////////////////////////////////
// signatures
if($sig = $current_user->getDefaultSignature()) {
if(!$focus->hasSignatureInBody($sig) && $focus->type != 'draft') {
if($current_user->getPreference('signature_prepend')) {
$description_html = '<br />'.from_html($sig['signature_html']).'<br /><br />'.$description_html;
//$description_html .= $sig['signature_html'];
$description = "\n".$sig['signature']."\n\n".$description;
} else {
$description_html .= '<br /><br />'.from_html($sig['signature_html']);
//$description_html .= $sig['signature_html'];
$description = $description."\n\n".$sig['signature'];
}
}
}
$xtpl->assign('DESCRIPTION2', $description);
// sigs
/////////////////////////////////////////////////
$tiny = new SugarTinyMCE();
$ed = $tiny->getInstance("description_html");
$xtpl->assign("TINY", $ed);
$xtpl->assign("DESCRIPTION_HTML2", $description_html);
if(isset($data)) {
$xtpl->assign('ASSIGNED_USER_NAME', $eedf->assignedUserName());
$xtpl->assign('ASSIGNED_USER_ID', $eedf->assignedUserId());
$xtpl->assign('DESCRIPTION_HTML', from_html($eedf->descriptionHTML()));
$xtpl->assign('DESCRIPTION', $eedf->description());
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $eedf->parentType()));
// $xtpl->assign('EXTRA_ASSIGNED', $eedf->extraAssigned());
$xtpl->assign('DATA', $_REQUEST['data']);
if(isset($_REQUEST['to_pdf']) && ($_REQUEST['to_pdf'] == 'true' || $_REQUEST['to_pdf'] == '1')) {
$xtpl->assign('TO_PDF', '<input type="hidden" name="to_pdf" value="1" />');
}
}
$xtpl->parse('main.htmlarea');
//// END TEXT EDITOR
///////////////////////////////////////
///////////////////////////////////////
//// SPECIAL INBOUND LANDING SCREEN ASSIGNS
if(!empty($_REQUEST['inbound_email_id'])) {
if(!empty($_REQUEST['start'])) {
$parts = $focus->getStartPage(base64_decode($_REQUEST['start']));
$xtpl->assign('RETURN_ACTION', $parts['action']);
$xtpl->assign('RETURN_MODULE', $parts['module']);
$xtpl->assign('GROUP', $parts['group']);
}
$xtpl->assign('ASSIGNED_USER_ID', $current_user->id);
$xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';');
}
//// END SPECIAL INBOUND LANDING SCREEN ASSIGNS
///////////////////////////////////////
echo '<script>var disabledModules='. $json->encode($disabled_parent_types) . ';</script>';
$jsVars = 'var lbl_send_anyways = "'.$mod_strings['LBL_SEND_ANYWAYS'].'";';
$xtpl->assign('JS_VARS', $jsVars);
if(isset($data)) {
$xtpl->assign('FROM_ADDR', $eedf->from());
$xtpl->assign('TO_ADDRS', $eedf->to_addrs());
$xtpl->assign('TO_ADDRS_IDS', $eedf->to_addrs_ids());
$xtpl->assign('TO_ADDRS_NAMES', $eedf->to_addrs_names());
$xtpl->assign('TO_ADDRS_EMAILS', $eedf->to_addrs_emails());
$xtpl->assign('CC_ADDRS', $eedf->cc_addrs());
$xtpl->assign('CC_ADDRS_IDS', $eedf->cc_addrs_ids());
$xtpl->assign('CC_ADDRS_NAMES', $eedf->cc_addrs_names());
$xtpl->assign('CC_ADDRS_EMAILS', $eedf->cc_addrs_emails());
$xtpl->assign('BCC_ADDRS', $eedf->bcc_addrs());
$xtpl->assign('BCC_ADDRS_IDS', $eedf->bcc_addrs_ids());
$xtpl->assign('BCC_ADDRS_NAMES', $eedf->bcc_addrs_names());
$xtpl->assign('BCC_ADDRS_EMAILS', $eedf->bcc_addrs_emails());
$xtpl->assign('NAME', from_html($eedf->subject()));
}
$xtpl->parse("main");
$xtpl->out("main");
echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>';
//// END XTEMPLATE ASSIGNMENT
///////////////////////////////////////////////////////////////////////////////
require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('EditView');
$javascript->setSugarBean($focus);
$skip_fields = array();
if($email_type == 'out') {
$skip_fields['name'] = 1;
$skip_fields['date_start'] = 1;
}
$javascript->addAllFields('',$skip_fields);
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
if($email_type == 'archived') {
$javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true);
$javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_START'], true);
}
echo $javascript->getScript();

View File

@@ -0,0 +1,438 @@
<!--
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
-->
<!-- BEGIN: main -->
<script type="text/javascript" language="Javascript">
{JS_VARS}
</script>
<script type="text/javascript" src="include/jsolait/init.js?s=5.0.0d&c="></script>
<script type="text/javascript" src="include/javascript/jsclass_base.js?s=5.0.0d&c="></script>
<script type="text/javascript" src="include/javascript/jsclass_async.js?s=5.0.0d&c="></script>
<script type="text/javascript" src="modules/EcmEmails/Email.js?s=5.0.0d&c="></script>
<script type="text/javascript" src="modules/Documents/documents.js?s=5.0.0d&c="></script>
<link rel="stylesheet" type="text/css" href="themes/Sugar/navigation.css?s=5.0.0d&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/style.css?s=5.0.0d&c=" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/colors.sugar.css?s=5.0.0d&c=" id="current_color_style" />
<link rel="stylesheet" type="text/css" href="themes/Sugar/fonts.normal.css?s=5.0.0d&c=" id="current_font_style"/>
{MESSAGE}
<script type="text/javascript" language="javascript">
YAHOO.util.Event.addListener(window, "load",
function() {
var template_select = document.forms.EditView.email_template;
if(typeof(template_select) == "object") {
fill_email(template_select.value);
}
}
);
</script>
<form action="index.php" method="post" name="EditView" enctype="multipart/form-data">
<input type="hidden" name="module" value="EcmEmails" />
<input type="hidden" name="action" value="Save" />
<input type="hidden" name="contact_id" value="{CONTACT_ID}" />
<input type="hidden" name="user_id" value="{USER_ID}" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="send" value="" />
<input type="hidden" name="type" value="out" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}" />
<input type="hidden" name="assigned_user_id" value="{ASSIGNED_USER_ID}" />
<input type="hidden" name="object_type" value="{OBJECT_TYPE}" />
<input type="hidden" name="object_id" value="{OBJECT_ID}" />
<input type="hidden" name="group" value="{GROUP}" />
<input type="hidden" name="origType" value="{TYPE}" />
<input type="hidden" name="data" value="{DATA}" />
{TO_PDF}
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm" style="border-top:0;">
<tr>
<td colspan="5">
<table class="moduleTitle" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td valign="top" >
<h2>{HEADER}</h2></td>
<td valign="top" align="left" nowrap="nowrap">{ADMIN_EDIT}</td></tr></tbody></table>
</td>
</tr>
<tr>
<td colspan="5">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL}" onclick="prepSave();this.form.action.value='Save';this.form.send.value='1';this.form.type.value='out';return fill_form('out', '{MOD.ERR_NOT_ADDRESSED}');" />
<input style="display:none;" type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="this.form.action.value='Save';this.form.send.value='0';this.form.type.value='draft';fill_form('draft', '{MOD.ERR_NOT_ADDRESSED}');" />
<input style="display:none;" type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" />
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
<!-- END: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot> </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
Powiązane z: </slot> </td>
<td class="dataField" style="width:400px;">
<slot>
<select tabindex='2' name='parent_type' onchange=" document.EditView.parent_name.value='';
changeQS();
checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);">
{TYPE_OPTIONS}</select>&nbsp;
<input id='parent_id' name='parent_id' type="hidden" value='{PARENT_ID}'>
<input class="sqsEnabled" id='parent_name' name='parent_name' tabindex='2' type='text' value="{PARENT_NAME}">
&nbsp;{CHANGE_PARENT_BUTTON}
<input class="sqsEnabled" tabindex='1' id="assigned_user_name" name='assigned_user_name' type="hidden" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" tabindex='1' class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1" onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' style="display:none;" />
</slot> </td>
<td nowrap >
<slot> </slot> </td>
<td rowspan="2" colspan="2">
<slot>
{EXTRA_ASSIGNED} </slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td colspan="1">&nbsp; </td>
<td colspan="4">
{MOD.LBL_NOTE_SEMICOLON} </td>
<td colspan="2">&nbsp; </td>
</tr>
<tr valign="top">
<td class="dataLabel">{MOD.LBL_TO_ACC} </td>
<td colspan="4" nowrap="NOWRAP" class="dataField"><table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="443">
<div id="accounts_div"></div><input type="hidden" name="accounts_count" id="accounts_count" value="0" />
<!--<input type="hidden" id="account_id" name="account_id" /><input type="text" id="account_name" name='account_name'>--> </td>
<td valign="top" style="padding-left: 4px;"> {CHANGE_ACC_ADDRS_BUTTON}</td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td class="dataLabel"><slot>{MOD.LBL_TO} </slot></td>
<td colspan="4" nowrap="NOWRAP" class="dataField"><table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><textarea id="to_addrs_field" name='to_addrs' tabindex='3' cols="80" rows="1" style="height:20px; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{TO_ADDRS}">{TO_ADDRS}</textarea>
<input type="hidden" id="to_addrs_ids" name="to_addrs_ids" value="{TO_ADDRS_IDS}" />
<input type="hidden" id="to_addrs_emails" name="to_addrs_emails" value="{TO_ADDRS_EMAILS}" />
<input type="hidden" id="to_addrs_names" name="to_addrs_names" value="{TO_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;"> {CHANGE_TO_ADDRS_BUTTON} </td>
</tr>
</table></td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_CC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="cc_addrs_field" name='cc_addrs' tabindex='3' cols="80" rows="1" style="height:20px; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{CC_ADDRS}">{CC_ADDRS}</textarea>
<input type="hidden" id="cc_addrs_ids" name="cc_addrs_ids" value="{CC_ADDRS_IDS}" />
<input type="hidden" id="cc_addrs_emails" name="cc_addrs_emails" value="{CC_ADDRS_EMAILS}" />
<input type="hidden" id="cc_addrs_names" name="cc_addrs_names" value="{CC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_CC_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_BCC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="bcc_addrs_field" name='bcc_addrs' tabindex='3' cols="80" rows="1" style="height:20px; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{BCC_ADDRS}">{BCC_ADDRS}</textarea>
<input type="hidden" id="bcc_addrs_ids" name="bcc_addrs_ids" value="{BCC_ADDRS_IDS}" />
<input type="hidden" id="bcc_addrs_emails" name="bcc_addrs_emails" value="{BCC_ADDRS_EMAILS}" />
<input type="hidden" id="bcc_addrs_names" name="bcc_addrs_names" value="{BCC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_BCC_ADDRS_BUTTON} </td>
</tr>
</table> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_FROM} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="from_addr_field" name='from_addr' tabindex='3' cols="80" rows="1" style="height:20px; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{FROM_ADDR}">{FROM_ADDR}</textarea> {FROM_ADDR_GROUP}
<input type="hidden" id="from_addr_email" name="from_addr_email" />
<input type="hidden" id="from_addr_name" name="from_addr_name" /> </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_SUBJECT} </slot> </td>
<td colspan='4' class="dataField">
<slot>
<textarea name='name' tabindex='4' cols="100" rows="1" style="height:20px; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" id="subjectfield">{NAME}</textarea>
</slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_BODY} </td>
<!-- BEGIN: htmlarea -->
<td colspan="4" class="dataLabel" valign="top" style="width:auto;">
<slot>
{MOD.LBL_USE_TEMPLATE}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select tabindex='2' name='email_template' onchange="fill_email(this.options[this.selectedIndex].value);">
{EMAIL_TEMPLATE_OPTIONS}
</select>
&nbsp;&nbsp;
<input type="button" class="button" name="clear" id="clear" value="Clear" onClick="fill_email('');">
&nbsp;&nbsp;
<input type="button" class="button" name="new_template" id="new_template" value="Template Fields" onClick="document.getElementById('template_fields').style.display='';" />
</slot> </td>
</tr>
<tr>
<td></td>
<td colspan="4">
<div id="template_fields" style="display:none">
<table>
<tr>
<td valign="top" class="dataLabel">
Templatate Fields: </td>
<td colspan="5" class="dataField">
<slot>
{MFP}
<input type="button" class="button" name="cancel_template_fields" id="cancel_template_fields" value="Hide" onClick="document.getElementById('template_fields').style.display='none';">
</slot> </td>
</tr>
</table>
</div> </td>
</tr>
<tr>
<td valign="top" class="dataLabel"> </td>
<td colspan="2" class="dataField">
<slot>
<div id="editor_select">
<input id="setEditor" name="setEditor" value="1" {EMAIL_EDITOR_OPTION} type="checkbox" onclick="toggle_textonly();">
{MOD.LBL_EMAIL_EDITOR_OPTION} </div>
</slot> </td>
<td class="dataLabel" valign="top">
<slot> </slot> </td>
<td class="dataField" nowrap width="1">
<slot> </slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">&nbsp; </td>
<td colspan="4" class="dataField">
{TINY}
<slot>
<div id="html_div">
<textarea id="description_html" name="description_html" onblur="">{DESCRIPTION_HTML2}</textarea>
</div>
<div id="alt_text_div">
<input id="toggle_textarea_elem" onclick="toggle_textarea();" type="checkbox" name="toggle_html">
{MOD.LBL_EDIT_ALT_TEXT} </div>
<div id="text_div" style="display: none;">
<textarea tabindex='5' id="description" name='description' cols="100" rows="20">{DESCRIPTION2}</textarea>
</div>
</slot> </td>
<!-- END: htmlarea -->
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_ATTACHMENTS} </td>
<td colspan="4">
{ATTACHMENTS_JAVASCRIPT} {ATTACHMENTS}
<div id="user_attachments">
{USER_ATTACHMENTS} </div>
<div id="template_attachments"> </div>
<div id="uploads_div">
<div style="display: none" id="file0">
<input id='email_attachment0' name='email_attachment0' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file1">
<input id='email_attachment1' name='email_attachment1' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file2">
<input id='email_attachment2' name='email_attachment2' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file3">
<input id='email_attachment3' name='email_attachment3' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file4">
<input id='email_attachment4' name='email_attachment4' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file5">
<input id='email_attachment5' name='email_attachment5' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file6">
<input id='email_attachment6' name='email_attachment6' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file7">
<input id='email_attachment7' name='email_attachment7' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file8">
<input id='email_attachment8' name='email_attachment8' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="file9">
<input id='email_attachment9' name='email_attachment9' tabindex='0' size='40' type='file' />
&nbsp;<input type="button" onclick="deleteFile('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document0">
<input name='documentId0' id='documentId0' tabindex='0' type='hidden' />
<input name='documentName0' id='documentName0' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('0');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('0');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document1">
<input name='documentId1' id='documentId1' tabindex='1' type='hidden' />
<input name='documentName1' id='documentName1' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('1');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('1');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document2">
<input name='documentId2' id='documentId2' tabindex='2' type='hidden' />
<input name='documentName2' id='documentName2' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('2');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('2');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document3">
<input name='documentId3' id='documentId3' tabindex='3' type='hidden' />
<input name='documentName3' id='documentName3' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('3');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('3');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document4">
<input name='documentId4' id='documentId4' tabindex='4' type='hidden' />
<input name='documentName4' id='documentName4' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('4');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('4');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document5">
<input name='documentId5' id='documentId5' tabindex='5' type='hidden' />
<input name='documentName5' id='documentName5' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('5');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('5');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document6">
<input name='documentId6' id='documentId6' tabindex='6' type='hidden' />
<input name='documentName6' id='documentName6' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('6');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('6');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document7">
<input name='documentId7' id='documentId7' tabindex='7' type='hidden' />
<input name='documentName7' id='documentName7' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('7');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('7');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document8">
<input name='documentId8' id='documentId8' tabindex='8' type='hidden' />
<input name='documentName8' id='documentName8' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('8');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('8');" class="button" value="{APP.LBL_REMOVE}" />
</div>
<div style="display: none" id="document9">
<input name='documentId9' id='documentId9' tabindex='9' type='hidden' />
<input name='documentName9' id='documentName9' disabled size='40' type='text' />
&nbsp;<input type="button" onclick="selectDocument('9');" class="button" value="{APP.LBL_SELECT_BUTTON_LABEL}" /><input type="button" onclick="deleteDocument('9');" class="button" value="{APP.LBL_REMOVE}" />
</div>
</div> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL} " onclick="prepSave();this.form.action.value='Save';this.form.send.value='1';this.form.type.value='out';return fill_form('out', '{MOD.ERR_NOT_ADDRESSED}');" />
<input style="display:none;" type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="this.form.action.value='Save';this.form.send.value='0';this.form.type.value='draft';fill_form('draft', '{MOD.ERR_NOT_ADDRESSED}');" />
<input style="display:none;" type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" /> </td>
<td colspan="4">
<input type="button" name="add_file_button" onclick="addFile();" value="{MOD.LBL_ADD_FILE}" class="button" />
<input type="button" name="add_document_button" onclick="addDocument();" value="{MOD.LBL_ADD_DOCUMENT}" class="button" /> </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
{JAVASCRIPT}
<script type="text/javascript" language="Javascript">
var old_load=window.onload; window.onload = function() {
old_load();
setEditor();
// cn: bug 5845 - use Group Inbox From info
if(window.switchEmail) {
switchEmail();
}
}
</script>
<!-- END: main -->

1013
modules/EcmEmails/Email.js Executable file

File diff suppressed because it is too large Load Diff

354
modules/EcmEmails/EmailSave.php Executable file
View File

@@ -0,0 +1,354 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* *******************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
*********************************************************************************/
require_once('modules/Emails/Email.php');
///////////////////////////////////////////////////////////////////////////////
//// EMAIL SEND/SAVE SETUP
$focus = new Email();
if(!isset($prefix)) {
$prefix = '';
}
if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'], $timedate->get_time_format(true), $_POST[$prefix.'meridiem']);
}
//retrieve the record
if(isset($_POST['record']) && !empty($_POST['record'])) {
$focus->retrieve($_POST['record']);
}
if(isset($_REQUEST['user_id'])) {
$focus->assigned_user_id = $_REQUEST['user_id'];
}
if(!$focus->ACLAccess('Save')){
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
if(!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
$check_notify = TRUE;
}
//populate the fields of this Email
$allfields = array_merge($focus->column_fields, $focus->additional_column_fields);
foreach($allfields as $field) {
if(isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
if (!isset($_REQUEST['to_addrs'])) {
$_REQUEST['to_addrs'] = "";
}
if (!isset($_REQUEST['to_addrs_ids'])) {
$_REQUEST['to_addrs_ids'] = "";
}
if (!isset($_REQUEST['to_addrs_names'])) {
$_REQUEST['to_addrs_names'] = "";
}
if (!isset($_REQUEST['to_addrs_emails'])) {
$_REQUEST['to_addrs_emails'] = "";
}
//compare the 3 fields and return list of contact_ids to link:
$focus->to_addrs_arr = $focus->parse_addrs($_REQUEST['to_addrs'], $_REQUEST['to_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['to_addrs_emails']);
// make sure the cc_* and bcc_* fields are at least empty if not set
$fields_to_check = array(
'cc_addrs',
'cc_addrs_ids',
'bcc_addrs',
'bcc_addrs_ids',
'cc_addrs_names',
'cc_addrs_emails',
'bcc_addrs_emails',
);
foreach ($fields_to_check as $field_to_check) {
if (!isset($_REQUEST[$field_to_check])) {
$_REQUEST[$field_to_check] = '';
}
}
$focus->cc_addrs_arr = $focus->parse_addrs($_REQUEST['cc_addrs'], $_REQUEST['cc_addrs_ids'], $_REQUEST['cc_addrs_names'], $_REQUEST['cc_addrs_emails']);
$focus->bcc_addrs_arr = $focus->parse_addrs($_REQUEST['bcc_addrs'], $_REQUEST['bcc_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['bcc_addrs_emails']);
if(!empty($_REQUEST['type'])) {
$focus->type = $_REQUEST['type'];
} elseif(empty($focus->type)) { // cn: from drafts/quotes
$focus->type = 'archived';
}
///////////////////////////////////////////////////////////////////////////////
//// TEMPLATE PARSING
// cn: bug 7244 - need to pass an empty bean to parse email templates
$object_arr = array();
if(!empty($focus->parent_id)) {
$object_arr[$focus->parent_type] = $focus->parent_id;
}
if(isset($focus->to_addrs_arr[0]['contact_id'])) {
$object_arr['Contacts'] = $focus->to_addrs_arr[0]['contact_id'];
}
if(empty($object_arr)) {
$object_arr = array('Contacts' => '123');
}
// do not parse email templates if the email is being saved as draft....
if($focus->type != 'draft' && count($object_arr) > 0) {
require_once($beanFiles['EmailTemplate']);
$focus->name = EmailTemplate::parse_template($focus->name, $object_arr);
$focus->description = EmailTemplate::parse_template($focus->description, $object_arr);
$focus->description_html = EmailTemplate::parse_template($focus->description_html, $object_arr);
}
//// END TEMPLATE PARSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// PREP FOR ATTACHMENTS
if(empty($focus->id)){
$focus->id = create_guid();
$focus->new_with_id = true;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// ATTACHMENT HANDLING
$focus->handleAttachments();
if($_SESSION['pricebook_id'])
{
$cn=explode(";",$_REQUEST['to_addrs_ids']);
if($_REQUEST['attach_pdf'])
{
$_REQUEST['images']=$_REQUEST['email_images'];
include('modules/EcmPriceBooks/CreatePDF.php');
if($microtime != '')
{
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = 'Products.pdf';
$n->filename = 'Products.pdf';
$n->file_mime_type = 'application/pdf';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$n->contact_id=trim($cn[0]);
$nid=$n->save();
rename('cache/upload/Products'.$microtime.'.pdf', 'cache/upload/'.$nid);
$focus->saved_attachments[] = $n;
}
}
if($_REQUEST['attach_xls'])
{
include('modules/EcmPriceBooks/CreateXLS.php');
if($microtime != '')
{
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = 'Products.xls';
$n->filename = 'Products.xls';
$n->file_mime_type = 'application/ms-excel';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$n->contact_id=trim($cn[0]);
$nid=$n->save();
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
$focus->saved_attachments[] = $n;
}
}
}
/*
}
if($_REQUEST['attach_pdf'])
{
include('modules/EcmPriceBooks/CreateXLS.php');
if($microtime != '')
{
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = 'Products.xls';
$n->filename = 'Products.xls';
$n->file_mime_type = 'application/x-msexcel';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$nid=$n->save();
$focus->saved_attachments[] = $n;
rename('cache/upload/Products'.$microtime.'.xls', 'cache/upload/'.$nid);
}
}
*/
//// END ATTACHMENT HANDLING
///////////////////////////////////////////////////////////////////////////////
$focus->status = 'draft';
if($focus->type == 'archived' ) {
$focus->status= 'archived';
} elseif(($focus->type == 'out' || $focus->type == 'forward')) {
///////////////////////////////////////////////////////////////////////////
//// REPLY PROCESSING
$old = array('&lt;','&gt;');
$new = array('<','>');
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' &lt;'.$_REQUEST['from_addr_email'].'&gt;') {
if(false === strpos($_REQUEST['from_addr'], '&lt;')) { // we have an email only?
$focus->from_addr = $_REQUEST['from_addr'];
$focus->from_name = '';
} else { // we have a compound string
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
$focus->from_addr = substr($newFromAddr, (1 + strpos($newFromAddr, '<')), (strpos($newFromAddr, '>') - strpos($newFromAddr, '<')) -1 );
$focus->from_name = substr($newFromAddr, 0, (strpos($newFromAddr, '<') -1));
}
} elseif(!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
$focus->from_addr = $_REQUEST['from_addr_email'];
$focus->from_name = $_REQUEST['from_addr_name'];
} else {
$focus->from_addr = $focus->getSystemDefaultEmail();
}
//// REPLY PROCESSING
///////////////////////////////////////////////////////////////////////////
if($focus->send()) {
$focus->status = 'sent';
} else {
$focus->status = 'send_error';
}
}
$focus->to_addrs = $_REQUEST['to_addrs'];
// delete the existing relationship of all the email addresses with this email
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
// delete al the relationship of this email with all the beans
$query = "update emails_beans set deleted = 1, bean_id = '', bean_module = '' WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
$GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
if(!in_array($_REQUEST['object_id'],$exContactIds)){
$rel = strtolower($_REQUEST['object_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['object_id']);
$GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
}
}
//// handle legacy parent_id/parent_type relationship calls
elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
if(!isset($exContactIds) || !in_array($_REQUEST['parent_id'],$exContactIds)){
$rel = strtolower($_REQUEST['parent_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['parent_id']);
}
}
//// END RELATIONSHIP LINKING
///////////////////////////////////////////////////////////////////////////////
// If came from email archiving edit view, this would have been set from form input.
if (!isset($focus->date_start))
{
$today = gmdate('Y-m-d H:i:s');
$focus->date_start = $timedate->to_display_date($today);
$focus->time_start = $timedate->to_display_time($today, true);
}
$focus->date_sent = "";
$focus->save(false);
//// END EMAIL SAVE/SEND SETUP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// RELATIONSHIP LINKING
$focus->load_relationship('users');
$focus->users->add($current_user->id);
if(!empty($_REQUEST['to_addrs_ids'])) {
$focus->load_relationship('contacts');
$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
foreach($exContactIds as $contactId) {
$contactId = trim($contactId);
$focus->contacts->add($contactId);
}
}
///////////////////////////////////////////////////////////////////////////////
//// PAGE REDIRECTION
///////////////////////////////////////////////////////////////////////////////
$return_id = $focus->id;
if(empty($_POST['return_module'])) {
$return_module = "Emails";
} else {
$return_module = $_POST['return_module'];
}
if(empty($_POST['return_action'])) {
$return_action = "DetailView";
} else {
$return_action = $_POST['return_action'];
}
$GLOBALS['log']->debug("Saved record with id of ".$return_id);
require_once('include/formbase.php');
if($focus->type == 'draft') {
if($return_module == 'Emails') {
header("Location: index.php?module=$return_module&action=ListViewDrafts");
} else {
handleRedirect($return_id, 'Emails');
}
} elseif($focus->type == 'out') {
if($return_module == 'Home') {
header('Location: index.php?module='.$return_module.'&action=index');
}
if(!empty($_REQUEST['return_id'])) {
$return_id = $_REQUEST['return_id'];
}
header('Location: index.php?action='.$return_action.'&module='.$return_module.'&record='.$return_id.'&assigned_user_id='.$current_user->id.'&type=inbound');
} elseif(isset($_POST['return_id']) && $_POST['return_id'] != "") {
$return_id = $_POST['return_id'];
}
header("Location: index.php?module=EcmPriceBooks&action=Emails&to_pdf=1&bodyclass=tabForm&type=out&pricebook_id=".$_REQUEST['pricebook_id']);
?>

333
modules/EcmEmails/Emails.html Executable file
View File

@@ -0,0 +1,333 @@
<!--
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
-->
<!-- BEGIN: main -->
{MESSAGE}
<form action="index.php" method="post" name="EditView" enctype="multipart/form-data">
<input type="hidden" name="module" value="EcmPriceBooks" />
<input type="hidden" name="action" value="EmailSave" />
<input type="hidden" name="to_pdf" value="1" />
<input type="hidden" name="contact_id" value="{CONTACT_ID}" />
<input type="hidden" name="user_id" value="{USER_ID}" />
<input type="hidden" name="return_module" value="{RETURN_MODULE}" />
<input type="hidden" name="return_id" value="{RETURN_ID}" />
<input type="hidden" name="send" value="" />
<input type="hidden" name="type" value="out" />
<input type="hidden" name="record" value="{ID}" />
<input type="hidden" name="return_action" value="{RETURN_ACTION}" />
<input type="hidden" name="inbound_email_id" value="{INBOUND_EMAIL_ID}" />
<input type="hidden" name="assigned_user_id" value="{ASSIGNED_USER_ID}" />
<input type="hidden" name="object_type" value="{OBJECT_TYPE}" />
<input type="hidden" name="object_id" value="{OBJECT_ID}" />
<input type="hidden" name="group" value="{GROUP}" />
<input type="hidden" name="origType" value="{TYPE}" />
<input type="hidden" name="invoiceout_id" value="{INVOICEOUT_ID}" />
<input type="hidden" name="pricebook_id" value="{PRICEBOOK_ID}" />
<input type="hidden" name="pIdFrom" value="{PIDFROM}" />
<input type="hidden" name="pTypeFrom" value="{PTYPEFROM}" />
<input type="hidden" name="pIdTo" value="{PIDTO}" />
<input type="hidden" name="pTypeTo" value="{PTYPETO}" />
<input type="hidden" name="bodyclass" value="{BODYCLASS}" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<th class="dataLabel" align="left" colspan="8">
<h4>Send email</h4><br>
</th>
<tr>
<td style="padding-bottom: 2px;">
<input type="submit" name="button" class="button" {disable_send} title="{MOD.LBL_SEND_BUTTON_TITLE}" accesskey="{MOD.LBL_SEND_BUTTON_KEY}" value=" {MOD.LBL_SEND_BUTTON_LABEL} " />
<!--
<input type="submit" name="button" class="button" title="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_TITLE}" accesskey="{MOD.LBL_SAVE_AS_DRAFT_BUTTON_KEY}" value=" {MOD.LBL_SAVE_AS_DRAFT_BUTTON_LABEL} " onclick="return invoiceoutAlert('save_draft');" />
<input type="submit" name="button" class="button" title="{APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{APP.LBL_CANCEL_BUTTON_KEY}" value=" {APP.LBL_CANCEL_BUTTON_LABEL} " onclick="this.form.action.value='{RETURN_ACTION}'; this.form.module.value='{RETURN_MODULE}'; this.form.record.value='{RETURN_ID}'; {MYINBOX}" />
-->
</td>
<td align="right" nowrap>
</td>
<td align='right'>
{ADMIN_EDIT}
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- BEGIN: open_source_1 -->
<td nowrap class="dataLabel">
<slot> </slot>
Attach PDF </td>
<td nowrap>
<slot> </slot> </td>
<!-- END: open_source_1 -->
<td nowrap>
<slot> </slot> </td>
<td>
<div style="display:none;">
<slot>
<select tabindex='2' name='parent_type' onChange=" document.EditView.parent_name.value='';
changeQS();
checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);">
{TYPE_OPTIONS}</select>&nbsp; </slot>
</div>
<input type="checkbox" name="attach_pdf" value="1" checked>
Images:
<input type="checkbox" name="email_images" value="true" checked></td>
<td class="dataField" nowrap>
<div style="display:none;">
<slot>
<input id='parent_id' name='parent_id' type="hidden" value='{PARENT_ID}'>
<input class="sqsEnabled" id='parent_name' name='parent_name' tabindex='2' type='text' value="{PARENT_NAME}">
&nbsp;{CHANGE_PARENT_BUTTON} </slot>
</div> </td>
</tr>
<tr>
<td class="dataLabel">
<div style="display:none;">
<slot>
{APP.LBL_ASSIGNED_TO}&nbsp; </slot>
</div>
Attach XLS </td>
<td class="dataField">
<div style="display:none;">
<slot>
<input class="sqsEnabled" tabindex='1' id="assigned_user_name" name='assigned_user_name' type="text" value="{ASSIGNED_USER_NAME}">
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{ASSIGNED_USER_ID}" />
<input title="{APP.LBL_SELECT_BUTTON_TITLE}" accesskey="{APP.LBL_SELECT_BUTTON_KEY}" type="button" tabindex='1' class="button" value='{APP.LBL_SELECT_BUTTON_LABEL}' name="btn1" onclick='open_popup("Users", 600, 400, "", true, false, {encoded_users_popup_request_data});' />
</slot>
</div> </td>
<td nowrap>
<slot> </slot> </td>
<td nowrap>
<slot> </slot>
<span class="dataLabel">
<input type="checkbox" name="attach_xls" value="checkbox">
</span></td>
<td nowrap>
<slot> </slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td colspan="1">&nbsp; </td>
<td colspan="4">
{MOD.LBL_NOTE_SEMICOLON} </td>
<td colspan="2">&nbsp; </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_TO} </slot> </td>
<td colspan="4" class="dataField" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="to_addrs_field" name='to_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{TO_ADDRS}">{TO_ADDRS}</textarea>
<input type="hidden" id="to_addrs_ids" name="to_addrs_ids" value="{TO_ADDRS_IDS}" />
<input type="hidden" id="to_addrs_emails" name="to_addrs_emails" value="{TO_ADDRS_EMAILS}" />
<input type="hidden" id="to_addrs_names" name="to_addrs_names" value="{TO_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_TO_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_CC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="cc_addrs_field" name='cc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{CC_ADDRS}">{CC_ADDRS}</textarea>
<input type="hidden" id="cc_addrs_ids" name="cc_addrs_ids" value="{CC_ADDRS_IDS}" />
<input type="hidden" id="cc_addrs_emails" name="cc_addrs_emails" value="{CC_ADDRS_EMAILS}" />
<input type="hidden" id="cc_addrs_names" name="cc_addrs_names" value="{CC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_CC_ADDRS_BUTTON} </td>
</tr>
</table>
</slot> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_BCC} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="bcc_addrs_field" name='bcc_addrs' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{BCC_ADDRS}">{BCC_ADDRS}</textarea>
<input type="hidden" id="bcc_addrs_ids" name="bcc_addrs_ids" value="{BCC_ADDRS_IDS}" />
<input type="hidden" id="bcc_addrs_emails" name="bcc_addrs_emails" value="{BCC_ADDRS_EMAILS}" />
<input type="hidden" id="bcc_addrs_names" name="bcc_addrs_names" value="{BCC_ADDRS_NAMES}" /> </td>
<td style="padding-left: 4px;">
{CHANGE_BCC_ADDRS_BUTTON} </td>
</tr>
</table> </td>
</tr>
<tr valign="top">
<td class="dataLabel">
<slot>
{MOD.LBL_FROM} </slot> </td>
<td class="dataField" colspan="4" nowrap="NOWRAP">
<slot>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<textarea id="from_addr_field" name='from_addr' tabindex='3' cols="80" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" value="{FROM_ADDR}">{FROM_ADDR}</textarea> {FROM_ADDR_GROUP}
<input type="hidden" id="from_addr_email" name="from_addr_email" />
<input type="hidden" id="from_addr_name" name="from_addr_name" /> </td>
</tr>
</table>
</slot> </td>
</tr>
<tr>
<td colspan="5">&nbsp; </td>
</tr>
<tr>
<td class="dataLabel">
<slot>
{MOD.LBL_SUBJECT} </slot> </td>
<td colspan='4' class="dataField">
<slot>
<textarea name='name' tabindex='4' cols="100" rows="1" style="height: 1.6.em; overflow-y:auto; font-family:sans-serif,monospace; font-size:inherit;" id="subjectfield">{NAME}</textarea>
</slot> </td>
</tr>
<tr>
<td valign="top" class="dataLabel">
{MOD.LBL_BODY} </td>
<!-- BEGIN: htmlarea -->
<td colspan="2" class="dataField">
<div style="display:none;">
<slot>
<div id="editor_select">
<input id="setEditor" name="setEditor" value="1" {EMAIL_EDITOR_OPTION} type="checkbox" onClick="toggle_textonly();" />
{MOD.LBL_EMAIL_EDITOR_OPTION} </div>
</slot>
</div> </td>
<td class="dataLabel" valign="top">
<slot>
{MOD.LBL_USE_TEMPLATE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select tabindex='2' name='email_template' onChange="fill_email(this.options[this.selectedIndex].value);">
{EMAIL_TEMPLATE_OPTIONS}
</select>
&nbsp;&nbsp;
<input type="button" class="button" name="clear" id="clear" value="Clear" onClick="fill_email('');">
&nbsp;&nbsp;
<input type="button" class="button" name="new_template" id="new_template" value="Template Fields" onClick="document.getElementById('template_fields').style.display='';" />
</slot> </td>
<td class="dataField" nowrap width="1">
<slot> </slot> </td>
</tr>
<tr>
<td></td>
<td colspan="4">
<div id="template_fields" style="display:none">
<table>
<tr>
<td valign="top" class="dataLabel">
Templatate Fields:
</td>
<td colspan="5" class="dataField">
<slot>
{MFP}
<input type="button" class="button" name="cancel_template_fields" id="cancel_template_fields" value="Hide" onClick="document.getElementById('template_fields').style.display='none';">
</slot>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td valign="top" class="dataLabel">&nbsp; </td>
<td colspan="4" class="dataField">
{TINY}
<slot>
<div style="display:none;">
<div id="html_div">
<textarea id="description_html" onBlur="">{DESCRIPTION_HTML}</textarea>
</div>
</div>
<div style="display:none;">
<div id="alt_text_div">
<input id="toggle_textarea_elem" onClick="toggle_textarea();" type="checkbox" name="toggle_html">
{MOD.LBL_EDIT_ALT_TEXT} </div>
</div>
<div id="text_div" style="display: none;"> </div>
<textarea tabindex='5' id="description" name='description' cols="100" rows="20">{DESCRIPTION}</textarea>
</slot> </td>
<!-- END: htmlarea -->
</tr>
</table>
</td>
</tr>
</table>
</form>
{JAVASCRIPT}
<!-- END: main -->

895
modules/EcmEmails/Emails.php Executable file
View File

@@ -0,0 +1,895 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* EditView for Email
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$toTemplate = '';
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='' && isset($_REQUEST['pIdTo']) && $_REQUEST['pIdTo']!='') {
if($_REQUEST['pTypeTo'] == "Accounts") {
require_once('modules/Accounts/Account.php');
$acc = new Account();
$acc->retrieve($_REQUEST['pIdTo']);
if(isset($acc->id) && $acc->id!='') {
$_REQUEST['to_addrs'] = $acc->name.' <'.$acc->email1.'>; ';
}
}
if($_REQUEST['pTypeTo'] == "Contacts") {
require_once('modules/Contacts/Contact.php');
$con = new Contact();
$con->retrieve($_REQUEST['pIdTo']);
if(isset($con->id) && $con->id!='') {
$_REQUEST['to_addrs'] = $con->name.' <'.$con->email1.'>; ';
}
}
}
if(isset($_REQUEST['pTypeTo']) && $_REQUEST['pTypeTo']!='')
if($_REQUEST['pTypeTo'] == "Accounts") $toTemplate = 'InvoiceTemplateAccount';
else
if($_REQUEST['pTypeTo'] == "Contacts") $toTemplate = 'InvoiceTemplateContact';
if(isset($_REQUEST['pTypeFrom']) && $_REQUEST['pTypeFrom']!='' && isset($_REQUEST['pIdFrom']) && $_REQUEST['pIdFrom']!='') {
if($_REQUEST['pTypeFrom'] == "Users") {
require_once('modules/Users/User.php');
$us = new User();
global $current_user;
$us->retrieve($current_user->id);//$_REQUEST['pIdFrom']);
if(isset($us->id) && $us->id!='') {
$_REQUEST['from_addr'] = $us->name.' <'.$us->email1.'>; ';
}
}
}
echo '<script type="text/javascript">var asynchronous_key = "'.$_SESSION['asynchronous_key'].'";</script>';
$GLOBALS['log']->info("Email edit view");
require_once('include/SugarTinyMCE.php');
require_once('modules/Emails/Email.php');
require_once('modules/EmailTemplates/EmailTemplate.php');
require_once('XTemplate/xtpl.php');
global $theme;
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once($theme_path.'layout_utils.php');
global $app_strings;
global $app_list_strings;
global $current_user;
global $sugar_version, $sugar_config;
global $timedate;
$mod_strings = return_module_language($current_language, 'Emails');
$OPT = array();
if(isset($_REQUEST['invoiceout_id']) && $_REQUEST['invoiceout_id']!='') {
$OPT['invoiceout_id'] = $_REQUEST['invoiceout_id'];
} else $OPT['invoiceout_id'] = '';
if(isset($_REQUEST['sended']) && $_REQUEST['sended']!='') {
$OPT['sended'] = $_REQUEST['sended'];
} else $OPT['sended'] = '0';
$json = getJSONobj();
echo '<script language="javascript">
var OPT = '.$json->encode($OPT).';
function invoiceoutAlert(method) {
if(OPT[\'invoiceout_id\']==\'\') {
alert(\'Invoice not saved!\');
return false;
}
if(method == \'save\') {
prepSave(); document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'1\'; document.forms.EditView.type.value=\'out\'; return fill_form(\'out\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
}
if(method == \'save_draft\') {
document.forms.EditView.action.value=\'EmailSave\'; document.forms.EditView.send.value=\'0\'; document.forms.EditView.type.value=\'draft\'; fill_form(\'draft\', \''.$mod_strings['ERR_NOT_ADDRESSED'].'\');
}
};
if(OPT[\'sended\']==\'1\') alert(\'Email was sended\');
</script>';
///////////////////////////////////////////////////////////////////////////////
//// PREPROCESS BEAN DATA FOR DISPLAY
$focus = new Email();
$email_type = 'archived';
if(isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
}
if(!empty($_REQUEST['type'])) {
$email_type = $_REQUEST['type'];
} elseif(!empty($focus->id)) {
$email_type = $focus->type;
}
$focus->type = $email_type;
//needed when creating a new email with default values passed in
if(isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
$focus->contact_name = $_REQUEST['contact_name'];
}
if(!empty($_REQUEST['load_id']) && !empty($beanList[$_REQUEST['load_module']])) {
$class_name = $beanList[$_REQUEST['load_module']];
require_once($beanFiles[$class_name]);
$contact = new $class_name();
if($contact->retrieve($_REQUEST['load_id'])) {
$link_id = $class_name . '_id';
$focus->$link_id = $_REQUEST['load_id'];
$focus->contact_name = (isset($contact->full_name)) ? $contact->full_name : $contact->name;
$focus->to_addrs_names = $focus->contact_name;
$focus->to_addrs_ids = $_REQUEST['load_id'];
//Retrieve the email address.
//If Opportunity or Case then Oppurtinity/Case->Accounts->(email_addr_bean_rel->email_addresses)
//If Contacts, Leads etc.. then Contact->(email_addr_bean_rel->email_addresses)
$sugarEmailAddress = new SugarEmailAddress();
if($class_name == 'Opportunity' || $class_name == 'aCase'){
$account = new Account();
if($contact->account_id != null && $account->retrieve($contact->account_id)){
$sugarEmailAddress->handleLegacyRetrieve($account);
if(isset($account->email1)){
$focus->to_addrs_emails = $account->email1;
$focus->to_addrs = "$focus->contact_name <$account->email1>";
}
}
}
else{
$sugarEmailAddress->handleLegacyRetrieve($contact);
if(isset($contact->email1)){
$focus->to_addrs_emails = $contact->email1;
$focus->to_addrs = "$focus->contact_name <$contact->email1>";
}
}
if(!empty($_REQUEST['parent_type']) && empty($app_list_strings['record_type_display'][$_REQUEST['parent_type']])){
if(!empty($app_list_strings['record_type_display'][$_REQUEST['load_module']])){
$_REQUEST['parent_type'] = $_REQUEST['load_module'];
$_REQUEST['parent_id'] = $focus->contact_id;
$_REQUEST['parent_name'] = $focus->to_addrs_names;
} else {
unset($_REQUEST['parent_type']);
unset($_REQUEST['parent_id']);
unset($_REQUEST['parent_name']);
}
}
}
}
if(isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
$focus->contact_id = $_REQUEST['contact_id'];
}
if(isset($_REQUEST['parent_name'])) {
$focus->parent_name = $_REQUEST['parent_name'];
}
if(isset($_REQUEST['parent_id'])) {
$focus->parent_id = $_REQUEST['parent_id'];
}
if(isset($_REQUEST['parent_type'])) {
$focus->parent_type = $_REQUEST['parent_type'];
}
elseif(is_null($focus->parent_type)) {
$focus->parent_type = $app_list_strings['record_type_default_key'];
}
if(isset($_REQUEST['to_email_addrs'])) {
$focus->to_addrs = $_REQUEST['to_email_addrs'];
}
// needed when clicking through a Contacts detail view:
if(isset($_REQUEST['to_addrs_ids'])) {
$focus->to_addrs_ids = $_REQUEST['to_addrs_ids'];
}
if(isset($_REQUEST['to_addrs_emails'])) {
$focus->to_addrs_emails = $_REQUEST['to_addrs_emails'];
}
if(isset($_REQUEST['to_addrs_names'])) {
$focus->to_addrs_names = $_REQUEST['to_addrs_names'];
}
if(isset($_REQUEST['to_addrs'])) {
$focus->to_addrs = $_REQUEST['to_addrs'];
}// user's email, go through 3 levels of precedence:
if(isset($_REQUEST['from_addr'])) {
$focus->from_addr = $_REQUEST['from_addr'];
}// user's email, go through 3 levels of precedence:
$from = $current_user->getEmailInfo();
//// END PREPROCESSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// XTEMPLATE ASSIGNMENT
if($email_type == 'archived') {
// echo get_module_title('Emails', $mod_strings['LBL_ARCHIVED_MODULE_NAME'].":", true);
$xtpl=new XTemplate('modules/Emails/EditViewArchive.html');
} else {
// echo get_module_title('Emails', $mod_strings['LBL_COMPOSE_MODULE_NAME'].":", true);
$xtpl=new XTemplate('modules/EcmPriceBooks/Emails.html');
}
echo "\n</p>\n";
// CHECK USER'S EMAIL SETTINGS TO ENABLE/DISABLE 'SEND' BUTTON
if(!$focus->check_email_settings() &&($email_type == 'out' || $email_type == 'draft')) {
print "<font color='red'>".$mod_strings['WARNING_SETTINGS_NOT_CONF']." <a href='index.php?module=Users&action=EditView&record=".$current_user->id."&return_module=Emails&type=out&return_action=EditView'>".$mod_strings['LBL_EDIT_MY_SETTINGS']."</a></font>";
$xtpl->assign("DISABLE_SEND", 'DISABLED');
}
// CHECK THAT SERVER HAS A PLACE TO PUT UPLOADED TEMP FILES SO THAT ATTACHMENTS WILL WORK
// cn: Bug 5995
$tmpUploadDir = ini_get('upload_tmp_dir');
if(!empty($tmpUploadDir)) {
if(!is_writable($tmpUploadDir)) {
echo "<font color='red'>{$mod_strings['WARNING_UPLOAD_DIR_NOT_WRITABLE']}</font>";
}
} else {
//echo "<font color='red'>{$mod_strings['WARNING_NO_UPLOAD_DIR']}</font>";
}
///////////////////////////////////////////////////////////////////////////////
//// INBOUND EMAIL HANDLING
if(isset($_REQUEST['email_name'])) {
$name = str_replace('_',' ',$_REQUEST['email_name']);
}
if(isset($_REQUEST['inbound_email_id'])) {
$ieMail = new Email();
$ieMail->retrieve($_REQUEST['inbound_email_id']);
$invoiceoutd = '';
// cn: bug 9725: replies/forwards lose real content
$invoiceoutdHtml = $ieMail->invoiceoutHtmlEmail($ieMail->description_html);
// plain-text
$desc = nl2br(trim($ieMail->description));
$exDesc = explode('<br />', $desc);
foreach($exDesc as $k => $line) {
$invoiceoutd .= '> '.trim($line)."\r";
}
// prefill empties with the other's contents
if(empty($invoiceoutdHtml) && !empty($invoiceoutd)) {
$invoiceoutdHtml = nl2br($invoiceoutd);
}
if(empty($invoiceoutd) && !empty($invoiceoutdHtml)) {
$invoiceoutd = strip_tags(br2nl($invoiceoutdHtml));
}
// forwards have special text
if($_REQUEST['type'] == 'forward') {
$header = $ieMail->getForwardHeader();
// subject is handled in Subject line handling below
} else {
// we have a reply in focus
$header = $ieMail->getReplyHeader();
}
$invoiceoutd = br2nl($header.$invoiceoutd);
$invoiceoutdHtml = $header.$invoiceoutdHtml;
// if not a forward: it's a reply
if($_REQUEST['type'] != 'forward') {
$ieMailName = 'RE: '.$ieMail->name;
} else {
$ieMailName = $ieMail->name;
}
$focus->id = null; // nulling this to prevent overwriting a replied email(we're basically doing a "Duplicate" function)
$focus->to_addrs = $ieMail->from_addr;
$focus->description = $invoiceoutd; // don't know what i was thinking: ''; // this will be filled on save/send
$focus->description_html = $invoiceoutdHtml; // cn: bug 7357 - htmlentities() breaks FCKEditor
$focus->parent_type = $ieMail->parent_type;
$focus->parent_id = $ieMail->parent_id;
$focus->parent_name = $ieMail->parent_name;
$focus->name = $ieMailName;
$xtpl->assign('INBOUND_EMAIL_ID',$_REQUEST['inbound_email_id']);
// un/READ flags
if(!empty($ieMail->status)) {
// "Read" flag for InboundEmail
if($ieMail->status == 'unread') {
// creating a new instance here to avoid data corruption below
$e = new Email();
$e->retrieve($ieMail->id);
$e->status = 'read';
$e->save();
$email_type = $e->status;
}
}
///////////////////////////////////////////////////////////////////////////
//// PRIMARY PARENT LINKING
if(empty($focus->parent_type) && empty($focus->parent_id)) {
$focus->fillPrimaryParentFields();
}
//// END PRIMARY PARENT LINKING
///////////////////////////////////////////////////////////////////////////
// setup for my/mailbox email switcher
$mbox = $ieMail->getMailboxDefaultEmail();
$user = $current_user->getPreferredEmail();
$useGroup = '&nbsp;<input id="use_mbox" name="use_mbox" type="checkbox" CHECKED onClick="switchEmail()" >
<script type="text/javascript">
function switchEmail() {
var mboxName = "'.$mbox['name'].'";
var mboxAddr = "'.$mbox['email'].'";
var userName = "'.$user['name'].'";
var userAddr = "'.$user['email'].'";
if(document.getElementById("use_mbox").checked) {
document.getElementById("from_addr_field").value = mboxName + " <" + mboxAddr + ">";
document.getElementById("from_addr_name").value = mboxName;
document.getElementById("from_addr_email").value = mboxAddr;
} else {
document.getElementById("from_addr_field").value = userName + " <" + userAddr + ">";
document.getElementById("from_addr_name").value = userName;
document.getElementById("from_addr_email").value = userAddr;
}
}
</script>';
$useGroup .= $mod_strings['LBL_USE_MAILBOX_INFO'];
$xtpl->assign('FROM_ADDR_GROUP', $useGroup);
}
//// END INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// SUBJECT FIELD MANIPULATION
$name = '';
if(!empty($_REQUEST['parent_id']) && !empty($_REQUEST['parent_type'])) {
$focus->parent_id = $_REQUEST['parent_id'];
$focus->parent_type = $_REQUEST['parent_type'];
}
if(!empty($focus->parent_id) && !empty($focus->parent_type)) {
if($focus->parent_type == 'Cases') {
require_once('modules/Cases/Case.php');
$myCase = new aCase();
$myCase->retrieve($focus->parent_id);
$myCaseMacro = $myCase->getEmailSubjectMacro();
if(isset($ieMail->name) && !empty($ieMail->name)) { // if replying directly to an InboundEmail
$oldEmailSubj = $ieMail->name;
} elseif(isset($_REQUEST['parent_name']) && !empty($_REQUEST['parent_name'])) {
$oldEmailSubj = $_REQUEST['parent_name'];
} else {
$oldEmailSubj = $focus->name; // replying to an email using old subject
}
if(!preg_match('/^re:/i', $oldEmailSubj)) {
$oldEmailSubj = 'RE: '.$oldEmailSubj;
}
$focus->name = $oldEmailSubj;
if(strpos($focus->name, str_replace('%1',$myCase->case_number,$myCaseMacro))) {
$name = $focus->name;
} else {
$name = $focus->name.' '.str_replace('%1',$myCase->case_number,$myCaseMacro);
}
} else {
$name = $focus->name;
}
} else {
if(empty($focus->name)) {
$name = '';
} else {
$name = $focus->name;
}
}
if($email_type == 'forward') {
$name = 'FW: '.$name;
}
//// END SUBJECT FIELD MANIPULATION
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// GENERAL TEMPLATE ASSIGNMENTS
$xtpl->assign('MOD', return_module_language($current_language, 'Emails'));
$xtpl->assign('APP', $app_strings);
if(!isset($focus->id)) $xtpl->assign('USER_ID', $current_user->id);
if(!isset($focus->id) && isset($_REQUEST['contact_id'])) $xtpl->assign('CONTACT_ID', $_REQUEST['contact_id']);
$xtpl->assign("INVOICEOUT_ID",$_REQUEST['invoiceout_id']);
if(isset($_REQUEST['return_module']) && !empty($_REQUEST['return_module'])) {
$xtpl->assign('RETURN_MODULE', $_REQUEST['return_module']);
} else {
$xtpl->assign('RETURN_MODULE', 'Emails');
}
if(isset($_REQUEST['return_action']) && !empty($_REQUEST['return_action']) && ($_REQUEST['return_action'] != 'SubPanelViewer')) {
$xtpl->assign('RETURN_ACTION', $_REQUEST['return_action']);
} else {
$xtpl->assign('RETURN_ACTION', 'DetailView');
}
if(isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
$xtpl->assign('RETURN_ID', $_REQUEST['return_id']);
}
// handle Create $module then Cancel
if(empty($_REQUEST['return_id']) && !isset($_REQUEST['type'])) {
$xtpl->assign('RETURN_ACTION', 'index');
}
$xtpl->assign('THEME', $theme);
$xtpl->assign('IMAGE_PATH', $image_path);$xtpl->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
if(isset($_REQUEST['bodyclass']) && $_REQUEST['bodyclass'] != '') $xtpl->assign('BODYCLASS',$_REQUEST['bodyclass']);
//require_once('modules/EcmPriceBooks/EcmPriceBook.php');
//$m = new EcmPriceBook();
//$mfp = $m->loadParserArray('email');
$xtpl->assign("MFP",$mfp);
///////////////////////////////////////////////////////////////////////////////
//// QUICKSEARCH CODE
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
$sqs_objects = array('parent_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
);
$json = getJSONobj();
$quicksearch_js = $qsd->getQSScripts();
$sqs_objects_encoded = $json->encode($sqs_objects);
$quicksearch_js .= <<<EOQ
<script type="text/javascript" language="javascript">sqs_objects = $sqs_objects_encoded;
function changeQS() {
//new_module = document.getElementById('parent_type').value;
new_module = document.EditView.parent_type.value;
if(new_module == 'Contacts' || new_module == 'Leads' || typeof(disabledModules[new_module]) != 'undefined') {
sqs_objects['parent_name']['disable'] = true;
document.getElementById('parent_name').readOnly = true;
}
else {
sqs_objects['parent_name']['disable'] = false;
document.getElementById('parent_name').readOnly = false;
}
sqs_objects['parent_name']['module'] = new_module;
}
changeQS();
</script>
EOQ;
$xtpl->assign('JAVASCRIPT', get_set_focus_js().$quicksearch_js);
//// END QUICKSEARCH CODE
///////////////////////////////////////////////////////////////////////////////
// cn: bug 14191 - duping archive emails overwrites the original
if(!isset($_REQUEST['isDuplicate']) || $_REQUEST['isDuplicate'] != 'true') {
$xtpl->assign('ID', $focus->id);
}
if(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
$xtpl->assign('OBJECT_ID', $_REQUEST['parent_id']);
$xtpl->assign('OBJECT_TYPE', $_REQUEST['parent_type']);
}
$xtpl->assign('FROM_ADDR', $focus->from_addr);
$xtpl->assign('FROM_ADDR', $current_user->first_name." ".$current_user->last_name." <". $current_user->getPreference('mail_fromaddress').">");
//// prevent TO: prefill when type is 'forward'
if($email_type != 'forward') {
$xtpl->assign('TO_ADDRS', $focus->to_addrs);
$xtpl->assign('FROM_ADDRS', $focus->from_addrs);
$xtpl->assign('TO_ADDRS_IDS', $focus->to_addrs_ids);
$xtpl->assign('TO_ADDRS_NAMES', $focus->to_addrs_names);
$xtpl->assign('TO_ADDRS_EMAILS', $focus->to_addrs_emails);
$xtpl->assign('CC_ADDRS', $focus->cc_addrs);
$xtpl->assign('CC_ADDRS_IDS', $focus->cc_addrs_ids);
$xtpl->assign('CC_ADDRS_NAMES', $focus->cc_addrs_names);
$xtpl->assign('CC_ADDRS_EMAILS', $focus->cc_addrs_emails);
$xtpl->assign('BCC_ADDRS', $focus->bcc_addrs);
$xtpl->assign('BCC_ADDRS_IDS', $focus->bcc_addrs_ids);
$xtpl->assign('BCC_ADDRS_NAMES', $focus->bcc_addrs_names);
$xtpl->assign('BCC_ADDRS_EMAILS', $focus->bcc_addrs_emails);
}
//$xtpl->assign('FROM_ADDR', $from['name'].' <'.$from['email'].'>');
$xtpl->assign('FROM_ADDR_NAME', $from['name']);
$xtpl->assign('FROM_ADDR_EMAIL', $from['email']);
$xtpl->assign('NAME', from_html($name));
//$xtpl->assign('DESCRIPTION_HTML', from_html($focus->description_html));
$xtpl->assign('DESCRIPTION', $focus->description);
$xtpl->assign('TYPE',$email_type);
// Unimplemented until jscalendar language files are fixed
// $xtpl->assign('CALENDAR_LANG',((empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]));
$xtpl->assign('CALENDAR_LANG', 'en');
$xtpl->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
$xtpl->assign('DATE_START', $focus->date_start);
$xtpl->assign('TIME_FORMAT', '('. $timedate->get_user_time_format().')');
$xtpl->assign('TIME_START', substr($focus->time_start,0,5));
$xtpl->assign('TIME_MERIDIEM', $timedate->AMPMMenu('',$focus->time_start));
$parent_types = $app_list_strings['record_type_display'];
$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
foreach($disabled_parent_types as $disabled_parent_type){
if($disabled_parent_type != $focus->parent_type){
unset($parent_types[$disabled_parent_type]);
}
}
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign('USER_DATEFORMAT', '('. $timedate->get_user_date_format().')');
$xtpl->assign('PARENT_NAME', $focus->parent_name);
$xtpl->assign('PARENT_ID', $focus->parent_id);
if(empty($focus->parent_type)) {
$xtpl->assign('PARENT_RECORD_TYPE', '');
} else {
$xtpl->assign('PARENT_RECORD_TYPE', $focus->parent_type);
}
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
$record = '';
if(!empty($_REQUEST['record'])){
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
//// END GENERAL TEMPLATE ASSIGNMENTS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
///
/// SETUP PARENT POPUP
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'parent_id',
'name' => 'parent_name',
),
);
$encoded_popup_request_data = $json->encode($popup_request_data);
/// Users Popup
$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'assigned_user_id',
'user_name' => 'assigned_user_name',
),
);
$xtpl->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
$xtpl->assign('PRICEBOOK_ID', $_REQUEST['pricebook_id']);
//
///////////////////////////////////////
$change_parent_button = '<input type="button" name="button" tabindex="2" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $app_strings['LBL_SELECT_BUTTON_LABEL'] . '" '
. "onclick='open_popup(document.EditView.parent_type.value,600,400,\"&tree=ProductsProd\",true,false,$encoded_popup_request_data);' />\n";
$xtpl->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
$button_attr = '';
if(!ACLController::checkAccess('Contacts', 'list', true)){
$button_attr = 'disabled="disabled"';
}
$change_to_addrs_button = '<input type="button" name="to_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_TO_ADDRS_BUTTON", $change_to_addrs_button);
$change_cc_addrs_button = '<input type="button" name="cc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_CC_ADDRS_BUTTON", $change_cc_addrs_button);
$change_bcc_addrs_button = '<input type="button" name="bcc_button" tabindex="3" class="button" '
. 'title="' . $app_strings['LBL_SELECT_BUTTON_TITLE'] . '" '
. 'accesskey="' . $app_strings['LBL_SELECT_BUTTON_KEY'] . '" '
. 'value="' . $mod_strings['LBL_EMAIL_SELECTOR'] . '" '
. "onclick='button_change_onclick(this);' $button_attr />\n";
$xtpl->assign("CHANGE_BCC_ADDRS_BUTTON", $change_bcc_addrs_button);
///////////////////////////////////////
//// USER ASSIGNMENT
global $current_user;
if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
$record = '';
if(!empty($_REQUEST['record'])) {
$record = $_REQUEST['record'];
}
$xtpl->assign('ADMIN_EDIT',"<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".get_image($image_path."EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>");
}
if(empty($focus->assigned_user_id) && empty($focus->id))
$focus->assigned_user_id = $current_user->id;
if(empty($focus->assigned_name) && empty($focus->id))
$focus->assigned_user_name = $current_user->user_name;
$xtpl->assign('ASSIGNED_USER_OPTIONS', get_select_options_with_id(get_user_array(TRUE, 'Active', $focus->assigned_user_id), $focus->assigned_user_id));
$xtpl->assign('ASSIGNED_USER_NAME', $focus->assigned_user_name);
$xtpl->assign('ASSIGNED_USER_ID', $focus->assigned_user_id);
$xtpl->assign('DURATION_HOURS', $focus->duration_hours);
$xtpl->assign('TYPE_OPTIONS', get_select_options_with_id($parent_types, $focus->parent_type));
$xtpl->assign("PIDFROM",$_REQUEST['pIdFrom']);
$xtpl->assign("PTYPEFROM",$_REQUEST['pTypeFrom']);
$xtpl->assign("PIDTO",$_REQUEST['pIdTo']);
$xtpl->assign("PTYPETO",$_REQUEST['pTypeTo']);
if(isset($focus->duration_minutes)) {
$xtpl->assign('DURATION_MINUTES_OPTIONS', get_select_options_with_id($focus->minutes_values,$focus->duration_minutes));
}
//// END USER ASSIGNMENT
///////////////////////////////////////
//Add Custom Fields
require_once('modules/DynamicFields/templates/Files/EditView.php');
require_once("modules/Notes/Note.php");
///////////////////////////////////////
//// ATTACHMENTS
$attachments = '';
if(!empty($focus->id) || (!empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward')) {
$attachments = "<input type='hidden' name='removeAttachment' id='removeAttachment' value=''>\n";
$ids = '';
$focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
$note = new Note();
$where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
$notes_list = $note->get_full_list("", $where,true);
if(!isset($notes_list)) {
$notes_list = array();
}
for($i = 0;$i < count($notes_list);$i++) {
$the_note = $notes_list[$i];
if(empty($the_note->filename)) {
continue;
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
if(!empty($ids)) {
$ids .= ",";
}
$ids .= $the_note->id;
$attachments .= "
<div id='noteDiv{$the_note->id}'>
<img onclick='deletePriorAttachment(\"{$the_note->id}\");' src='themes/{$theme}/images/delete_inline.gif' value='{$the_note->id}'>&nbsp;";
$attachments .= '<a href="'.UploadFile::get_url($the_note->filename,$the_note->id).'" target="_blank">'. $the_note->filename .'</a></div>';
}
// cn: bug 8034 - attachments from forwards/replies lost when saving drafts
$attachments .= "<input type='hidden' name='prior_attachments' value='{$ids}'>";
// workaround $mod_strings being overriden by Note object instantiation above.
global $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'Emails');
}
$attJs = '<script type="text/javascript">';
$attJs .= 'var file_path = "'.$sugar_config['site_url'].'/'.$sugar_config['upload_dir'].'";';
$attJs .= 'var lnk_remove = "'.$app_strings['LNK_REMOVE'].'";';
$attJs .= '</script>';
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
//// END ATTACHMENTS
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// DOCUMENTS
$popup_request_data = array(
'call_back_function' => 'document_set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'related_doc_id',
'document_name' => 'related_document_name',
),
);
$json = getJSONobj();
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
//// END DOCUMENTS
///////////////////////////////////////////////////////////////////////////////
$parse_open = true;
if($parse_open) {
$xtpl->parse('main.open_source_1');
}
///////////////////////////////////////////////////////////////////////////////
//// EMAIL TEMPLATES
if(ACLController::checkAccess('EmailTemplates', 'list', true) && ACLController::checkAccess('EmailTemplates', 'view', true)) {
$et = new EmailTemplate();
$etResult = $focus->db->query($et->create_list_query('','',''));
$email_templates_arr[] = '';
$toTemplateId = '';
while($etA = $focus->db->fetchByAssoc($etResult)) {
if($toTemplate == $etA['name']) { $toTemplateId = $etA['id']; }
$email_templates_arr[$etA['id']] = $etA['name'];
}
} else {
$email_templates_arr = array('' => $app_strings['LBL_NONE']);
}
$xtpl->assign('EMAIL_TEMPLATE_OPTIONS', get_select_options_with_id($email_templates_arr, $toTemplateId));
//// END EMAIL TEMPLATES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
//// TEXT EDITOR
// cascade from User to Sys Default
$editor = $focus->getUserEditorPreference();
if($editor != 'plain') {
// this box is checked by Javascript on-load.
$xtpl->assign('EMAIL_EDITOR_OPTION', 'CHECKED');
}
$description_html = from_html($focus->description_html);
$description = $focus->description;
/////////////////////////////////////////////////
// signatures
if($sig = $current_user->getDefaultSignature()) {
if(!$focus->hasSignatureInBody($sig) && $focus->type != 'draft') {
if($current_user->getPreference('signature_prepend')) {
$description_html = '<br />'.from_html($sig['signature_html']).'<br /><br />'.$description_html;
$description = "\n".$sig['signature']."\n\n".$description;
} else {
$description_html .= '<br /><br />'.from_html($sig['signature_html']);
$description = $description."\n\n".$sig['signature'];
}
}
}
$xtpl->assign('DESCRIPTION', $description);
// sigs
/////////////////////////////////////////////////
$tiny = new SugarTinyMCE();
$ed = $tiny->getInstance("description_html");
$xtpl->assign("TINY", $ed);
$xtpl->assign("DESCRIPTION_HTML", $description_html);
if((!isset($_REQUEST['record']) || $_REQUEST['record'] == '') && isset($toTemplateId) && $toTemplateId != "") {
require_once('modules/EmailTemplates/EmailTemplate.php');
$et = new EmailTemplate();
$et->retrieve($toTemplateId);
if(isset($et->id) && $et->id != '') {
$xtpl->assign("NAME",$et->subject);
$xtpl->assign("DESCRIPTION",$et->body);
$xtpl->assign("DESCRIPTION_HTML",$et->body_html);
}
}
$xtpl->parse('main.htmlarea');
//// END TEXT EDITOR
///////////////////////////////////////
///////////////////////////////////////
//// SPECIAL INBOUND LANDING SCREEN ASSIGNS
if(!empty($_REQUEST['inbound_email_id'])) {
if(!empty($_REQUEST['start'])) {
$parts = $focus->getStartPage(base64_decode($_REQUEST['start']));
$xtpl->assign('RETURN_ACTION', $parts['action']);
$xtpl->assign('RETURN_MODULE', $parts['module']);
$xtpl->assign('GROUP', $parts['group']);
}
$xtpl->assign('ASSIGNED_USER_ID', $current_user->id);
$xtpl->assign('MYINBOX', 'this.form.type.value=\'inbound\';');
}
//// END SPECIAL INBOUND LANDING SCREEN ASSIGNS
///////////////////////////////////////
echo '<script>var disabledModules='. $json->encode($disabled_parent_types) . ';</script>';
$jsVars = 'var lbl_send_anyways = "'.$mod_strings['LBL_SEND_ANYWAYS'].'";';
$xtpl->assign('JS_VARS', $jsVars);
$xtpl->parse("main");
$xtpl->out("main");
echo '<script>checkParentType(document.EditView.parent_type.value, document.EditView.change_parent);</script>';
//// END XTEMPLATE ASSIGNMENT
///////////////////////////////////////////////////////////////////////////////
require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('email_EditView');
$javascript->setSugarBean($focus);
$skip_fields = array();
if($email_type == 'out') {
$skip_fields['name'] = 1;
$skip_fields['date_start'] = 1;
}
$javascript->addAllFields('',$skip_fields);
$javascript->addToValidateBinaryDependency('parent_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('parent_type', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $mod_strings['LBL_MEMBER_OF'], 'false', '', 'parent_id');
$javascript->addToValidateBinaryDependency('user_name', 'alpha', $app_strings['ERR_SQS_NO_MATCH_FIELD'] . $app_strings['LBL_ASSIGNED_TO'], 'false', '', 'assigned_user_id');
if($email_type == 'archived') {
$javascript->addFieldIsValidDate('date_start', 'date', $mod_strings['LBL_DATE'], $mod_strings['ERR_DATE_START'], true);
$javascript->addFieldIsValidTime('time_start', 'time', $mod_strings['LBL_TIME'], $mod_strings['ERR_TIME_START'], true);
}
echo $javascript->getScript();

37
modules/EcmEmails/Forms.php Executable file
View File

@@ -0,0 +1,37 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*********************************************************************************/
require_once('include/EditView/SideQuickCreate.php');

52
modules/EcmEmails/Menu.php Executable file
View File

@@ -0,0 +1,52 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
global $mod_strings;
if(ACLController::checkAccess('EcmEmails', 'edit', true))
$module_menu[] =array("index.php?module=EcmEmails&action=EditView&return_module=EcmEmails&return_action=DetailView", $mod_strings['LNK_NEW_ECMEMAIL'],"CreateEcmEmails", 'EcmEmails');
if(ACLController::checkAccess('EcmEmails', 'list', true))
$module_menu[]=array("index.php?module=EcmEmails&action=index&return_module=EcmEmails&return_action=DetailView", $mod_strings['LNK_ECMEMAIL_LIST'],"EcmEmails", 'EcmEmails');
if(ACLController::checkAccess('EcmEmails','list', true)) $module_menu[]=array('#', '<span style="display: none">wp_shortcut_fill_0</span>', '');
?>

616
modules/EcmEmails/Save.php Executable file
View File

@@ -0,0 +1,616 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* *******************************************************************************/
/*********************************************************************************
* Description:
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
* Reserved. Contributor(s): ______________________________________..
*********************************************************************************/
ob_start();
$_REQUEST['description']=$_REQUEST['description_html'];
$temp_desc=$_REQUEST['description'];
//print_r($_REQUEST);
$assigned_ids = array();
if(isset($_REQUEST['assigned_ids']) && is_array($_REQUEST['assigned_ids'])) {
foreach($_REQUEST['assigned_ids'] as $value) $assigned_ids[] = explode(":|:", $value);
}
$data = array();
if(isset($_REQUEST['data']) && $_REQUEST['data'] != '') {
$data = unserialize(base64_decode($_REQUEST['data']));
}
require_once('modules/EcmEmails/EcmEmailsDataFormatter.php');
$eedf = new EcmEmailsDataFormatter($data);
if(isset($_REQUEST['description']) && $_REQUEST['description'] != '') {
$mfp = $eedf->loadMFP();
if($mfp != null) {
$_REQUEST['description'] = $mfp->parseText($_REQUEST['description']);
$_REQUEST['name'] = $mfp->parseText($_REQUEST['name']);
$_POST['description'] = $_REQUEST['description'];
$_POST['name'] = $_REQUEST['name'];
}
}
$user_attachment = array();
if(isset($_REQUEST['user_attachment']) && is_array($_REQUEST['user_attachment'])) {
$user_attachment_tmp = $_REQUEST['user_attachment'];
if(isset($_REQUEST['user_remove_attachment']) && is_array($_REQUEST['user_remove_attachment']))
$user_attachment_tmp = array_diff($user_attachment_tmp, $_REQUEST['user_remove_attachment']);
$user_attachment = $user_attachment_tmp;
}
require_once('modules/Emails/Email.php');
///////////////////////////////////////////////////////////////////////////////
//// EMAIL SEND/SAVE SETUP
$focus = new Email();
if(!isset($prefix)) {
$prefix = '';
}
if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
$_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'], $timedate->get_time_format(true), $_POST[$prefix.'meridiem']);
}
//retrieve the record
if(isset($_POST['record']) && !empty($_POST['record'])) {
$focus->retrieve($_POST['record']);
}
if(isset($_REQUEST['user_id'])) {
$focus->assigned_user_id = $_REQUEST['user_id'];
}
if(!$focus->ACLAccess('Save')){
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
if(!empty($_POST['assigned_user_id']) && ($focus->assigned_user_id != $_POST['assigned_user_id']) && ($_POST['assigned_user_id'] != $current_user->id)) {
$check_notify = TRUE;
}
//populate the fields of this Email
$allfields = array_merge($focus->column_fields, $focus->additional_column_fields);
foreach($allfields as $field) {
if(isset($_POST[$field])) {
$value = $_POST[$field];
$focus->$field = $value;
}
}
if (!isset($_REQUEST['to_addrs'])) {
$_REQUEST['to_addrs'] = "";
}
if (!isset($_REQUEST['to_addrs_ids'])) {
$_REQUEST['to_addrs_ids'] = "";
}
if (!isset($_REQUEST['to_addrs_names'])) {
$_REQUEST['to_addrs_names'] = "";
}
if (!isset($_REQUEST['to_addrs_emails'])) {
$_REQUEST['to_addrs_emails'] = "";
}
//GROUP ACCOUNTS SENDING//
$cacc=$_REQUEST['accounts_count'];
//if($cacc>0){
$i=0;
while($i!=$cacc){
$i++;
//account
$acc_id=$_REQUEST['account_id_'.$i];
if($_REQUEST['account_name_'.$i])$acc[$acc_id]['name']=$_REQUEST['account_name_'.$i];
else continue;
$j=-1;
while($j!=100){
$j++;
if($_REQUEST['account_email_check_'.$i.'_'.$j]){
$acc[$acc_id]['addrs'][]=$_REQUEST['account_email_check_'.$i.'_'.$j];
$em.=$_REQUEST['account_email_check_'.$i.'_'.$j]."; ";
}
}
//cnt
$j=-1;
while($j!=100){
$j++;
$cnt_id=$_REQUEST['contact_id_'.$i.'_'.$j];
if($_REQUEST['contact_name_'.$i.'_'.$j] && $_REQUEST['contact_id_'.$i.'_'.$j]){
$cnt[$cnt_id]['name']=$_REQUEST['contact_name_'.$i.'_'.$j];
$n=1;
while($n!=100){
$n++;
if($_REQUEST['contact_email_check_'.$i.'_'.$j.'_'.$n]){
$cnt[$cnt_id]['addrs'][]=$_REQUEST['contact_email_check_'.$i.'_'.$j.'_'.$n];
$em.=$_REQUEST['contact_email_check_'.$i.'_'.$j.'_'.$n]."; ";
}
}
}
}
//acc
$j=-1;
while($j!=100){
$j++;
$ac_id=$_REQUEST['acc_id_'.$i.'_'.$j];
if($_REQUEST['acc_name_'.$i.'_'.$j] && $_REQUEST['acc_id_'.$i.'_'.$j]){
$ac[$ac_id]['name']=$_REQUEST['acc_name_'.$i.'_'.$j];
$n=1;
while($n!=100){
$n++;
if($_REQUEST['acc_email_check_'.$i.'_'.$j.'_'.$n]){
$ac[$ac_id]['addrs'][]=$_REQUEST['acc_email_check_'.$i.'_'.$j.'_'.$n];
$em.=$_REQUEST['acc_email_check_'.$i.'_'.$j.'_'.$n]."; ";
}
}
}
}
$acc[$acc_id]['contacts']=$cnt;
$acc[$acc_id]['accounts']=$ac;
}
//}
/*print_r($_REQUEST);
print '<br>'.'acc_email_'.$i.'_'.$j.'_'.$n;
print_r($acc);
print $em."<br>";
die();*/
$_REQUEST['to_addrs'].="; ".$em;
$_REQUEST['to_addrs_emails'].="; ".$em;
$_REQUEST['to_addrs_ids'].="; ".$emids;
$_REQUEST['to_addrs_namess'].="; ".$emids;
//////////////////////////
if($_REQUEST['group']){
//foreach($_REQUEST['group'] as $gr){
$w=$GLOBALS['db']->query("select account_id from ecmemailgroups_accounts where ecmemailgroup_id='".$_REQUEST['group']."' and deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query(
"select email_addresses.email_address as addr
from
email_addr_bean_rel
inner join email_addresses
on email_addresses.id=email_addr_bean_rel.email_address_id
where
email_addr_bean_rel.bean_module='Accounts' and
email_addr_bean_rel.bean_id='".$r['account_id']."' and
email_addr_bean_rel.deleted='0' and
email_addresses.deleted='0'"));
if($rr['addr']){
$em.=$rr['addr']."; ";
$emids.=$r['account_id']."; ";
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from accounts where id='".$r['account_id']."'"));
$emnames.=$rrr['name']."; ";
}
}
$w=$GLOBALS['db']->query("select contact_id from ecmemailgroups_contacts where ecmemailgroup_id='".$_REQUEST['group']."' and deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query(
"select email_addresses.email_address as addr
from
email_addr_bean_rel
inner join email_addresses
on email_addresses.id=email_addr_bean_rel.email_address_id
where
email_addr_bean_rel.bean_module='Contacts' and
email_addr_bean_rel.bean_id='".$r['contact_id']."' and
email_addr_bean_rel.deleted='0' and
email_addresses.deleted='0'"));
if($rr['addr']){
$em.=$rr['addr']."; ";
$emids.=$r['contact_id']."; ";
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name,last_name from contacts where id='".$r['contact_id']."'"));
$emnames.=$rrr['first_name']." ".$rrr['last_name']."; ";
}
}
//}
$_REQUEST['to_addrs'].="; ".$em;
$_REQUEST['to_addrs_emails'].="; ".$em;
$_REQUEST['to_addrs_ids'].="; ".$emids;
$_REQUEST['to_addrs_namess'].="; ".$emids;
}
//compare the 3 fields and return list of contact_ids to link:
$focus->to_addrs_arr = $focus->parse_addrs($_REQUEST['to_addrs'], $_REQUEST['to_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['to_addrs_emails']);
// make sure the cc_* and bcc_* fields are at least empty if not set
$fields_to_check = array(
'cc_addrs',
'cc_addrs_ids',
'bcc_addrs',
'bcc_addrs_ids',
'cc_addrs_names',
'cc_addrs_emails',
'bcc_addrs_emails',
);
foreach ($fields_to_check as $field_to_check) {
if (!isset($_REQUEST[$field_to_check])) {
$_REQUEST[$field_to_check] = '';
}
}
$focus->cc_addrs_arr = $focus->parse_addrs($_REQUEST['cc_addrs'], $_REQUEST['cc_addrs_ids'], $_REQUEST['cc_addrs_names'], $_REQUEST['cc_addrs_emails']);
$focus->bcc_addrs_arr = $focus->parse_addrs($_REQUEST['bcc_addrs'], $_REQUEST['bcc_addrs_ids'], $_REQUEST['to_addrs_names'], $_REQUEST['bcc_addrs_emails']);
if(!empty($_REQUEST['type'])) {
$focus->type = $_REQUEST['type'];
} elseif(empty($focus->type)) { // cn: from drafts/quotes
$focus->type = 'archived';
}
///////////////////////////////////////////////////////////////////////////////
//// TEMPLATE PARSING
// cn: bug 7244 - need to pass an empty bean to parse email templates
$object_arr = array();
if(!empty($focus->parent_id)) {
$object_arr[$focus->parent_type] = $focus->parent_id;
}
if(isset($focus->to_addrs_arr[0]['contact_id'])) {
$object_arr['Contacts'] = $focus->to_addrs_arr[0]['contact_id'];
}
if(empty($object_arr)) {
$object_arr = array('Contacts' => '123');
}
// do not parse email templates if the email is being saved as draft....
if($focus->type != 'draft' && count($object_arr) > 0) {
require_once($beanFiles['EmailTemplate']);
$focus->name = EmailTemplate::parse_template($focus->name, $object_arr);
$focus->description = EmailTemplate::parse_template($focus->description, $object_arr);
$focus->description_html = EmailTemplate::parse_template($focus->description_html, $object_arr);
}
//if(!$focus->description)$focus->description=$temp_desc;
//if(!$focus->description_html)$focus->description_html=$temp_desc;
//echo $focus->description_html." ".$focus->description;die();
//// END TEMPLATE PARSING
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// PREP FOR ATTACHMENTS
if(empty($focus->id)){
$focus->id = create_guid();
$focus->new_with_id = true;
}
//print_r($_POST);die();
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// ATTACHMENT HANDLING
$focus->handleAttachments();
/*
var_dump($focus->parent_id);
var_dump($focus->saved_attachments[0]->name);
var_dump($focus->saved_attachments[0]->parent_name);
*/
//var_dump($focus->saved_attachments[0]->file);
//die();
//foreach($user_attachment as $att) {
$user_notes = $eedf->getAttachmentsNotes($user_attachment, $focus->name, $focus->module_dir, $focus->id);
if(is_array($user_notes) && count($user_notes) > 0)
foreach($user_notes as $un)
$focus->saved_attachments[] = $un;
/*
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$att[0];
$n->filename = $att[0];
$n->file_mime_type = 'application/pdf';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$nid = $n->save();
var_dump($att[1]); die();
if(!copy($att[1], $sugar_config['upload_dir'].$nid)) {
//$errors= error_get_last(); echo "COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message'];
}
*/
//$focus->saved_attachments[] = $n;
// }
/*
foreach($user_attachment as $att) {
$user_notes = $eedf->getAttachmentNotes($focus->name, $focus->module_dir, $focus->id);
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$att[0];
$n->filename = $att[0];
$n->file_mime_type = 'application/pdf';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$nid = $n->save();
var_dump($att[1]); die();
if(!copy($att[1], $sugar_config['upload_dir'].$nid)) {
//$errors= error_get_last(); echo "COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message'];
}
$focus->saved_attachments[] = $n;
}
*/
/*
if(isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
require_once('modules/EcmQuotes/EcmQuote.php');
$off = new EcmQuote();
$off->retrieve($_REQUEST['quote_id']);
$off->formatNumber();
if(isset($off->id) && $off->id != '') {
require_once('modules/Notes/Note.php');
$n = new Note();
$n->name = $mod_strings['LBL_EMAIL_ATTACHMENT'].': '.$off->createPdfFileName(false);
$n->filename = $off->createPdfFileName();
$n->file_mime_type = 'application/pdf';
$n->parent_id = $focus->id;
$n->parent_type = $focus->module_dir;
$n->parent_name = $focus->name;
$nid = $n->save();
//var_dump($sugar_config['upload_dir'].'oferta.pdf'); die();
//echo $off->name; die();
//global $sugar_config;
if($nid) $off->getPDF(null,'F',$sugar_config['upload_dir'].$nid);
$focus->saved_attachments[] = $n;
}
$off->setTemplate();
$off->loadParser();
$focus->name = $off->template->mfp->parseText($focus->name);
$focus->description = $off->template->mfp->parseText($focus->description);
$focus->description_html = $off->template->mfp->parseText($focus->description_html);
}
*/
//// END ATTACHMENT HANDLING
///////////////////////////////////////////////////////////////////////////////
$focus->status = 'draft';
//echo '<pre>';print_r($focus);echo '</pre>';
$_REQUEST['send']=1;
if($focus->type == 'archived' ) {
$focus->status= 'archived';
}
elseif(($focus->type == 'out' || $focus->type == 'forward')) {
///////////////////////////////////////////////////////////////////////////
//// REPLY PROCESSING
$old = array('&lt;','&gt;');
$new = array('<','>');
if($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'].' &lt;'.$_REQUEST['from_addr_email'].'&gt;') {
if(false === strpos($_REQUEST['from_addr'], '&lt;')) { // we have an email only?
$focus->from_addr = $_REQUEST['from_addr'];
$focus->from_name = '';
} else { // we have a compound string
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
$focus->from_addr = substr($newFromAddr, (1 + strpos($newFromAddr, '<')), (strpos($newFromAddr, '>') - strpos($newFromAddr, '<')) -1 );
$focus->from_name = substr($newFromAddr, 0, (strpos($newFromAddr, '<') -1));
}
} elseif(!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
$focus->from_addr = $_REQUEST['from_addr_email'];
$focus->from_name = $_REQUEST['from_addr_name'];
} else {
$focus->from_addr = $focus->getSystemDefaultEmail();
//echo $focus->from_addr;
}
//// REPLY PROCESSING
///////////////////////////////////////////////////////////////////////////
$expl=explode("&lt;",$_REQUEST['from_addr']);
$exppp=explode("&gt;",$expl[1]);
$focus->from_addr = trim($exppp[0]);
$focus->from_name = trim($expl[0]);
//echo "addr: (".$focus->from_addr.") name: (".$focus->from_name.") all: ".$_REQUEST['from_addr'];
$focus->reply_to_addr=$focus->from_addr;
if($focus->send()) {
$focus->status = 'sent';
$eerr=$focus->ErrorInfo;
} else {
//echo "err";
$focus->status = 'send_error';
$eerr=$focus->ErrorInfo;echo $focus->ErrorInfo;
}
//echo $eerr;die();
}
// delete the existing relationship of all the email addresses with this email
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
// delete al the relationship of this email with all the beans
$query = "update emails_beans set deleted = 1, bean_id = '', bean_module = '' WHERE email_id = '{$focus->id}'";
$focus->db->query($query);
//relations add//
if(count($acc)>0){
foreach($acc as $key=>$value){
$GLOBALS['db']->query("insert into emails_beans(id,email_id,bean_id,bean_module,date_modified,deleted)
values('".create_guid()."','".$focus->id."','".$key."','Accounts','".date("Y-m-d H:i:s")."','0')");
}
}
if(count($cnt)>0){
foreach($cnt as $key=>$value){
$GLOBALS['db']->query("insert into emails_beans(id,email_id,bean_id,bean_module,date_modified,deleted)
values('".create_guid()."','".$focus->id."','".$key."','Contacts','".date("Y-m-d H:i:s")."','0')");
}
}
if(count($ac)>0){
foreach($ac as $key=>$value){
$GLOBALS['db']->query("insert into emails_beans(id,email_id,bean_id,bean_module,date_modified,deleted)
values('".create_guid()."','".$focus->id."','".$key."','Accounts','".date("Y-m-d H:i:s")."','0')");
}
}
///////////////////////////////
if(isset($_REQUEST['object_type']) && !empty($_REQUEST['object_type']) && isset($_REQUEST['object_id']) && !empty($_REQUEST['object_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
$GLOBALS['log']->debug("CESELY".$_REQUEST['object_type']);
if(!in_array($_REQUEST['object_id'],$exContactIds)){
$rel = strtolower($_REQUEST['object_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['object_id']);
$GLOBALS['log']->debug("CESELY LOADED".$_REQUEST['object_type']);
}
}
//// handle legacy parent_id/parent_type relationship calls
elseif(isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
//run linking code only if the object_id has not been linked as part of the contacts above
if(!isset($exContactIds) || !in_array($_REQUEST['parent_id'],$exContactIds)){
$rel = strtolower($_REQUEST['parent_type']);
$focus->load_relationship($rel);
$focus->$rel->add($_REQUEST['parent_id']);
}
}
//// END RELATIONSHIP LINKING
///////////////////////////////////////////////////////////////////////////////
// If came from email archiving edit view, this would have been set from form input.
if (!isset($focus->date_start))
{
$today = gmdate('Y-m-d H:i:s');
$focus->date_start = $timedate->to_display_date($today);
$focus->time_start = $timedate->to_display_time($today, true);
}
$focus->date_sent = "";
$focus->save(false);
$GLOBALS['db']->query("update emails_text set from_addr='".$_REQUEST['from_addr']."',to_addrs='".$_REQUEST['to_addrs']."' where email_id='".$focus->id."'");
//// END EMAIL SAVE/SEND SETUP
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//// RELATIONSHIP LINKING
if(isset($data)) {
$eedf->saveEmailRelationToAssignedIds($focus->id);
}
$focus->load_relationship('users');
$focus->users->add($current_user->id);
if(!empty($_REQUEST['to_addrs_ids'])) {
$focus->load_relationship('contacts');
$exContactIds = explode(';', $_REQUEST['to_addrs_ids']);
foreach($exContactIds as $contactId) {
$contactId = trim($contactId);
$focus->contacts->add($contactId);
}
}
$out1 = ob_get_contents();
ob_end_clean();
if(isset($_REQUEST['to_pdf']) && ($_REQUEST['to_pdf'] == '1' || $_REQUEST['to_pdf'] == 'true')) {
echo '
<script language="javascript" src="include/ECM/EcmPreviewPDF/EcmPreviewPDF.js"></script>
<script language="javascript">
alert(\'Email Sent'.$eerr.'\');
DisplayOtherIframe(true);
parent.document.getElementById("PreviewPDF_div").style.display="none";
</script>
';
die();
}
//header("Location: index.php?action=EditView&module=EcmEmails".((isset($_REQUEST['to_pdf']) && ($_REQUEST['to_pdf'] == '1' || $_REQUEST['to_pdf'] == 'true'))?'&to_pdf=1':''));
die();
echo "Email Wyslany!";
echo $focus->status;
die();
///////////////////////////////////////////////////////////////////////////////
//// PAGE REDIRECTION
///////////////////////////////////////////////////////////////////////////////
$return_id = $focus->id;
if(empty($_POST['return_module'])) {
$return_module = "EcmEmails";
} else {
$return_module = $_POST['return_module'];
}
if(empty($_POST['return_action'])) {
$return_action = "DetailView";
} else {
$return_action = $_POST['return_action'];
}
$GLOBALS['log']->debug("Saved record with id of ".$return_id);
require_once('include/formbase.php');
if($focus->type == 'draft') {
if($return_module == 'EcmEmails') {
header("Location: index.php?module=$return_module&action=ListViewDrafts");
} else {
handleRedirect($return_id, 'EcmEmails');
}
} elseif($focus->type == 'out') {
if($return_module == 'Home') {
header('Location: index.php?module='.$return_module.'&action=index');
}
if(!empty($_REQUEST['return_id'])) {
$return_id = $_REQUEST['return_id'];
}
header('Location: index.php?action='.$return_action.'&module='.$return_module.'&record='.$return_id.'&assigned_user_id='.$current_user->id.'&type=inbound');
} elseif(isset($_POST['return_id']) && $_POST['return_id'] != "") {
$return_id = $_POST['return_id'];
}
header("Location: index.php?action=$return_action&module=$return_module&record=$return_id");
?>

View File

@@ -0,0 +1,61 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Contains field arrays that are used for caching
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
$fields_array['EcmEmail']=array(
'column_fields'=>array(
"id",
"date_entered",
"date_modified",
"modified_user_id",
"assigned_user_id",
"name",
),
'list_fields'=>array(
'id',
'assigned_user_name',
'assigned_user_id',
'name',
),
'required_fields' => array('name'=>1),
);
?>

View File

@@ -0,0 +1,81 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: Defines the English language pack for the base application.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
$mod_strings = array (
'LBL_TO_ACC' => 'Send to account',
'LBL_TO_GROUP' => 'Send to group',
'LBL_ASSIGNED_TO_ID' => 'Assigned To',
'LBL_VALUE' => 'Value',
'LBL_MODULE_NAME' => 'Email',
'LBL_MODULE_TITLE' => 'Email: Home',
'LBL_MODULE_ID' => 'Email',
'LBL_SEARCH_FORM_TITLE' => 'Email Search',
'LBL_LIST_FORM_TITLE' => 'Email List',
'LBL_NEW_FORM_TITLE' => 'New Email',
'LBL_SUBJECT' => 'Subject:',
'LBL_ECMEMAIL' => 'Email:',
'LBL_ECMEMAIL_SUBJECT' => 'Email Subject:',
'LBL_LIST_SUBJECT' => 'Name',
'LBL_LIST_LAST_MODIFIED' => 'Last Modified',
'LNK_NEW_ECMEMAIL' => 'Create Email',
'LNK_ECMEMAIL_LIST' => 'Email',
'ERR_DELETE_RECORD' => 'You must specify a record number in order to delete the email.',
'LBL_LIST_MY_ECMEMAILS' => 'My Assigned Email',
'LBL_CREATED_BY' => 'Created by:',
'LBL_DATE_CREATED' => 'Create Date:',
'LBL_MODIFIED_BY' => 'Last Modified by:',
'LBL_DATE_LAST_MODIFIED' => 'Modify Date:',
'LBL_DEFAULT_SUBPANEL_TITLE' => 'Email',
'LBL_SYSTEM_ID' => 'System ID',
'LBL_LIST_ASSIGNED_TO_NAME' => 'Assigned User',
'LBL_LIST_VALUE' => 'Value',
'LBL_ASSIGNED_TO_NAME' => 'Assigned to',
'LBL_RELATED_TO' => 'Related To:',
);
?>

View File

@@ -0,0 +1,44 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$searchFields['EcmEmails'] =
array (
'name' => array( 'query_type'=>'default'),
'value' => array( 'query_type'=>'default'),
'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true),
'assigned_user_id'=> array('query_type'=>'default'),
);
?>

View File

@@ -0,0 +1,64 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*********************************************************************************/
require_once('include/utils.php');
function additionalDetailsEcmEmail($fields) {
static $mod_strings;
global $app_strings;
if(empty($mod_strings)) {
global $current_language;
$mod_strings = return_module_language($current_language, 'EcmEmails');
}
$overlib_string = '';
if(!empty($fields['DATE_ENTERED']))
$overlib_string .= '<b>'. $app_strings['LBL_DATE_ENTERED'] . '</b> ' . $fields['DATE_ENTERED'] . '<br>';
if(!empty($fields['NAME']))
$overlib_string .= '<b>'. $mod_strings['LBL_NAME'] . '</b> ' . $fields['NAME'] . '<br>';
return array('fieldToAddTo' => 'NAME',
'string' => $overlib_string,
'editLink' => "index.php?action=EditView&module=EcmEmails&return_module=EcmEmails&record={$fields['ID']}",
'viewLink' => "index.php?action=DetailView&module=EcmEmails&return_module=EcmEmails&record={$fields['ID']}");
}
?>

View File

@@ -0,0 +1,64 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$viewdefs['EcmEmails']['DetailView'] = array(
'templateMeta'=>array(
'form'=>array(
'buttons'=>array(
'EDIT',
'DUPLICATE',
'DELETE',
)
),
'maxColumns'=>'2',
'widths'=>array(
array(
'label'=>'10',
'field' =>'30'
),
array(
'label'=>'10',
'field'=>'30'
)
),
),
'panels'=>array(
array(
'name',
'assigned_user_name',
),
)
);
?>

View File

@@ -0,0 +1,51 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$viewdefs['EcmEmails']['EditView'] = array(
'templateMeta'=>array(
'form' => array('buttons'=>array('SAVE', 'CANCEL')),
'maxColumns'=>'2',
'widths'=>array(
array('label'=>'10','field'=>'30'),
array('label'=>'10','field'=>'30'),
),
),
'panels'=>array(
'default'=>array(
array('name','assigned_user_name'),
),
),
);
?>

View File

@@ -0,0 +1,56 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$listViewDefs['EcmEmails'] = array(
'NAME' => array(
'width' => '32',
'label' => 'LBL_LIST_SUBJECT',
'default' => true,
'link' => true),
'VALUE' => array(
'width' => '10',
'label' => 'LBL_LIST_VALUE',
'default' => true),
'ASSIGNED_USER_NAME' => array(
'width' => '9',
'label' => 'LBL_LIST_ASSIGNED_USER',
'default' => true)
);
?>

View File

@@ -0,0 +1,51 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on Jun 1, 2007
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$metafiles['EcmEmails'] = array(
'detailviewdefs' => 'modules/EcmEmails/metadata/detailviewdefs.php',
'editviewdefs' => 'modules/EcmEmails/metadata/editviewdefs.php',
'listviewdefs' => 'modules/EcmEmails/metadata/listviewdefs.php',
'searchdefs' => 'modules/EcmEmails/metadata/searchdefs.php',
'popupdefs' => 'modules/EcmEmails/metadata/popupdefs.php',
'searchfields' => 'modules/EcmEmails/metadata/SearchFields.php',
);
?>

View File

@@ -0,0 +1,67 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$popupMeta = array('moduleMain' => 'EcmEmail',
'varName' => 'ECMEMAIL',
'orderBy' => 'ecmemails.name',
'whereClauses' =>
array('name' => 'ecmemails.name'),
'listviewdefs' => array(
'NAME' => array(
'width' => '32',
'label' => 'LBL_LIST_SUBJECT',
'default' => true,
'link' => true),
'VALUE' => array(
'width' => '10',
'label' => 'LBL_LIST_VALUE',
'default' => true),
'ASSIGNED_USER_NAME' => array(
'width' => '9',
'label' => 'LBL_LIST_ASSIGNED_USER',
'default' => true)
),
'searchdefs' => array(
'name',
'value',
array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
)
);
?>

View File

@@ -0,0 +1,59 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*
* Created on May 29, 2007
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
$searchdefs['EcmEmails'] = array(
'templateMeta' => array(
'maxColumns' => '3',
'widths' => array('label' => '10', 'field' => '30'),
),
'layout' => array(
'basic_search' => array(
'name',
array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
),
'advanced_search' => array(
'name',
'value',
array('name' => 'assigned_user_id', 'type' => 'enum', 'label' => 'LBL_ASSIGNED_TO', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
),
),
);
?>

View File

@@ -0,0 +1,71 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*********************************************************************************/
$viewdefs['EcmEmails']['SideQuickCreate'] = array(
'templateMeta' => array('form'=>array('buttons'=>array('SAVE'),
'button_location'=>'bottom',
'headerTpl'=>'include/EditView/header.tpl',
'footerTpl'=>'include/EditView/footer.tpl',
),
'maxColumns' => '1',
'panelClass'=>'none',
'labelsOnTop'=>true,
'widths' => array(
array('label' => '10', 'field' => '30'),
),
),
'panels' =>array (
'DEFAULT' =>
array (
array (
array('name'=>'name', 'displayParams'=>array('size'=>20, 'required'=>true)),
),
array(
array('name'=>'value', 'displayParams'=>array('size'=>20)),
),
array (
array('name'=>'assigned_user_name', 'displayParams'=>array('required'=>true, 'size'=>11, 'selectOnly'=>true)),
),
),
)
);
?>

View File

@@ -0,0 +1,65 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$GLOBALS['studioDefs']['EcmEmails'] = array(
'LBL_DETAILVIEW'=>array(
'template'=>'xtpl',
'template_file'=>'modules/EcmEmails/DetailView.html',
'php_file'=>'modules/EcmEmails/DetailView.php',
'type'=>'DetailView',
),
'LBL_EDITVIEW'=>array(
'template'=>'xtpl',
'template_file'=>'modules/EcmEmails/EditView.html',
'php_file'=>'modules/EcmEmails/EditView.php',
'type'=>'EditView',
),
'LBL_LISTVIEW'=>array(
'template'=>'listview',
'meta_file'=>'modules/EcmEmails/listviewdefs.php',
'type'=>'ListView',
),
'LBL_SEARCHFORM'=>array(
'template'=>'xtpl',
'template_file'=>'modules/EcmEmails/SearchForm.html',
'php_file'=>'modules/EcmEmails/ListView.php',
'type'=>'SearchForm',
),
);

View File

@@ -0,0 +1,42 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Layout definition for EcmEmails
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$layout_defs['EcmEmails']['subpanel_setup'] = array(
);
?>

View File

@@ -0,0 +1,97 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* Subpanel Layout definition for EcmEmails
*
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
$subpanel_layout = array(
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateButton'),
array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => 'EcmEmails'),
),
'where' => '',
'list_fields' => array(
'AD' => array (
'widget_class' => 'SubPanelAdditionalDetailsLink',
'vname' => '&nbsp;',
'sortable' => false,
'width' => 0,
),
'ecmemail_number'=>array(
'vname' => 'LBL_LIST_NUMBER',
'width' => '5%',
),
'name'=>array(
'vname' => 'LBL_LIST_SUBJECT',
'widget_class' => 'SubPanelDetailViewLink',
'width' => '50%',
),
'status'=>array(
'vname' => 'LBL_LIST_STATUS',
'width' => '15%',
),
'type'=>array(
'vname' => 'LBL_LIST_TYPE',
'width' => '15%',
),
'priority'=>array(
'vname' => 'LBL_LIST_PRIORITY',
'width' => '11%',
),
'assigned_user_name' => array (
'name' => 'assigned_user_name',
'vname' => 'LBL_LIST_ASSIGNED_TO_NAME',
),
'edit_button'=>array(
'widget_class' => 'SubPanelEditButton',
'module' => 'EcmEmails',
'width' => '4%',
),
'remove_button'=>array(
'widget_class' => 'SubPanelRemoveButton',
'module' => 'EcmEmails',
'width' => '5%',
),
),
);
?>

View File

@@ -0,0 +1,95 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<form name="ecmemailsQuickCreate" id="ecmemailsQuickCreate" method="POST" action="index.php">
<input type="hidden" name="module" value="EcmEmails">
<input type="hidden" name="email_id" value="{$REQUEST.email_id}">
<input type="hidden" name="account_id" value="{$REQUEST.account_id}">
<input type="hidden" name="case_id" value="{$REQUEST.acase_id}">
<input type="hidden" name="contact_id" value="{$REQUEST.contact_id}">
<input type="hidden" name="return_action" value="{$REQUEST.return_action}">
<input type="hidden" name="return_module" value="{$REQUEST.return_module}">
<input type="hidden" name="return_id" value="{$REQUEST.return_id}">
<input type="hidden" name="action" value='Save'>
<input type="hidden" name="duplicate_parent_id" value="{$REQUEST.duplicate_parent_id}">
<input type="hidden" name="to_pdf" value='1'>
<input id='assigned_user_id' name='assigned_user_id' type="hidden" value="{$ASSIGNED_USER_ID}" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" style="padding-bottom: 2px;">
<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" type="submit" name="button" {$saveOnclick|default:"onclick=\"return check_form('EcmEmailsQuickCreate');\""} value=" {$APP.LBL_SAVE_BUTTON_LABEL} " >
<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" type="submit" name="button" {$cancelOnclick|default:"onclick=\"this.form.action.value='$RETURN_ACTION'; this.form.module.value='$RETURN_MODULE'; this.form.record.value='$RETURN_ID'\""} value=" {$APP.LBL_CANCEL_BUTTON_LABEL} ">
<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" type="submit" name="button" onclick="this.form.to_pdf.value='0';this.form.action.value='EditView'; this.form.module.value='EcmEmails';" value=" {$APP.LBL_FULL_FORM_BUTTON_LABEL} "></td>
<td align="right" nowrap><span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span> {$APP.NTC_REQUIRED}</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabForm">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th align="left" class="dataLabel" colspan="4"><h4 class="dataLabel"><slot>{$MOD.LBL_ECMEMAIL_INFORMATION}</slot></h4></th>
</tr>
<tr>
<td valign="top" class="dataLabel" width="15%"><slot>{$MOD.LBL_SUBJECT} <span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span></slot></td>
<td width="35%"><slot><textarea name='name' cols="40" tabindex='1' rows="1">{$NAME}</textarea></slot></td>
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_TYPE}</slot></td>
<td width="35%"><slot><select tabindex='2' name='type'>{$TYPE_OPTIONS}</select></slot></td>
</tr>
<tr>
<td valign="top" class="dataLabel" rowspan="2" width="15%"><slot>{$MOD.LBL_DESCRIPTION}</slot></td>
<td rowspan="2" width="35%"><slot><textarea name='description' tabindex='1' cols="40" rows="4">{$DESCRIPTION}</textarea></slot></td>
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_PRIORITY}</slot></td>
<td class="dataField" nowrap width="35%"><slot><select tabindex='2' name='priority'>{$PRIORITY_OPTIONS}</select></slot></td>
</tr>
<tr>
<td class="dataLabel" width="15%"><slot>{$MOD.LBL_STATUS}</slot></td>
<td width="35%"><slot><select tabindex='2' name='status'>{$STATUS_OPTIONS}</select></slot></td>
</tr>
</table>
</form>
<script>
{$additionalScripts}
</script>

88
modules/EcmEmails/vardefs.php Executable file
View File

@@ -0,0 +1,88 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$dictionary['EcmEmail']=array(
'table'=>'ecmemails',
'audited'=>true,
'comment'=>'EcmEmails',
'duplicate_merge'=>true ,
'unified_search'=>true,
'fields'=>array(
'name'=>array(
'name'=>'name',
'vname'=>'LBL_NAME',
'type'=>'varchar',
'len'=>'255',
),
),
'indices'=>array(
array('name'=>'idx_ecmemail_id_del','type'=>'index','fields'=>array('id','deleted')),
array('name'=>'idx_ecmemail_assigned_del','type'=>'index','fields'=>array( 'deleted', 'assigned_user_id')),
),
'relationships'=>array(
'ecmemails_assigned_user'=>array(
'lhs_module'=>'Users',
'lhs_table'=>'users',
'lhs_key'=>'id',
'rhs_module'=>'EcmEmails',
'rhs_table'=>'ecmemails',
'rhs_key'=>'assigned_user_id',
'relationship_type'=>'one-to-many'
),
'ecmemails_modified_user'=>array(
'lhs_module'=>'Users',
'lhs_table'=>'users',
'lhs_key'=>'id',
'rhs_module'=>'EcmEmails',
'rhs_table'=>'ecmemails',
'rhs_key'=>'modified_user_id',
'relationship_type'=>'one-to-many'
),
'ecmemails_created_by'=>array(
'lhs_module'=>'Users',
'lhs_table'=>'users',
'lhs_key'=>'id',
'rhs_module'=>'EcmEmails',
'rhs_table'=>'ecmemails',
'rhs_key'=>'created_by',
'relationship_type'=>'one-to-many'
)
),
'optimistic_locking'=>true,
);
require_once('include/SugarObjects/VardefManager.php');
VardefManager::createVardef('EcmEmails','EcmEmail', array('default','assignable'));
?>