*** /usr/share/zabbix/include/views/configuration.action.list.php.orig	2013-08-21 15:59:24.000000000 +0200
--- /usr/share/zabbix/include/views/configuration.action.list.php	2013-10-06 08:18:49.000000000 +0200
***************
*** 20,24 ****
  
  
! $actionWidget = new CWidget();
  
  // create new action button
--- 20,24 ----
  
  
! $actionWidget = new CWidget(null, 'item-list');
  
  // create new action button
***************
*** 40,43 ****
--- 40,146 ----
  $actionWidget->addHeaderRowNumber();
  
+ // filter
+ $filter_table = new CTable('', 'filter');
+ $filter_table->setAttribute('name', 'zbx_filter');
+ $filter_table->setAttribute('id', 'zbx_filter');
+ 
+ //row 1
+ $filter_table->addRow(array(
+ 	new CCol(array(bold(_('Name')), SPACE._('like').': '), 'label col1'),
+ 	new CCol(new CTextBox('filter_name', $data['filter_name'], ZBX_TEXTBOX_FILTER_SIZE)),
+ 	new CCol(bold(_('Host group').': '), 'label col2'),
+ 	new CCol(array(
+ 		new CTextBox('filter_group', $data['filter_group'], ZBX_TEXTBOX_FILTER_SIZE),
+ 		new CButton('btn_group', _('Select'),
+ 			'return PopUp("popup.php?srctbl=host_group&srcfld1=name'.
+ 			'&dstfrm='.$filter_table->getName().'&dstfld1=filter_group", 450, 450);'
+ 		)
+ 	), 'col2'),
+ 	new CCol(array(_('send to').SPACE,bold(_('User group').': ')), 'label col3'),
+ 	new CCol(array(
+ 		new CTextBox('filter_usrgrp', $data['filter_usrgrp'], ZBX_TEXTBOX_FILTER_SIZE),
+ 		new CButton('btn_usrgrp', _('Select'),
+ 			'return PopUp("popup.php?srctbl=usrgrp&srcfld1=name&srcfld2=name'.
+ 			'&dstfrm='.$filter_table->getName().'&dstfld1=filter_usrgrp&dstfld2=filter_usrgrp", 450, 450);'
+ 		)
+ 	), 'col3'),
+ 	new CCol(bold(_('Status').': '), 'label col4'),
+ 	new CComboBox('filter_status', $data['filter_status'], null, array(
+ 		-1 => _('all'),
+ 		0 => _('Enabled'),
+ 		1 => _('Disabled')
+ 	), 'col4')
+ ));
+ 
+ //row 2
+ $filter_table->addRow(array(
+ 	new CCol(array(_('default').SPACE,bold(_('Step'.SPACE.'duration')),': '), 'label col1'),
+ 	new CCol(new CNumericBox('filter_esc_period', $data['filter_esc_period'], 6)),
+ 	new CCol(bold(_('Host').': '), 'label col2'),
+ 	new CCol(array(
+ 		new CTextBox('filter_host', $data['filter_host'], ZBX_TEXTBOX_FILTER_SIZE),
+ 		new CButton('btn_host', _('Select'),
+ 			'return PopUp("popup.php?srctbl=hosts_and_templates&srcfld1=name'.
+ 			'&dstfrm='.$filter_table->getName().'&dstfld1=filter_host", 450, 450);'
+ 		)
+ 	), 'col2'),
+ 	new CCol(array(_('send to').SPACE,bold(_('User').': ')), 'label col3'),
+ 	new CCol(array(
+ 		new CTextBox('filter_user', $data['filter_user'], ZBX_TEXTBOX_FILTER_SIZE),
+ 		new CButton('btn_user', _('Select'),
+ 			'return PopUp("popup.php?srctbl=users&srcfld1=alias'.
+ 			'&dstfrm='.$filter_table->getName().'&dstfld1=filter_user", 450, 450);'
+ 		)
+ 	), 'col3'),
+ 	new CCol(bold(_('Recovery').': '), 'label col4'),
+ 	new CComboBox('filter_recovery_msg', $data['filter_recovery_msg'], null, array(
+ 		-1 => _('all'),
+ 		0 => _('No'),
+ 		1 => _('Yes')
+ 	), 'col4')
+ ));
+ 
+ //row 3
+ $filter_table->addRow(array(
+ 	new CCol(array(_('default').SPACE,bold(_('Subject')), SPACE._('like').': '), 'label col1'),
+ 	new CCol(new CTextBox('filter_subject', $data['filter_subject'], ZBX_TEXTBOX_FILTER_SIZE)),
+ 	new CCol(array(bold(_('Trigger')), SPACE._('like').': '), 'label col2'),
+ 	new CCol(array(
+ 		new CTextBox('filter_trigger', $data['filter_trigger'], ZBX_TEXTBOX_FILTER_SIZE)
+ 	), 'col2'),
+ 	new CCol(array(_('global').SPACE,bold(_('Script').': ')), 'label col3'),
+ 	new CCol(array(
+ 		new CTextBox('filter_script', $data['filter_script'], ZBX_TEXTBOX_FILTER_SIZE),
+ 		new CButton('btn_script', _('Select'),
+ 			'return PopUp("popup.php?srctbl=scripts&srcfld1=name&srcfld2=name'.
+ 			'&dstfrm='.$filter_table->getName().'&dstfld1=filter_script&dstfld2=filter_script", 450, 450);'
+ 		)
+ 	), 'col3')
+ ));
+ 
+ //row 4
+ $filter_table->addRow(array(
+ 	new CCol(array(_('default').SPACE,bold(_('Message')), SPACE._('like').': '), 'label col1'),
+ 	new CCol(new CTextBox('filter_message', $data['filter_message'], ZBX_TEXTBOX_FILTER_SIZE)),
+ ));
+ 
+ $filter = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);");
+ $filter->useJQueryStyle('main');
+ 
+ $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');");
+ $reset->useJQueryStyle();
+ 
+ $div_buttons = new CDiv(array($filter, SPACE, $reset));
+ $div_buttons->setAttribute('style', 'padding: 4px 0;');
+ 
+ $filter_table->addRow(new CCol($div_buttons, 'center', 8));
+ 
+ $filter_form = new CForm('get');
+ $filter_form->setAttribute('name', 'zbx_filter');
+ $filter_form->setAttribute('id', 'zbx_filter');
+ $filter_form->addItem($filter_table);
+ 
+ $actionWidget->addFlicker($filter_form, CProfile::get('web.actionconf.filter.state', 0));
+ 
  // create form
  $actionForm = new CForm('get');
