From 6ddcfcbb19a07037d4503af914bd4a50ee98b0c5 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Wed, 6 Feb 2019 12:51:02 +0100
Subject: [PATCH] Fixed code style lintern

Former-commit-id: d7757a56f8368761776f80f826600d601b56b6d9
---
 .../godmode/setup/setup_notifications.php     | 360 +++++++++---------
 .../include/functions_notifications.php       | 315 +++++++++------
 .../operation/users/user_edit_header.php      | 124 +++---
 3 files changed, 425 insertions(+), 374 deletions(-)

diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php
index bf842951aa..d315f14711 100644
--- a/pandora_console/godmode/setup/setup_notifications.php
+++ b/pandora_console/godmode/setup/setup_notifications.php
@@ -1,10 +1,9 @@
-<?php 
+<?php
 
 // Pandora FMS - http://pandorafms.com
 // ==================================================
 // Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
 // Please see http://pandorafms.org for full contribution list
-
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation for version 2.
@@ -12,103 +11,104 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
-
 // Warning: This file may be required into the metaconsole's setup
-
 // Load global vars
 global $config;
 
-require_once ($config['homedir'] . '/include/functions_notifications.php');
+require_once $config['homedir'].'/include/functions_notifications.php';
 
-check_login ();
+check_login();
 
 if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) {
     db_pandora_audit('ACL Violation', 'Trying to access Setup Management');
-    require ('general/noaccess.php');
+    include 'general/noaccess.php';
     return;
 }
 
 // AJAX actions.
 $source_id = get_parameter('source_id', '');
 $users = get_parameter('users', '');
-$elements = get_parameter('elements', array());
+$elements = get_parameter('elements', []);
 $id = empty($source_id) ? 0 : get_notification_source_id($source_id);
-$is_users = $users === "users";
+$is_users = $users === 'users';
 if (get_parameter('get_selection_two_ways_form', 0)) {
-	$info_selec = $is_users
-		? notifications_get_user_source_not_configured($id)
-		: notifications_get_group_source_not_configured($id);
+    $info_selec = $is_users ? notifications_get_user_source_not_configured($id) : notifications_get_group_source_not_configured($id);
 
-	echo notifications_print_two_ways_select(
-		$info_selec,
-		$users,
-		$source_id
-	);
-	return;
+    echo notifications_print_two_ways_select(
+        $info_selec,
+        $users,
+        $source_id
+    );
+    return;
 }
+
 if (get_parameter('add_source_to_database', 0)) {
-	$res = $is_users
-		? notifications_add_users_to_source($id, $elements)
-		: notifications_add_group_to_source($id, $elements);
-	$result = array(
-		'result' => $res
-	);
-	echo json_encode($result);
-	return;
+    $res = $is_users ? notifications_add_users_to_source($id, $elements) : notifications_add_group_to_source($id, $elements);
+    $result = ['result' => $res];
+    echo json_encode($result);
+    return;
 }
+
 if (get_parameter('remove_source_on_database', 0)) {
-	$res = $is_users
-		? notifications_remove_users_from_source($id, $elements)
-		: notifications_remove_group_from_source($id, $elements);
-	$result = array(
-		'result' => $res
-	);
-	echo json_encode($result);
-	return;
+    $res = $is_users ? notifications_remove_users_from_source($id, $elements) : notifications_remove_group_from_source($id, $elements);
+    $result = ['result' => $res];
+    echo json_encode($result);
+    return;
 }
 
 // Form actions.
 if (get_parameter('update_config', 0)) {
-	$res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){
-		$id = notifications_desc_to_id($source['description']);
-		if (empty($id)) return false;
-		$enable_value = switch_to_int(get_parameter("enable-$id"));
-		$mail_value = (int)get_parameter("mail-{$id}", 0);
-		$user_value = (int)get_parameter("user-{$id}", 0);
-		$postpone_value = (int)get_parameter("postpone-{$id}", 0);
-		$all_users = (int)get_parameter("all-{$id}", 0);
-		$res = db_process_sql_update(
-			'tnotification_source',
-			array(
-				'enabled' => $enable_value,
-				'user_editable' => $user_value,
-				'also_mail' => $mail_value,
-				'max_postpone_time' => $postpone_value
-			),
-			array('id' => $source['id'])
-		);
-		$all_users_res = $all_users
-			? notifications_add_group_to_source($source['id'], array(0))
-			: notifications_remove_group_from_source($source['id'], array(0));
-		return $all_users_res && $res && $carry;
-	}, true);
+    $res_global = array_reduce(
+        notifications_get_all_sources(),
+        function ($carry, $source) {
+            $id = notifications_desc_to_id($source['description']);
+            if (empty($id)) {
+                return false;
+            }
+
+            $enable_value = switch_to_int(get_parameter("enable-$id"));
+            $mail_value = (int) get_parameter("mail-{$id}", 0);
+            $user_value = (int) get_parameter("user-{$id}", 0);
+            $postpone_value = (int) get_parameter("postpone-{$id}", 0);
+            $all_users = (int) get_parameter("all-{$id}", 0);
+            $res = db_process_sql_update(
+                'tnotification_source',
+                [
+                    'enabled'           => $enable_value,
+                    'user_editable'     => $user_value,
+                    'also_mail'         => $mail_value,
+                    'max_postpone_time' => $postpone_value,
+                ],
+                ['id' => $source['id']]
+            );
+            $all_users_res = $all_users ? notifications_add_group_to_source($source['id'], [0]) : notifications_remove_group_from_source($source['id'], [0]);
+            return $all_users_res && $res && $carry;
+        },
+        true
+    );
 }
 
 // Notification table. It is just a wrapper.
 $table_content = new StdClass();
