--- /usr/share/zabbix/include/views/administration.general.gui.edit.php.orig	2013-10-12 15:51:49.000000000 +0200
+++ /usr/share/zabbix/include/views/administration.general.gui.edit.php	2013-10-23 16:41:12.000000000 +0200
@@ -25,6 +25,7 @@
 
 $comboDdFirstEntry = new CComboBox('dropdown_first_entry', $this->data['config']['dropdown_first_entry']);
 $comboDdFirstEntry->addItem(ZBX_DROPDOWN_FIRST_NONE, _('None'));
+$comboDdFirstEntry->addItem(ZBX_DROPDOWN_FIRST_NONEALL, _('None / offer all'));
 $comboDdFirstEntry->addItem(ZBX_DROPDOWN_FIRST_ALL, _('All'));
 
 $guiTab = new CFormList('scriptsTab');
--- /usr/share/zabbix/include/defines.inc.php.orig	2013-10-15 11:25:56.000000000 +0200
+++ /usr/share/zabbix/include/defines.inc.php	2013-10-23 14:40:18.000000000 +0200
@@ -112,6 +122,7 @@
 
 define('ZBX_DROPDOWN_FIRST_NONE',	0);
 define('ZBX_DROPDOWN_FIRST_ALL',	1);
+define('ZBX_DROPDOWN_FIRST_NONEALL',	2);
 
 define('T_ZBX_STR',			0);
 define('T_ZBX_INT',			1);
@@ -869,7 +896,7 @@
 define('ZBX_TEXTAREA_STANDARD_ROWS',	7);
 
 // validation
-define('DB_ID',		"({}>=0&&bccomp('{}',\"10000000000000000000\")<0)&&");
+define('DB_ID',		"({}>=-1&&bccomp('{}',\"10000000000000000000\")<0)&&");
 define('NOT_EMPTY',	"({}!='')&&");
 define('NOT_ZERO',	"({}!=0)&&");
 define('NO_TRIM',	'NO_TRIM');
--- /usr/share/zabbix/include/classes/class.cpagefilter.php.orig	2013-10-12 15:51:50.000000000 +0200
+++ /usr/share/zabbix/include/classes/class.cpagefilter.php	2013-10-23 18:32:09.000000000 +0200
@@ -379,8 +379,10 @@
 		CProfile::update($this->_profileIdx['groups'], $groupid, PROFILE_TYPE_ID);
 		CProfile::update(self::GROUP_LATEST_IDX, $groupid, PROFILE_TYPE_ID);
 
-		$this->isSelected['groupsSelected'] = ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['groups'])) || $groupid > 0;
-		$this->isSelected['groupsAll'] = $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['groups']) && $groupid == 0;
+		$this->isSelected['groupsSelected'] = ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['groups']) || $groupid > 0)
+			|| ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONEALL && !empty($this->data['groups']) && $groupid == -1);
+		$this->isSelected['groupsAll'] = $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['groups']) && $groupid == 0
+			|| $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONEALL && !empty($this->data['groups']) && $groupid == -1;
 		$this->ids['groupid'] = $groupid;
 	}
 
@@ -395,6 +397,11 @@
 	private function _initHosts($hostid, $options) {
 		$this->data['hosts'] = array();
 
+		if (!$this->groupsSelected && $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONEALL && $hostid > 0) {
+			$this->groupid = -1;
+			$this->groupsSelected = true;
+		}
+
 		if (!$this->groupsSelected) {
 			$hostid = 0;
 		}
@@ -435,7 +442,8 @@
 			CProfile::update($this->_profileIdx['hosts'], $hostid, PROFILE_TYPE_ID);
 			CProfile::update(self::HOST_LATEST_IDX, $hostid, PROFILE_TYPE_ID);
 		}
-		$this->isSelected['hostsSelected'] = ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['hosts'])) || $hostid > 0;
+		$this->isSelected['hostsSelected'] = ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['hosts'])) || $hostid > 0
+			|| $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONEALL && $hostid != 0;
 		$this->isSelected['hostsAll'] = $this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL && !empty($this->data['hosts']) && $hostid == 0;
 		$this->ids['hostid'] = $hostid;
 	}
