Index: branches/5.2.x/core/units/scheduled_tasks/agents_config.php =================================================================== --- branches/5.2.x/core/units/scheduled_tasks/agents_config.php (revision 14990) +++ branches/5.2.x/core/units/scheduled_tasks/agents_config.php (nonexistent) @@ -1,173 +0,0 @@ -<?php -/** -* @version $Id$ -* @package In-Portal -* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved. -* @license GNU/GPL -* In-Portal is Open Source software. -* This means that this software may have been modified pursuant -* the GNU General Public License, and as distributed it includes -* or is derivative of works licensed under the GNU General Public License -* or other free or open source software licenses. -* See http://www.in-portal.org/license for copyright notices and details. -*/ - -defined('FULL_PATH') or die('restricted access!'); - - $config = Array ( - 'Prefix' => 'agent', - 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), - 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), - 'EventHandlerClass' => Array ('class' => 'AgentEventHandler', 'file' => 'agent_eh.php', 'build_event' => 'OnBuild'), - 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), - - 'AutoLoad' => true, - - 'QueryString' => Array ( - 1 => 'id', - 2 => 'Page', - 3 => 'PerPage', - 4 => 'event', - 5 => 'mode', - ), - - 'Hooks' => Array ( - Array ( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'adm', - 'HookToSpecial' => '*', - 'HookToEvent' => Array ('OnAfterCacheRebuild'), - 'DoPrefix' => '', - 'DoSpecial' => '*', - 'DoEvent' => 'OnRefreshAgents', - ), - ), - - 'IDField' => 'AgentId', - - 'TableName' => TABLE_PREFIX . 'Agents', - - 'TitleField' => 'AgentName', - - 'StatusField' => Array ('Status'), - - 'TitlePresets' => Array ( - 'default' => Array ( - 'new_status_labels' => Array ('agent' => '!la_title_AddingAgent!'), - 'edit_status_labels' => Array ('agent' => '!la_title_EditingAgent!'), - 'new_titlefield' => Array ('agent' => '!la_title_NewAgent!'), - ), - - 'agent_list' => Array ( - 'prefixes' => Array ('agent_List'), 'format' => "!la_title_Agents!", - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'process', 'cancel', 'view', 'dbl-click'), - ), - - 'agent_edit' => Array ('prefixes' => Array ('agent'), 'format' => "#agent_status# '#agent_titlefield#'", - 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'), - ), - ), - - 'PermSection' => Array('main' => 'in-portal:agents'), - - 'Sections' => Array ( - 'in-portal:agents' => Array ( - 'parent' => 'in-portal:website_setting_folder', - 'icon' => 'conf_agents', - 'label' => 'la_title_Agents', - 'url' => Array('t' => 'agents/agent_list', 'pass' => 'm'), - 'permissions' => Array('view', 'add', 'edit', 'delete'), - 'priority' => 6, - 'type' => stTREE, - ), - ), - - 'ListSQLs' => Array ( - '' => ' SELECT %1$s.* %2$s FROM %1$s', - ), - - 'ListSortings' => Array ( - '' => Array ( - 'Sorting' => Array ('AgentName' => 'asc'), - ) - ), - - 'Fields' => Array ( - 'AgentId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), - - 'AgentName' => Array ( - 'type' => 'string', 'max_len' => 255, - 'unique' => Array (), - 'required' => 1, 'not_null' => 1, 'default' => '' - ), - - 'AgentType' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_User', 2 => 'la_opt_System'), 'use_phrases' => 1, - 'required' => 1, 'not_null' => 1, 'default' => 1 - ), - 'Status' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Active', 0 => 'la_opt_Disabled'), 'use_phrases' => 1, - 'required' => 1, 'not_null' => 1, 'default' => 1 - ), - 'Event' => Array ( - 'type' => 'string', 'max_len' => 255, - 'formatter' => 'kFormatter', 'regexp' => '/^[a-z-]*[.]{0,1}[a-z-]*:On[A-Za-z0-9]*$/', - 'required' => 1, 'not_null' => 1, 'default' => '' - ), - 'RunInterval' => Array ('type' => 'int', 'required' => 1, 'not_null' => 1, 'default' => 0), - 'RunMode' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', 'options' => Array (reBEFORE => 'la_opt_Before', reAFTER => 'la_opt_After'), 'use_phrases' => 1, - 'required' => 1, 'not_null' => 1, 'default' => 2 - ), - 'LastRunOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL), - - 'LastRunStatus' => Array ( - 'type' => 'int', - 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Success', 0 => 'la_opt_Failed', 2 => 'la_opt_Running'), 'use_phrases' => 1, - 'not_null' => 1, 'default' => 1 - ), - - 'NextRunOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'), - 'RunTime' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), - 'Timeout' => Array ( - 'type' => 'int', - 'min_value_inc' => 1, - 'not_null' => 1, 'default' => NULL - ), - 'LastTimeoutOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL), - 'SiteDomainLimitation' => Array ( - 'type' => 'string', 'max_len' => 255, - 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'SiteDomains ORDER BY DomainName ASC', 'option_key_field' => 'DomainId', 'option_title_field' => 'DomainName', 'multiple' => 1, - 'not_null' => 1, 'default' => '' - ), - ), - - 'Grids' => Array ( - 'Default' => Array ( - 'Icons' => Array ( - 'default' => 'icon16_item.png', - 0 => 'icon16_disabled.png', - ), - 'Fields' => Array ( - 'AgentId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 50, ), - 'AgentName' => Array ('title' => 'column:la_fld_Name', 'filter_block' => 'grid_like_filter', 'width' => 200, ), - 'AgentType' => Array ('title' => 'column:la_fld_Type', 'filter_block' => 'grid_options_filter', 'width' => 60, ), - 'Event' => Array ('filter_block' => 'grid_like_filter', 'width' => 280, ), - 'RunInterval' => Array ('filter_block' => 'grid_range_filter', 'width' => 100, ), - 'RunMode' => Array ('filter_block' => 'grid_options_filter', 'width' => 85, ), - 'LastRunOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ), - 'RunTime' => Array ('filter_block' => 'grid_range_filter', 'width' => 145, ), - 'LastRunStatus' => Array ('filter_block' => 'grid_options_filter', 'width' => 120, ), - 'NextRunOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ), - 'Status' => Array ('filter_block' => 'grid_options_filter', 'width' => 65, ), - '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), - ), - ), - ), - ); \ No newline at end of file Property changes on: branches/5.2.x/core/units/scheduled_tasks/agents_config.php ___________________________________________________________________ Deleted: cvs2svn:cvs-rev ## -1 +0,0 ## -1.1.2.6 \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Id \ No newline at end of property Index: branches/5.2.x/core/units/scheduled_tasks/agent_eh.php =================================================================== --- branches/5.2.x/core/units/scheduled_tasks/agent_eh.php (revision 14990) +++ branches/5.2.x/core/units/scheduled_tasks/agent_eh.php (nonexistent) @@ -1,181 +0,0 @@ -<?php -/** -* @version $Id$ -* @package In-Portal -* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved. -* @license GNU/GPL -* In-Portal is Open Source software. -* This means that this software may have been modified pursuant -* the GNU General Public License, and as distributed it includes -* or is derivative of works licensed under the GNU General Public License -* or other free or open source software licenses. -* See http://www.in-portal.org/license for copyright notices and details. -*/ - - defined('FULL_PATH') or die('restricted access!'); - - class AgentEventHandler extends kDBEventHandler { - - /** - * Allows to override standard permission mapping - * - */ - function mapPermissions() - { - parent::mapPermissions(); - - $permissions = Array ( - 'OnMassCancel' => Array ('self' => 'add|edit'), - 'OnRunAgents' => Array ('self' => 'add|edit'), - ); - - $this->permMapping = array_merge($this->permMapping, $permissions); - } - - /** - * [HOOK] Refreshes agents list in database based on cached data from unit configs - * - * @param kEvent $event - */ - function OnRefreshAgents(&$event) - { - $regular_events = $this->Application->EventManager->getAgents(true); - - $object =& $event->getObject( Array ('skip_autoload' => true) ); - /* @var $object kDBItem */ - - $processed_ids = Array (); - $agents = $this->Conn->Query($object->GetSelectSQL(), 'AgentName'); - - foreach ($regular_events as $run_mode => $events) { - - foreach ($events as $agent_name => $agent_params) { - if ( !isset($agents[$agent_name]) ) { - $fields_hash = Array ( - 'Event' => $agent_params['EventName'], - 'AgentName' => $agent_name, - 'AgentType' => Agent::AGENT_TYPE_SYSTEM, - 'Status' => array_key_exists('Status', $agent_params) ? $agent_params['Status'] : STATUS_ACTIVE, - 'RunInterval' => $agent_params['RunInterval'], - 'RunMode' => $run_mode, - ); - - $object->Clear(); - $object->SetDBFieldsFromHash($fields_hash); - $object->Create(); - } - else { - $object->LoadFromHash( $agents[$agent_name] ); - } - - $processed_ids[] = $object->GetID(); - } - - } - - // delete all non-processed agents (ones, that were deleted from unit configs) - $sql = 'SELECT ' . $object->IDField . ' - FROM ' . $object->TableName . ' - WHERE (AgentType = ' . Agent::AGENT_TYPE_SYSTEM . ') AND (' . $object->IDField . ' NOT IN (' . implode(',', $processed_ids) . '))'; - $delete_ids = $this->Conn->GetCol($sql); - - if ($delete_ids) { - $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - /* @var $temp_handler kTempTablesHandler */ - - $temp_handler->DeleteItems($event->Prefix, $event->Special, $delete_ids); - } - - $this->Application->removeObject($event->getPrefixSpecial()); - } - - /** - * Don't allow to delete other user's messages - * - * @param kEvent $event - * @param string $type - * @return void - * @access protected - */ - protected function customProcessing(&$event, $type) - { - if ($event->Name == 'OnMassDelete' && $type == 'before') { - if ($this->Application->isDebugMode()) { - // allow to delete system agents in debug mode - return ; - } - - $ids = $event->getEventParam('ids'); - if ($ids) { - $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); - - $sql = 'SELECT ' . $id_field . ' - FROM ' . $table_name . ' - WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ') AND AgentType <> ' . Agent::AGENT_TYPE_SYSTEM; - $allowed_ids = $this->Conn->GetCol($sql); - - $event->setEventParam('ids', $allowed_ids); - } - } - } - - /** - * Cancels agents, that are currently running - * - * @param kEvent $event - */ - function OnMassCancel(&$event) - { - $ids = $this->StoreSelectedIDs($event); - - if ($ids) { - $object =& $event->getObject( Array ('skip_autoload' => true) ); - /* @var $object kDBItem */ - - foreach ($ids as $id) { - $object->Load($id); - - if ($object->GetDBField('LastRunStatus') == Agent::LAST_RUN_RUNNING) { - // only changes status, doesn't affect currency running agents - $object->SetDBField('LastRunStatus', Agent::LAST_RUN_FAILED); - $object->Update(); - } - } - } - - $this->clearSelectedIDs($event); - } - - /** - * Runs selected agents - * - * @param kEvent $event - */ - function OnRunAgents(&$event) - { - $ids = $this->StoreSelectedIDs($event); - - if ($ids) { - $object =& $event->getObject( Array ('skip_autoload' => true) ); - /* @var $object kDBItem */ - - $where_clause = Array ( - $object->TableName . '.' . $object->IDField . ' IN (' . implode(',', $ids) . ')', - $object->TableName . '.Status = ' . STATUS_ACTIVE, - $object->TableName . '.LastRunStatus <> ' . Agent::LAST_RUN_RUNNING, - ); - - $sql = $object->GetSelectSQL() . ' - WHERE (' . implode(') AND (', $where_clause) . ')'; - $agents = $this->Conn->Query($sql); - - foreach ($agents as $agent_data) { - $agent_data['EventName'] = $agent_data['Event']; - $this->Application->EventManager->runAgent($agent_data); - } - } - - $this->clearSelectedIDs($event); - } - } \ No newline at end of file Property changes on: branches/5.2.x/core/units/scheduled_tasks/agent_eh.php ___________________________________________________________________ Deleted: cvs2svn:cvs-rev ## -1 +0,0 ## -1.1.2.1 \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -Id \ No newline at end of property Index: branches/5.2.x/core/admin_templates/scheduled_tasks/agent_list.tpl =================================================================== --- branches/5.2.x/core/admin_templates/scheduled_tasks/agent_list.tpl (revision 14990) +++ branches/5.2.x/core/admin_templates/scheduled_tasks/agent_list.tpl (nonexistent) @@ -1,91 +0,0 @@ -<inp2:m_include t="incs/header"/> -<inp2:m_RenderElement name="combined_header" section="in-portal:agents" prefix="agent" title_preset="agent_list" pagination="1"/> - -<!-- ToolBar --> -<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0"> -<tbody> - <tr> - <td> - <script type="text/javascript"> - //do not rename - this function is used in default grid for double click! - function edit() - { - std_edit_item('agent', 'agents/agent_edit'); - } - - var a_toolbar = new ToolBar(); - a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_NewAgent" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>', - function() { - std_precreate_item('agent', 'agents/agent_edit'); - } ) ); - - a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) ); - a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>', - function() { - std_delete_items('agent') - } ) ); - - a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - - a_toolbar.AddButton( - new ToolBarButton( - 'approve', - '<inp2:m_phrase label="la_ToolTip_Approve" escape="1"/>', - function() { - submit_event('agent', 'OnMassApprove'); - } - ) - ); - - a_toolbar.AddButton( - new ToolBarButton( - 'decline', - '<inp2:m_phrase label="la_ToolTip_Decline" escape="1"/>', - function() { - submit_event('agent', 'OnMassDecline'); - } - ) - ); - - a_toolbar.AddButton( new ToolBarSeparator('sep2') ); - - a_toolbar.AddButton( - new ToolBarButton( - 'process', - '<inp2:m_phrase label="la_ToolTip_Run" escape="1"/>', - function() { - submit_event('agent', 'OnRunAgents'); - } - ) - ); - - a_toolbar.AddButton( - new ToolBarButton( - 'cancel', - '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', - function() { - submit_event('agent', 'OnMassCancel'); - } - ) - ); - - a_toolbar.AddButton( new ToolBarSeparator('sep3') ); - - a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() { - show_viewmenu(a_toolbar,'view'); - } - ) ); - - a_toolbar.Render(); - </script> - </td> - <inp2:m_RenderElement name="search_main_toolbar" prefix="agent" grid="Default"/> - </tr> -</tbody> -</table> - -<inp2:m_RenderElement name="grid" PrefixSpecial="agent" IdField="AgentId" grid="Default"/> -<script type="text/javascript"> - Grids['agent'].SetDependantToolbarButtons( new Array('edit','delete', 'approve', 'decline', 'process', 'cancel') ); -</script> -<inp2:m_include t="incs/footer"/> \ No newline at end of file Property changes on: branches/5.2.x/core/admin_templates/scheduled_tasks/agent_list.tpl ___________________________________________________________________ Deleted: cvs2svn:cvs-rev ## -1 +0,0 ## -1.1.2.6 \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: branches/5.2.x/core/admin_templates/scheduled_tasks/agent_edit.tpl =================================================================== --- branches/5.2.x/core/admin_templates/scheduled_tasks/agent_edit.tpl (revision 14990) +++ branches/5.2.x/core/admin_templates/scheduled_tasks/agent_edit.tpl (nonexistent) @@ -1,97 +0,0 @@ -<inp2:adm_SetPopupSize width="750" height="600"/> -<inp2:m_include t="incs/header"/> - -<inp2:m_RenderElement name="combined_header" section="in-portal:agents" prefix="agent" title_preset="agent_edit"/> - -<!-- ToolBar --> -<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0"> -<tbody> - <tr> - <td> - <script type="text/javascript"> - a_toolbar = new ToolBar(); - a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() { - submit_event('agent', '<inp2:agent_SaveEvent/>'); - } - ) ); - a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() { - cancel_edit('agent', 'OnCancelEdit','<inp2:agent_SaveEvent/>','<inp2:m_Phrase label="la_FormCancelConfirmation" escape="1"/>'); - } - ) ); - - a_toolbar.AddButton( new ToolBarButton('reset_edit', '<inp2:m_phrase label="la_ToolTip_Reset" escape="1"/>', function() { - reset_form('agent', 'OnReset', '<inp2:m_Phrase label="la_FormResetConfirmation" escape="1"/>'); - } - ) ); - - a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - - a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() { - go_to_id('agent', '<inp2:agent_PrevId/>'); - } - ) ); - a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() { - go_to_id('agent', '<inp2:agent_NextId/>'); - } - ) ); - - - - a_toolbar.Render(); - - <inp2:m_if check="agent_IsSingle" > - a_toolbar.HideButton('prev'); - a_toolbar.HideButton('next'); - a_toolbar.HideButton('sep1'); - <inp2:m_else/> - <inp2:m_if check="agent_IsLast" > - a_toolbar.DisableButton('next'); - </inp2:m_if> - <inp2:m_if check="agent_IsFirst" > - a_toolbar.DisableButton('prev'); - </inp2:m_if> - </inp2:m_if> - </script> - </td> - </tr> -</tbody> -</table> - -<inp2:agent_SaveWarning name="grid_save_warning"/> -<inp2:agent_ErrorWarning name="form_error_warning"/> - -<div id="scroll_container"> - <table class="edit-form"> - <inp2:m_RenderElement name="inp_id_label" prefix="agent" field="AgentId" title="la_fld_Id"/> - - <inp2:m_if check="agent_Field" name="AgentType" equals_to="1" db="db"> - <inp2:m_RenderElement name="inp_edit_box" prefix="agent" field="AgentName" title="la_fld_Name"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="AgentType" title="la_fld_Type" has_empty="1"/> - <inp2:m_RenderElement name="inp_edit_radio" prefix="agent" field="Status" has_empty="1"/> - <inp2:m_RenderElement name="inp_edit_box" prefix="agent" field="Event"/> - <inp2:m_else/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="AgentName" title="la_fld_Name"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="AgentType" title="la_fld_Type" has_empty="1"/> - <inp2:m_RenderElement name="inp_edit_radio" prefix="agent" field="Status" has_empty="1"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="Event"/> - </inp2:m_if> - - <inp2:m_RenderElement name="inp_edit_box" prefix="agent" field="RunInterval"/> - <inp2:m_RenderElement name="inp_edit_options" prefix="agent" field="RunMode" has_empty="1"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="LastRunOn"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="LastRunStatus"/> - <inp2:m_RenderElement name="inp_edit_date_time" prefix="agent" field="NextRunOn"/> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="RunTime"/> - <inp2:m_RenderElement name="inp_edit_box" prefix="agent" field="Timeout" style="width: 50px"/> - - <inp2:m_if check="agent_Field" name="LastTimeoutOn" db="db"> - <inp2:m_RenderElement name="inp_label" prefix="agent" field="LastTimeoutOn"/> - </inp2:m_if> - - <inp2:m_RenderElement name="inp_edit_checkboxes" prefix="agent" field="SiteDomainLimitation"/> - - <inp2:m_RenderElement name="inp_edit_filler"/> - </table> -</div> - -<inp2:m_include t="incs/footer"/> \ No newline at end of file Property changes on: branches/5.2.x/core/admin_templates/scheduled_tasks/agent_edit.tpl ___________________________________________________________________ Deleted: cvs2svn:cvs-rev ## -1 +0,0 ## -1.1.2.6 \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property