Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Thu, Jul 17, 1:40 PM

in-portal

Index: trunk/kernel/units/email_events/email_events_event_handler.php
===================================================================
--- trunk/kernel/units/email_events/email_events_event_handler.php (revision 3390)
+++ trunk/kernel/units/email_events/email_events_event_handler.php (revision 3391)
@@ -1,217 +1,222 @@
<?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();
$this->Application->LinkVar('module', 'current_module');
$module = $this->Application->GetVar('module');
$object->addFilter('module_filter', '%1$s.Module = \''.$module.'\'');
}
}
/**
* 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);
}
/**
* 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);
}
}
/**
* Raised when email message shoul be sent
*
* @param kEvent $event
*/
function OnEmailEvent(&$event){
$email_event = $event->getEventParam('EmailEventName');
if( strpos($email_event, '_') !== false )
{
trigger_error('<span class="debug_error">Invalid email event name</span> <b>'.$email_event.'</b>. Use only <b>UPPERCASE characters</b> and <b>dots</b> as email event names', E_USER_ERROR);
}
-
+
$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 && $this->Application->IsAdmin() ) 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->Clear();
$old_autoload = $this->Application->getUnitOption('u', 'AutoLoad');
$this->Application->setUnitOption('u', 'AutoLoad', false);
$from_user_object = &$this->Application->recallObject('u.-email'.$from_user_id);
$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'));
+ if ( $from_user_object->IsLoaded() ) {
+ $from_user_email = $from_user_object->GetDBField('Email');
+ $from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
+ }
+ else {
+ $from_user_email = $this->Application->ConfigValue('Smtp_AdminMailFrom');
+ }
$to_user_object = &$this->Application->recallObject('u.-email'.$to_user_id);
$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);
+ $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);
$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;
}
}
-
+
if ($event->status == erSUCCESS){
if (!$from_user_name) {
$from_user_name = strip_tags( $this->Application->ConfigValue('Site_Name') );
}
- $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
fromuser = '.$this->Conn->qstr($from_user_name.' ('.$from_user_email.')').',
addressto = '.$this->Conn->qstr($to_user_name.' ('.$to_user_email.')').',
subject = '.$this->Conn->qstr($email_object->Subject).',
timestamp = UNIX_TIMESTAMP(),
event = '.$this->Conn->qstr($email_event);
$this->Conn->Query($sql);
}
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.15
\ No newline at end of property
+1.16
\ No newline at end of property
Index: trunk/admin/install/upgrades/readme_1_1_4.txt
===================================================================
--- trunk/admin/install/upgrades/readme_1_1_4.txt (revision 3390)
+++ trunk/admin/install/upgrades/readme_1_1_4.txt (revision 3391)
@@ -1,4 +1,17 @@
-0009270 - Email events were sent to incorrect users
-0007619 - Reset to base toolbar icon added for disabled button state (Stylesheets)
-0009436 - Registration of user is broken (no in release), fixed.
-0007193 - Block styles without base style were not saved during coping from Temp -> Live table
+Readme notes for In-portal Platform 1.1.4
+Intechnic Corporation, December 23, 2005
+
+This release has been solely focused on integrating In-portal with mod_rewrite.
+The integration allows In-portal to generate and parse meaningful,
+friendly URLs with no query string. Please consult the product manual
+section 4.2.12. "URLs Structure & Mod_Rewrite" for more information.
+A number of bug-fixes has also been included in this release.
+
+IMPORTANT:
+Upgrade Notes
+
+After upgrading to this version, please open Administrative Console,
+Structure & Data -> Catalog section and click
+the 'Rebuild Category Cache' button (an icon with a folder and blue arrows between Approve and Cut icons).
+Then go to Configuration -> Themes and click 'Rescan Themes' button (the last one in the toolbar).
+These operations are critical before enabling mod_rewrite functionality.
\ No newline at end of file
Property changes on: trunk/admin/install/upgrades/readme_1_1_4.txt
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ 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 3390)
+++ trunk/core/units/email_events/email_events_event_handler.php (revision 3391)
@@ -1,217 +1,222 @@
<?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();
$this->Application->LinkVar('module', 'current_module');
$module = $this->Application->GetVar('module');
$object->addFilter('module_filter', '%1$s.Module = \''.$module.'\'');
}
}
/**
* 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);
}
/**
* 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);
}
}
/**
* Raised when email message shoul be sent
*
* @param kEvent $event
*/
function OnEmailEvent(&$event){
$email_event = $event->getEventParam('EmailEventName');
if( strpos($email_event, '_') !== false )
{
trigger_error('<span class="debug_error">Invalid email event name</span> <b>'.$email_event.'</b>. Use only <b>UPPERCASE characters</b> and <b>dots</b> as email event names', E_USER_ERROR);
}
-
+
$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 && $this->Application->IsAdmin() ) 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->Clear();
$old_autoload = $this->Application->getUnitOption('u', 'AutoLoad');
$this->Application->setUnitOption('u', 'AutoLoad', false);
$from_user_object = &$this->Application->recallObject('u.-email'.$from_user_id);
$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'));
+ if ( $from_user_object->IsLoaded() ) {
+ $from_user_email = $from_user_object->GetDBField('Email');
+ $from_user_name = trim($from_user_object->GetDBField('FirstName').' '.$from_user_object->GetDBField('LastName'));
+ }
+ else {
+ $from_user_email = $this->Application->ConfigValue('Smtp_AdminMailFrom');
+ }
$to_user_object = &$this->Application->recallObject('u.-email'.$to_user_id);
$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);
+ $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);
$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;
}
}
-
+
if ($event->status == erSUCCESS){
if (!$from_user_name) {
$from_user_name = strip_tags( $this->Application->ConfigValue('Site_Name') );
}
- $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'EmailLog SET
fromuser = '.$this->Conn->qstr($from_user_name.' ('.$from_user_email.')').',
addressto = '.$this->Conn->qstr($to_user_name.' ('.$to_user_email.')').',
subject = '.$this->Conn->qstr($email_object->Subject).',
timestamp = UNIX_TIMESTAMP(),
event = '.$this->Conn->qstr($email_event);
$this->Conn->Query($sql);
}
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.15
\ No newline at end of property
+1.16
\ No newline at end of property

Event Timeline