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:
mdtrooper 2012-10-26 17:37:57 +00:00
parent 4c16ac1d13
commit 16324125b9
4 changed files with 69 additions and 59 deletions

View File

@ -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>
* include/functions_reporting.php,

View File

@ -807,7 +807,7 @@ function api_get_all_agents($thrash1, $thrash2, $other, $thrash3) {
}
if (isset($other['data'][3])) {
// Filter by name
if ($other['data'][3] != ""){
if ($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
*/
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.'));
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.'));
return;
}
@ -2755,7 +2755,7 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
// Check if the agent exists
$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.'));
return;
}
@ -2768,7 +2768,7 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
return;
}
if ($id_agent_policy === false){
if ($id_agent_policy === false) {
$success = enterprise_hook('policies_create_agent', array($other['data'][0], $id, true));
}
else {
@ -2780,7 +2780,6 @@ function api_set_add_agent_policy($id, $thrash1, $other, $thrash3) {
returnData('string', array('type' => 'string', 'data' => $success));
else
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
*/
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.'));
return;
}
@ -3647,28 +3646,29 @@ function api_set_apply_policy($id, $thrash1, $other, $thrash3) {
*
* @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();
# Get all policies
$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.'));
return;
}
$num_policies = count($policies);
$count_results = 0;
foreach ($policies as $policy){
$return_value = set_apply_policy($policy['id'], '', 'return', '');
foreach ($policies as $policy) {
$return_value = enterprise_hook('add_policy_queue_operation',
array($policy['id'], 0, 'apply'));
if ($return_value != -1){
if ($return_value != -1) {
$count_results++;
}
}
if ($num_policies > $count_results){
if ($num_policies > $count_results) {
$errors = $num_policies - $count_results;
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) {
$group_name = $id;
if ($id == ""){
if ($id == "") {
returnError('error_create_group', __('Error in group creation. Group_name cannot be left blank.'));
return;
}
if ($other['data'][0] == ""){
if ($other['data'][0] == "") {
returnError('error_create_group', __('Error in group creation. Icon_name cannot be left blank.'));
return;
}
if ($other['data'][1] != ""){
if ($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.'));
return;
}
}
if ($other['data'][1] != ""){
if ($other['data'][1] != "") {
$values = array(
'icon' => $other['data'][0],
'parent' => $other['data'][1]