diff -urN zabbix-2.2.6.org/frontends/php/api/classes/CMaintenance.php zabbix-2.2.6.ZBX-8884/frontends/php/api/classes/CMaintenance.php --- zabbix-2.2.6.org/frontends/php/api/classes/CMaintenance.php 2014-08-27 22:07:26.000000000 +0900 +++ zabbix-2.2.6.ZBX-8884/frontends/php/api/classes/CMaintenance.php 2014-10-10 22:35:49.000000000 +0900 @@ -484,23 +484,33 @@ } // Checking whether a maintenance with this name already exists. First, getting all maintenances with the same name as this - $receivedMaintenances = API::Maintenance()->get(array( - 'filter' => array('name' => $maintenance['name']) - )); + if (isset($maintenance['name'])) { + $receivedMaintenances = API::Maintenance()->get(array( + 'filter' => array('name' => $maintenance['name']) + )); - // validate if maintenance name already exists - foreach ($receivedMaintenances as $rMaintenance) { - if (bccomp($rMaintenance['maintenanceid'], $maintenance['maintenanceid']) != 0) { - self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%s" already exists.', $maintenance['name'])); + // validate if maintenance name already exists + foreach ($receivedMaintenances as $rMaintenance) { + if (bccomp($rMaintenance['maintenanceid'], $maintenance['maintenanceid']) != 0) { + self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%s" already exists.', $maintenance['name'])); + } } } // validate maintenance active since + if (!isset($maintenance['active_since'])) { + // if not set, then existing value is assumed. + $maintenance['active_since'] = $updMaintenances[$maintenance['maintenanceid']]['active_since']; + } if (!validateUnixTime($maintenance['active_since'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active since'))); } // validate maintenance active till + if (!isset($maintenance['active_till'])) { + // if not set, then existing value is assumed. + $maintenance['active_till'] = $updMaintenances[$maintenance['maintenanceid']]['active_till']; + } if (!validateUnixTime($maintenance['active_till'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active till'))); } @@ -511,6 +521,10 @@ } // validate timeperiods + if (!isset($maintenance['timeperiods'])) { + // if not set, then existing value is assumed. + $maintenance['timeperiods'] = $updMaintenances[$maintenance['maintenanceid']]['timeperiods']; + } if (empty($maintenance['timeperiods'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.')); } @@ -551,6 +565,14 @@ } } + // if timeperiods not set, then existing value is assumed. + foreach ($maintenances as &$maintenance) { + if (!isset($maintenance['timeperiods'])) { + $maintenance['timeperiods'] = $updMaintenances[$maintenance['maintenanceid']]['timeperiods']; + } + } + unset($maintenance); + $this->removeSecondsFromTimes($maintenances); $update = array();