*** /usr/share/zabbix/actionconf.php.orig	2013-08-21 15:59:26.000000000 +0200
--- /usr/share/zabbix/actionconf.php	2013-10-06 08:27:30.000000000 +0200
***************
*** 64,67 ****
--- 64,81 ----
  	'form' =>				array(T_ZBX_STR, O_OPT, P_SYS,	null,		null),
  	'form_refresh' =>		array(T_ZBX_INT, O_OPT, null,	null,		null),
+ 	// filter
+ 	'filter_set' =>			array(T_ZBX_STR, O_OPT, P_ACT,  null, null),
+ 	'filter_name' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_status' =>		array(T_ZBX_INT, O_OPT, null,   IN(array(-1, 0, 1)), null),
+ 	'filter_group' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_host' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_usrgrp' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_user' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_trigger' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_script' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_subject' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_message' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_esc_period' =>		array(T_ZBX_STR, O_OPT, null,   null, null),
+ 	'filter_recovery_msg' =>	array(T_ZBX_STR, O_OPT, null,   null, null),
  	// ajax
  	'favobj' =>				array(T_ZBX_STR, O_OPT, P_ACT,	null,		null),
***************
*** 81,85 ****
  if (isset($_REQUEST['favobj'])) {
  	if ($_REQUEST['favobj'] == 'filter') {
! 		CProfile::update('web.audit.filter.state', $_REQUEST['favstate'], PROFILE_TYPE_INT);
  	}
  }
--- 95,99 ----
  if (isset($_REQUEST['favobj'])) {
  	if ($_REQUEST['favobj'] == 'filter') {
! 		CProfile::update('web.actionconf.filter.state', $_REQUEST['favstate'], PROFILE_TYPE_INT);
  	}
  }
