Index: admin_templates/img/icons/icon24_system_event_subscriptions.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: admin_templates\img\icons\icon24_system_event_subscriptions.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: admin_templates/system_event_subscriptions/system_event_subscription_edit.tpl
===================================================================
--- admin_templates/system_event_subscriptions/system_event_subscription_edit.tpl (revision 15268)
+++ admin_templates/system_event_subscriptions/system_event_subscription_edit.tpl (working copy)
@@ -66,6 +66,7 @@
+
Index: install/english.lang
===================================================================
--- install/english.lang (revision 15268)
+++ install/english.lang (working copy)
@@ -467,6 +467,7 @@
SW1wb3J0IEZpbGU=
SW1wb3J0IEZpbGVuYW1l
SW5jbHVkZSBmaWVsZCB0aXRsZXM=
+ SW5jbHVkZSBTdWJsZXZlbHM=
SW5wdXQgRGF0ZSBGb3JtYXQ=
SW5wdXQgVGltZSBGb3JtYXQ=
SW5zdGFsbCBNb2R1bGVz
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 15268)
+++ install/install_schema.sql (working copy)
@@ -146,6 +146,7 @@
SubscriberEmail varchar(255) NOT NULL DEFAULT '',
UserId int(11) DEFAULT NULL,
CategoryId int(11) DEFAULT NULL,
+ IncludeSublevels tinyint(4) NOT NULL DEFAULT '1',
ItemId int(11) DEFAULT NULL,
ParentItemId int(11) DEFAULT NULL,
SubscribedOn int(11) DEFAULT NULL,
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 15275)
+++ install/upgrades.sql (working copy)
@@ -2718,6 +2718,7 @@
SubscriberEmail varchar(255) NOT NULL DEFAULT '',
UserId int(11) DEFAULT NULL,
CategoryId int(11) DEFAULT NULL,
+ IncludeSublevels tinyint(4) NOT NULL DEFAULT '1',
ItemId int(11) DEFAULT NULL,
ParentItemId int(11) DEFAULT NULL,
SubscribedOn int(11) DEFAULT NULL,
Index: kernel/event_manager.php
===================================================================
--- kernel/event_manager.php (revision 15252)
+++ kernel/event_manager.php (working copy)
@@ -310,16 +310,17 @@
return;
}
- $category_ids = $item_id = $parent_item_id = false;
$where_clause = Array ();
$where_clause['EmailEventId'] = 'EmailEventId = ' . $email_event['EventId'];
try {
+ $category_ids = Array ();
+
$category = $this->Application->recallObject('c');
/* @var $category kDBItem */
if ( $category->isLoaded() ) {
- $category_ids = trim(str_replace('|', ',', $category->GetDBField('ParentPath')), ',');
+ $category_ids = explode('|', substr($category->GetDBField('ParentPath'), 1, -1));
}
}
catch (Exception $e) {
@@ -328,6 +329,8 @@
$where_clause['CategoryId'] = $this->_getSubscriberFilter('CategoryId', $category_ids, true);
try {
+ $item_id = $parent_item_id = false;
+
$object = $event->getObject();
/* @var $object kDBItem */
@@ -385,17 +388,22 @@
*
* @param string $field
* @param mixed $value
- * @param bool $use_in_clause
+ * @param bool $is_category
* @return string
* @access protected
*/
- protected function _getSubscriberFilter($field, $value, $use_in_clause = false)
+ protected function _getSubscriberFilter($field, $value, $is_category = false)
{
if ( $value ) {
// send to this item subscribers AND to subscribers to all items
- $clause = $use_in_clause ? ' IN (' . $value . ')' : ' = ' . $this->Conn->qstr($value);
+ if ( $is_category ) {
+ $clause = 'IF(IncludeSublevels = 1, ' . $field . ' IN (' . implode(',', $value) . '), ' . $field . ' = ' . end($value) . ')';
+ }
+ else {
+ $clause = $field . ' = ' . $this->Conn->qstr($value);
+ }
- return $field . $clause . ' OR ' . $field . ' IS NULL';
+ return $clause . ' OR ' . $field . ' IS NULL';
}
// send to subscribers to all items
Index: units/system_event_subscriptions/system_event_subscription_tp.php
===================================================================
--- units/system_event_subscriptions/system_event_subscription_tp.php (revision 15274)
+++ units/system_event_subscriptions/system_event_subscription_tp.php (working copy)
@@ -217,11 +217,16 @@
*
* @return string
* @access protected
+ * @throws Exception
*/
protected function _getPrefix()
{
$event = new kEvent($this->_subscriptions->GetDBField('BindToSystemEvent'));
+ if ( !$event->Prefix ) {
+ throw new Exception('Subscription "#' . $this->_subscriptions->GetID() . '" is connected to invalid or missing e-mail event "#' . $this->_subscriptions->GetDBField('EmailEventId') . '"');
+ }
+
return $event->Prefix;
}
Index: units/system_event_subscriptions/system_event_subscriptions_config.php
===================================================================
--- units/system_event_subscriptions/system_event_subscriptions_config.php (revision 15268)
+++ units/system_event_subscriptions/system_event_subscriptions_config.php (working copy)
@@ -103,6 +103,11 @@
'SubscriberEmail' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'UserId' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'default' => NULL),
'CategoryId' => Array ('type' => 'int', 'default' => NULL),
+ 'IncludeSublevels' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => 1
+ ),
'ItemId' => Array ('type' => 'int', 'default' => NULL),
'ParentItemId' => Array ('type' => 'int', 'default' => NULL),
'SubscribedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#')
@@ -124,6 +129,7 @@
'UserId' => Array ('title' => 'la_col_PortalUserId', 'filter_block' => 'grid_range_filter', 'width' => 80),
'Username' => Array ('filter_block' => 'grid_like_filter'),
'CategoryId' => Array ('title' => 'column:la_fld_CategoryId', /*'data_block' => 'grid_category_td',*/ 'filter_block' => 'grid_range_filter', 'width' => 100),
+ 'IncludeSublevels' => Array ('filter_block' => 'grid_options_filter', 'width' => 100),
'CategoryName' => Array ('title' => 'column:la_fld_Category', 'filter_block' => 'grid_like_filter', 'width' => 200),
'ItemId' => Array ('filter_block' => 'grid_range_filter', 'width' => 80),
'ItemName' => Array ('data_block' => 'grid_item_name_td', 'associated_field' => 'ItemId', 'filter_block' => 'grid_like_filter', 'width' => 120),