@@ -628,7 +636,8 @@
 		natcasesort($items);
 
 		if (!$this->config['popupDD']) {
-			$items = array(0 => ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONE) ? _('not selected') : _('all')) + $items;
+			if ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_NONEALL) $items = array(-1 => _('all')) + $items;
+			$items = array(0 => ($this->config['DDFirst'] == ZBX_DROPDOWN_FIRST_ALL) ? _('all') : _('not selected')) + $items;
 		}
 
 		foreach ($items as $id => $name) {
--- /usr/share/zabbix/events.php.orig	2013-10-21 10:48:13.000000000 +0200
+++ /usr/share/zabbix/events.php	2013-10-27 16:01:53.000000000 +0100
@@ -142,7 +155,6 @@
 	));
 
 	foreach ($oldTriggers as $oldTrigger) {
-		$_REQUEST['triggerid'] = 0;
 		$oldTrigger['hosts'] = zbx_toHash($oldTrigger['hosts'], 'hostid');
 		$oldTrigger['items'] = zbx_toHash($oldTrigger['items'], 'itemid');
 		$oldTrigger['functions'] = zbx_toHash($oldTrigger['functions'], 'functionid');
@@ -152,6 +164,8 @@
 			break;
 		}
 
+		$_REQUEST['triggerid'] = 0;
+
 		$newTriggers = API::Trigger()->get(array(
 			'output' => array(
 				'triggerid',
@@ -328,6 +361,8 @@
 	$filterForm->addVar('triggerid', get_request('triggerid'));
 	$filterForm->addVar('stime', get_request('stime'));
 	$filterForm->addVar('period', get_request('period'));
+	$filterForm->addVar('hostid', $pageFilter->hostid);
+	$filterForm->addVar('groupid', $pageFilter->groupid);
 
 	if (isset($_REQUEST['triggerid']) && ($_REQUEST['triggerid'] > 0)) {
 		$dbTrigger = API::Trigger()->get(array(
@@ -701,8 +798,9 @@
 				)));
 
 				$tr_desc = new CSpan($description, 'pointer');
+				$groupid = ($config['dropdown_first_entry'] == ZBX_DROPDOWN_FIRST_NONEALL?-1:0);
 				$tr_desc->addAction('onclick', "create_mon_trigger_menu(event, ".
-						" [{'triggerid': '".$trigger['triggerid']."', 'lastchange': '".$event['clock']."'}],".
+						" [{'triggerid': '".$trigger['triggerid']."', 'lastchange': '".$event['clock']."', 'groupid': '".$groupid."', 'hostid': '".$host['hostid']."'}],".
 						zbx_jsvalue($items, true).");");
 
 				// duration
--- /usr/share/zabbix/js/functions.js.orig	2013-10-12 15:51:48.000000000 +0200
+++ /usr/share/zabbix/js/functions.js	2013-10-27 15:01:21.000000000 +0100
@@ -577,7 +577,7 @@
 
 // triggers js menu
 function create_mon_trigger_menu(e, args, items) {
-	var tr_menu = [[t('Triggers'), null, null, {'outer' : ['pum_oheader'], 'inner' : ['pum_iheader']}], [t('Events'), 'events.php?triggerid=' + args[0].triggerid + '&nav_time=' + args[0].lastchange, null]];
+	var tr_menu = [[t('Triggers'), null, null, {'outer' : ['pum_oheader'], 'inner' : ['pum_iheader']}], [t('Events'), 'events.php?triggerid=' + args[0].triggerid + '&nav_time=' + args[0].lastchange + '&groupid=' + args[0].groupid + '&hostid=' + args[0].hostid, null]];
 	if (args.length > 1 && !is_null(args[1])) {
 		tr_menu.push(args[1]);
 	}
--- /usr/share/zabbix/tr_status.php.orig	2013-10-25 15:17:22.000000000 +0200
+++ /usr/share/zabbix/tr_status.php	2013-11-13 16:31:49.000000000 +0100
@@ -509,7 +509,7 @@
 		// trigger js menu
 		$menu_trigger_conf = 'null';
 		if($admin_links && $trigger['flags'] == ZBX_FLAG_DISCOVERY_NORMAL){
-			$configurationUrl = 'triggers.php?form=update&triggerid='.$trigger['triggerid'].'&hostid='.$pageFilter->hostid.'&switch_node='.id2nodeid($trigger['triggerid']);
+			$configurationUrl = 'triggers.php?form=update&triggerid='.$trigger['triggerid'].'&hostid='.($pageFilter->hostid<0?0:$pageFilter->hostid).'&switch_node='.id2nodeid($trigger['triggerid']);
 			$menu_trigger_conf = "['"._('Configuration of triggers')."',".CJs::encodeJson($configurationUrl).",
 				null, {'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
 		}
@@ -521,9 +521,11 @@
 		}
 
 		$description = new CSpan($trigger['description'], 'link_menu');
+		$groupid = ($config['dropdown_first_entry'] == ZBX_DROPDOWN_FIRST_NONEALL?-1:0);
+		usort($trigger['hosts'], function($a, $b) { return strcmp($a['name'], $b['name']); });
 		$description->addAction('onclick',
 			"javascript: create_mon_trigger_menu(event, [{'triggerid': '".$trigger['triggerid'].
-				"', 'lastchange': '".$trigger['lastchange']."'}, ".$menu_trigger_conf.", ".$menu_trigger_url."],".
+				"', 'lastchange': '".$trigger['lastchange']."', 'groupid': '".$groupid."', 'hostid': '".$trigger['hosts'][0]['hostid']."'}, ".$menu_trigger_conf.", ".$menu_trigger_url."],".
 			zbx_jsvalue($items, true).");"
 		);
 
@@ -580,6 +582,7 @@
 
 // host JS menu {{{
 		$hosts_list = array();
+		$trigger_host_cnt = count($trigger['hosts']);
 		foreach($trigger['hosts'] as $trigger_host){
 			$host = $hosts[$trigger_host['hostid']];
 
@@ -635,7 +638,7 @@
 			}
 
 			// add comma after hosts, except last
-			if (next($trigger['hosts'])) {
+			if (--$trigger_host_cnt > 0) {
 				$hosts_span->addItem(','.SPACE);
 			}
 
--- /usr/share/zabbix/latest.php.orig	2013-10-21 10:48:58.000000000 +0200
+++ /usr/share/zabbix/latest.php	2013-11-30 22:11:15.000000000 +0100
@@ -188,7 +208,7 @@
 $table->setHeader(array(
 	$link,
 	is_show_all_nodes() ? make_sorting_header(_('Node'), 'h.hostid') : null,
-	($_REQUEST['hostid'] == 0) ? make_sorting_header(_('Host'), 'h.name') : NULL,
+	($_REQUEST['hostid'] < 1) ? make_sorting_header(_('Host'), 'h.name') : NULL,
 	make_sorting_header(_('Name'), 'i.name'),
 	make_sorting_header(_('Last check'), 'i.lastclock'),
 	_('Last value'),
@@ -230,7 +250,7 @@
 $hosts = API::Host()->get($options);
 
 // fetch scripts for the host JS menu
-if ($_REQUEST['hostid'] == 0) {
+if ($_REQUEST['hostid'] < 1) {
 	$hostScripts = API::Script()->getScriptsByHosts($options['hostids']);
 }
 
@@ -379,7 +415,7 @@
 	// host JS menu link
 
 	$hostSpan = null;
-	if ($_REQUEST['hostid'] == 0) {
+	if ($_REQUEST['hostid'] < 1) {
 		$hostSpan = new CSpan($host['name'], 'link_menu menu-host');
 		$scripts = $hostScripts[$host['hostid']];
 		$hostSpan->setAttribute('data-menu', hostMenuData($host, $scripts));
