Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1067791
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 3:29 PM
Size
30 KB
Mime Type
text/x-diff
Expires
Thu, Jul 17, 3:29 PM (48 m, 33 s)
Engine
blob
Format
Raw Data
Handle
690906
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/units/email_events/email_events_event_handler.php
===================================================================
--- trunk/kernel/units/email_events/email_events_event_handler.php (revision 2443)
+++ trunk/kernel/units/email_events/email_events_event_handler.php (revision 2444)
@@ -1,198 +1,198 @@
<?php
class EmailEventsEventsHandler extends InpDBEventHandler
{
-
+
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
if($event->Special == 'module')
{
$object =& $event->getObject();
$object->addFilter('module_filter', '%1$s.Module = \'In-Commerce\'');
}
}
/**
* Sets status Front-End Only to selected email events
*
* @param kEvent $event
*/
function OnFrontOnly(&$event)
{
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$ids = implode(',', $ids);
-
+
$table = $this->Application->getUnitOption($event->Prefix,'TableName');
$sql = 'UPDATE '.$table.' SET Enabled = 2 WHERE EventId IN ('.$ids.')';
- $this->Conn->Query($sql);
+ $this->Conn->Query($sql);
}
-
+
/**
- * Sets selected user to email events selected
+ * Sets selected user to email events selected
*
* @param kEvent $event
- */
+ */
function OnSelectUser(&$event)
{
$user_name = $this->Application->GetVar( $event->getPrefixSpecial(true).'_PopupSelectedUser' );
if( strlen($user_name) > 0 )
{
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$ids = implode(',', $ids);
-
+
$user_id = $this->Conn->GetOne('SELECT PortalUserId FROM '.TABLE_PREFIX.'PortalUser WHERE Login = '.$this->Conn->qstr($user_name) );
-
+
$table = $this->Application->getUnitOption($event->Prefix,'TableName');
$sql = 'UPDATE '.$table.' SET FromUserId = '.$user_id.' WHERE EventId IN ('.$ids.')';
-
- $this->Conn->Query($sql);
+
+ $this->Conn->Query($sql);
}
}
-
+
/**
* Raised when email message shoul be sent
*
* @param kEvent $event
- */
+ */
function OnEmailEvent(&$event){
-
+
$email_event = $event->getEventParam('EmailEventName');
$to_user_id = $event->getEventParam('EmailEventToUserId');
$email_event_type = $event->getEventParam('EmailEventType');
-
+
$this->Application->setUnitOption('emailmessages', 'AutoLoad', false);
$message_object = &$this->Application->recallObject('emailmessages');
-
+
$event_table = $this->Application->getUnitOption('emailevents', 'TableName');
-
+
$event_object = &$event->getObject();
$event_object->Load(array('Event'=>$email_event, 'Type'=>$email_event_type));
$event_id = $event_object->GetDBField('EventId');
$from_user_id = $event_object->GetDBField('FromUserId');
$type = $event_object->GetDBField('Type');
$enabled = $event_object->GetDBField('Enabled');
-
+
$direct_send_params = $event->getEventParam('DirectSendParams');
-
+
if ($enabled == 0) return; // disabled event
if ($enabled == 2 && defined("ADMIN")) return; // event only for front-end
if ($type == 1){
// For type "Admin" recipient is a user from field FromUserId which means From/To user in Email events list
$to_user_id = $from_user_id;
$from_user_id = -1;
}
/*
if (!($to_user_id > 0) && !$direct_send_params){
// if we can not determine recepient we will not send email
return;
}
*/
//Parse Message Template
$message_object->Load(array('EventId' => $event_id, 'LanguageId' => $this->Application->GetVar('m_lang')));
$message_type = $message_object->GetDBField('MessageType');
$message_template = $message_object->GetDBField('Template');
$email_object = &$this->Application->recallObject('kEmailMessage');
- $email_object->Compiled = false;
-
+ $email_object->Clear();
+
$old_autoload = $this->Application->getUnitOption('u', 'AutoLoad');
$this->Application->setUnitOption('u', 'AutoLoad', false);
-
+
$from_user_object = &$this->Application->recallObject('u.-item');
$from_user_object->Load($from_user_id);
// here if we don't have from_user loaded, it takes a default user from config values
$from_user_email = $from_user_object->GetDBField('Email')?$from_user_object->GetDBField('Email'):$this->Application->ConfigValue('Smtp_AdminMailFrom');
$from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
-
+
$to_user_object = &$this->Application->recallObject('u.-item');
$to_user_object->Load($to_user_id);
$to_user_email = $to_user_object->GetDBField('Email');
$to_user_name = trim($to_user_object->GetDBField('FirstName').' '.$to_user_object->GetDBField('LastName'));
$this->Application->setUnitOption('u', 'AutoLoad', $old_autoload);
if($direct_send_params){
$to_user_email = ($direct_send_params['to_email']?$direct_send_params['to_email']:$to_user_email);
$to_user_name = ($direct_send_params['to_name']?$direct_send_params['to_name']:$to_user_name);
$from_user_email = ($direct_send_params['from_email']?$direct_send_params['from_email']:$from_user_email);
$from_user_name = ($direct_send_params['from_name']?$direct_send_params['from_name']:$from_user_name);
$message_body_additional = $direct_send_params['message'];
}
$to_user_email = $to_user_email?$to_user_email:$this->Application->ConfigValue('Smtp_AdminMailFrom');
-
-
+
+
$this->Application->makeClass('Template');
$this->Application->InitParser();
$parser_params = $this->Application->Parser->Params;
$direct_send_params['message_text'] = $message_body_additional;
$this->Application->Parser->Params = array_merge_recursive2($this->Application->Parser->Params, $direct_send_params);
$message_template = str_replace('<inp:touser _Field', '<inp2:u_Field name', $message_template);
$message_template = $this->Application->Parser->Parse($message_template, 'email_template', 0);
$this->Application->Parser->Params = $parser_params;
-
- $message_template = str_replace("\r", "", $message_template);
-
- list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
-
-
+
+ $message_template = str_replace("\r", "", $message_template);
+
+ list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
+
+
$email_object->setFrom($from_user_email, $from_user_name);
$email_object->setTo($to_user_email, $to_user_name);
$email_object->setSubject('Mail message');
-
-
+
+
$email_object->setHeaders($message_headers);
-
+
if ($message_type == 'html'){
$email_object->setHTMLBody($message_body);
}
else {
$email_object->setTextBody($message_body);
}
-
+
$smtp_object = &$this->Application->recallObject('kSmtpClient');
-
+
$smtp_server = $this->Application->ConfigValue('Smtp_Server');
$smtp_port = $this->Application->ConfigValue('Smtp_Port');
-
+
$smtp_authenticate = $this->Application->ConfigValue('Smtp_Authenticate');
if ($smtp_authenticate){
$smtp_user = $this->Application->ConfigValue('Smtp_User');
$smtp_pass = $this->Application->ConfigValue('Smtp_Pass');
}else{
$smtp_user = '';
$smtp_pass = '';
}
-
-
+
+
if ($smtp_server){
if ($email_object->sendSMTP($smtp_object, $smtp_server, $smtp_user, $smtp_pass, $smtp_authenticate)){
$event->status=erSUCCESS;
}
else {
$event->status=erFAIL;
}
}else{
if($email_object->send()){
$event->status=erSUCCESS;
}
else {
$event->status=erFAIL;
- }
+ }
}
-
+
return $event;
- }
+ }
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/email_events/email_events_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property
Index: trunk/admin/editor/cmseditor/fckstyles.xml
===================================================================
--- trunk/admin/editor/cmseditor/fckstyles.xml (revision 2443)
+++ trunk/admin/editor/cmseditor/fckstyles.xml (revision 2444)
@@ -1,42 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
* For further information visit:
* http://www.fckeditor.net/
*
* File Name: fckstyles.xml
* This is the sample style definitions file. It makes the styles combo
* completely customizable.
* See FCKConfig.StylesXmlPath in the configuration file.
*
* Version: 2.0 RC3
* Modified: 2005-02-09 13:51:09
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<Styles>
<Style name="Page Title" element="span">
<Attribute name="class" value="page_title" />
</Style>
<Style name="Subtitle" element="span">
<Attribute name="class" value="subtitle" />
</Style>
<Style name="Caption" element="span">
<Attribute name="class" value="caption" />
</Style>
<Style name="Grey Text" element="span">
<Attribute name="class" value="greytext" />
</Style>
<Style name="Normal Text" element="span">
<Attribute name="class" value="normaltext" />
</Style>
<Style name="Note" element="span">
<Attribute name="class" value="note" />
</Style>
-
</Styles>
\ No newline at end of file
Property changes on: trunk/admin/editor/cmseditor/fckstyles.xml
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/kernel/utility/email.php
===================================================================
--- trunk/core/kernel/utility/email.php (revision 2443)
+++ trunk/core/kernel/utility/email.php (revision 2444)
@@ -1,420 +1,432 @@
<?php
class kEmailMessage extends kBase {
var $Compiled;
var $Headers;
var $HeadersArray;
var $BodyText;
var $BodyHtml;
var $Body;
// var $Subject;
// var $From;
// var $To;
// var $ReplyTo;
// var $CC;
// var $BCC;
var $Charset;
var $LineFeed;
var $TransferEncoding;
var $From;
var $To;
-
-
+
+
var $IsMultipart;
var $Parts;
var $Files;
-
-
+
+
var $TextBoundary;
var $EmailBoundary;
-
+
function kEmailMessage(){
//$this->TextBoundary = uniqid(time());
- $this->EmailBoundary = uniqid(time());
+ $this->EmailBoundary = uniqid(time());
$this->LineFeed = "\n";
$this->Charset='ISO-8859-1';
$this->TransferEncoding='8bit';
- $this->Body = '';
+ $this->Body = '';
$this->setHeader('Subject', 'Automatically generated message');
$this->HeadersArray=array();
-
+
$this->setHeader('Mime-Version', '1.0');
}
-
+
function setHeader($header, $value){
$this->HeadersArray[$header] = $value;
$this->Compiled = false;
}
-
+
function setHeaders($headers){
$headers=str_replace("\r", "", $headers);
$headers_lines = explode("\n", $headers);
foreach ($headers_lines as $line_num => $line){
list($header_field, $header_value) = explode(':', $line, 2);
$header_value = trim($header_value);
$this->setHeader($header_field, $header_value);
}
-
+
}
function appendHeader($header, $value){
$this->HeadersArray[$header][] = $value;
- $this->Compiled = false;
+ $this->Compiled = false;
}
-
-
+
+
function setFrom($from, $name=''){
-
+
$this->From = $from;
-
+
if ($name!=''){
$from = trim($name).' <'.$from.'>';
}
$this->setHeader('From', trim($from));
}
function setTo($to, $name=''){
-
+
$this->To = $to;
-
+
if ($name!=''){
$to = trim($name).' <'.$to.'>';
}
-
+
$this->setHeader('To', trim($to));
}
function setSubject($subj){
$this->setHeader('Subject', $subj);
- }
-
+ }
+
function SetCC($to_cc){
$this->appendHeader('CC', $to_cc);
}
function SetBCC($to_bcc){
$this->appendHeader('BCC', $to_bcc);
- }
-
+ }
+
function setReplyTo($reply_to){
$this->setHeader('Reply-to', $reply_to);
}
-
+
+ function Clear()
+ {
+ $this->Compiled = false;
+ $this->Body = '';
+ $this->BodyHtml = '';
+ $this->BodyText = '';
+ $this->Headers = '';
+ $this->Files = '';
+ $this->From = '';
+ $this->To = '';
+ }
+
function setTextBody($body_text){
-
+
$this->BodyText = $body_text;
$this->Compiled = false;
}
function setHTMLBody($body_html){
-
+
$this->BodyHtml = $body_html;
$this->IsMultipart = true;
$this->Compiled = false;
- }
-
+ }
+
function compileBody(){
$search = array (
"'(<\/td>.*)[\r\n]+(.*<td)'i",//formating text in tables
"'(<br[ ]?[\/]?>)|(<\/p>)|(<\/div>)|(<\/tr>)'i",
"'<head>(.*?)</head>'si",
"'<style(.*?)</style>'si",
"'<title>(.*?)</title>'si",
"'<script(.*?)</script>'si",
// "'^[\s\n\r\t]+'", //strip all spacers & newlines in the begin of document
// "'[\s\n\r\t]+$'", //strip all spacers & newlines in the end of document
- "'&(quot|#34);'i",
+ "'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"
- );
+ );
$replace = array (
"\\1\t\\2",
"\n",
"",
"",
"",
"",
// "",
// "",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)"
- );
+ );
if($this->BodyHtml){
-
+
$not_html = preg_replace ($search, $replace, $this->BodyHtml);
$not_html = strip_tags($not_html);
// $not_html = $this->removeBlankLines($not_html);
// Fixing problem with add exclamation characters "!" into the body of the email.
$not_html = wordwrap($not_html, 72);
$this->BodyHtml = wordwrap($this->BodyHtml, 72);
$this->Body = '';
//$this->Body .= 'Content-Type: multipart/alternative;'.$this->LF()." ".'boundary="----='.$this->TextBoundary.'"'.$this->LF();
//$this->Body .= $this->LF();
$this->Body .= '------='.$this->EmailBoundary.$this->LF();
$this->Body .= 'Content-Type: text/plain;'.$this->LF()." ".'charset="'.$this->Charset.'"'.$this->LF();
$this->Body .= $this->LF();
$this->Body .= $not_html.$this->LF().$this->LF();
$this->Body .= '------='.$this->EmailBoundary.$this->LF();
$this->Body .= 'Content-Type: text/html;'.$this->LF()." ".'charset="'.$this->Charset.'"'.$this->LF();
$this->Body .= 'Content-Transfer-Encoding: '.$this->TransferEncoding.$this->LF();
$this->Body .= 'Content-Description: HTML part'.$this->LF();
$this->Body .= 'Content-Disposition: inline'.$this->LF();
$this->Body .= $this->LF();
-
+
$this->BodyHtml = str_replace("\r", "", $this->BodyHtml);
$this->BodyHtml = str_replace("\n", $this->LF(), $this->BodyHtml);
-
+
$this->Body .= $this->BodyHtml;
$this->Body .= $this->LF().$this->LF();
-
-
+
+
$this->IsMultipart = true;
-
+
}else{
$not_html = preg_replace ($search, $replace, $this->BodyText);
$not_html = strip_tags($not_html);
// $not_html = $this->removeBlankLines($not_html);
// Fixing problem with add exclamation characters "!" into the body of the email.
$not_html = wordwrap($not_html, 72);
-
-
+
+
if ($this->IsMultipart){
$this->Body .= '------='.$this->EmailBoundary.$this->LF();
$this->Body .= 'Content-Type: text/plain;'.$this->LF()." ".'charset="'.$this->Charset.'"'.$this->LF();
$this->Body .= 'Content-Disposition: inline'.$this->LF();
$this->Body .= $this->LF();
- $this->Body .= $not_html.$this->LF().$this->LF();
+ $this->Body .= $not_html.$this->LF().$this->LF();
}else{
//$this->BodyText = str_replace("\r", "", $this->BodyText);
- //$this->BodyText = str_replace("\n", $this->LF(), $this->BodyText);
+ //$this->BodyText = str_replace("\n", $this->LF(), $this->BodyText);
$this->Body = $not_html;
}
-
+
}
-
- }
-
-
+ }
+
+
+
function setCharset($charset){
$this->Charset = $charset;
$this->Compiled = false;
}
function setLineFeed($linefeed){
$this->LineFeed=$linefeed;
}
-
-
+
+
function attachFile($filepath, $mime="application/octet-stream"){
-
+
if(is_file($filepath)){
$file_info = array('path'=>$filepath, 'mime'=>$mime);
- $this->Files[] = $file_info;
+ $this->Files[] = $file_info;
}else{
die('File "'.$filepath.'" not exist...'."\n");
}
-
+
$this->IsMultipart = true;
$this->Compiled = false;
}
-
+
function LF($str=''){
$str = str_replace("\n", "", $str);
$str = str_replace("\r", "", $str);
return $str.$this->LineFeed;
}
-
+
function getContentType(){
$content_type="";
if ($this->IsMultipart){
$content_type .= $this->LF('multipart/alternative;');
$content_type .= $this->LF(" ".'boundary="----='.$this->EmailBoundary.'"');
}else{
$content_type .= $this->LF('text/plain;');
$content_type .= $this->LF(" ".'charset='.$this->Charset);
}
-
+
return $content_type;
-
+
}
-
+
// ========================================
-
+
function compileHeaders(){
$this->Headers="";
-
+
// $this->Headers .= "From: ".$this->LF($this->From);
//if ($this->ReplyTo){
// $this->Headers .= "Reply-To: ".$this->ReplyTo.$this->LF();
//}
//$this->Headers .= "To: ".$this->LF($this->To);
//$this->Headers .= "Subject: ".$this->LF($this->Subject);
/*
if (sizeof($this->CC)){
$this->Headers .= "Cc: ";
foreach ($this->Cc as $key => $addr){
$this->Headers.=$this->LF($addr.',');
}
}
if (sizeof($this->BCC)){
$this->Headers .= "Bcc: ";
foreach ($this->BCC as $key => $addr){
$this->Headers.=$this->LF($addr.',');
}
}
*/
-
+
foreach ($this->HeadersArray as $key => $val){
if ($key=="To" || $key=="") continue; // avoid duplicate "To" field in headers
if (is_array($val)){
$val = chunk_split(implode(', ', $val),72, $this->LF().' ');
-
-
+
+
$this->Headers .= $key.": ".$val.$this->LF();
}else{
$this->Headers .= $key.": ".$val.$this->LF();
}
-
+
}
-
+
$this->Headers .= "Content-Type: ".$this->getContentType();
-
+
//$this->Headers .= "Content-Transfer-Encoding: ".$this->TransferEncoding.$this->LF();
-
-
+
+
}
function compileFiles(){
if ($this->Files){
foreach($this->Files as $key => $file_info)
{
$filepath = $file_info['path'];
$mime = $file_info['mime'];
$attachment_header = $this->LF('------='.$this->EmailBoundary);
$attachment_header .= $this->LF('Content-Type: '.$mime.'; name="'.basename($filepath).'"');
$attachment_header .= $this->LF('Content-Transfer-Encoding: base64');
$attachment_header .= $this->LF('Content-Description: '.basename($filepath));
$attachment_header .= $this->LF('Content-Disposition: attachment; filename="'.basename($filepath).'"');
$attachment_header .= $this->LF('');
-
+
$attachment_data = fread(fopen($filepath,"rb"),filesize($filepath));
$attachment_data = base64_encode($attachment_data);
$attachment_data = chunk_split($attachment_data,72);
-
+
$this->Body .= $attachment_header.$attachment_data.$this->LF('');
$this->IsMultipart = true;
}
- }
+ }
}
-
+
function compile(){
-
+
if ($this->Compiled) return;
-
+
$this->compileBody();
-
+
$this->compileFiles();
-
+
$this->compileHeaders();
-
+
// Compile
if ($this->IsMultipart){
- $this->Body .= '------='.$this->EmailBoundary.'--'.$this->LF();
+ $this->Body .= '------='.$this->EmailBoundary.'--'.$this->LF();
}
-
+
$this->Compiled = true;
}
-
+
// ========================================
-
+
function getHeaders(){
-
+
$this->Compile();
return $this->Headers;
}
-
+
function getBody(){
-
+
$this->Compile();
return $this->Body;
}
function send(){
-
+
return mail($this->HeadersArray['To'], $this->HeadersArray['Subject'], "", $this->getHeaders().$this->LF().$this->LF().$this->getBody());
//return mail($this->HeadersArray['To'], $this->HeadersArray['Subject'], "", $this->getHeaders().$this->LF().$this->LF().$this->getBody(), '-f'.$this->From);
-
+
}
function sendSMTP(&$smtp_object, $smtp_host, $user, $pass, $auth_used = 0){
-
+
$params['host'] = $smtp_host; // The smtp server host/ip
$params['port'] = 25; // The smtp server port
$params['helo'] = $_SERVER['HTTP_HOST']; // What to use when sending the helo command. Typically, your domain/hostname
$params['auth'] = TRUE; // Whether to use basic authentication or not
$params['user'] = $user; // Username for authentication
-
-
+
+
$params['pass'] = $pass; // Password for authentication
- $params['debug'] = 1;
+ $params['debug'] = 1;
if ($auth_used == 0){
$params['authmethod'] = 'NOAUTH'; // forse disabling auth
}
-
+
$send_params['recipients'] = array($this->To); // The recipients (can be multiple)
$send_params['headers'] = array(
'From: '.$this->HeadersArray['From'], // Headers
'To: '.$this->HeadersArray['To'],
'Subject: '.$this->HeadersArray['Subject'],
'Content-type: '.$this->getContentType(),
$this->getBody(),
);
$send_params['from'] = $this->From; // This is used as in the MAIL FROM: cmd
// It should end up as the Return-Path: header
$send_params['body']="\n";
-
-
+
+
if($smtp_object->connect($params) && $smtp_object->send($send_params)){
return true;
}else {
if (defined('DEBUG_MODE')){
global $debugger;
$debugger->appendHTML('<pre>'.$smtp_object->debugtext.'</pre>');
//define('DBG_REDIRECT', 1);
}
return false;
}
}
-
-
+
+
}
?>
Property changes on: trunk/core/kernel/utility/email.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/core/units/email_events/email_events_event_handler.php
===================================================================
--- trunk/core/units/email_events/email_events_event_handler.php (revision 2443)
+++ trunk/core/units/email_events/email_events_event_handler.php (revision 2444)
@@ -1,198 +1,198 @@
<?php
class EmailEventsEventsHandler extends InpDBEventHandler
{
-
+
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
if($event->Special == 'module')
{
$object =& $event->getObject();
$object->addFilter('module_filter', '%1$s.Module = \'In-Commerce\'');
}
}
/**
* Sets status Front-End Only to selected email events
*
* @param kEvent $event
*/
function OnFrontOnly(&$event)
{
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$ids = implode(',', $ids);
-
+
$table = $this->Application->getUnitOption($event->Prefix,'TableName');
$sql = 'UPDATE '.$table.' SET Enabled = 2 WHERE EventId IN ('.$ids.')';
- $this->Conn->Query($sql);
+ $this->Conn->Query($sql);
}
-
+
/**
- * Sets selected user to email events selected
+ * Sets selected user to email events selected
*
* @param kEvent $event
- */
+ */
function OnSelectUser(&$event)
{
$user_name = $this->Application->GetVar( $event->getPrefixSpecial(true).'_PopupSelectedUser' );
if( strlen($user_name) > 0 )
{
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$ids = implode(',', $ids);
-
+
$user_id = $this->Conn->GetOne('SELECT PortalUserId FROM '.TABLE_PREFIX.'PortalUser WHERE Login = '.$this->Conn->qstr($user_name) );
-
+
$table = $this->Application->getUnitOption($event->Prefix,'TableName');
$sql = 'UPDATE '.$table.' SET FromUserId = '.$user_id.' WHERE EventId IN ('.$ids.')';
-
- $this->Conn->Query($sql);
+
+ $this->Conn->Query($sql);
}
}
-
+
/**
* Raised when email message shoul be sent
*
* @param kEvent $event
- */
+ */
function OnEmailEvent(&$event){
-
+
$email_event = $event->getEventParam('EmailEventName');
$to_user_id = $event->getEventParam('EmailEventToUserId');
$email_event_type = $event->getEventParam('EmailEventType');
-
+
$this->Application->setUnitOption('emailmessages', 'AutoLoad', false);
$message_object = &$this->Application->recallObject('emailmessages');
-
+
$event_table = $this->Application->getUnitOption('emailevents', 'TableName');
-
+
$event_object = &$event->getObject();
$event_object->Load(array('Event'=>$email_event, 'Type'=>$email_event_type));
$event_id = $event_object->GetDBField('EventId');
$from_user_id = $event_object->GetDBField('FromUserId');
$type = $event_object->GetDBField('Type');
$enabled = $event_object->GetDBField('Enabled');
-
+
$direct_send_params = $event->getEventParam('DirectSendParams');
-
+
if ($enabled == 0) return; // disabled event
if ($enabled == 2 && defined("ADMIN")) return; // event only for front-end
if ($type == 1){
// For type "Admin" recipient is a user from field FromUserId which means From/To user in Email events list
$to_user_id = $from_user_id;
$from_user_id = -1;
}
/*
if (!($to_user_id > 0) && !$direct_send_params){
// if we can not determine recepient we will not send email
return;
}
*/
//Parse Message Template
$message_object->Load(array('EventId' => $event_id, 'LanguageId' => $this->Application->GetVar('m_lang')));
$message_type = $message_object->GetDBField('MessageType');
$message_template = $message_object->GetDBField('Template');
$email_object = &$this->Application->recallObject('kEmailMessage');
- $email_object->Compiled = false;
-
+ $email_object->Clear();
+
$old_autoload = $this->Application->getUnitOption('u', 'AutoLoad');
$this->Application->setUnitOption('u', 'AutoLoad', false);
-
+
$from_user_object = &$this->Application->recallObject('u.-item');
$from_user_object->Load($from_user_id);
// here if we don't have from_user loaded, it takes a default user from config values
$from_user_email = $from_user_object->GetDBField('Email')?$from_user_object->GetDBField('Email'):$this->Application->ConfigValue('Smtp_AdminMailFrom');
$from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
-
+
$to_user_object = &$this->Application->recallObject('u.-item');
$to_user_object->Load($to_user_id);
$to_user_email = $to_user_object->GetDBField('Email');
$to_user_name = trim($to_user_object->GetDBField('FirstName').' '.$to_user_object->GetDBField('LastName'));
$this->Application->setUnitOption('u', 'AutoLoad', $old_autoload);
if($direct_send_params){
$to_user_email = ($direct_send_params['to_email']?$direct_send_params['to_email']:$to_user_email);
$to_user_name = ($direct_send_params['to_name']?$direct_send_params['to_name']:$to_user_name);
$from_user_email = ($direct_send_params['from_email']?$direct_send_params['from_email']:$from_user_email);
$from_user_name = ($direct_send_params['from_name']?$direct_send_params['from_name']:$from_user_name);
$message_body_additional = $direct_send_params['message'];
}
$to_user_email = $to_user_email?$to_user_email:$this->Application->ConfigValue('Smtp_AdminMailFrom');
-
-
+
+
$this->Application->makeClass('Template');
$this->Application->InitParser();
$parser_params = $this->Application->Parser->Params;
$direct_send_params['message_text'] = $message_body_additional;
$this->Application->Parser->Params = array_merge_recursive2($this->Application->Parser->Params, $direct_send_params);
$message_template = str_replace('<inp:touser _Field', '<inp2:u_Field name', $message_template);
$message_template = $this->Application->Parser->Parse($message_template, 'email_template', 0);
$this->Application->Parser->Params = $parser_params;
-
- $message_template = str_replace("\r", "", $message_template);
-
- list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
-
-
+
+ $message_template = str_replace("\r", "", $message_template);
+
+ list($message_headers, $message_body) = explode("\n\n", $message_template, 2);
+
+
$email_object->setFrom($from_user_email, $from_user_name);
$email_object->setTo($to_user_email, $to_user_name);
$email_object->setSubject('Mail message');
-
-
+
+
$email_object->setHeaders($message_headers);
-
+
if ($message_type == 'html'){
$email_object->setHTMLBody($message_body);
}
else {
$email_object->setTextBody($message_body);
}
-
+
$smtp_object = &$this->Application->recallObject('kSmtpClient');
-
+
$smtp_server = $this->Application->ConfigValue('Smtp_Server');
$smtp_port = $this->Application->ConfigValue('Smtp_Port');
-
+
$smtp_authenticate = $this->Application->ConfigValue('Smtp_Authenticate');
if ($smtp_authenticate){
$smtp_user = $this->Application->ConfigValue('Smtp_User');
$smtp_pass = $this->Application->ConfigValue('Smtp_Pass');
}else{
$smtp_user = '';
$smtp_pass = '';
}
-
-
+
+
if ($smtp_server){
if ($email_object->sendSMTP($smtp_object, $smtp_server, $smtp_user, $smtp_pass, $smtp_authenticate)){
$event->status=erSUCCESS;
}
else {
$event->status=erFAIL;
}
}else{
if($email_object->send()){
$event->status=erSUCCESS;
}
else {
$event->status=erFAIL;
- }
+ }
}
-
+
return $event;
- }
+ }
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/email_events/email_events_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.7
\ No newline at end of property
Event Timeline
Log In to Comment