mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
2012-10-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php: fixed the function "api_set_apply_all_policies". Fixes: #3576289 * include/functions.php, include/functions_filemanager.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7099 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c340567b3a
commit
ebc3460ff2
@ -1,3 +1,13 @@
|
|||||||
|
2012-10-26 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_api.php: fixed the function
|
||||||
|
"api_set_apply_all_policies".
|
||||||
|
|
||||||
|
Fixes: #3576289
|
||||||
|
|
||||||
|
* include/functions.php, include/functions_filemanager.php: cleaned
|
||||||
|
source code style.
|
||||||
|
|
||||||
2012-10-26 Ramon Novoa <rnovoa@artica.es>
|
2012-10-26 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* include/functions_reporting.php,
|
* include/functions_reporting.php,
|
||||||
|
@ -807,7 +807,7 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) {
|
|||||||
}
|
}
|
||||||
if (isset($other['data'][3])) {
|
if (isset($other['data'][3])) {
|
||||||
// Filter by name
|
// Filter by name
|
||||||
if ($other['data'][3] != ""){
|
if ($other['data'][3] != "") {
|
||||||
$where .= " AND nombre LIKE ('%" . $other['data'][3] . "%')";
|
$where .= " AND nombre LIKE ('%" . $other['data'][3] . "%')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2742,12 +2742,12 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) {
|
|||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
|
function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
|
||||||
if ($id == ""){
|
if ($id == "") {
|
||||||
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_policy cannot be left blank.'));
|
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_policy cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other['data'][0] == ""){
|
if ($other['data'][0] == "") {
|
||||||
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_agent cannot be left blank.'));
|
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_agent cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2755,7 +2755,7 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
|
|||||||
// Check if the agent exists
|
// Check if the agent exists
|
||||||
$result_agent = db_get_value ('id_agente', 'tagente', 'id_agente', (int) $other['data'][0]);
|
$result_agent = db_get_value ('id_agente', 'tagente', 'id_agente', (int) $other['data'][0]);
|
||||||
|
|
||||||
if (!$result_agent){
|
if (!$result_agent) {
|
||||||
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_agent doesn\'t exists.'));
|
returnError('error_add_agent_policy', __('Error adding agent to policy. Id_agent doesn\'t exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2768,7 +2768,7 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id_agent_policy === false){
|
if ($id_agent_policy === false) {
|
||||||
$success = enterprise_hook('policies_create_agent', array($other['data'][0], $id, true));
|
$success = enterprise_hook('policies_create_agent', array($other['data'][0], $id, true));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2780,7 +2780,6 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
|
|||||||
returnData('string', array('type' => 'string', 'data' => $success));
|
returnData('string', array('type' => 'string', 'data' => $success));
|
||||||
else
|
else
|
||||||
returnError('error_add_agent_policy', 'Error adding agent to policy.');
|
returnError('error_add_agent_policy', 'Error adding agent to policy.');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3575,7 +3574,7 @@ function api_set_update_snmp_module_policy($id, $thrash1, $other, $thrash3) {
|
|||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_apply_policy($id, $thrash1, $other, $thrash3) {
|
function api_set_apply_policy($id, $thrash1, $other, $thrash3) {
|
||||||
if ($id == ""){
|
if ($id == "") {
|
||||||
returnError('error_apply_policy', __('Error applying policy. Id_policy cannot be left blank.'));
|
returnError('error_apply_policy', __('Error applying policy. Id_policy cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3647,28 +3646,29 @@ function api_set_apply_policy($id, $thrash1, $other, $thrash3) {
|
|||||||
*
|
*
|
||||||
* @param $thrash3 Don't use
|
* @param $thrash3 Don't use
|
||||||
*/
|
*/
|
||||||
function api_set_apply_all_policies($id, $thrash1, $other, $thrash3) {
|
function api_set_apply_all_policies($thrash1, $thrash2, $other, $thrash3) {
|
||||||
$policies = array();
|
$policies = array();
|
||||||
|
|
||||||
# Get all policies
|
# Get all policies
|
||||||
$policies = enterprise_hook('policies_get_policies', array(false, false, false, true));
|
$policies = enterprise_hook('policies_get_policies', array(false, false, false, true));
|
||||||
|
|
||||||
if ($duplicated === ENTERPRISE_NOT_HOOK) {
|
if ($policies === ENTERPRISE_NOT_HOOK) {
|
||||||
returnError('error_apply_all_policy', __('Error applying all policies.'));
|
returnError('error_apply_all_policy', __('Error applying all policies.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_policies = count($policies);
|
$num_policies = count($policies);
|
||||||
$count_results = 0;
|
$count_results = 0;
|
||||||
foreach ($policies as $policy){
|
foreach ($policies as $policy) {
|
||||||
$return_value = set_apply_policy($policy['id'], '', 'return', '');
|
$return_value = enterprise_hook('add_policy_queue_operation',
|
||||||
|
array($policy['id'], 0, 'apply'));
|
||||||
|
|
||||||
if ($return_value != -1){
|
if ($return_value != -1) {
|
||||||
$count_results++;
|
$count_results++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($num_policies > $count_results){
|
if ($num_policies > $count_results) {
|
||||||
$errors = $num_policies - $count_results;
|
$errors = $num_policies - $count_results;
|
||||||
|
|
||||||
returnError('error_apply_policy', 'Error applying policy. ' . $errors . ' failed. ');
|
returnError('error_apply_policy', 'Error applying policy. ' . $errors . ' failed. ');
|
||||||
@ -3700,26 +3700,26 @@ function api_set_apply_all_policies($id, $thrash1, $other, $thrash3) {
|
|||||||
function api_set_create_group($id, $thrash1, $other, $thrash3) {
|
function api_set_create_group($id, $thrash1, $other, $thrash3) {
|
||||||
$group_name = $id;
|
$group_name = $id;
|
||||||
|
|
||||||
if ($id == ""){
|
if ($id == "") {
|
||||||
returnError('error_create_group', __('Error in group creation. Group_name cannot be left blank.'));
|
returnError('error_create_group', __('Error in group creation. Group_name cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other['data'][0] == ""){
|
if ($other['data'][0] == "") {
|
||||||
returnError('error_create_group', __('Error in group creation. Icon_name cannot be left blank.'));
|
returnError('error_create_group', __('Error in group creation. Icon_name cannot be left blank.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other['data'][1] != ""){
|
if ($other['data'][1] != "") {
|
||||||
$group = groups_get_group_by_id($other['data'][1]);
|
$group = groups_get_group_by_id($other['data'][1]);
|
||||||
|
|
||||||
if ($group == false){
|
if ($group == false) {
|
||||||
returnError('error_create_group', __('Error in group creation. Id_parent_group doesn\'t exists.'));
|
returnError('error_create_group', __('Error in group creation. Id_parent_group doesn\'t exists.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other['data'][1] != ""){
|
if ($other['data'][1] != "") {
|
||||||
$values = array(
|
$values = array(
|
||||||
'icon' => $other['data'][0],
|
'icon' => $other['data'][0],
|
||||||
'parent' => $other['data'][1]
|
'parent' => $other['data'][1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user