From 60eba2ed730438994b817f95b1bb59b27e480557 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2006 23:04:52 +0000 Subject: [PATCH] New: Debut gestion possibilite de mettre plusieurs boites RSS. --- htdocs/admin/boxes.php | 199 +++++++++--------- htdocs/admin/external_rss.php | 17 ++ htdocs/boxes.php | 2 +- htdocs/includes/boxes/box_external_rss.php | 2 +- .../modules/DolibarrModules.class.php | 14 +- .../includes/modules/modExternalRss.class.php | 28 ++- htdocs/index.php | 2 +- htdocs/main.inc.php | 2 +- 8 files changed, 157 insertions(+), 109 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 2efb12030dd..bfe3ea8db30 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -168,63 +168,65 @@ print_titre($langs->trans("BoxesAvailable")); print ''; print ''; -print ''; +print ''; +print ''; print ''; -print ''; -print ''; +print ''; print "\n"; -$sql = "SELECT rowid, name, file FROM ".MAIN_DB_PREFIX."boxes_def"; +$sql = "SELECT rowid, name, file, note FROM ".MAIN_DB_PREFIX."boxes_def"; $resql = $db->query($sql); $var=True; if ($resql) { - $html=new Form($db); - - $num = $db->num_rows($resql); - $i = 0; - - // Boucle sur toutes les boites - while ($i < $num) - { - $obj = $db->fetch_object($resql); - - $module=eregi_replace('.php$','',$obj->file); - include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php"); - - $box=new $module(); - - if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1) + $html=new Form($db); + + $num = $db->num_rows($resql); + $i = 0; + + // Boucle sur toutes les boites + while ($i < $num) { - // La boite est déjà activée - // \todo - // L'idéal serait de supprimer la valeur du tableau + $obj = $db->fetch_object($resql); + + $module=eregi_replace('.php$','',$obj->file); + include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php"); + + $box=new $module(); + + if (in_array($obj->rowid, $actives) && $box->box_multiple <> 1) + { + // La boite est déjà activée + // \todo + // L'idéal serait de supprimer la valeur du tableau + } + else + { + $var = ! $var; + + print ''; + $logo=eregi_replace("^object_","",$box->boximg); + print ''; + print ''; + print ''; + print ''; + + // Pour chaque position possible, on affiche un lien + // d'activation si boite non deja active pour cette position + print ''; + + print ''; + } + $i++; } - else - { - $var = ! $var; - - print ''; - $logo=eregi_replace("^object_","",$box->boximg); - print ''; - - // Pour chaque position possible, on affiche un lien - // d'activation si boite non deja active pour cette position - print ''; - - print ''; - print ''; - } - $i++; - } - - $db->free($resql); + + $db->free($resql); } print '
'.$langs->trans("Box").''.$langs->trans("Box").''.$langs->trans("Note").''.$langs->trans("SourceFile").''.$langs->trans("ActivateOn").' '.$langs->trans("ActivateOn").'
'.img_object("",$logo).' '.$box->boxlabel.'' . ($obj->note?$obj->note:' ') . '' . $obj->file . ''; + print $html->select_array("pos",$pos_name); + print ''; + print ''; + print ' '; + print '
'.img_object("",$logo).' '.$box->boxlabel.'' . $obj->file . ''; - print $html->select_array("pos",$pos_name); - print ''; - print ''; - print ' '; - print ' 
'; @@ -239,14 +241,14 @@ print_titre($langs->trans("BoxesActivated")); print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; print ''; print "\n"; -$sql = "SELECT b.rowid, b.box_id, b.position, d.name, d.file"; +$sql = "SELECT b.rowid, b.box_id, b.position, d.name, d.file, d.note"; $sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql .= " where b.box_id = d.rowid"; $sql .= " ORDER by position, box_order"; @@ -255,53 +257,54 @@ $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - $var=true; - - $box_order=1; - $foundrupture=1; - - // On lit avec un coup d'avance - $obj = $db->fetch_object($resql); - - while ($obj && $i < $num) - { - $var = ! $var; - $objnext = $db->fetch_object($resql); - - $module=eregi_replace('.php$','',$obj->file); - include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php"); - $box=new $module(); - - $logo=eregi_replace("^object_","",$box->boximg); - print ''; - print ''; - print ''; - $hasnext=true; - $hasprevious=true; - if ($foundrupture) { $hasprevious=false; $foundrupture=0; } - if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; } - print ''; - print ''; - print ''; - - print "\n"; - $i++; - - $box_order++; - - if (! $foundrupture) $objprevious = $obj; - else $box_order=1; - $obj=$objnext; - } - - $db->free($resql); + $num = $db->num_rows($resql); + $i = 0; + $var=true; + + $box_order=1; + $foundrupture=1; + + // On lit avec un coup d'avance + $obj = $db->fetch_object($resql); + + while ($obj && $i < $num) + { + $var = ! $var; + $objnext = $db->fetch_object($resql); + + $module=eregi_replace('.php$','',$obj->file); + include_once(DOL_DOCUMENT_ROOT."/includes/boxes/".$module.".php"); + $box=new $module(); + + $logo=eregi_replace("^object_","",$box->boximg); + print ''; + print ''; + print ''; + print ''; + $hasnext=true; + $hasprevious=true; + if ($foundrupture) { $hasprevious=false; $foundrupture=0; } + if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; } + print ''; + print ''; + print ''; + + print "\n"; + $i++; + + $box_order++; + + if (! $foundrupture) $objprevious = $obj; + else $box_order=1; + $obj=$objnext; + } + + $db->free($resql); } print '
'.$langs->trans("Box").' '.$langs->trans("ActiveOn").''.$langs->trans("Box").''.$langs->trans("Note").''.$langs->trans("ActiveOn").''.$langs->trans("Position").''.$langs->trans("Disable").'
'.img_object("",$logo).' '.$box->boxlabel.' ' . $pos_name[$obj->position] . ''.$box_order.''; - print ($hasnext?''.img_down().' ':''); - print ($hasprevious?''.img_up().'':''); - print ''; - print ''.img_delete().''; - print '
'.img_object("",$logo).' '.$box->boxlabel.'' . ($obj->note?$obj->note:' ') . '' . $pos_name[$obj->position] . ''.$box_order.''; + print ($hasnext?''.img_down().' ':''); + print ($hasprevious?''.img_up().'':''); + print ''; + print ''.img_delete().''; + print '

'; diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 987a68d0c9e..f9cda29dbae 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -54,11 +54,19 @@ if ($_POST["action"] == 'add' || $_POST["modify"]) $external_rss_urlrss = "external_rss_urlrss_" . $_POST["norss"]; if(isset($_POST[$external_rss_urlrss])) { + $boxlabel='(ExternalRSSInformations)'; $external_rss_title = "external_rss_title_" . $_POST["norss"]; //$external_rss_url = "external_rss_url_" . $_POST["norss"]; $db->begin(); + // Ajoute boite box_external_rss dans définition des boites + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file, note) VALUES ('".$boxlabel."','box_external_rss.php','".addslashes($_POST["norss"].' ('.$_POST[$external_rss_title]).")')"; + if (! $db->query($sql)) + { + $err++; + } + $result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . $_POST["norss"],$_POST[$external_rss_title]); if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . $_POST["norss"],$_POST[$external_rss_urlrss]); @@ -81,6 +89,15 @@ if ($_POST["delete"]) if(isset($_POST["norss"])) { $db->begin(); + // Supprime boite box_external_rss de définition des boites + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE file ='box_external_rss.php' AND note like '".$_POST["norss"]." %'"; + if (! $db->query($sql)) + { + dolibarr_print_error($db,"sql=$sql"); + exit; + } + $result1=dolibarr_del_const($db,"EXTERNAL_RSS_TITLE_" . $_POST["norss"]); if ($result1) $result2=dolibarr_del_const($db,"EXTERNAL_RSS_URLRSS_" . $_POST["norss"]); diff --git a/htdocs/boxes.php b/htdocs/boxes.php index 26ba0feb25f..e575a3b93d9 100644 --- a/htdocs/boxes.php +++ b/htdocs/boxes.php @@ -51,7 +51,7 @@ class InfoBox /** - * \brief Retourne liste des boites elligibles pour la zone + * \brief Retourne tableau des boites elligibles pour la zone * \param $zone ID de la zone (0 pour la Homepage, ...) * \return array Tableau des boites qualifiées */ diff --git a/htdocs/includes/boxes/box_external_rss.php b/htdocs/includes/boxes/box_external_rss.php index b5bd6671314..62fcd61fbd9 100644 --- a/htdocs/includes/boxes/box_external_rss.php +++ b/htdocs/includes/boxes/box_external_rss.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Éric Seigne - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 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 diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 32a891b5b8c..4a011ff1710 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -371,8 +371,11 @@ class DolibarrModules { $titre = $this->boxes[$key][0]; $file = $this->boxes[$key][1]; + $note = $this->boxes[$key][2]; - $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def WHERE name ='".$titre."'"; + $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE file ='".$file."'"; + if ($note) $sql.=" AND note ='".addslashes($note)."'"; $result=$this->db->query($sql); if ($result) @@ -380,7 +383,8 @@ class DolibarrModules $row = $this->db->fetch_row($result); if ($row[0] == 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file) VALUES ('".$titre."','".$file."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file, note)"; + $sql.= " VALUES ('".$titre."','".$file."','".addslashes($note)."')"; if (! $this->db->query($sql)) { $err++; @@ -410,10 +414,12 @@ 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]; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def WHERE file = '".$file."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def "; + $sql.= "WHERE file = '".$file."'"; if (! $this->db->query($sql) ) { $err++; diff --git a/htdocs/includes/modules/modExternalRss.class.php b/htdocs/includes/modules/modExternalRss.class.php index a086abdc730..6db23412a31 100644 --- a/htdocs/includes/modules/modExternalRss.class.php +++ b/htdocs/includes/modules/modExternalRss.class.php @@ -74,8 +74,7 @@ class modExternalRss extends DolibarrModules // Boxes $this->boxes = array(); - $this->boxes[0][0] = "Informations externes RSS"; - $this->boxes[0][1] = "box_external_rss.php"; + // Les boites sont ajoutées lors de la configuration des flux // Permissions $this->rights = array(); @@ -89,7 +88,27 @@ class modExternalRss extends DolibarrModules function init() { $sql = array(); - + + // Recherche configuration de boites + $this->boxes=array(); + $sql="select name, value from ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE name like 'EXTERNAL_RSS_TITLE_%'"; + $result=$this->db->query($sql); + if ($result) + { + while ($obj = $this->db->fetch_object($result)) + { + if (eregi('EXTERNAL_RSS_TITLE_([0-9]+)',$obj->name,$reg)) + { + // Definie la boite si on a trouvée une ancienne configuration + $this->boxes[$reg[1]][0] = "Informations externes RSS"; + $this->boxes[$reg[1]][1] = "box_external_rss.php"; + $this->boxes[$reg[1]][2] = $reg[1]." (".$obj->value.")"; + } + } + $this->db->free($result); + } + return $this->_init($sql); } @@ -101,6 +120,9 @@ class modExternalRss extends DolibarrModules { $sql = array(); + // Supprime anciennes delcarations de la boite RSS + $this->boxes[0][1] = "box_external_rss.php"; + return $this->_remove($sql); } } diff --git a/htdocs/index.php b/htdocs/index.php index 2270c492665..3310f5be923 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 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 diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 39e082d37d4..29f528d9d4b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -463,7 +463,7 @@ function left_menu($menu_array, $help_url='', $form_search='') if ($helpbaseurl) print ''; } - if (MAIN_SHOW_BUGTRACK_LINK == 1) + if ($conf->global->MAIN_SHOW_BUGTRACK_LINK == 1) { // Lien vers le bugtrack $bugbaseurl='http://savannah.nongnu.org/bugs/?';