/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin ec_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all ec_files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the ec_attachments */ function send_webmail($to_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '') { global $adb, $log; global $current_user; $log->debug("Entering send_webmail() method ..."); $key = "webmail_array_" . $current_user->id; $webmail_array = getSqlCacheData($key); if (!$webmail_array) { $webmail_array = $adb->getFirstLine("select * from ec_systems where server_type='email' and smownerid='" . $current_user->id . "'"); if (empty($webmail_array)) { return "No Smtp Server!"; } setSqlCacheData($key, $webmail_array); } $from_email = $webmail_array['from_email']; if ($from_email == '') { $from_email = $webmail_array['server_username']; } require_once 'include/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsSMTP(); // telling the class to use SMTP $result = ""; try { $mail->CharSet = "UTF-8"; $mail->Host = $webmail_array['server']; // SMTP server //$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->Port = $webmail_array['server_port']; // set the SMTP port for the GMAIL server $mail->Username = $webmail_array['server_username']; // SMTP account username $mail->Password = $webmail_array['server_password']; // SMTP account password $mail->AddReplyTo($from_email, ""); $mail->AddAddress($to_email, ""); $mail->SetFrom($from_email, ""); $mail->Subject = $subject; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML($contents); $mail->Send(); } catch (phpmailerException $e) { $result = $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { $result = $e->getMessage(); //Boring error messages from anything else! } $log->debug("Exit send_webmail() method ..."); return $result; }
/** Function to get a action for a given action id * @param $action id -- action id :: Type integer * @returns $actionname-- action name :: Type string */ function getActionname($actionid) { global $log; $log->debug("Entering getActionname() method ..."); global $adb; $curactionname = ''; $key = "actionnamelist"; $actionnamelist = getSqlCacheData($key); if (!$actionnamelist) { global $adb; $sql = "select * from ec_actionmapping where securitycheck=0"; $result = $adb->query($sql); $actionnamelist = array(); $noofrows = $adb->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $name = $adb->query_result($result, $i, "actionname"); $id = $adb->query_result($result, $i, "actionid"); $actionnamelist[$id] = $name; } setSqlCacheData($key, $actionnamelist); } if (isset($actionnamelist[$actionid])) { $curactionname = $actionnamelist[$actionid]; } $log->debug("Exiting getActionname method ..."); return $curactionname; }
function send_webmail($mail, $to_email, $subject, $contents, $smownerid, $callback) { global $adb, $log; global $current_user; $log->debug("Entering send_webmail() method ..."); $key = "webmail_array_" . $smownerid; $webmail_array = getSqlCacheData($key); if (!$webmail_array) { $webmail_array = $adb->getFirstLine("select * from ec_systems where server_type='email' and smownerid='" . $current_user->id . "'"); if (empty($webmail_array)) { return "No Smtp Server!"; } setSqlCacheData($key, $webmail_array); } $from_email = $webmail_array['from_email']; if ($from_email == '') { $from_email = $webmail_array['server_username']; } $options = array('from' => $from_email, 'to' => $to_email, 'cc' => '', 'smtp_host' => $webmail_array['server'], 'smtp_port' => $webmail_array['server_port'], 'smtp_username' => $webmail_array['server_username'], 'smtp_password' => $webmail_array['server_password'], 'subject' => $subject, 'content' => $contents, 'content_type' => "HTML", 'charset' => "utf8", 'tls' => "false", 'compress' => '', 'callback_url' => $callback); $mail->setOpt($options); $ret = $mail->send(); if ($ret === false) { $errMsg = $mail->errmsg() . '<br>'; $log->info("send_webmail ::errormsg:" . $mail->errmsg()); } $mail->clean(); // 重用此对象 $log->debug("Exit send_webmail() method ..."); return $errMsg; }
/** * merged with getDBValidationData and split_validationdataArray functions for performance */ function getSplitDBValidationData($tablearray, $tabid = '') { global $log; $log->debug("Entering getSplitDBValidationData() method ..."); $key = "split_validationdata_" . $tabid; $validationData = getSqlCacheData($key); if (!$validationData) { $fieldName_array = array(); $sql = ''; $tab_con = ""; $numValues = count($tablearray); global $adb, $mod_strings; if ($tabid != '') { $tab_con = ' and tabid=' . $tabid; } for ($i = 0; $i < $numValues; $i++) { if (in_array("emails", $tablearray)) { if ($numValues > 1 && $i != $numValues - 1) { $sql .= "select fieldlabel,fieldname,typeofdata from ec_field where tablename='" . $tablearray[$i] . "'and tabid=10 and displaytype <> 2 union "; } else { $sql .= "select fieldlabel,fieldname,typeofdata from ec_field where tablename='" . $tablearray[$i] . "' and tabid=10 and displaytype <> 2 "; } } else { if ($numValues > 1 && $i != $numValues - 1) { $sql .= "select fieldlabel,fieldname,typeofdata from ec_field where tablename='" . $tablearray[$i] . "'" . $tab_con . " and displaytype=1 union "; } else { $sql .= "select fieldlabel,fieldname,typeofdata from ec_field where tablename='" . $tablearray[$i] . "'" . $tab_con . " and displaytype=1"; } } } $result = $adb->query($sql); $noofrows = $adb->num_rows($result); $fieldName_array = array(); for ($i = 0; $i < $noofrows; $i++) { $fieldlabel = $mod_strings[$adb->query_result($result, $i, 'fieldlabel')]; $fieldname = $adb->query_result($result, $i, 'fieldname'); $typeofdata = $adb->query_result($result, $i, 'typeofdata'); //echo '<br> '.$fieldlabel.'....'.$fieldname.'....'.$typeofdata; $fldLabel_array = array(); $fldLabel_array[$fieldlabel] = $typeofdata; $fieldName_array[$fieldname] = $fldLabel_array; } $validationData = split_validationdataArray($fieldName_array); setSqlCacheData($key, $validationData); } $log->debug("Exiting getSplitDBValidationData method ..."); return $validationData; }
/** This function returns the ec_field details for a given ec_fieldname. * Param $uitype - UI type of the ec_field * Param $fieldname - Form ec_field name * Param $fieldlabel - Form ec_field label name * Param $maxlength - maximum length of the ec_field * Param $col_fields - array contains the ec_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $module_name - module name * Return type is an array */ function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $mandatory = 0, $typeofdata = "") { global $log; $log->debug("Entering getOutputHtml() method ..."); global $adb, $log; global $theme; global $mod_strings; global $app_strings; global $current_user; global $noof_group_rows; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //$fieldlabel = from_html($fieldlabel); $fieldvalue = array(); $final_arr = array(); $value = $col_fields[$fieldname]; $custfld = ''; $ui_type[] = $uitype; $editview_fldname[] = $fieldname; if ($generatedtype == 2) { $mod_strings[$fieldlabel] = $fieldlabel; } if (!isset($mod_strings[$fieldlabel])) { $mod_strings[$fieldlabel] = $fieldlabel; } if ($uitype == 5) { if ($value == '') { if ($mandatory == 1) { $disp_value = getNewDisplayDate(); } } else { $disp_value = getDisplayDate($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $disp_value; } elseif ($uitype == 15 || $uitype == 16 || $uitype == 111) { $editview_label[] = $mod_strings[$fieldlabel]; //changed by dingjianting on 2007-10-3 for cache pickListResult $key = "picklist_array_" . $fieldname; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } setSqlCacheData($key, $picklist_array); } //Mikecrowe fix to correctly default for custom pick lists $options = array(); $found = false; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == '1021' || $uitype == '1022' || $uitype == '1023') { $typearr = explode("::", $typeofdata); $multifieldid = $typearr[1]; $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getMultiFieldEditViewValue($multifieldid, $uitype, $col_fields); $fieldvalue[] = $multifieldid; //print_r($fieldvalue); } elseif ($uitype == 10) { $query = "SELECT ec_entityname.* FROM ec_crmentityrel inner join ec_entityname on ec_entityname.modulename=ec_crmentityrel.relmodule WHERE ec_crmentityrel.module='" . $module_name . "' and ec_entityname.entityidfield='" . $fieldname . "'"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $rel_modulename = $adb->query_result($fldmod_result, 0, 'modulename'); $rel_tablename = $adb->query_result($fldmod_result, 0, 'tablename'); $rel_entityname = $adb->query_result($fldmod_result, 0, 'fieldname'); $rel_entityid = $adb->query_result($fldmod_result, 0, 'entityidfield'); } if ($value != '') { $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } elseif (isset($_REQUEST[$fieldname]) && $_REQUEST[$fieldname] != '') { if ($_REQUEST['module'] == $rel_modulename) { $module_entityname = ''; } else { $value = $_REQUEST[$fieldname]; $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } } if (isset($app_strings[$fieldlabel])) { $editview_label[] = $app_strings[$fieldlabel]; } elseif (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } $fieldvalue[] = $module_entityname; $fieldvalue[] = $value; $fieldvalue[] = $rel_entityname; $fieldvalue[] = $rel_modulename; } elseif ($uitype == 17) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 85) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 86) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 87) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 88) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 89) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 33) { $pick_query = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row['colvalue']; } $editview_label[] = $mod_strings[$fieldlabel]; $mulsel = "select colvalue from ec_picklist where colname='" . $fieldname . "' order by sequence asc"; $multiselect_result = $adb->query($mulsel); $noofoptions = $adb->num_rows($multiselect_result); $options = array(); $found = false; $valur_arr = explode(' |##| ', $value); for ($j = 0; $j < $noofoptions; $j++) { $multiselect_combo = $adb->query_result($multiselect_result, $j, "colvalue"); if (in_array($multiselect_combo, $valur_arr)) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $options[] = array($multiselect_combo => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 19 || $uitype == 20) { if (isset($_REQUEST['body'])) { $value = $_REQUEST['body']; } $editview_label[] = $mod_strings[$fieldlabel]; //$value = to_html($value); //$value = htmlspecialchars($value, ENT_QUOTES, "UTF-8"); $fieldvalue[] = $value; } elseif ($uitype == 21 || $uitype == 24) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 22) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 52) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 77) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '') { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } $combo_lbl_name = 'assigned_user_id'; $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); $fieldvalue[] = $users_combo; } elseif ($uitype == 53) { $editview_label[] = $mod_strings[$fieldlabel]; global $current_user; if ($value != '' && $value != 0) { $assigned_user_id = $value; } else { $assigned_user_id = $current_user->id; } if ($fieldlabel == 'Assigned To') { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } else { $user_array = get_user_array(FALSE, "Active", $assigned_user_id); $users_combo = get_select_options_array($user_array, $assigned_user_id); } $fieldvalue[] = $users_combo; } elseif ($uitype == 1004) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 1008) { if (isset($mod_strings[$fieldlabel])) { $editview_label[] = $mod_strings[$fieldlabel]; } else { $editview_label[] = $fieldlabel; } if (empty($value)) { global $current_user; $value = $current_user->id; } $fieldvalue[] = getUserName($value); } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_name = ""; /*$convertmode = ""; if(isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') $value = $_REQUEST['account_id']; }*/ if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $value = $_REQUEST['account_id']; } if ($value != '') { $account_name = getAccountName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $account_name; $fieldvalue[] = $value; } elseif ($uitype == 54) { $options = array(); if ($value == "") { $key = "currentuser_group_" . $current_user->id; $currentuser_group = getSqlCacheData($key); if (!$currentuser_group) { $query = "select ec_groups.groupname from ec_groups left join ec_users2group on ec_users2group.groupid=ec_groups.groupid where ec_users2group.userid='" . $current_user->id . "' and ec_users2group.groupid!=0"; $result = $adb->query($query); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { $currentuser_group = $adb->query_result($result, 0, "groupname"); } setSqlCacheData($key, $currentuser_group); } $value = $currentuser_group; } $key = "picklist_array_group"; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pick_query = "select * from ec_groups order by groupid"; $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = $row["groupname"]; } setSqlCacheData($key, $picklist_array); } $editview_label[] = $mod_strings[$fieldlabel]; foreach ($picklist_array as $pickListValue) { if ($value == $pickListValue) { $chk_val = "selected"; } else { $chk_val = ''; } $options[] = array($pickListValue => $chk_val); } $fieldvalue[] = $options; } elseif ($uitype == 59) { if ($value != '') { $product_name = getProductName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $product_name; $fieldvalue[] = $value; } elseif ($uitype == 64) { $editview_label[] = $mod_strings[$fieldlabel]; $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']); $fieldvalue[] = $value; } elseif ($uitype == 56) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } elseif ($uitype == 57) { $accountid = $col_fields['account_id']; if (empty($accountid)) { $convertmode = ""; if (isset($_REQUEST['convertmode'])) { $convertmode = $_REQUEST['convertmode']; } if ($convertmode != 'update_quote_val' && $convertmode != 'update_so_val') { if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') { $accountid = $_REQUEST['account_id']; } } } $contact_name = ''; // if(trim($value) != '') // { // $contact_name = getContactName($value); // } // elseif(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') // { // if(isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && $fieldname = 'contact_id') // { // $contact_name = ''; // } // else // { // $value = $_REQUEST['contact_id']; // $contact_name = getContactName($value); // } // // } if (trim($value) == '') { if (isset($_REQUEST['module']) && $_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) { } else { $value = $_REQUEST['contact_id']; } } $contactopts = getContactOptions($accountid, $value); //Checking for contacts duplicate $editview_label[] = $mod_strings[$fieldlabel]; // $fieldvalue[] = $contact_name; $fieldvalue[] = $contactopts; $fieldvalue[] = $value; } elseif ($uitype == 76) { if ($value != '') { $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') { $value = $_REQUEST['potental_id']; $potential_name = getPotentialName($value); } elseif (isset($_REQUEST['potentialid']) && $_REQUEST['potentialid'] != '') { $value = $_REQUEST['potentalid']; $potential_name = getPotentialName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $potential_name; $fieldvalue[] = $value; } elseif ($uitype == 80) { if ($value != '') { $salesorder_name = getSoName($value); } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') { $value = $_REQUEST['salesorder_id']; $salesorder_name = getSoName($value); } $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $salesorder_name; $fieldvalue[] = $value; } elseif ($uitype == 101) { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = getUserName($value); $fieldvalue[] = $value; } else { $editview_label[] = $mod_strings[$fieldlabel]; $fieldvalue[] = $value; } $final_arr[] = $ui_type; $final_arr[] = $editview_label; $final_arr[] = $editview_fldname; $final_arr[] = $fieldvalue; $log->debug("Exiting getOutputHtml method ..."); return $final_arr; }
$modname = $_REQUEST["modname"]; $tabid = getTabid($modname); $key = "check_update_smownerid_" . $current_user->id . "_" . $tabid; $readonly = getSqlCacheData($key); if (!$readonly) { $readonly = 0; $query = "select fieldid from ec_field where tabid = {$tabid} and columnname = 'smownerid' "; $result = $adb->query($query); $numrows = $adb->num_rows($result); if ($numrows && $numrows == 1) { $fieldid = $adb->query_result($result, 0, "fieldid"); } $profileId = getRoleRelatedProfileId($current_user->roleid); if ($profileId > 0) { $query = "select visible,readonly from ec_profile2field where profileid = {$profileId}\n\t\t\t\t\tand tabid = {$tabid} and fieldid = {$fieldid} "; $result = $adb->query($query); $numrows = $adb->num_rows($result); if ($numrows && $numrows == 1) { $readonly = $adb->query_result($result, 0, "readonly"); } } setSqlCacheData($key, $readonly); } if ($readonly == 0) { echo 'No'; die; } else { echo 'Yes'; die; } die;
function insertIntoEntityTable($table_name, $module) { global $log; global $current_user; $log->debug("Entering into function insertIntoEntityTable()"); if (isset($this->column_fields['createdtime']) && $this->column_fields['createdtime'] != "") { $createdtime = getDisplayDate_WithTime($this->column_fields['createdtime']); } else { $createdtime = date('YmdHis'); } if (isset($this->column_fields['modifiedtime']) && $this->column_fields['modifiedtime'] != "") { $modifiedtime = getDisplayDate_WithTime($this->column_fields['modifiedtime']); } else { $modifiedtime = date('YmdHis'); } if (isset($this->column_fields['assigned_user_id']) && $this->column_fields['assigned_user_id'] != '') { $ownerid = $this->column_fields['assigned_user_id']; } else { $ownerid = $current_user->id; } $this->column_fields['assigned_user_id'] = $ownerid; $key = "import_columnnames_" . $module . "_" . $table_name; $importColumns = getSqlCacheData($key); if (!$importColumns) { $importColumns = array(); $tabid = getTabid($module); $sql = "select fieldname,columnname from ec_field where tabid=" . $tabid . " and tablename='" . $table_name . "' and displaytype in (1,3,4)"; $result = $this->db->query($sql); $noofrows = $this->db->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $fieldname = $this->db->query_result($result, $i, "fieldname"); $columname = $this->db->query_result($result, $i, "columnname"); $importColumns[$fieldname] = $columname; } setSqlCacheData($key, $importColumns); } if ($this->mode == 'edit') { $update = ""; $iCount = 0; foreach ($importColumns as $fieldname => $columname) { if (isset($this->column_fields[$fieldname])) { $fldvalue = trim($this->column_fields[$fieldname]); $fldvalue = stripslashes($fldvalue); $fldvalue = $this->db->formatString($table_name, $columname, $fldvalue); if ($fldvalue != "" && $fldvalue != "NULL" && $fldvalue != "''") { if ($iCount == 0) { $update = $columname . "=" . $fldvalue . ""; $iCount = 1; } else { $update .= ', ' . $columname . "=" . $fldvalue . ""; } } } } if (trim($update) != '') { $sql1 = "update " . $table_name . " set modifiedby='" . $current_user->id . "',modifiedtime=" . $this->db->formatDate($date_var) . "," . $update . " where " . $this->tab_name_index[$table_name] . "=" . $this->id; $this->db->query($sql1); } } else { $column = $this->tab_name_index[$table_name]; $value = $this->id; foreach ($importColumns as $fieldname => $columname) { if (isset($this->column_fields[$fieldname])) { $fldvalue = trim($this->column_fields[$fieldname]); $fldvalue = stripslashes($fldvalue); $fldvalue = $this->db->formatString($table_name, $columname, $fldvalue); if ($fldvalue != "" && $fldvalue != "NULL" && $fldvalue != "''") { $column .= ", " . $columname; $value .= ", " . $fldvalue . ""; } } } $sql1 = "insert into " . $table_name . " (" . $column . ",smcreatorid,smownerid,createdtime,modifiedtime) values(" . $value . ",'" . $current_user->id . "','" . $current_user->id . "'," . $this->db->formatDate($createdtime) . "," . $this->db->formatDate($modifiedtime) . ")"; $this->db->query($sql1); } $log->debug("Exiting function insertIntoEntityTable()"); }
/** * 通过模块名取到当前模块的表名、编号名、id名 */ function getModTabName($modname) { global $log; $log->debug("Entering getModTabName({$modname}) method ..."); $key = "getModTabName_{$modname}"; $entityname = getSqlCacheData($key); if (!$entityname) { global $adb; $entityname = array(); $query = "select tabid,tablename,fieldname,entityidfield \n\t\t\t\t\tfrom ec_entityname where modulename = '{$modname}' "; $result = $adb->query($query); $tabid = $adb->query_result($result, 0, "tabid"); $tablename = $adb->query_result($result, 0, "tablename"); $fieldname = $adb->query_result($result, 0, "fieldname"); $entityidfield = $adb->query_result($result, 0, "entityidfield"); $entityname['tabid'] = $tabid; $entityname['tablename'] = $tablename; $entityname['fieldname'] = $fieldname; $entityname['entityidfield'] = $entityidfield; setSqlCacheData($key, $entityname); } $log->debug("Exiting getModTabName method ..."); return $entityname; }
function getMultiFieldEditViewValue($multifieldid, $uitype, $col_fields) { global $adb; if ($uitype == '1021') { $level = 1; } elseif ($uitype == '1022') { $level = 2; } elseif ($uitype == '1023') { $level = 3; } $multifieldinfo = getMultiFieldInfo($multifieldid); $totallevel = $multifieldinfo["totallevel"]; $tablename = $multifieldinfo["tablename"]; if ($level == 1) { $pick_query = "select * from {$tablename} where thelevel=1 order by sortorderid"; $parentid = 0; } elseif ($level == 2) { $parentlabel = $multifieldinfo["fields"][0]["fieldname"]; $parentval = $col_fields[$parentlabel]; $parentid = getActualFieldID($level, $tablename, $parentval); $pick_query = "select * from {$tablename} where thelevel=2 and parentfieldid={$parentid} order by sortorderid"; } elseif ($level == 3) { $toplabel = $multifieldinfo["fields"][0]["fieldname"]; $topval = $col_fields[$toplabel]; $parentlabel = $multifieldinfo["fields"][1]["fieldname"]; $parentval = $col_fields[$parentlabel]; $parentid = getActualFieldID($level, $tablename, $parentval, $topval); $pick_query = "select * from {$tablename} where thelevel=3 and parentfieldid={$parentid} order by sortorderid"; } $key = "MultiFieldPickArray_" . $multifieldid . "_{$level}_{$parentid}"; $picklist_array = getSqlCacheData($key); if (!$picklist_array) { $pickListResult = $adb->getList($pick_query); $picklist_array = array(); foreach ($pickListResult as $row) { $picklist_array[] = array($row['actualfieldid'], $row['actualfieldname']); } setSqlCacheData($key, $picklist_array); } $options = array(); $found = false; $thislabel = $multifieldinfo["fields"][$level - 1]["fieldname"]; $value = $col_fields[$thislabel]; foreach ($picklist_array as &$pickListValue) { if ($value == $pickListValue[1]) { $chk_val = "selected"; $found = true; } else { $chk_val = ''; } $pickListValue[2] = $chk_val; $options[] = $pickListValue; } // print_r($options); return $options; }
function formatString($tablename, $fldname, $str) { $this->println("ADODB formatString table=" . $tablename . " fldname=" . $fldname . " str=" . $str); $this->checkConnection(); $key = "tablemetacolumns_" . $tablename; $metaColumns = getSqlCacheData($key); if (!$metaColumns) { $metaColumns = array(); $adoflds = $this->database->MetaColumns($tablename); if (is_array($adoflds)) { foreach ($adoflds as $fld) { $metaColumns[$fld->name] = $fld->type; } } setSqlCacheData($key, $metaColumns); } if (is_array($metaColumns) && isset($metaColumns[$fldname])) { $fldtype = strtoupper($metaColumns[$fldname]); if (strcmp($fldtype, 'CHAR') == 0 || strcmp($fldtype, 'VARCHAR') == 0 || strcmp($fldtype, 'VARCHAR2') == 0 || strcmp($fldtype, 'LONGTEXT') == 0 || strcmp($fldtype, 'TEXT') == 0) { //$this->println("ADODB return else normal"); if (empty($str) || $str == 'null' || $str == 'NULL') { return $this->quote(''); } else { return $this->database->Quote($str); } } else { if (strcmp($fldtype, 'DATE') == 0 || strcmp($fldtype, 'TIMESTAMP') == 0 || strcmp($fldtype, 'DATETIME') == 0) { return $this->formatDate($str); } else { if ((strcmp($fldtype, 'NUMERIC') == 0 || strcmp($fldtype, 'INT') == 0) && empty($str)) { return '0'; } else { //if(empty ($str)) return ''; //else return "'".$str."'"; return "'" . $str . "'"; } } } } else { return "'" . $str . "'"; } $this->println("format String Illegal field name " . $fldname); return $str; }
/** This function returns the related ec_tab details for a given entity or a module. * Param $module - module name * Param $focus - module object * Return type is an array */ function getRelatedLists($module, $focus) { global $log; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering getRelatedLists() method ..."); $focus_list = array(); $relatedLists = array(); global $adb; $key = "getRelatedLists_" . $module; $result = getSqlCacheData($key); if (!$result) { $cur_tab_id = getTabid($module); $sql1 = "select ec_relatedlists.*,ec_tab.name as related_tabname from ec_relatedlists left join ec_tab on ec_tab.tabid=ec_relatedlists.related_tabid where ec_relatedlists.tabid=" . $cur_tab_id . " and ec_relatedlists.presence=0 order by sequence"; $result = $adb->query($sql1); setSqlCacheData($key, $result); } $num_row = $adb->num_rows($result); for ($i = 0; $i < $num_row; $i++) { $rel_tab_id = $adb->query_result($result, $i, "related_tabid"); $related_tabname = $adb->query_result($result, $i, "related_tabname"); $function_name = $adb->query_result($result, $i, "name"); $label = $adb->query_result($result, $i, "label"); if (method_exists($focus, $function_name)) { if ($function_name != "get_generalmodules" && $function_name != "get_child_list" && $function_name != "get_parent_list") { $focus_list[$label] = $focus->{$function_name}($focus->id); } else { $focus_list[$label] = $focus->{$function_name}($focus->id, $related_tabname); } } } /* $approvehistory=getApproveHistory($focus->id); if($approvehistory!==false){ $focus_list['审批历史']=$approvehistory; } */ $log->debug("Exiting getRelatedLists method ..."); return $focus_list; }
function getProductFieldLabelList($basemodule) { $fieldLabelList = array(); global $log; //$fieldlist = array("productname","productcode","serialno","unit_price","catalogname"); $log->debug("Entering getProductFieldLabelList() method ..."); $key = "inventory_product_fieldlabellist_" . $basemodule; $fieldLabelList = getSqlCacheData($key); if (!$fieldLabelList) { global $adb; global $current_language; $product_mod_strings = return_specified_module_language($current_language, "Products"); $fieldLabelList = array(); $sql = "select ec_productfieldlist.*,ec_field.fieldlabel from ec_productfieldlist inner join ec_field on ec_field.columnname=ec_productfieldlist.fieldname where ec_productfieldlist.module='" . $basemodule . "' and ec_field.tabid=14 order by ec_productfieldlist.id"; $result = $adb->query($sql); $noofrows = $adb->num_rows($result); for ($i = 0; $i < $noofrows; $i++) { $fieldarr = array(); //$fieldname = $adb->query_result($result,$i,"fieldname"); //if($fieldname == "catalogid") $fieldname = "catalogname"; //elseif($fieldname == "vendor_id") $fieldname = "vendorname"; $fieldlabel = $adb->query_result($result, $i, "fieldlabel"); if (isset($product_mod_strings[$fieldlabel])) { $fieldlabel = $product_mod_strings[$fieldlabel]; } $width = $adb->query_result($result, $i, "width"); $fieldarr["LABEL"] = $fieldlabel; $fieldarr["LABEL_WIDTH"] = $width; $fieldLabelList[] = $fieldarr; unset($fieldarr); } setSqlCacheData($key, $fieldLabelList); } $log->debug("Exiting getProductFieldLabelList method ..."); return $fieldLabelList; }
} if ($parentfieldid == '0') { $parentfieldid = '-1'; } if ($thelevel == '1') { $fldname = 'ec_account.bill_country'; } else { if ($thelevel == '2') { $fldname = 'ec_account.bill_state'; } else { if ($thelevel == '3') { $fldname = 'ec_account.bill_city'; } } } $tree = array(); $tree["treeid"] = $actualfieldid; $tree["treename"] = $actualfieldname; $tree["click"] = "search_field={$fldname}&search_text={$actualfieldname}&sortview={$sortview}"; $tree["treeparent"] = $parentfieldid; $treeproj[] = $tree; } } setSqlCacheData($key, $treeproj); } } } require_once "include/Zend/Json.php"; $json = new Zend_Json(); $jsontree = $json->encode($treeproj); echo $jsontree;
/** Function to get the permitted module name Array with presence as 0 * @returns permitted module name Array :: Type Array * */ function getPermittedModuleNames() { global $log; $log->debug("Entering getPermittedModuleNames() method ..."); $permittedModules = array(); $key = "moduletabseqlist"; $tab_seq_array = getSqlCacheData($key); if (!$tab_seq_array) { global $adb; $sql = "select * from ec_tab order by tabid"; $result = $adb->query($sql); $num_rows = $adb->num_rows($result); $tab_seq_array = array(); for ($i = 0; $i < $num_rows; $i++) { $id = $adb->query_result($result, $i, 'tabid'); $presence = $adb->query_result($result, $i, 'presence'); $tab_seq_array[$id] = $presence; } setSqlCacheData($key, $tab_seq_array); } foreach ($tab_seq_array as $tabid => $seq_value) { if ($seq_value == 0) { $permittedModules[] = getTabModuleName($tabid); } } $log->debug("Exiting getPermittedModuleNames method ..."); return $permittedModules; }
function getNewCvColumnListSQL($cvid) { global $adb; $key = "entityname_fieldlist"; $entitylist = getSqlCacheData($key); if (!$entitylist) { $entitylist = array(); $sql = "select * from ec_entityname"; $result = $adb->query($sql); $noofrows = $adb->num_rows($result); if ($noofrows > 0) { for ($i = 0; $i < $noofrows; $i++) { $tablename = $adb->query_result($result, $i, "tablename"); $fieldname = $adb->query_result($result, $i, "fieldname"); $entityidfield = $adb->query_result($result, $i, "entityidfield"); $tabid = $adb->query_result($result, $i, "tabid"); $modulename = $adb->query_result($result, $i, "modulename"); $entitylist[$entityidfield] = array('tablename' => $tablename, 'fieldname' => $fieldname, 'tabid' => $tabid, 'modulename' => $modulename); } setSqlCacheData($key, $entitylist); } } $columnslist = $this->getColumnsListByCvid($cvid); if (isset($columnslist)) { foreach ($columnslist as $columnname => $value) { $tablefield = ""; if ($value != "") { $list = explode(":", $value); //Added For getting status for Activities -Jaguar $sqllist_column = $list[0] . "." . $list[1]; if ($this->Fenzumodule == "Calendar") { if ($list[1] == "status") { $sqllist_column = "case when (ec_activity.status not like '') then ec_activity.status else ec_activity.eventstatus end as activitystatus"; } } //Added for for assigned to sorting if ($list[1] == "smownerid") { $sqllist_column = "ec_users.user_name as assigned_user_id"; $sqllist[] = $sqllist_column; } else { if (strlen($list[1]) > 3) { //$sqllist[] = $sqllist_column; $moduleid = $list[1]; $postfix = substr($moduleid, -3, 3); if ($postfix == "_id") { $moduleid = substr($moduleid, 0, strlen($moduleid) - 3); $moduleid = $moduleid . "id"; if (isset($entitylist[$moduleid])) { $tablename = $entitylist[$moduleid]["tablename"]; $fieldname = $entitylist[$moduleid]["fieldname"]; $sqllist_column = $tablename . "." . $fieldname; } } } $sqllist[] = $sqllist_column . " as " . $list[2]; } //Ends $tablefield[$list[0]] = $list[1]; $fieldlabel = trim(str_replace($this->escapemodule, " ", $list[3])); $this->list_fields[$fieldlabel] = $tablefield; $this->list_fields_name[$fieldlabel] = $list[2]; } } $returnsql = implode(",", $sqllist); } return $returnsql; }
function getAdvSearchfields($module, $column = '') { global $log; $log->debug("Entering getAdvSearchfields(" . $module . ") method ..."); global $current_user; //changed by dingjianting on 2007-10-3 for cache HeaderArray $key = "OPTION_SET_" . $module . "_" . $column; $OPTION_SET = getSqlCacheData($key); if (!$OPTION_SET) { global $adb; global $mod_strings; $tabid = getTabid($module); //changed by dingjianting on 2007-9-5 for search function need not hidden fields $sql = "select * from ec_field inner join ec_def_org_field on ec_def_org_field.fieldid=ec_field.fieldid"; $sql .= " where ec_def_org_field.visible=0 and ec_field.tabid=" . $tabid . " and"; $sql .= " ec_field.displaytype in (1,2)"; $sql .= " order by block,sequence"; $result = $adb->query($sql); $noofrows = $adb->num_rows($result); $block = ''; for ($i = 0; $i < $noofrows; $i++) { $fieldtablename = $adb->query_result($result, $i, "tablename"); $fieldcolname = $adb->query_result($result, $i, "columnname"); $block = $adb->query_result($result, $i, "block"); $fieldtype = $adb->query_result($result, $i, "typeofdata"); $fieldtype = explode("~", $fieldtype); $fieldtypeofdata = $fieldtype[0]; $fieldlabel = $adb->query_result($result, $i, "fieldlabel"); if ($fieldlabel == "Related To") { $fieldlabel = "Related to"; } if ($fieldlabel == "Start Date & Time") { $fieldlabel = "Start Date"; if ($module == 'Calendar' && $block == 19) { $module_columnlist['ec_activity:time_start::Activities_Start Time:I'] = 'Start Time'; } } //changed by dingjianting on 2006-10-11 for advanced search //$fieldlabel = str_replace(" ","_",$fieldlabel); if (isset($mod_strings[$fieldlabel])) { $fieldlabel = $mod_strings[$fieldlabel]; } if ($fieldlabel != 'Related to') { if ($column == $fieldtablename . "." . $fieldcolname) { $OPTION_SET .= "<option value=\\'" . $fieldtablename . "." . $fieldcolname . "\\' selected>" . $fieldlabel . "</option>"; } elseif ($fieldlabel == "Product Code") { $OPTION_SET .= "<option value=\\'" . $fieldtablename . "." . $fieldcolname . "\\'>" . $mod_strings[$fieldlabel] . "</option>"; } else { $OPTION_SET .= "<option value=\\'" . $fieldtablename . "." . $fieldcolname . "\\'>" . $fieldlabel . "</option>"; } } } setSqlCacheData($key, $OPTION_SET); } $log->debug("Exiting getAdvSearchfields method ..."); return $OPTION_SET; }
$id = $date_array['id']; } if ($db_update) { if ($id == '') { $id = $adb->getUniqueID("ec_systems"); $sql = "insert into ec_systems(id,server,server_port,server_username,server_password,server_type,smtp_auth,smownerid,from_email,from_name,`interval`) values(" . $id . ",'" . $server . "','" . $port . "','" . $server_username . "','" . $server_password . "','" . $server_type . "','" . $smtp_auth . "','" . $current_user->id . "','" . $from_email . "','" . $from_name . "','" . $interval . "')"; } else { $sql = "update ec_systems set server = '" . $server . "', server_username = '******', server_password = '******', smtp_auth='" . $smtp_auth . "', server_type = '" . $server_type . "',from_name = '" . $from_name . "',from_email = '" . $from_email . "',server_port='" . $port . "',smownerid='" . $current_user->id . "',`interval`='" . $interval . "' where id = " . $id; } $adb->query($sql); } $options = array('id' => $id, 'server' => $server, 'server_port' => $port, 'server_username' => $server_username, 'server_password' => $server_password, 'server_type' => $server_type, 'smtp_auth' => $smtp_auth, 'smownerid' => $current_user->id, 'from_email' => $from_email, 'from_name' => $from_name); if ($server_type == 'email') { $key = "webmail_array_" . $current_user->id; } setSqlCacheData($key, $options); //Added code to send a test mail to the currently logged in user if ($server_type != 'backup' && $server_type != 'proxy') { include_once "modules/Webmails/mail.php"; global $current_user; $to_email = $server_username; $subject = $mod_strings['Test_mail_configuration']; $description = $mod_strings['Test_mail_Description']; $error_str = ""; if ($to_email != '' && $smtp_auth == 'true') { $mail_status = send_webmail($to_email, $subject, $description); if ($mail_status != "") { $error_str = "mail_error=" . urlencode($mail_status); } } //$action = 'EmailConfig';
function get_userfolder($userid) { $key = "get_userfolder_" . $userid; $userfolder = getSqlCacheData($key); if (!$userfolder) { global $adb, $mailstore_directory; //global $log; $userfolder = ""; $current_username = getUserName($userid); if ($current_username == "") { return $mailstore_directory; } require_once "include/utils/ChineseSpellUtils.php"; $spell = new ChineseSpell(); $length = str_len($current_username); $current_username = iconv_ec("UTF-8", "GBK", $current_username); $current_username = $spell->getFullSpell($current_username, ""); $current_username = strtolower($current_username); $userfolder = $mailstore_directory . $current_username . "/"; setSqlCacheData($key, $userfolder); } return $userfolder; }
function getSearchListViewEntries($focus, $module, $list_result, $navigation_array, $oCv = '') { global $log; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering getSearchListViewEntries() method ..."); global $adb, $current_user; $noofrows = $adb->num_rows($list_result); $list_header = ''; $list_block = array(); //getting the ec_fieldtable entries from database $tabid = getTabid($module); if ($oCv != "" && $oCv) { if (isset($oCv->list_fields)) { $focus->search_fields = $oCv->list_fields; $focus->search_fields_name = $oCv->list_fields_name; } } $key_ui = "getlistview_fieldsui_" . $tabid; $fieldlist = getSqlCacheData($key_ui); if (!$fieldlist) { $fieldlist = array(); $query = "SELECT DISTINCT ec_field.fieldname,ec_field.columnname,ec_field.uitype FROM ec_field\n\t\t\t LEFT JOIN ec_def_org_field ON ec_def_org_field.fieldid = ec_field.fieldid\n\t\t\t WHERE ec_field.tabid = " . $tabid . " AND (ec_def_org_field.visible = 0 or ec_field.displaytype=3) "; $result = $adb->query($query); $rownum = $adb->num_rows($result); $field = array(); for ($k = 0; $k < $rownum; $k++) { $columnname = $adb->query_result($result, $k, "columnname"); $uitype = $adb->query_result($result, $k, "uitype"); $fieldlist[$columnname] = $uitype; } setSqlCacheData($key_ui, $fieldlist); } if ($navigation_array['end_val'] > 0) { for ($i = 1; $i <= $noofrows; $i++) { $entity_id = $adb->query_result($list_result, $i - 1, "crmid"); $list_header = array(); foreach ($focus->search_fields as $name => $tableinfo) { $fieldname = $focus->search_fields_name[$name]; $tableinfo = array_values($tableinfo); $columnname = $tableinfo[0]; $value = ""; if ($columnname != '') { $list_result_count = $i - 1; $uitype = $fieldlist[$columnname]; $value = getValue($uitype, $list_result, $columnname, $focus, $module, $entity_id, $list_result_count, "search", $focus->popup_type); } $list_header[] = $value; } $list_block[$entity_id] = $list_header; } } $log->debug("Exiting getSearchListViewEntries method ..."); return $list_block; }
/** * merged with getDBValidationData and split_validationdataArray functions for performance */ function getQuickValidationData($tabid, $display_type_check) { global $log; $log->debug("Entering getQuickValidationData() method ..."); $key = "quickedit_validationdata_" . $tabid; $validationData = getSqlCacheData($key); if (!$validationData) { $sql = ''; global $adb, $mod_strings, $current_user; //retreive the ec_profileList from database require 'user_privileges/user_privileges_' . $current_user->id . '.php'; $sql = "SELECT ec_field.* FROM ec_field INNER JOIN ec_def_org_field ON ec_def_org_field.fieldid=ec_field.fieldid AND ec_def_org_field.visible=0 WHERE ec_field.tabid=" . $tabid . " AND ec_field.block IN " . $blockid_list . " AND " . $display_type_check . " ORDER BY block,sequence"; $result = $adb->query($sql); $noofrows = $adb->num_rows($result); $fieldName_array = array(); for ($i = 0; $i < $noofrows; $i++) { $fieldlabel = $mod_strings[$adb->query_result($result, $i, 'fieldlabel')]; $fieldname = $adb->query_result($result, $i, 'fieldname'); $typeofdata = $adb->query_result($result, $i, 'typeofdata'); $fldLabel_array = array(); $fldLabel_array[$fieldlabel] = $typeofdata; $fieldName_array[$fieldname] = $fldLabel_array; } $validationData = split_validationdataArray($fieldName_array); setSqlCacheData($key, $validationData); } $log->debug("Exiting getQuickValidationData method ..."); return $validationData; }
/** * Function to get related custom module records * @param integer $id - current tab record id * returns related custom module records in array format */ function get_generalmodules($id, $related_tabname) { global $log, $singlepane_view, $currentModule; $log->debug("Entering get_generalmodules() method ..."); require_once "modules/{$related_tabname}/{$related_tabname}.php"; $focus = new $related_tabname(); $button = ''; if ($singlepane_view == 'true') { $returnset = '&return_module=' . $currentModule . '&return_action=DetailView&return_id=' . $id; } else { $returnset = '&return_module=' . $currentModule . '&return_action=CallRelatedList&return_id=' . $id; } $key = "generalmodules_" . $currentModule . "_query_" . $related_tabname; $query = getSqlCacheData($key); $related_bean = substr($related_tabname, 0, -1); $related_bean = strtolower($related_bean); $lowerCurrentModule = strtolower($currentModule); if (!$query) { $query = "SELECT ec_" . $related_bean . "s.*,\n\t\t\t\tec_" . $related_bean . "s." . $related_bean . "sid as crmid,ec_users.user_name\n\t\t\t\tFROM ec_" . $related_bean . "s\n\t\t\t\tINNER JOIN ec_" . $lowerCurrentModule . "\n\t\t\t\t\tON ec_" . $lowerCurrentModule . "." . $lowerCurrentModule . "id = ec_" . $related_bean . "s." . $lowerCurrentModule . "id\n\t\t\t\tLEFT JOIN ec_users\n\t\t\t\t\tON ec_" . $related_bean . "s.smownerid = ec_users.id\n\t\t\t\tWHERE ec_" . $related_bean . "s.deleted = 0"; setSqlCacheData($key, $query); } $query .= " and ec_" . $related_bean . "s." . $lowerCurrentModule . "id = " . $id . " "; $log->debug("Exiting get_generalmodules method ..."); return GetRelatedList($currentModule, $related_tabname, $focus, $query, $button, $returnset); }
$query = "select * from ec_account where accountid in ({$idstring_str}) and deleted=0 and email !='' "; $rows = $adb->getList($query); $account_str = ''; foreach ($rows as $row) { $membername = $row['membername']; $email = $row['email']; $account_str .= $email . '(' . $membername . '),'; } $smarty->assign("receiveaccountinfo", $account_str); $adb->query("delete from ec_maillists where deleted=1"); //生成事件id $sjid = $adb->getUniqueID("ec_crmentity"); $sql = "insert into ec_maillists(maillistsid,deleted) values(" . $sjid . ",1)"; $adb->query($sql); $smarty->assign("sjid", $sjid); $adb->query("insert into ec_crmentity (crmid,setype,smcreatorid,smownerid,createdtime,modifiedtime) values('" . $sjid . "','Maillists'," . $current_user->id . "," . $current_user->id . ",'" . $nowdatetime . "','" . $nowdatetime . "')"); $key = "webmail_array_" . $current_user->id; $webmail_array = getSqlCacheData($key); if (!$webmail_array) { $webmail_array = $adb->getFirstLine("select * from ec_systems where server_type='email' and smownerid='" . $current_user->id . "'"); if (empty($webmail_array)) { echo "No Smtp Server!"; die; } setSqlCacheData($key, $webmail_array); } $from_email = $webmail_array['from_email']; $from_name = $webmail_array['from_name']; $smarty->assign("from_email", $from_email); $smarty->assign("from_name", $from_name); $smarty->display('QunfaMailForm.tpl');