mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge branch 'ent-3279-planned-downtime-creation-api-cli' into 'develop'
API/CLI: fixed planned downtime creation See merge request artica/pandorafms!2184 Former-commit-id: 84f21e2c9762af3a1c1c04c24dc6e35848c0f437
This commit is contained in:
commit
a54903d9c6
@ -6175,17 +6175,29 @@ function api_set_planned_downtimes_deleted($id, $thrash1, $thrash2, $returnType)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new planned downtime.
|
* Create a new planned downtime.
|
||||||
|
* e.g.: api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
||||||
*
|
*
|
||||||
* @param $id name of planned downtime.
|
* @param $id name of planned downtime.
|
||||||
* @param $thrash1 Don't use.
|
* @param $thrash1 Don't use.
|
||||||
* @param array $other it's array, $other as param is <description>;<date_from>;<date_to>;<id_group>;<monday>;
|
* @param array $other Contains the following elements (in order):
|
||||||
* <tuesday>;<wednesday>;<thursday>;<friday>;<saturday>;<sunday>;<periodically_time_from>;<periodically_time_to>;
|
* <description>
|
||||||
* <periodically_day_from>;<periodically_day_to>;<type_downtime>;<type_execution>;<type_periodicity>; in this order
|
* <date_from>
|
||||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
* <date_to>
|
||||||
* example:
|
* <id_group>
|
||||||
*
|
* <monday>
|
||||||
* api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
* <tuesday>
|
||||||
*
|
* <wednesday>
|
||||||
|
* <thursday>
|
||||||
|
* <friday>
|
||||||
|
* <saturday>
|
||||||
|
* <sunday>
|
||||||
|
* <periodically_time_from>
|
||||||
|
* <periodically_time_to>
|
||||||
|
* <periodically_day_from>
|
||||||
|
* <periodically_day_to>
|
||||||
|
* <type_downtime>
|
||||||
|
* <type_execution>
|
||||||
|
* <type_periodicity>
|
||||||
* @param $thrash3 Don't use.
|
* @param $thrash3 Don't use.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -6249,20 +6261,16 @@ function api_set_planned_downtimes_created($id, $thrash1, $other, $thrash3)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add new items to planned Downtime.
|
* Add new items to planned Downtime.
|
||||||
|
* e.g.: api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
||||||
*
|
*
|
||||||
* @param $id id of planned downtime.
|
* @param $id id of planned downtime.
|
||||||
* @param $thrash1 Don't use.
|
* @param $thrash1 Don't use.
|
||||||
* @param array $other it's array, $other as param is <id_agent1;id_agent2;id_agent3;....id_agentn;>;
|
* @param array $other
|
||||||
* <name_module1;name_module2;name_module3;......name_modulen;> in this order
|
* The first index contains a list of agent Ids.
|
||||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
* The second index contains a list of module names.
|
||||||
* example:
|
* The list separator is the character ';'.
|
||||||
*
|
|
||||||
* api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
|
||||||
*
|
|
||||||
* @param $thrash3 Don't use.
|
* @param $thrash3 Don't use.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
||||||
{
|
{
|
||||||
if (defined('METACONSOLE')) {
|
if (defined('METACONSOLE')) {
|
||||||
|
@ -725,8 +725,6 @@ function planned_downtimes_created($values)
|
|||||||
$check_group = (bool) db_get_value('id_grupo', 'tgrupo', 'id_grupo', $values['id_group']);
|
$check_group = (bool) db_get_value('id_grupo', 'tgrupo', 'id_grupo', $values['id_group']);
|
||||||
$check = (bool) db_get_value('name', 'tplanned_downtime', 'name', $values['name']);
|
$check = (bool) db_get_value('name', 'tplanned_downtime', 'name', $values['name']);
|
||||||
|
|
||||||
$datetime_from = strtotime($values['once_date_from'].' '.$values['once_time_from']);
|
|
||||||
$datetime_to = strtotime($values['once_date_to'].' '.$values['once_time_to']);
|
|
||||||
$now = time();
|
$now = time();
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
@ -735,16 +733,16 @@ function planned_downtimes_created($values)
|
|||||||
'return' => false,
|
'return' => false,
|
||||||
'message' => __('Not created. Error inserting data. Start time must be higher than the current time'),
|
'message' => __('Not created. Error inserting data. Start time must be higher than the current time'),
|
||||||
];
|
];
|
||||||
|
} else if ($values['type_execution'] == 'once' && !$config['past_planned_downtimes'] && $values['date_to'] <= $now) {
|
||||||
|
return [
|
||||||
|
'return' => false,
|
||||||
|
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||||
|
];
|
||||||
} else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) {
|
} else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) {
|
||||||
return [
|
return [
|
||||||
'return' => false,
|
'return' => false,
|
||||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'),
|
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'),
|
||||||
];
|
];
|
||||||
} else if ($values['type_execution'] == 'once' && $values['date_to'] <= $now) {
|
|
||||||
return [
|
|
||||||
'return' => false,
|
|
||||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
|
||||||
];
|
|
||||||
} else if ($values['type_execution'] == 'periodically'
|
} else if ($values['type_execution'] == 'periodically'
|
||||||
&& (($values['type_periodicity'] == 'weekly' && $values['periodically_time_from'] >= $values['periodically_time_to'])
|
&& (($values['type_periodicity'] == 'weekly' && $values['periodically_time_from'] >= $values['periodically_time_to'])
|
||||||
|| ($values['type_periodicity'] == 'monthly' && $values['periodically_day_from'] == $values['periodically_day_to'] && $values['periodically_time_from'] >= $values['periodically_time_to']))
|
|| ($values['type_periodicity'] == 'monthly' && $values['periodically_day_from'] == $values['periodically_day_to'] && $values['periodically_time_from'] >= $values['periodically_time_to']))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user