***************
*** 101,104 ****
--- 115,163 ----
  
  /*
+  * Filter
+  */
+ if (isset($_REQUEST['filter_set'])) {
+ 	$_REQUEST['filter_name'] = get_request('filter_name');
+ 	$_REQUEST['filter_status'] = get_request('filter_status', -1);
+ 	$_REQUEST['filter_group'] = get_request('filter_group');
+ 	$_REQUEST['filter_host'] = get_request('filter_host');
+ 	$_REQUEST['filter_usrgrp'] = get_request('filter_usrgrp');
+ 	$_REQUEST['filter_user'] = get_request('filter_user');
+ 	$_REQUEST['filter_trigger'] = get_request('filter_trigger');
+ 	$_REQUEST['filter_script'] = get_request('filter_script');
+ 	$_REQUEST['filter_subject'] = get_request('filter_subject');
+ 	$_REQUEST['filter_message'] = get_request('filter_message');
+ 	$_REQUEST['filter_esc_period'] = get_request('filter_esc_period');
+ 	$_REQUEST['filter_recovery_msg'] = get_request('filter_recovery_msg', -1);
+ 
+ 	CProfile::update('web.actionconf.filter_name', $_REQUEST['filter_name'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_status', $_REQUEST['filter_status'], PROFILE_TYPE_INT);
+ 	CProfile::update('web.actionconf.filter_group', $_REQUEST['filter_group'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_host', $_REQUEST['filter_host'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_usrgrp', $_REQUEST['filter_usrgrp'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_user', $_REQUEST['filter_user'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_trigger', $_REQUEST['filter_trigger'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_script', $_REQUEST['filter_script'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_subject', $_REQUEST['filter_subject'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_message', $_REQUEST['filter_message'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_esc_period', $_REQUEST['filter_esc_period'], PROFILE_TYPE_STR);
+ 	CProfile::update('web.actionconf.filter_recovery_msg', $_REQUEST['filter_recovery_msg'], PROFILE_TYPE_STR);
+ }
+ else {
+ 	$_REQUEST['filter_name'] = CProfile::get('web.actionconf.filter_name');
+ 	$_REQUEST['filter_status'] = CProfile::get('web.actionconf.filter_status', -1);
+ 	$_REQUEST['filter_group'] = CProfile::get('web.actionconf.filter_group');
+ 	$_REQUEST['filter_host'] = CProfile::get('web.actionconf.filter_host');
+ 	$_REQUEST['filter_usrgrp'] = CProfile::get('web.actionconf.filter_usrgrp');
+ 	$_REQUEST['filter_user'] = CProfile::get('web.actionconf.filter_user');
+ 	$_REQUEST['filter_trigger'] = CProfile::get('web.actionconf.filter_trigger');
+ 	$_REQUEST['filter_script'] = CProfile::get('web.actionconf.filter_script');
+ 	$_REQUEST['filter_subject'] = CProfile::get('web.actionconf.filter_subject');
+ 	$_REQUEST['filter_message'] = CProfile::get('web.actionconf.filter_message');
+ 	$_REQUEST['filter_esc_period'] = CProfile::get('web.actionconf.filter_esc_period');
+ 	$_REQUEST['filter_recovery_msg'] = CProfile::get('web.actionconf.filter_recovery_msg', -1);
+ }
+ 
+ /*
   * Actions
   */
***************
*** 439,448 ****
  }
  else {
  	$data = array(
! 		'eventsource' => get_request('eventsource')
  	);
  
  	$sortfield = getPageSortField('name');
  
  	$data['actions'] = API::Action()->get(array(
  		'output' => API_OUTPUT_EXTEND,
--- 498,605 ----
  }
  else {
+ 	$filters = null;
+ 
  	$data = array(
! 		'actions' => null,
! 		'eventsource' => get_request('eventsource'),
! 		'filter_status' => get_request('filter_status'),
! 		'filter_name' => get_request('filter_name'),
! 		'filter_group' => get_request('filter_group'),
! 		'filter_host' => get_request('filter_host'),
! 		'filter_usrgrp' => get_request('filter_usrgrp'),
! 		'filter_user' => get_request('filter_user'),
! 		'filter_trigger' => get_request('filter_trigger'),
! 		'filter_script' => get_request('filter_script'),
! 		'filter_subject' => get_request('filter_subject'),
! 		'filter_message' => get_request('filter_message'),
! 		'filter_esc_period' => get_request('filter_esc_period'),
! 		'filter_recovery_msg' => get_request('filter_recovery_msg')
  	);
  
  	$sortfield = getPageSortField('name');
  
+ 	$options = array(
+ 		'editable' => true,
+ 		'output' => API_OUTPUT_SHORTEN,
+ 		'limit' => $config['search_limit'] + 1
+ 	);
+ 
+ 	if (isset($_REQUEST['filter_name']) && !zbx_empty($_REQUEST['filter_name'])) {
+ 		$opt = array_merge($options, array('search' => array('name' => $data['filter_name'])));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_status'] > -1) {
+ 		$opt = array_merge($options, array('filter' => array('status' => $data['filter_status'])));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_group']) {
+ 		$opt = array_merge($options, array('filter' => array('name' => $data['filter_group'])));
+ 		$groupids = zbx_objectValues(API::HostGroup()->get($opt), 'groupid');
+ 
+ 		$opt = array_merge($options, array('groupids' => $groupids));
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_host']) {
+ 		$opt = array_merge($options, array('filter' => array('name' => $data['filter_host'])));
+ 		$hostids = zbx_objectValues(API::Host()->get($opt), 'hostid');
+ 
+ 		$opt = array_merge($options, array('hostids' => $hostids));
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_usrgrp']) {
+ 		$opt = array_merge($options, array('filter' => array('name' => $data['filter_usrgrp'])));
+ 		$usrgrpids = zbx_objectValues(API::UserGroup()->get($opt), 'usrgrpid');
+ 
+ 		$opt = array_merge($options, array('usrgrpids' => $usrgrpids));
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_user']) {
+ 		$opt = array_merge($options, array('filter' => array('alias' => $data['filter_user'])));
+ 		$userids = zbx_objectValues(API::User()->get($opt), 'userid');
+ 
+ 		$opt = array_merge($options, array('userids' => $userids));
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_trigger']) {
+ 		$opt = array_merge($options, array('search' => array('description' => $data['filter_trigger'])));
+ 		$triggerids = zbx_objectValues(API::Trigger()->get($opt), 'triggerid');
+ 
+ 		$opt = array_merge($options, array('triggerids' => $triggerids));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_script']) {
+ 		$opt = array_merge($options, array('filter' => array('name' => $data['filter_script'])));
+ 		$scriptids = zbx_objectValues(API::Script()->get($opt), 'scriptid');
+ 
+ 		$opt = array_merge($options, array('scriptids' => $scriptids));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_subject']) {
+ 		$opt['search']['def_shortdata'] = $data['filter_subject'];
+ 		$opt['search']['r_shortdata'] = $data['filter_subject'];
+ 		$opt['searchByAny'] = true;
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_message']) {
+ 		$opt['search']['def_longdata'] = $data['filter_message'];
+ 		$opt['search']['r_longdata'] = $data['filter_message'];
+ 		$opt['searchByAny'] = true;
+ 		$filters[] = zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_esc_period']) {
+ 		$opt = array_merge($options, array('filter' => array('esc_period' => $data['filter_esc_period'])));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 	if ($data['filter_recovery_msg'] > -1) {
+ 		$opt = array_merge($options, array('filter' => array('recovery_msg' => $data['filter_recovery_msg'])));
+ 		$filters[]= zbx_objectValues(API::Action()->get($opt), 'actionid');
+ 	}
+ 
+ 	if (1 < count($filters)) {
+ 		$data['actions'] = call_user_func_array('array_intersect', $filters);
+ 	} else {
+ 		$data['actions'] = $filters[0];
+ 	}
+ 
  	$data['actions'] = API::Action()->get(array(
  		'output' => API_OUTPUT_EXTEND,
***************
*** 452,456 ****
  		'editable' => true,
  		'sortfield' => $sortfield,
! 		'limit' => $config['search_limit'] + 1
  	));
  
--- 609,614 ----
  		'editable' => true,
  		'sortfield' => $sortfield,
! 		'limit' => $config['search_limit'] + 1,
! 		'actionids' => $data['actions']
  	));
  
