Index: core/kernel/managers/scheduled_task_manager.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/managers/scheduled_task_manager.php (revision 15928) +++ core/kernel/managers/scheduled_task_manager.php (revision ) @@ -81,13 +81,14 @@ * @param string $short_name name to be used to store last maintenance run info * @param string $event_string * @param int $run_schedule run schedule like for Cron + * @param string $module * @param int $status * @access public */ - public function add($short_name, $event_string, $run_schedule, $status = STATUS_ACTIVE) + public function add($short_name, $event_string, $run_schedule, $module, $status = STATUS_ACTIVE) { $this->tasks[$short_name] = Array ( - 'Event' => $event_string, 'RunSchedule' => $run_schedule, 'Status' => $status + 'Event' => $event_string, 'RunSchedule' => $run_schedule, 'Module' => $module, 'Status' => $status ); } \ No newline at end of file Index: core/kernel/utility/unit_config.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/utility/unit_config.php (revision 15919) +++ core/kernel/utility/unit_config.php (revision ) @@ -1141,8 +1141,30 @@ foreach ($scheduled_tasks as $short_name => $scheduled_task_info) { $event_status = array_key_exists('Status', $scheduled_task_info) ? $scheduled_task_info['Status'] : STATUS_ACTIVE; - $this->Application->delayUnitProcessing('registerScheduledTask', Array ($short_name, $this->_prefix . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunSchedule'], $event_status)); + $this->Application->delayUnitProcessing('registerScheduledTask', Array ($short_name, $this->_prefix . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunSchedule'], $this->getModule(), $event_status)); } + } + + /** + * Detects module by unit location. + * + * @return string + */ + public function getModule() + { + $module_path = $this->getModuleFolder() . '/'; + + foreach ( $this->Application->ModuleInfo as $module_name => $module_data ) { + if ( $module_name == 'In-Portal' ) { + continue; + } + + if ( $module_data['Path'] == $module_path ) { + return $module_name; + } + } + + return ''; } protected function _parseHooks() Index: core/install/upgrades.sql IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/install/upgrades.sql (revision 15944) +++ core/install/upgrades.sql (revision ) @@ -2959,3 +2959,5 @@ ALTER TABLE EmailLog ADD Status TINYINT NOT NULL DEFAULT '1' AFTER TextBody, ADD ErrorMessage VARCHAR(255) NOT NULL DEFAULT '' AFTER Status; + +ALTER TABLE ScheduledTasks ADD Module varchar(30) NOT NULL DEFAULT 'Core'; Index: core/units/scheduled_tasks/scheduled_tasks_config.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/scheduled_tasks/scheduled_tasks_config.php (revision 15908) +++ core/units/scheduled_tasks/scheduled_tasks_config.php (revision ) @@ -145,7 +145,12 @@ 'not_null' => 1, 'default' => '' ), 'Settings' => Array ('type' => 'string', 'default' => NULL), + 'Module' => Array ( + 'type' => 'string', + 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Modules WHERE (Loaded = 1) AND (Name <> "In-Portal") ORDER BY LoadOrder', 'option_key_field' => 'Name', 'option_title_field' => 'Name', + 'not_null' => 1, 'required' => 1, 'default' => 'Core' - ), + ), + ), 'Grids' => Array ( 'Default' => Array ( @@ -167,6 +172,7 @@ 'Timeout' => Array ('filter_block' => 'grid_range_filter', 'width' => 85), 'LastTimeoutOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145), 'SiteDomainLimitation' => Array ('data_block' => 'grid_picker_td', 'filter_block' => 'grid_multioptions_filter', 'separator' => ', ', 'width' => 145), + 'Module' => Array ('filter_block' => 'grid_options_filter', 'width' => 65), ), ), ), \ No newline at end of file Index: core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl (revision 15908) +++ core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl (revision ) @@ -69,11 +69,13 @@ + + \ No newline at end of file Index: core/kernel/event_manager.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/event_manager.php (revision 15908) +++ core/kernel/event_manager.php (revision ) @@ -119,12 +119,13 @@ * @param string $short_name name to be used to store last maintenance run info * @param string $event_string * @param int $run_schedule run schedule like for Cron + * @param string $module * @param int $status * @access public */ - public function registerScheduledTask($short_name, $event_string, $run_schedule, $status = STATUS_ACTIVE) + public function registerScheduledTask($short_name, $event_string, $run_schedule, $module, $status = STATUS_ACTIVE) { - $this->ScheduledTasks->add($short_name, $event_string, $run_schedule, $status); + $this->ScheduledTasks->add($short_name, $event_string, $run_schedule, $module, $status); } /** \ No newline at end of file Index: core/install/install_schema.sql IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/install/install_schema.sql (revision 15944) +++ core/install/install_schema.sql (revision ) @@ -782,6 +782,7 @@ LastTimeoutOn int(10) unsigned DEFAULT NULL, SiteDomainLimitation varchar(255) NOT NULL DEFAULT '', Settings text, + Module varchar(30) NOT NULL DEFAULT 'Core', PRIMARY KEY (ScheduledTaskId), KEY `Status` (`Status`), KEY LastRunOn (LastRunOn), \ No newline at end of file Index: core/install/upgrades.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/install/upgrades.php (revision 15928) +++ core/install/upgrades.php (revision ) @@ -2358,15 +2358,29 @@ */ public function Upgrade_5_3_0_B1($mode) { - if ( $mode != 'before' ) { - return; - } - + if ( $mode == 'before' ) { - $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); - /* @var $ml_helper kMultiLanguageHelper */ + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ - // add new ml columns to phrases/e-mail events - $ml_helper->createFields('phrases'); - $ml_helper->createFields('emailevents'); + // add new ml columns to phrases/e-mail events + $ml_helper->createFields('phrases'); + $ml_helper->createFields('emailevents'); + } + elseif ( $mode == 'after' ) { + $sql = 'SELECT Event, ScheduledTaskId + FROM ' . TABLE_PREFIX . 'ScheduledTasks'; + $scheduled_tasks = $this->Conn->GetCol($sql, 'ScheduledTaskId'); + + foreach ( $scheduled_tasks as $id => $event_string ) { + $event = new kEvent($event_string); + $module = $event->getUnitConfig()->getModule(); + + $this->Conn->doUpdate( + array('Module' => $module), + TABLE_PREFIX . 'ScheduledTasks', + 'ScheduledTaskId = ' . $id + ); + } + } } } \ No newline at end of file Index: core/units/scheduled_tasks/scheduled_task_eh.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/scheduled_tasks/scheduled_task_eh.php (revision 15908) +++ core/units/scheduled_tasks/scheduled_task_eh.php (revision ) @@ -87,6 +87,7 @@ 'Event' => $scheduled_task_params['Event'], 'Name' => $scheduled_task_name, 'Type' => ScheduledTask::TYPE_SYSTEM, + 'Module' => $scheduled_task_params['Module'], 'Status' => isset($scheduled_task_params['Status']) ? $scheduled_task_params['Status'] : STATUS_ACTIVE, 'RunSchedule' => $scheduled_task_params['RunSchedule'], ); @@ -287,6 +288,14 @@ protected function OnAfterConfigRead(kEvent $event) { parent::OnAfterConfigRead($event); + + if ( $this->Application->findModule('Name', 'Custom') ) { + $config = $event->getUnitConfig(); + + $fields = $config->getFields(); + $fields['Module']['default'] = 'Custom'; + $config->setFields($fields); + } $cron_helper = $this->Application->recallObject('kCronHelper'); /* @var $cron_helper kCronHelper */ \ No newline at end of file Index: core/kernel/application.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/kernel/application.php (revision 15928) +++ core/kernel/application.php (revision ) @@ -2143,12 +2143,13 @@ * @param string $short_name name to be used to store last maintenance run info * @param string $event_string * @param int $run_schedule run schedule like for Cron + * @param string $module * @param int $status * @access public */ - public function registerScheduledTask($short_name, $event_string, $run_schedule, $status = STATUS_ACTIVE) + public function registerScheduledTask($short_name, $event_string, $run_schedule, $module, $status = STATUS_ACTIVE) { - $this->EventManager->registerScheduledTask($short_name, $event_string, $run_schedule, $status); + $this->EventManager->registerScheduledTask($short_name, $event_string, $run_schedule, $module, $status); } /**