-$table_content->data = array();
+$table_content->data = [];
 $table_content->width = '100%';
 $table_content->id = 'notifications-wrapper';
 $table_content->class = 'databox filters';
 $table_content->size['name'] = '30%';
-$table_remote->style['name'] = 'font-weight: bold';
 
 // Print each source configuration
-$table_content->data = array_map(function ($source) {
-	return notifications_print_global_source_configuration($source);
-}, notifications_get_all_sources());
+$table_content->data = array_map(
+    function ($source) {
+        return notifications_print_global_source_configuration($source);
+    },
+    notifications_get_all_sources()
+);
 $table_content->data[] = html_print_submit_button(
-	__('Update'), 'update_button', false, 'class="sub upd" style="display: flex; "', true
+    __('Update'),
+    'update_button',
+    false,
+    'class="sub upd" style="display: flex; "',
+    true
 );
 
 echo '<form id="form_enable" method="post">';
@@ -121,151 +121,151 @@ echo '</form>';
 
 // Get the source id
 function notifications_get_source_id(id) {
-	var matched = id.match(/.*-(.*)/);
-	if (matched == null) return '';
-	return matched[1];
+    var matched = id.match(/.*-(.*)/);
+    if (matched == null) return '';
+    return matched[1];
 }
 
 // Get index of two ways element dialog.
 function notifications_two_ways_element_get_dialog (id, source_id) {
-	return 'global_config_notifications_dialog_add-' + id + '-' + source_id;
+    return 'global_config_notifications_dialog_add-' + id + '-' + source_id;
 }
 
 // Get index of two ways element form.
 function notifications_two_ways_element_get_sufix (id, source_id) {
-	return 'multi-' + id + '-' + source_id;
+    return 'multi-' + id + '-' + source_id;
 }
 
 // Disable or enable the select seeing the checked value of notify all users
 function notifications_disable_source(event) {
-	var id = notifications_get_source_id(event.target.id);
-	var is_checked = document.getElementById(event.target.id).checked;
-	var selectors = ['groups', 'users'];
-	selectors.map(function (select) {
-		document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked;
-	});
+    var id = notifications_get_source_id(event.target.id);
+    var is_checked = document.getElementById(event.target.id).checked;
+    var selectors = ['groups', 'users'];
+    selectors.map(function (select) {
+        document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked;
+    });
 }
 
 // Open a dialog with selector of source elements.
 function add_source_dialog(users, source_id) {
-	// Display the dialog
-	var dialog_id = notifications_two_ways_element_get_dialog(users, source_id);
-	// Clean id element.
-	var previous_dialog = document.getElementById(dialog_id);
-	if (previous_dialog !== null) previous_dialog.remove();
-	// Create or recreate the content.
-	var not_dialog = document.createElement('div');
-	not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper');
-	not_dialog.setAttribute('id', dialog_id);
-	document.body.appendChild(not_dialog);
-	$("#" + dialog_id).dialog({
-		resizable: false,
-		draggable: true,
-		modal: true,
-		dialogClass: "global_config_notifications_dialog_add_full",
-		overlay: {
-			opacity: 0.5,
-			background: "black"
-		},
-		closeOnEscape: true,
-		modal: true
-	});
+    // Display the dialog
+    var dialog_id = notifications_two_ways_element_get_dialog(users, source_id);
+    // Clean id element.
+    var previous_dialog = document.getElementById(dialog_id);
+    if (previous_dialog !== null) previous_dialog.remove();
+    // Create or recreate the content.
+    var not_dialog = document.createElement('div');
+    not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper');
+    not_dialog.setAttribute('id', dialog_id);
+    document.body.appendChild(not_dialog);
+    $("#" + dialog_id).dialog({
+        resizable: false,
+        draggable: true,
+        modal: true,
+        dialogClass: "global_config_notifications_dialog_add_full",
+        overlay: {
+            opacity: 0.5,
+            background: "black"
+        },
+        closeOnEscape: true,
+        modal: true
+    });
 
-	jQuery.post ("ajax.php",
-		{"page" : "godmode/setup/setup_notifications",
-			"get_selection_two_ways_form" : 1,
-			"users" : users,
-			"source_id" : source_id
-		},
-		function (data, status) {
-			not_dialog.innerHTML = data
-		},
-		"html"
-	);
+    jQuery.post ("ajax.php",
+        {"page" : "godmode/setup/setup_notifications",
+            "get_selection_two_ways_form" : 1,
+            "users" : users,
+            "source_id" : source_id
+        },
+        function (data, status) {
+            not_dialog.innerHTML = data
+        },
+        "html"
+    );
 }
 
 // Move from selected and not selected source elements.
 function notifications_modify_two_ways_element (id, source_id, operation) {
-	var index_sufix = notifications_two_ways_element_get_sufix (id, source_id);
-	var start_id = operation === 'add' ? 'all-' : 'selected-';
-	var end_id = operation !== 'add' ? 'all-' : 'selected-';
-	var select = document.getElementById(
-		start_id + index_sufix
-	);
-	var select_end = document.getElementById(
-		end_id + index_sufix
-	);
-	for (var i = select.options.length - 1; i >= 0; i--) {
-		if(select.options[i].selected){
-			select_end.appendChild(select.options[i]);
-		}
-	}
+    var index_sufix = notifications_two_ways_element_get_sufix (id, source_id);
+    var start_id = operation === 'add' ? 'all-' : 'selected-';
+    var end_id = operation !== 'add' ? 'all-' : 'selected-';
+    var select = document.getElementById(
+        start_id + index_sufix
+    );
+    var select_end = document.getElementById(
+        end_id + index_sufix
+    );
+    for (var i = select.options.length - 1; i >= 0; i--) {
+        if(select.options[i].selected){
+            select_end.appendChild(select.options[i]);
+        }
+    }
 }
 
 // Add elements to database and close dialog
 function notifications_add_source_element_to_database(id, source_id) {
-	var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id);
-	var select = document.getElementById(index);
-	var selected = [];
-	for (var i = select.options.length - 1; i >= 0; i--) {
-		selected.push(select.options[i].value);
-	}
-	jQuery.post ("ajax.php",
-		{"page" : "godmode/setup/setup_notifications",
-			"add_source_to_database" : 1,
-			"users" : id,
-			"source_id" : source_id,
-			"elements": selected
-		},
-		function (data, status) {
-			if (data.result) {
-				// Append to other element
-				var out_select = document.getElementById(
-					notifications_two_ways_element_get_sufix(id, source_id)
-				);
-				for (var i = select.options.length - 1; i >= 0; i--) {
-					out_select.appendChild(select.options[i]);
-				}
-				// Close the dialog
-				$("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close");
-			} else {
-				console.log("Cannot update element.");
-			}
-		},
-		"json"
-	);
+    var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id);
+    var select = document.getElementById(index);
+    var selected = [];
+    for (var i = select.options.length - 1; i >= 0; i--) {
+        selected.push(select.options[i].value);
+    }
+    jQuery.post ("ajax.php",
+        {"page" : "godmode/setup/setup_notifications",
+            "add_source_to_database" : 1,
+            "users" : id,
+            "source_id" : source_id,
+            "elements": selected
+        },
+        function (data, status) {
+            if (data.result) {
+                // Append to other element
+                var out_select = document.getElementById(
+                    notifications_two_ways_element_get_sufix(id, source_id)
+                );
+                for (var i = select.options.length - 1; i >= 0; i--) {
+                    out_select.appendChild(select.options[i]);
+                }
+                // Close the dialog
+                $("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close");
+            } else {
+                console.log("Cannot update element.");
+            }
+        },
+        "json"
+    );
 }
 
 // Add elements to database and remove it form main select
 function remove_source_elements(id, source_id) {
-	var index = notifications_two_ways_element_get_sufix(id, source_id);
-	var select = document.getElementById(index);
-	var selected = [];
-	var selected_index = [];
-	for (var i = select.options.length - 1; i >= 0; i--) {
-		if(select.options[i].selected){
-			selected.push(select.options[i].value);
-			selected_index.push(i);
-		}
-	}
-	jQuery.post ("ajax.php",
-		{"page" : "godmode/setup/setup_notifications",
-			"remove_source_on_database" : 1,
-			"users" : id,
-			"source_id" : source_id,
-			"elements": selected
-		},
-		function (data, status) {
-			if (data.result) {
-				// Append to other element
-				for (var i = selected_index.length - 1; i >= 0; i--) {
-					select.remove(selected_index[i]);
-				}
-			} else {
-				console.log("Cannot delete elements.");
-			}
-		},
-		"json"
-	);
+    var index = notifications_two_ways_element_get_sufix(id, source_id);
+    var select = document.getElementById(index);
+    var selected = [];
+    var selected_index = [];
+    for (var i = select.options.length - 1; i >= 0; i--) {
+        if(select.options[i].selected){
+            selected.push(select.options[i].value);
+            selected_index.push(i);
+        }
+    }
+    jQuery.post ("ajax.php",
+        {"page" : "godmode/setup/setup_notifications",
+            "remove_source_on_database" : 1,
+            "users" : id,
+            "source_id" : source_id,
+            "elements": selected
+        },
+        function (data, status) {
+            if (data.result) {
+                // Append to other element
+                for (var i = selected_index.length - 1; i >= 0; i--) {
+                    select.remove(selected_index[i]);
+                }
+            } else {
+                console.log("Cannot delete elements.");
+            }
+        },
+        "json"
+    );
 }
 </script>
diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php
index 9467c0ff92..ac030349ef 100644
--- a/pandora_console/include/functions_notifications.php
+++ b/pandora_console/include/functions_notifications.php
@@ -29,6 +29,7 @@
 
 define('NOTIFICATIONS_POSTPONE_FOREVER', -1);
 
+
 /**
  * Retrieves source ID for given source.
  *
@@ -49,6 +50,7 @@ function get_notification_source_id(string $source)
     );
 }
 
+
 /**
  * Converts description into a handable identifier
  *
@@ -56,12 +58,14 @@ function get_notification_source_id(string $source)
  *
  * @return string First word in lowercase. Empty string if no word detected.
  */
-function notifications_desc_to_id(string $desc) {
+function notifications_desc_to_id(string $desc)
+{
     preg_match('/^[a-zA-Z]*/', $desc, $matches);
     $match = $matches[0];
     return isset($match) ? $match : '';
 }
 
+
 /**
  * Retrieve all targets for given message.
  *
@@ -158,30 +162,36 @@ function check_notification_readable(int $id_message)
     return (bool) db_get_value_sql($sql);
 }
 
+
 /**
  * Return all info from tnotification_source
  *
  * @return array with sources info
  */
-function notifications_get_all_sources() {
-    return mysql_db_get_all_rows_in_table('tnotification_source');
+function notifications_get_all_sources()
+{
+    return db_get_all_rows_in_table('tnotification_source');
 }
 
+
 /**
  * Return the user sources to be inserted into a select
  *
- * @param int $source_id Source database identificator
+ * @param integer $source_id Source database identificator
  *
  * @return array with the user id in keys and user id in value too
  */
-function notifications_get_user_sources_for_select($source_id) {
+function notifications_get_user_sources_for_select($source_id)
+{
     $users = db_get_all_rows_filter(
         'tnotification_source_user',
-        array('id_source' => $source_id),
+        ['id_source' => $source_id],
         'id_user'
     );
     // If fails or no one is selected, return empty array
-    if ($users === false) return array();
+    if ($users === false) {
+        return [];
+    }
 
     return index_array($users, 'id_user', 'id_user');
 }
@@ -190,186 +200,231 @@ function notifications_get_user_sources_for_select($source_id) {
 /**
  * Return the groups sources to be inserted into a select
  *
- * @param int $source_id Source database identificator
+ * @param integer $source_id Source database identificator
  *
  * @return array with the group id in keys and group name in value
  */
-function notifications_get_group_sources_for_select($source_id) {
-    $groups = notifications_get_group_sources (
-        array('id_source' => $source_id),
-        array('id_group')
+function notifications_get_group_sources_for_select($source_id)
+{
+    $groups = notifications_get_group_sources(
+        ['id_source' => $source_id],
+        ['id_group']
     );
     return index_array($groups, 'id_group', 'name');
 }
 
+
 /**
  * Get the group sources
  *
  * @param array $filter Filter of sql query.
  */
-function notifications_get_group_sources ($filter = array(), $fields = array()) {
+function notifications_get_group_sources($filter=[], $fields=[])
+{
     // Get only the tnotifications_source_group fields in addition to group name.
-    if (empty($fields)) $fields[] = "tnsg.*";
-    $fields = array_map(function($field) {
-        if (!preg_match("/^tnsg./", $field)) $field = "tnsg.{$field}";
-        return $field;
-    }, $fields);
+    if (empty($fields)) {
+        $fields[] = 'tnsg.*';
+    }
+
+    $fields = array_map(
+        function ($field) {
+            if (!preg_match('/^tnsg./', $field)) {
+                $field = "tnsg.{$field}";
+            }
+
+            return $field;
+        },
+        $fields
+    );
 
     // Get groups.
     $groups = db_get_all_rows_filter(
         'tnotification_source_group tnsg
             LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo',
         $filter,
-        array_merge ($fields, array('IFNULL(tg.nombre, "All") AS name'))
+        array_merge($fields, ['IFNULL(tg.nombre, "All") AS name'])
     );
 
     // If fails or no one is selected, return empty array
-    if ($groups === false) return array();
+    if ($groups === false) {
+        return [];
+    }
+
     return $groups;
 }
 
+
 /**
  * Delete a set of groups from notification source
  *
  * @param int Source id
  * @param array Id of groups to be deleted
  *
- * @return bool True if success. False otherwise.
+ * @return boolean True if success. False otherwise.
  */
-function notifications_remove_group_from_source ($source_id, $groups) {
+function notifications_remove_group_from_source($source_id, $groups)
+{
     // Source id is mandatory
-    if (!isset($source_id)) return false;
+    if (!isset($source_id)) {
+        return false;
+    }
 
     // Delete from database
-    return db_process_sql_delete (
+    return db_process_sql_delete(
         'tnotification_source_group',
-        array(
-            'id_group' => $groups,
-            'id_source' => $source_id
-        )
+        [
+            'id_group'  => $groups,
+            'id_source' => $source_id,
+        ]
     ) !== false;
 }
 
+
 /**
  * Delete a set of users from notification source
  *
  * @param int Source id
  * @param array Id of users to be deleted
  *
- * @return bool True if success. False otherwise.
+ * @return boolean True if success. False otherwise.
  */
-function notifications_remove_users_from_source ($source_id, $users) {
+function notifications_remove_users_from_source($source_id, $users)
+{
     // Source id is mandatory
-    if (!isset($source_id)) return false;
+    if (!isset($source_id)) {
+        return false;
+    }
 
     // Delete from database
-    return db_process_sql_delete (
+    return db_process_sql_delete(
         'tnotification_source_user',
-        array(
-            'id_user' => $users,
-            'id_source' => $source_id
-        )
+        [
+            'id_user'   => $users,
+            'id_source' => $source_id,
+        ]
     ) !== false;
 }
 
+
 /**
  * Insert a set of groups to notification source
  *
  * @param int Source id
  * @param array Id of groups to be deleted
  *
- * @return bool True if success. False otherwise.
+ * @return boolean True if success. False otherwise.
  */
-function notifications_add_group_to_source ($source_id, $groups) {
+function notifications_add_group_to_source($source_id, $groups)
+{
     // Source id is mandatory
-    if (!isset($source_id)) return false;
+    if (!isset($source_id)) {
+        return false;
+    }
 
     // Insert into database all groups passed
     $res = true;
     foreach ($groups as $group) {
-        if (empty($group)) continue;
+        if (empty($group)) {
+            continue;
+        }
+
         $res = $res && db_process_sql_insert(
             'tnotification_source_group',
-            array(
-                'id_group' => $group,
-                'id_source' => $source_id)
-            ) !== false;
+            [
+                'id_group'  => $group,
+                'id_source' => $source_id,
+            ]
+        ) !== false;
     }
+
     return $res;
 }
 
+
 /**
  * Insert a set of users to notification source
  *
  * @param int Source id
  * @param array Id of users to be deleted
  *
- * @return bool True if success. False otherwise.
+ * @return boolean True if success. False otherwise.
  */
- function notifications_add_users_to_source ($source_id, $users) {
+function notifications_add_users_to_source($source_id, $users)
+{
     // Source id is mandatory
-    if (!isset($source_id)) return false;
+    if (!isset($source_id)) {
+        return false;
+    }
 
     // Insert into database all groups passed
     $res = true;
     foreach ($users as $user) {
-        if (empty($user)) continue;
+        if (empty($user)) {
+            continue;
+        }
+
         $res = $res && db_process_sql_insert(
             'tnotification_source_user',
-            array(
-                'id_user' => $user,
-                'id_source' => $source_id)
-            ) !== false;
+            [
+                'id_user'   => $user,
+                'id_source' => $source_id,
+            ]
+        ) !== false;
     }
+
     return $res;
 }
 
+
 /**
  * Get the groups that not own to a source and, for that reason, they can be
  * added to the source.
  *
- * @param int $source_id Source id.
+ * @param  integer $source_id Source id.
  * @return array Indexed by id group all selectable groups.
  */
-function notifications_get_group_source_not_configured ($source_id) {
+function notifications_get_group_source_not_configured($source_id)
+{
     $groups_selected = notifications_get_group_sources_for_select($source_id);
-    $all_groups = users_get_groups_for_select(false, "AR", false, true, $groups_selected);
+    $all_groups = users_get_groups_for_select(false, 'AR', false, true, $groups_selected);
     return array_diff($all_groups, $groups_selected);
 }
 
+
 /**
  * Get the users that not own to a source and, for that reason, they can be
  * added to the source.
  *
- * @param int $source_id
+ * @param  integer $source_id
  * @return array Indexed by id user, all selectable users.
  */
-function notifications_get_user_source_not_configured ($source_id) {
+function notifications_get_user_source_not_configured($source_id)
+{
     $users_selected = array_keys(notifications_get_user_sources_for_select($source_id));
     $users = get_users(
         'id_user',
-        array('!id_user' => $users_selected),
-        array('id_user')
+        ['!id_user' => $users_selected],
+        ['id_user']
     );
     return index_array($users, 'id_user', 'id_user');
 }
 
+
 /**
  * Print the notification ball to see unread messages
  *
  * @return string with HTML code of notification ball
  */
-function notifications_print_ball() {
+function notifications_print_ball()
+{
     $num_notifications = messages_get_count();
-    $class_status = $num_notifications == 0
-        ? 'notification-ball-no-messages'
-        : 'notification-ball-new-messages';
-    return
-        "<div class='notification-ball $class_status' id='notification-ball-header'>
+    $class_status = $num_notifications == 0 ? 'notification-ball-no-messages' : 'notification-ball-new-messages';
+    return "<div class='notification-ball $class_status' id='notification-ball-header'>
             $num_notifications
         </div>";
 }
 
+
 /**
  * Print notification configuration global
  *
@@ -377,58 +432,61 @@ function notifications_print_ball() {
  *
  * @return string with HTML of source configuration
  */
-function notifications_print_global_source_configuration($source) {
-
+function notifications_print_global_source_configuration($source)
+{
     // Get some values to generate the title
     $id = notifications_desc_to_id($source['description']);
-    $switch_values = array (
-        'name' => "enable-" . $id,
-        'value' => $source['enabled']
-    );
+    $switch_values = [
+        'name'  => 'enable-'.$id,
+        'value' => $source['enabled'],
+    ];
 
     // Search if group all is set and handle that situation
     $source_groups = notifications_get_group_sources_for_select($source['id']);
-    $is_group_all = isset($source_groups["0"]);
-    if($is_group_all) unset($source_groups["0"]);
+    $is_group_all = isset($source_groups['0']);
+    if ($is_group_all) {
+        unset($source_groups['0']);
+    }
 
     // Generate the title
     $html_title = "<div class='global-config-notification-title'>";
-    $html_title .=     html_print_switch($switch_values);
-    $html_title .=    "<h2>{$source['description']}</h2>";
-    $html_title .= "</div>";
+    $html_title .= html_print_switch($switch_values);
+    $html_title .= "<h2>{$source['description']}</h2>";
+    $html_title .= '</div>';
 
     // Generate the html for title
     $html_selectors = "<div class='global-config-notification-selectors'>";
-    $html_selectors .=       notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all);
-    $html_selectors .=       notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all);
-    $html_selectors .= "</div>";
+    $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all);
+    $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all);
+    $html_selectors .= '</div>';
 
     // Generate the checkboxes and time select
     $html_checkboxes = "<div class='global-config-notification-checkboxes'>";
-    $html_checkboxes .= "   <span>";
-    $html_checkboxes .=         html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)');
-    $html_checkboxes .=         __('Notify all users');
-    $html_checkboxes .= "   </span><br><span>";
-    $html_checkboxes .=         html_print_checkbox("mail-$id", 1, $source['also_mail'], true);
-    $html_checkboxes .=         __('Also email users with notification content');
-    $html_checkboxes .= "   </span><br><span>";
-    $html_checkboxes .=         html_print_checkbox("user-$id", 1, $source['user_editable'], true);
-    $html_checkboxes .=         __('Users cannot modify notification preferences');
-    $html_checkboxes .= "   </span>";
-    $html_checkboxes .= "</div>";
+    $html_checkboxes .= '   <span>';
+    $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)');
+    $html_checkboxes .= __('Notify all users');
+    $html_checkboxes .= '   </span><br><span>';
+    $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true);
+    $html_checkboxes .= __('Also email users with notification content');
+    $html_checkboxes .= '   </span><br><span>';
+    $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true);
+    $html_checkboxes .= __('Users cannot modify notification preferences');
+    $html_checkboxes .= '   </span>';
+    $html_checkboxes .= '</div>';
 
     // Generate the select with the time
     $html_select_pospone = __('Users can postpone notifications up to');
-    $html_select_pospone .= html_print_select (
-		array(
-            SECONDS_5MINUTES => __('5 minutes'),
-            SECONDS_15MINUTES => __('15 minutes'),
-            SECONDS_12HOURS => __('12 hours'),
-            SECONDS_1DAY => __('1 day'),
-            SECONDS_1WEEK => __('1 week'),
-            SECONDS_15DAYS => __('15 days'),
-            SECONDS_1MONTH => __('1 month'),
-            NOTIFICATIONS_POSTPONE_FOREVER => __('forever')),
+    $html_select_pospone .= html_print_select(
+        [
+            SECONDS_5MINUTES               => __('5 minutes'),
+            SECONDS_15MINUTES              => __('15 minutes'),
+            SECONDS_12HOURS                => __('12 hours'),
+            SECONDS_1DAY                   => __('1 day'),
+            SECONDS_1WEEK                  => __('1 week'),
+            SECONDS_15DAYS                 => __('15 days'),
+            SECONDS_1MONTH                 => __('1 month'),
+            NOTIFICATIONS_POSTPONE_FOREVER => __('forever'),
+        ],
         "postpone-{$id}",
         $source['max_postpone_time'],
         '',
@@ -438,58 +496,61 @@ function notifications_print_global_source_configuration($source) {
     );
 
     // Return all html
-    return $html_title . $html_selectors . $html_checkboxes . $html_select_pospone;
+    return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone;
 }
 
+
 /**
  * Print select boxes of notified users or groups
  *
- * @param array $info_selec All info required for build the selector
- * @param string $id users|groups
- * @param string $source_id Id of source
- * @param bool $disabled Disable the selectors
+ * @param array   $info_selec All info required for build the selector
+ * @param string  $id         users|groups
+ * @param string  $source_id  Id of source
+ * @param boolean $disabled   Disable the selectors
  *
  * @return string HTML with the generated selector
  */
-function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) {
-
-    $title = $id == "users" ? __('Notified users') : __('Notified groups');
-    $add_title = $id == "users" ? __('Add users') : __('Add groups');
-    $delete_title = $id == "users" ? __('Delete users') : __('Delete groups');
+function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled)
+{
+    $title = $id == 'users' ? __('Notified users') : __('Notified groups');
+    $add_title = $id == 'users' ? __('Add users') : __('Add groups');
+    $delete_title = $id == 'users' ? __('Delete users') : __('Delete groups');
 
     // Generate the HTML
     $html_select = "<div class='global-config-notification-single-selector'>";
-    $html_select .= "   <div>";
+    $html_select .= '   <div>';
     $html_select .= "       <h4>$title</h4>";
     // Put a true if empty sources to avoid to sow the 'None' value
-    $html_select .=         html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true,'', $disabled);
-    $html_select .= "   </div>";
+    $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true, '', $disabled);
+    $html_select .= '   </div>';
     $html_select .= "   <div class='global-notifications-icons'>";
-    $html_select .=         html_print_image('images/input_add.png', true, array('title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')"));
-    $html_select .=         html_print_image('images/input_delete.png', true, array('title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')"));
-    $html_select .= "   </div>";
-    $html_select .= "</div>";
+    $html_select .= html_print_image('images/input_add.png', true, ['title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')"]);
+    $html_select .= html_print_image('images/input_delete.png', true, ['title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')"]);
+    $html_select .= '   </div>';
+    $html_select .= '</div>';
     return $html_select;
 }
 
+
 /**
  * Print the select with right and left arrows to select new sources
  * (groups or users).
  *
- * @param array $info_selec Array with source info.
- * @param string $users users|groups.
- * @param source $source_id Source id.
+ * @param  array  $info_selec Array with source info.
+ * @param  string $users      users|groups.
+ * @param  source $source_id  Source id.
  * @return string HTML with the select code.
  */
-function notifications_print_two_ways_select($info_selec, $users, $source_id) {
+function notifications_print_two_ways_select($info_selec, $users, $source_id)
+{
     $html_select = "<div class='global_config_notifications_dialog_add'>";
-	$html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true,'');
-	$html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>";
-    $html_select .= html_print_image('images/darrowright.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')"));
-    $html_select .= html_print_image('images/darrowleft.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')"));
-	$html_select .= "</div>";
+    $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, '');
+    $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>";
+    $html_select .= html_print_image('images/darrowright.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')"]);
+    $html_select .= html_print_image('images/darrowleft.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')"]);
+    $html_select .= '</div>';
     $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, '');
-    $html_select .= "</div>";
+    $html_select .= '</div>';
     $html_select .= html_print_button(__('Add'), 'Add', false, "notifications_add_source_element_to_database('$users', '$source_id')", "class='sub add'", true);
 
     return $html_select;
diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php
index 99e0567e57..4b329eee77 100644
--- a/pandora_console/operation/users/user_edit_header.php
+++ b/pandora_console/operation/users/user_edit_header.php
@@ -4,7 +4,6 @@
 // ==================================================
 // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
 // Please see http://pandorafms.org for full contribution list
-
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation for version 2.
@@ -12,86 +11,77 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
-
-
 // Load global vars
 global $config;
 
-check_login ();
+check_login();
 
 enterprise_hook('open_meta_frame');
 
-include_once($config['homedir'] . "/include/functions_profile.php");
-include_once($config['homedir'] . '/include/functions_users.php');
-include_once ($config['homedir'] . '/include/functions_groups.php');
-include_once ($config['homedir'] . '/include/functions_visual_map.php');
+require_once $config['homedir'].'/include/functions_profile.php';
+require_once $config['homedir'].'/include/functions_users.php';
+require_once $config['homedir'].'/include/functions_groups.php';
+require_once $config['homedir'].'/include/functions_visual_map.php';
 
 $meta = false;
-if (enterprise_installed() && defined("METACONSOLE")) {
-	$meta = true;
+if (enterprise_installed() && defined('METACONSOLE')) {
+    $meta = true;
 }
 
-$id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter
-$status = get_parameter ("status", -1); // Flag to print action status message
-
-$user_info = get_user_info ($id);
-$id = $user_info["id_user"]; //This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem)
-
-if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM"))
-	AND ($id != $config["id_user"])) {
-
-	db_pandora_audit("ACL Violation","Trying to view a user without privileges");
-	require ("general/noaccess.php");
-	exit;
+$id = get_parameter_get('id', $config['id_user']);
+// ID given as parameter
+$status = get_parameter('status', -1);
+// Flag to print action status message
+$user_info = get_user_info($id);
+$id = $user_info['id_user'];
+// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem)
+if ((!check_acl($config['id_user'], users_get_groups($id), 'UM'))
+    and ($id != $config['id_user'])
+) {
+    db_pandora_audit('ACL Violation', 'Trying to view a user without privileges');
+    include 'general/noaccess.php';
+    exit;
 }
 
-//If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
-if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) {
-	$view_mode = false;
-}
-else {
-	$view_mode = true;
+// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info
+if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) {
+    $view_mode = false;
+} else {
+    $view_mode = true;
 }
 
-$urls = array();
+$urls = [];
 if (is_metaconsole()) {
-	user_meta_print_header();
-	$urls['main'] = 'index.php?sec=advanced&amp;sec2=advanced/users_setup&amp;tab=user_edit';
-}
-else {
-	$urls['main'] = "index.php?sec=workspace&amp;sec2=operation/users/user_edit";
-	$urls['notifications'] = "index.php?sec=workspace&amp;sec2=operation/users/user_edit_notifications";
-	$buttons = array(
-		'main' => array(
-			'active' => $_GET['sec2'] === 'operation/users/user_edit',
-			'text' =>
-				"<a href='{$urls['main']}'>".
-				html_print_image (
-					"images/user_green.png",
-					true,
-					array ("title" => __('User management'))
-				).'</a>'
-		),
-		'notifications' => array(
-			'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
-			'text' =>
-				"<a href='{$urls['notifications']}'>".
-				html_print_image (
-					"images/alerts_template.png",
-					true,
-					array ("title" => __('User notifications'))
-				).'</a>'
-		)
-	);
+    user_meta_print_header();
+    $urls['main'] = 'index.php?sec=advanced&amp;sec2=advanced/users_setup&amp;tab=user_edit';
+} else {
+    $urls['main'] = 'index.php?sec=workspace&amp;sec2=operation/users/user_edit';
+    $urls['notifications'] = 'index.php?sec=workspace&amp;sec2=operation/users/user_edit_notifications';
+    $buttons = [
+        'main'          => [
+            'active' => $_GET['sec2'] === 'operation/users/user_edit',
+            'text'   => "<a href='{$urls['main']}'>".html_print_image(
+                'images/user_green.png',
+                true,
+                ['title' => __('User management')]
+            ).'</a>',
+        ],
+        'notifications' => [
+            'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications',
+            'text'   => "<a href='{$urls['notifications']}'>".html_print_image(
+                'images/alerts_template.png',
+                true,
+                ['title' => __('User notifications')]
+            ).'</a>',
+        ],
+    ];
 
-	ui_print_page_header (
-		__('User detail editor'),
-		"images/op_workspace.png",
-		false,
-		"",
-		false,
-		$buttons
-	);
+    ui_print_page_header(
+        __('User detail editor'),
+        'images/op_workspace.png',
+        false,
+        '',
+        false,
+        $buttons
+    );
 }
-
-?>
\ No newline at end of file