From 1d48f0f231234a8a543f815c6f054c0507c22970 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Jan 2008 19:54:54 +0000 Subject: [PATCH] Qual: Simplification code declaration boites --- htdocs/admin/boxes.php | 27 ++++++++++--------- .../modules/DolibarrModules.class.php | 11 ++++---- htdocs/includes/modules/modBanque.class.php | 2 -- htdocs/includes/modules/modBookmark.class.php | 1 - htdocs/includes/modules/modCommande.class.php | 1 - htdocs/includes/modules/modEnergie.class.php | 11 ++++---- .../includes/modules/modExpedition.class.php | 2 +- htdocs/includes/modules/modFacture.class.php | 4 --- .../includes/modules/modFournisseur.class.php | 3 --- htdocs/includes/modules/modProduit.class.php | 1 - htdocs/includes/modules/modPropale.class.php | 1 - htdocs/includes/modules/modService.class.php | 1 - .../includes/modules/modWebcalendar.class.php | 8 +++--- mysql/migration/2.2.0-2.4.0.sql | 6 ++++- mysql/tables/llx_boxes_def.sql | 2 +- 15 files changed, 37 insertions(+), 44 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index e80a95b1c07..8ac905ada30 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2008 Laurent Destailleur * * 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 @@ -56,8 +56,8 @@ if ($_POST["action"] == 'add') { $db->begin(); - // Si la boite n'est pas deja active - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position, fk_user) values (".$_POST["boxid"].",".$_POST["pos"].", 0)"; + // Si la boite n'est pas deja active, insert with box_order='' + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id, position, box_order, fk_user) values (".$_POST["boxid"].",".$_POST["pos"].", '', 0)"; dolibarr_syslog("boxes.php activate box sql=".$sql); $resql = $db->query($sql); @@ -143,10 +143,11 @@ print $langs->trans("BoxesDesc")."
\n"; $actives = array(); -$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, d.name, d.rowid as boxid"; -$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; -$sql .= " WHERE b.box_id = d.rowid AND fk_user=0"; -$sql .= " ORDER by position, box_order"; +$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,"; +$sql.= " d.rowid as boxid"; +$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; +$sql.= " WHERE b.box_id = d.rowid AND fk_user=0"; +$sql.= " ORDER by position, box_order"; $resql = $db->query($sql); if ($resql) @@ -164,7 +165,8 @@ if ($resql) array_push($actives,$obj->box_id); if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) $decalage++; - // On renumérote l'ordre des boites si l'une d'elle est à 0 (Ne doit arriver que sur des anciennes versions) + // On renumérote l'ordre des boites si l'une d'elle est à '' + // This occurs just after an insert. if ($decalage) { $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order=".$decalage." WHERE rowid=".$obj->rowid; @@ -174,7 +176,8 @@ if ($resql) if ($decalage) { - // Si on a renumerote, on corrige champ box_order (Ne doit arriver que sur des anciennes versions) + // Si on a renumerote, on corrige champ box_order + // This occurs just after an insert. $sql = "SELECT box_order"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes"; $sql.= " WHERE length(box_order) <= 2"; @@ -235,7 +238,7 @@ print ''.$langs->trans("SourceFile").''; print ''.$langs->trans("ActivateOn").''; print "\n"; -$sql = "SELECT rowid, name, file, note"; +$sql = "SELECT rowid, file, note, tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def"; $resql = $db->query($sql); $var=True; @@ -310,11 +313,11 @@ print ''.$langs->trans("Disable").''; print "\n"; $sql = "SELECT b.rowid, b.box_id, b.position,"; -$sql.= " d.name, d.file, d.note"; +$sql.= " d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " WHERE b.box_id = d.rowid"; $sql.= " AND b.fk_user=0"; -$sql.= " ORDER by position, box_order"; +$sql.= " ORDER by position, box_order"; // Note box_order return A01,A03...,B02,B04... $resql = $db->query($sql); diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 1398cba24af..6a5624927be 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -396,7 +396,7 @@ class DolibarrModules { foreach ($this->boxes as $key => $value) { - $titre = $this->boxes[$key][0]; + //$titre = $this->boxes[$key][0]; $file = $this->boxes[$key][1]; $note = $this->boxes[$key][2]; @@ -410,10 +410,11 @@ class DolibarrModules $row = $this->db->fetch_row($result); if ($row[0] == 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file, note)"; - $sql.= " VALUES ('".$titre."','".$file."',"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file,note)"; + $sql.= " VALUES ('".addslashes($file)."',"; $sql.= $note?"'".addslashes($note)."'":"null"; $sql.= ")"; + //print $sql; if (! $this->db->query($sql)) { $err++; @@ -480,12 +481,12 @@ class DolibarrModules $sql = "DELETE ".MAIN_DB_PREFIX."boxes"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def"; $sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid"; - $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$file."'"; + $sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".addslashes($file)."'"; dolibarr_syslog("DolibarrModules::delete_boxes sql=".$sql); $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql.= " WHERE file = '".$file."'"; + $sql.= " WHERE file = '".addslashes($file)."'"; dolibarr_syslog("DolibarrModules::delete_boxes sql=".$sql); if (! $this->db->query($sql)) { diff --git a/htdocs/includes/modules/modBanque.class.php b/htdocs/includes/modules/modBanque.class.php index 75b29579fcd..a37121e115c 100644 --- a/htdocs/includes/modules/modBanque.class.php +++ b/htdocs/includes/modules/modBanque.class.php @@ -75,8 +75,6 @@ class modBanque extends DolibarrModules // Boites $this->boxes = array(); - - $this->boxes[0][0] = "Soldes Comptes Bancaires"; $this->boxes[0][1] = "box_comptes.php"; // Permissions diff --git a/htdocs/includes/modules/modBookmark.class.php b/htdocs/includes/modules/modBookmark.class.php index 5ac2aaf866b..69f9fd32abe 100644 --- a/htdocs/includes/modules/modBookmark.class.php +++ b/htdocs/includes/modules/modBookmark.class.php @@ -76,7 +76,6 @@ class modBookmark extends DolibarrModules // Boites $this->boxes = array(); - $this->boxes[0][0] = "Mes derniers marque-pages"; $this->boxes[0][1] = "box_bookmarks.php"; // Permissions diff --git a/htdocs/includes/modules/modCommande.class.php b/htdocs/includes/modules/modCommande.class.php index 4fcae3cbf30..6eac938609f 100644 --- a/htdocs/includes/modules/modCommande.class.php +++ b/htdocs/includes/modules/modCommande.class.php @@ -89,7 +89,6 @@ class modCommande extends DolibarrModules // Boites $this->boxes = array(); - $this->boxes[0][0] = "Commandes"; $this->boxes[0][1] = "box_commandes.php"; // Permissions diff --git a/htdocs/includes/modules/modEnergie.class.php b/htdocs/includes/modules/modEnergie.class.php index 7dee2757149..52463b4c886 100644 --- a/htdocs/includes/modules/modEnergie.class.php +++ b/htdocs/includes/modules/modEnergie.class.php @@ -76,12 +76,11 @@ class modEnergie extends DolibarrModules // Boxes $this->boxes = array(); - - $this->boxes[0][0] = 'Energie'; - $this->boxes[0][1] = "box_energie_releve.php"; - - $this->boxes[1][0] = 'Energie Graph'; - $this->boxes[1][1] = "box_energie_graph.php"; + $r=0; + $this->boxes[$r][1] = "box_energie_releve.php"; + $r++; + $this->boxes[$r][1] = "box_energie_graph.php"; + $r++; // Permissions $this->rights = array(); diff --git a/htdocs/includes/modules/modExpedition.class.php b/htdocs/includes/modules/modExpedition.class.php index 7c9c6bc986c..d6f4e76fe1a 100644 --- a/htdocs/includes/modules/modExpedition.class.php +++ b/htdocs/includes/modules/modExpedition.class.php @@ -71,7 +71,7 @@ class modExpedition extends DolibarrModules // Constantes $this->const = array(); - $this->const[0][0] = "LIVRAISON_ADDON_PDF"; + $this->const[0][0] = "LIVRAISON_ADDON_PDF"; $this->const[0][1] = "chaine"; $this->const[0][2] = "typhon"; $this->const[0][3] = 'Nom du gestionnaire de génération des commandes en PDF'; diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php index 928ab06d732..f5005085e13 100644 --- a/htdocs/includes/modules/modFacture.class.php +++ b/htdocs/includes/modules/modFacture.class.php @@ -97,12 +97,8 @@ class modFacture extends DolibarrModules // Boites $this->boxes = array(); $r=0; - - $this->boxes[$r][0] = "Factures clients récentes impayées"; $this->boxes[$r][1] = "box_factures_imp.php"; $r++; - - $this->boxes[$r][0] = "Dernières factures clients saisies"; $this->boxes[$r][1] = "box_factures.php"; $r++; diff --git a/htdocs/includes/modules/modFournisseur.class.php b/htdocs/includes/modules/modFournisseur.class.php index b37bf8db147..cab87f46af1 100644 --- a/htdocs/includes/modules/modFournisseur.class.php +++ b/htdocs/includes/modules/modFournisseur.class.php @@ -87,15 +87,12 @@ class modFournisseur extends DolibarrModules $this->boxes = array(); $r=0; - $this->boxes[$r][0] = "Derniers founisseurs"; $this->boxes[$r][1] = "box_fournisseurs.php"; $r++; - $this->boxes[$r][0] = "Factures fournisseurs récentes impayées"; $this->boxes[$r][1] = "box_factures_fourn_imp.php"; $r++; - $this->boxes[$r][0] = "Dernières factures fournisseurs saisies"; $this->boxes[$r][1] = "box_factures_fourn.php"; $r++; diff --git a/htdocs/includes/modules/modProduit.class.php b/htdocs/includes/modules/modProduit.class.php index 9bf52e0397c..e2a6fb762c4 100644 --- a/htdocs/includes/modules/modProduit.class.php +++ b/htdocs/includes/modules/modProduit.class.php @@ -90,7 +90,6 @@ class modProduit extends DolibarrModules // Boxes $this->boxes = array(); - $this->boxes[0][0] = "Derniers produits/services enregistrés"; $this->boxes[0][1] = "box_produits.php"; // Permissions diff --git a/htdocs/includes/modules/modPropale.class.php b/htdocs/includes/modules/modPropale.class.php index 969b2281d74..01475b666c2 100644 --- a/htdocs/includes/modules/modPropale.class.php +++ b/htdocs/includes/modules/modPropale.class.php @@ -86,7 +86,6 @@ class modPropale extends DolibarrModules // Boxes $this->boxes = array(); - $this->boxes[0][0] = "Proposition commerciales"; $this->boxes[0][1] = "box_propales.php"; // Permissions diff --git a/htdocs/includes/modules/modService.class.php b/htdocs/includes/modules/modService.class.php index 9d9a3462864..5ba6b0aaeb0 100644 --- a/htdocs/includes/modules/modService.class.php +++ b/htdocs/includes/modules/modService.class.php @@ -72,7 +72,6 @@ class modService extends DolibarrModules // Boites $this->boxes = array(); - $this->boxes[0][0] = "Derniers services contractés"; $this->boxes[0][1] = "box_services_vendus.php"; // Permissions diff --git a/htdocs/includes/modules/modWebcalendar.class.php b/htdocs/includes/modules/modWebcalendar.class.php index 67debaf0104..dc2cb852a3c 100644 --- a/htdocs/includes/modules/modWebcalendar.class.php +++ b/htdocs/includes/modules/modWebcalendar.class.php @@ -88,11 +88,11 @@ class modWebcalendar extends DolibarrModules $this->boxes = array(); // List of boxes $r=0; - // Add here list of default box name and php file stored in includes/boxes that - // contains class to show a box. + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. // Example: - //$this->boxes[$r][0] = "My box"; - //$this->boxes[$r][1] = "mybox.php"; + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; //$r++; // Permissions diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql index 62502f6ba73..e5f81c9a01d 100644 --- a/mysql/migration/2.2.0-2.4.0.sql +++ b/mysql/migration/2.2.0-2.4.0.sql @@ -20,4 +20,8 @@ update llx_const set value='' where name='MAIN_FORCE_SETLOCALE_LC_TIME' and alter table llx_document_model modify type varchar(20) NOT NULL; -DELETE FROM llx_rights_def WHERE module = 'menudb'; \ No newline at end of file +DELETE FROM llx_rights_def WHERE module = 'menudb'; + +ALTER table llx_boxes_def drop column name; +ALTER table llx_boxes_def add column tms timestamp; + diff --git a/mysql/tables/llx_boxes_def.sql b/mysql/tables/llx_boxes_def.sql index 9a58c55b26f..89e3aa50895 100644 --- a/mysql/tables/llx_boxes_def.sql +++ b/mysql/tables/llx_boxes_def.sql @@ -21,7 +21,7 @@ create table llx_boxes_def ( rowid integer AUTO_INCREMENT PRIMARY KEY, - name varchar(255) NOT NULL, file varchar(255) NOT NULL, + tms timestamp, note text )type=innodb;