2007-02-06 Sancho Lerena <slerena@artica.es>
* include/functions.php: Pagination function now works fine. * operation/incidents/incident.php, indicent_detail.: Incident update/inser goes to main incident view. More usable interface. Pagination works fine, needs to adjust SQL to use LIMIT syntax for more optimized code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@373 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
169f607b66
commit
cae70f66b5
|
@ -1,3 +1,12 @@
|
|||
2007-02-06 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* include/functions.php: Pagination function now works fine.
|
||||
|
||||
* operation/incidents/incident.php, indicent_detail.: Incident
|
||||
update/inser goes to main incident view. More usable
|
||||
interface. Pagination works fine, needs to adjust SQL to use LIMIT
|
||||
syntax for more optimized code.
|
||||
|
||||
2007-02-05 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* include/functions_db.php: Added function to get
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
// Pandora - the Free monitoring system
|
||||
// ====================================
|
||||
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
|
||||
// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas, info@artica.es
|
||||
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
|
||||
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
|
||||
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
|
||||
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
|
||||
// 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; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
// as published by the Free Software Foundation; version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
|
|
|
@ -408,7 +408,7 @@ function pagination ($count, $url, $offset ) {
|
|||
|
||||
// This calculate index_limit, block limit for this search.
|
||||
if (($index_page + $block_limit) > $index_counter)
|
||||
$index_limit = $index_counter - 1;
|
||||
$index_limit = $index_counter;
|
||||
else
|
||||
$index_limit = $index_page + $block_limit;
|
||||
|
||||
|
@ -435,13 +435,14 @@ function pagination ($count, $url, $offset ) {
|
|||
echo " ";
|
||||
// Show PREVIOUS button
|
||||
if ($index_page > 0){
|
||||
$index_page_prev= ($index_page-$block_limit)*$block_size;
|
||||
$index_page_prev= ($index_page-(floor($block_limit/2)))*$block_size;
|
||||
if ($index_page_prev < 0)
|
||||
$index_page_prev = 0;
|
||||
echo '<a href="'.$url.'&offset='.$index_page_prev.'"><img src="images/control_rewind_blue.png"></a> ';
|
||||
}
|
||||
|
||||
// Draw blocks markers
|
||||
// $i stores number of page
|
||||
for ($i = $inicio_pag; $i < $index_limit; $i++) {
|
||||
$inicio_bloque = ($i * $block_size);
|
||||
$final_bloque = $inicio_bloque + $block_size;
|
||||
|
@ -449,33 +450,40 @@ function pagination ($count, $url, $offset ) {
|
|||
$final_bloque = ($i-1)*$block_size + $count-(($i-1) * $block_size);
|
||||
}
|
||||
echo "<span>";
|
||||
echo '<a href="'.$url.'&offset='.$inicio_bloque.'">';
|
||||
|
||||
$inicio_bloque_fake = $inicio_bloque + 1;
|
||||
// Show NEXT PAGE
|
||||
if (($i >= $inicio_pag + $block_limit) AND ($paginacion_maxima == 1)){
|
||||
// To Calculate last block (doesnt end with round data,
|
||||
// it must be shown if not round to block limit)
|
||||
echo '<a href="'.$url.'&offset='.$inicio_bloque.'">';
|
||||
if ($inicio_bloque == $offset)
|
||||
echo "<b>[ $i ]</b>";
|
||||
else
|
||||
echo "[ $i ]";
|
||||
echo '</a> ';
|
||||
echo "</span>";
|
||||
}
|
||||
// Show NEXT PAGE (fast forward)
|
||||
// Index_counter stores max of blocks
|
||||
if (($paginacion_maxima == 1) AND (($index_counter - $i) > 0)) {
|
||||
$prox_bloque = ($i+ceil($block_limit/2))*$block_size;
|
||||
if ($prox_bloque > $count)
|
||||
$prox_bloque = ($count -1) - $block_size;
|
||||
echo '<a href="'.$url.'&offset='.$prox_bloque.'">';
|
||||
echo "<img src='images/control_fastforward_blue.png'></a> ";
|
||||
$i = $index_counter;
|
||||
}
|
||||
else { // Calculate last block (doesnt end with round data, it must be shown if not round to block limit)
|
||||
if ($inicio_bloque == $offset)
|
||||
echo "<b>[ $i ]</b>";
|
||||
else
|
||||
echo "[ $i ]";
|
||||
echo '</a> ';
|
||||
}
|
||||
echo "</span>";
|
||||
}
|
||||
// if exists more registers than i can put in a page (defined by $block_size config parameter)
|
||||
// get offset for index calculation
|
||||
|
||||
}
|
||||
// Draw "last" block link
|
||||
if (($count - $block_size) > 0){
|
||||
echo ' <a href="'.$url.'&offset='.($count - $block_size).'">';
|
||||
echo "<img src='images/control_end_blue.png'>";
|
||||
echo "</a>";
|
||||
}
|
||||
// Draw "last" block link, ajust for last block will be the same
|
||||
// as painted in last block (last integer block).
|
||||
if (($count - $block_size) > 0){
|
||||
$myoffset = floor(($count-1)/ $block_size)* $block_size;
|
||||
echo ' <a href="'.$url.'&offset='.$myoffset.'">';
|
||||
echo "<img src='images/control_end_blue.png'>";
|
||||
echo "</a>";
|
||||
}
|
||||
// End div and layout
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
|
|
|
@ -18,21 +18,22 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
|
||||
$accion = "";
|
||||
require("include/config.php");
|
||||
if (comprueba_login() != 0) {
|
||||
audit_db("Noauth",$REMOTE_ADDR, "No authenticated acces","Trying to access incident viewer");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id_usuario =$_SESSION["id_usuario"];
|
||||
$accion = "";
|
||||
if (give_acl($id_usuario, 0, "IR")!=1) {
|
||||
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access incident viewer");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete incident
|
||||
if (isset($_GET["quick_delete"])){
|
||||
$id_inc = $_GET["quick_delete"];
|
||||
$sql2="SELECT * FROM tincidencia WHERE id_incidencia=".$id_inc;
|
||||
|
@ -52,6 +53,54 @@ if (isset($_GET["quick_delete"])){
|
|||
}
|
||||
}
|
||||
|
||||
// UPDATE incident
|
||||
if ((isset($_GET["action"])) AND ($_GET["action"]=="update")){
|
||||
$id_inc = $_POST["id_inc"];
|
||||
$grupo = entrada_limpia($_POST['grupo_form']);
|
||||
$usuario= entrada_limpia($_POST["usuario_form"]);
|
||||
if ((give_acl($id_usuario, $grupo, "IM")==1) OR ($usuario == $id_usuario)) { // Only admins (manage incident) or owners can modify incidents
|
||||
$id_author_inc = give_incident_author($id_inc);
|
||||
$titulo = entrada_limpia($_POST["titulo"]);
|
||||
$descripcion = entrada_limpia($_POST['descripcion']);
|
||||
$origen = entrada_limpia($_POST['origen_form']);
|
||||
$prioridad = entrada_limpia($_POST['prioridad_form']);
|
||||
$estado = entrada_limpia($_POST["estado_form"]);
|
||||
$ahora=date("Y/m/d H:i:s");
|
||||
$sql = "UPDATE tincidencia SET actualizacion = '".$ahora."', titulo = '".$titulo."', origen= '".$origen."', estado = '".$estado."', id_grupo = '".$grupo."', id_usuario = '".$usuario."', prioridad = '".$prioridad."', descripcion = '".$descripcion."' WHERE id_incidencia = ".$id_inc;
|
||||
$result=mysql_query($sql);
|
||||
if ($result)
|
||||
echo "<h3 class='suc'>".$lang_label["upd_incid_ok"]."</h3>";
|
||||
} else {
|
||||
audit_db($id_usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to update incident");
|
||||
echo "<h3 class='error'>".$lang_label["upd_incid_no"]."</h3>";
|
||||
no_permission();
|
||||
}
|
||||
}
|
||||
// INSERT incident
|
||||
if ((isset($_GET["action"])) AND ($_GET["action"]=="insert")){
|
||||
$grupo = entrada_limpia($_POST['grupo_form']);
|
||||
$usuario= entrada_limpia($_POST["usuario_form"]);
|
||||
if ((give_acl($id_usuario, $grupo, "IM") == 1) OR ($usuario == $id_usuario)) { // Only admins (manage
|
||||
// Read input variables
|
||||
$titulo = entrada_limpia($_POST['titulo']);
|
||||
$inicio = date("Y/m/d H:i:s");
|
||||
$descripcion = entrada_limpia($_POST['descripcion']);
|
||||
$texto = $descripcion; // to view in textarea after insert
|
||||
$origen = entrada_limpia($_POST['origen_form']);
|
||||
$prioridad = entrada_limpia($_POST['prioridad_form']);
|
||||
$actualizacion = $inicio;
|
||||
$id_creator = $id_usuario;
|
||||
$estado = entrada_limpia($_POST["estado_form"]);
|
||||
$sql = " INSERT INTO tincidencia (inicio,actualizacion,titulo,descripcion,id_usuario,origen,estado,prioridad,id_grupo, id_creator) VALUES ('".$inicio."','".$actualizacion."','".$titulo."','".$descripcion."','".$usuario."','".$origen."','".$estado."','".$prioridad."','".$grupo."','".$id_creator."') ";
|
||||
if (mysql_query($sql))
|
||||
echo "<h3 class='suc'>".$lang_label["create_incid_ok"]."</h3>";
|
||||
$id_inc=mysql_insert_id();
|
||||
} else {
|
||||
audit_db($id_usuario,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to create incident");
|
||||
no_permission();
|
||||
}
|
||||
}
|
||||
|
||||
// Search
|
||||
$busqueda="";
|
||||
if (isset($_POST["texto"]) OR (isset($_GET["texto"]))){
|
||||
|
@ -259,8 +308,7 @@ if (!mysql_num_rows($result2)) {
|
|||
// Fill array with data
|
||||
|
||||
// TOTAL incidents
|
||||
$total_incidentes = sizeof($incident_list);
|
||||
|
||||
$total_incidentes = sizeof($incident_list) - 1;
|
||||
$url = "index.php?sec=incidencias&sec2=operation/incidents/incident";
|
||||
|
||||
// add form filter values for group, priority, state, and search fields: user and text
|
||||
|
|
|
@ -89,49 +89,6 @@ if (isset($_GET["id"])){
|
|||
$res4 = mysql_query($sql4);
|
||||
}
|
||||
|
||||
// Modify incident
|
||||
if (isset($_POST["accion"])){
|
||||
$id_inc = $_POST["id_inc"];
|
||||
if ((give_acl($iduser_temp, $id_grupo, "IM")==1) OR ($usuario == $iduser_temp)) { // Only admins (manage incident) or owners can modify incidents
|
||||
// Edicion !!
|
||||
if ($_POST["accion"] == $lang_label["in_modinc"]){ // Modify Incident
|
||||
$id_author_inc = give_incident_author($id_inc);
|
||||
$titulo = entrada_limpia($_POST["titulo"]);
|
||||
$descripcion = entrada_limpia($_POST['descripcion']);
|
||||
$origen = entrada_limpia($_POST['origen']);
|
||||
$prioridad = entrada_limpia($_POST['prioridad']);
|
||||
$grupo = entrada_limpia($_POST['grupo']);
|
||||
$usuario= entrada_limpia($_POST["usuario"]);
|
||||
$estado = entrada_limpia($_POST["estado"]);
|
||||
$ahora=date("Y/m/d H:i:s");
|
||||
$sql = "UPDATE tincidencia SET actualizacion = '".$ahora."', titulo = '".$titulo."', origen= '".$origen."', estado = '".$estado."', id_grupo = '".$grupo."', id_usuario = '".$usuario."', prioridad = '".$prioridad."', descripcion = '".$descripcion."' WHERE id_incidencia = ".$id_inc;
|
||||
$result=mysql_query($sql);
|
||||
if ($result) echo "<h3 class='suc'>".$lang_label["upd_incid_ok"]."</h3>";
|
||||
// Re-read data for correct presentation
|
||||
// Obtain group of this incident
|
||||
$sql1='SELECT * FROM tincidencia WHERE id_incidencia = '.$id_inc;
|
||||
$result=mysql_query($sql1);
|
||||
$row=mysql_fetch_array($result);
|
||||
// Get values
|
||||
$titulo = $row["titulo"];
|
||||
$texto = $row["descripcion"];
|
||||
$inicio = $row["inicio"];
|
||||
$actualizacion = $row["actualizacion"];
|
||||
$estado = $row["estado"];
|
||||
$prioridad = $row["prioridad"];
|
||||
$origen = $row["origen"];
|
||||
$usuario = $row["id_usuario"];
|
||||
$nombre_real = dame_nombre_real($usuario);
|
||||
$id_grupo = $row["id_grupo"];
|
||||
$grupo = dame_nombre_grupo($id_grupo);
|
||||
}
|
||||
} else {
|
||||
audit_db($id_author_inc,$REMOTE_ADDR,"ACL Forbidden","User ".$_SESSION["id_usuario"]." try to update incident");
|
||||
echo "<h3 class='error'>".$lang_label["upd_incid_no"]."</h3>";
|
||||
no_permission();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete note
|
||||
if (isset($_GET["id_nota"])){
|
||||
$note_user = give_note_author ($_GET["id_nota"]);
|
||||
|
@ -190,30 +147,10 @@ if (isset($_GET["id"])){
|
|||
}
|
||||
}
|
||||
}
|
||||
} else { // Not given id
|
||||
// Insert data !
|
||||
if (isset($_POST["accion"]) and ($_POST["accion"] == $lang_label["create"])) {
|
||||
$iduser_temp=$_SESSION['id_usuario'];
|
||||
// Read input variables
|
||||
$titulo = entrada_limpia($_POST['titulo']);
|
||||
$inicio = date("Y/m/d H:i:s");
|
||||
$descripcion = entrada_limpia($_POST['descripcion']);
|
||||
$texto = $descripcion; // to view in textarea after insert
|
||||
$origen = entrada_limpia($_POST['origen']);
|
||||
$prioridad = entrada_limpia($_POST['prioridad']);
|
||||
$grupo = entrada_limpia($_POST['grupo']);
|
||||
$usuario= entrada_limpia($_SESSION["id_usuario"]);
|
||||
$actualizacion = $inicio;
|
||||
$id_creator = $iduser_temp;
|
||||
$estado = 0; // if the indicent is new, state (estado) is 0
|
||||
$sql = " INSERT INTO tincidencia (inicio,actualizacion,titulo,descripcion,id_usuario,origen,estado,prioridad,id_grupo, id_creator) VALUES ('".$inicio."','".$actualizacion."','".$titulo."','".$descripcion."','".$usuario."','".$origen."','".$estado."','".$prioridad."','".$grupo."','".$id_creator."') ";
|
||||
if (give_acl($iduser_temp, $grupo, "IW")==1){
|
||||
if (mysql_query($sql)) echo "<h3 class='suc'>".$lang_label["create_incid_ok"]."</h3>";
|
||||
$id_inc=mysql_insert_id();
|
||||
} else
|
||||
no_permission();
|
||||
// INSERT FORM.
|
||||
} elseif (isset($_GET["insert_form"])){
|
||||
} // else Not given id
|
||||
// Create incident from event... read event data
|
||||
elseif (isset($_GET["insert_form"])){
|
||||
|
||||
$iduser_temp=$_SESSION['id_usuario'];
|
||||
$titulo = "";
|
||||
if (isset($_GET["from_event"])){
|
||||
|
@ -235,22 +172,23 @@ if (isset($_GET["id"])){
|
|||
$inicio = $actualizacion;
|
||||
$id_creator = $iduser_temp;
|
||||
$creacion_incidente = 1;
|
||||
} else {
|
||||
audit_db($id_user,$REMOTE_ADDR, "HACK","Trying to create incident in a unusual way");
|
||||
no_permission();
|
||||
|
||||
}
|
||||
} else {
|
||||
audit_db($id_user,$REMOTE_ADDR, "HACK","Trying to create incident in a unusual way");
|
||||
no_permission();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ********************************************************************************************************
|
||||
// ********************************************************************************************************
|
||||
// Show the form
|
||||
// ********************************************************************************************************
|
||||
|
||||
if ($creacion_incidente == 0)
|
||||
echo "<form name='accion_form' method='POST' action='index.php?sec=incidencias&sec2=operation/incidents/incident_detail&id=".$id_inc."'>";
|
||||
echo "<form name='accion_form' method='POST' action='index.php?sec=incidencias&sec2=operation/incidents/incident&action=update'>";
|
||||
else
|
||||
echo "<form name='accion_form' method='POST' action='index.php?sec=incidencias&sec2=operation/incidents/incident_detail'>";
|
||||
echo "<form name='accion_form' method='POST' action='index.php?sec=incidencias&sec2=operation/incidents/incident&action=insert'>";
|
||||
|
||||
if (isset($id_inc)) {
|
||||
echo "<input type='hidden' name='id_inc' value='".$id_inc."'>";
|
||||
|
@ -272,7 +210,7 @@ echo '<td class="datos2"><b>'.$lang_label["updated_at"].'</b>';
|
|||
echo "<td class='datos2'><i>".$actualizacion."</i>";
|
||||
echo '<tr><td class="datos"><b>'.$lang_label["in_openedby"].'</b><td class="datos">';
|
||||
if ((give_acl($id_user, $id_grupo, "IM")==1) OR ($usuario == $id_user)) {
|
||||
echo "<select name='usuario' class='w200'>";
|
||||
echo "<select name='usuario_form' class='w200'>";
|
||||
echo "<option value='".$usuario."'>".$usuario." - ".dame_nombre_real($usuario);
|
||||
$sql1='SELECT * FROM tusuario ORDER BY id_usuario';
|
||||
$result=mysql_query($sql1);
|
||||
|
@ -282,7 +220,7 @@ if ((give_acl($id_user, $id_grupo, "IM")==1) OR ($usuario == $id_user)) {
|
|||
echo "</select>";
|
||||
}
|
||||
else {
|
||||
echo "<input type=hidden name='usuario' value='".$usuario."'>";
|
||||
echo "<input type=hidden name='usuario_form2' value='".$usuario."'>";
|
||||
echo $usuario." - (<i><a href='index.php?sec=usuario&sec2=operation/users/user_edit&ver=".$usuario."'>".$nombre_real."</a></i>)";
|
||||
}
|
||||
// Tipo de estado
|
||||
|
@ -293,9 +231,9 @@ else {
|
|||
// 13 - Cerrada / Closed
|
||||
|
||||
if ((give_acl($iduser_temp, $id_grupo, "IM")==1) OR ($usuario == $iduser_temp))
|
||||
echo '<td class="datos"><b>'.$lang_label["status"].'</b><td class="datos"><select name="estado" class="w135">';
|
||||
echo '<td class="datos"><b>'.$lang_label["status"].'</b><td class="datos"><select name="estado_form" class="w135">';
|
||||
else
|
||||
echo '<td class="datos"><b>'.$lang_label["status"].'</b><td class="datos"><select disabled name="estado" class="w135">';
|
||||
echo '<td class="datos"><b>'.$lang_label["status"].'</b><td class="datos"><select disabled name="estado_form" class="w135">';
|
||||
|
||||
switch ( $estado ){
|
||||
case 0: echo '<option value="0">'.$lang_label["in_state_0"]; break;
|
||||
|
@ -314,9 +252,9 @@ echo '</select>';
|
|||
|
||||
// Only owner could change source or user with Incident management privileges
|
||||
if ((give_acl($iduser_temp, $id_grupo, "IM")==1) OR ($usuario == $iduser_temp))
|
||||
echo '<tr><td class="datos2"><b>'.$lang_label["source"].'</b><td class="datos2"><select name="origen" class="w135">';
|
||||
echo '<tr><td class="datos2"><b>'.$lang_label["source"].'</b><td class="datos2"><select name="origen_form" class="w135">';
|
||||
else
|
||||
echo '<tr><td class="datos2"><b>'.$lang_label["source"].'</b><td class="datos2"><select disabled name="origen" class="w135">';
|
||||
echo '<tr><td class="datos2"><b>'.$lang_label["source"].'</b><td class="datos2"><select disabled name="origen_form" class="w135">';
|
||||
|
||||
// Fill combobox with source (origen)
|
||||
if ($origen != "")
|
||||
|
@ -330,9 +268,9 @@ echo "</select>";
|
|||
|
||||
// Group combo
|
||||
if ((give_acl($iduser_temp, $id_grupo, "IM")==1) OR ($usuario == $iduser_temp))
|
||||
echo '<td class="datos2"><b>'.$lang_label["group"].'</b><td class="datos2"><select name="grupo" class="w135">';
|
||||
echo '<td class="datos2"><b>'.$lang_label["group"].'</b><td class="datos2"><select name="grupo_form" class="w135">';
|
||||
else
|
||||
echo '<td class="datos2"><b>'.$lang_label["group"].'</b><td class="datos2"><select disabled name="grupo" class="w135">';
|
||||
echo '<td class="datos2"><b>'.$lang_label["group"].'</b><td class="datos2"><select disabled name="grupo_form" class="w135">';
|
||||
if ($id_grupo != 0)
|
||||
echo "<option value='".$id_grupo."'>".$grupo;
|
||||
$sql1='SELECT * FROM tgrupo ORDER BY nombre';
|
||||
|
@ -344,9 +282,9 @@ while ($row=mysql_fetch_array($result)){
|
|||
|
||||
echo '</select><tr>';
|
||||
if ((give_acl($iduser_temp, $id_grupo, "IM")==1) OR ($usuario == $iduser_temp))
|
||||
echo '<td class="datos"><b>'.$lang_label["priority"].'</b><td class="datos"><select name="prioridad" class="w135">';
|
||||
echo '<td class="datos"><b>'.$lang_label["priority"].'</b><td class="datos"><select name="prioridad_form" class="w135">';
|
||||
else
|
||||
echo '<td class="datos"><b>'.$lang_label["priority"].'</b><td class="datos"><select disabled name="prioridad" class="w135">';
|
||||
echo '<td class="datos"><b>'.$lang_label["priority"].'</b><td class="datos"><select disabled name="prioridad_form" class="w135">';
|
||||
|
||||
switch ( $prioridad ){
|
||||
case 0: echo '<option value="0">'.$lang_label["informative"]; break;
|
||||
|
|
Loading…
Reference in New Issue