New: Debut gestion possibilite de mettre plusieurs boites RSS.
This commit is contained in:
parent
ffc0f88f2a
commit
60eba2ed73
@ -168,63 +168,65 @@ print_titre($langs->trans("BoxesAvailable"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Box").'</td>';
|
||||
print '<td width="300">'.$langs->trans("Box").'</td>';
|
||||
print '<td>'.$langs->trans("Note").'</td>';
|
||||
print '<td>'.$langs->trans("SourceFile").'</td>';
|
||||
print '<td align="center" width="180">'.$langs->trans("ActivateOn").'</td>';
|
||||
print '<td align="center" width="80"> </td>';
|
||||
print '<td align="center" width="160">'.$langs->trans("ActivateOn").'</td>';
|
||||
print "</tr>\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 '<form action="boxes.php" method="POST">';
|
||||
$logo=eregi_replace("^object_","",$box->boximg);
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
||||
print '<td>' . ($obj->note?$obj->note:' ') . '</td>';
|
||||
print '<td>' . $obj->file . '</td>';
|
||||
|
||||
// Pour chaque position possible, on affiche un lien
|
||||
// d'activation si boite non deja active pour cette position
|
||||
print '<td align="center">';
|
||||
print $html->select_array("pos",$pos_name);
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
|
||||
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
|
||||
print '</td>';
|
||||
|
||||
print '</tr></form>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$var = ! $var;
|
||||
|
||||
print '<form action="boxes.php" method="POST">';
|
||||
$logo=eregi_replace("^object_","",$box->boximg);
|
||||
print '<tr '.$bc[$var].'><td>'.img_object("",$logo).' '.$box->boxlabel.'</td><td>' . $obj->file . '</td>';
|
||||
|
||||
// Pour chaque position possible, on affiche un lien
|
||||
// d'activation si boite non deja active pour cette position
|
||||
print '<td align="center">';
|
||||
print $html->select_array("pos",$pos_name);
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="boxid" value="'.$obj->rowid.'">';
|
||||
print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
|
||||
print '</td>';
|
||||
|
||||
print '<td> </td>';
|
||||
print '</tr></form>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -239,14 +241,14 @@ print_titre($langs->trans("BoxesActivated"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Box").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" width="180">'.$langs->trans("ActiveOn").'</td>';
|
||||
print '<td width="300">'.$langs->trans("Box").'</td>';
|
||||
print '<td>'.$langs->trans("Note").'</td>';
|
||||
print '<td align="center" width="160">'.$langs->trans("ActiveOn").'</td>';
|
||||
print '<td align="center" width="60" colspan="2">'.$langs->trans("Position").'</td>';
|
||||
print '<td align="center" width="80">'.$langs->trans("Disable").'</td>';
|
||||
print "</tr>\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 '<tr '.$bc[$var].'><td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">' . $pos_name[$obj->position] . '</td>';
|
||||
$hasnext=true;
|
||||
$hasprevious=true;
|
||||
if ($foundrupture) { $hasprevious=false; $foundrupture=0; }
|
||||
if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; }
|
||||
print '<td align="center" width="10">'.$box_order.'</td>';
|
||||
print '<td align="center" width="50">';
|
||||
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objnext->rowid.'">'.img_down().'</a> ':'');
|
||||
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objprevious->rowid.'">'.img_up().'</a>':'');
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="boxes.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\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 '<tr '.$bc[$var].'>';
|
||||
print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
|
||||
print '<td>' . ($obj->note?$obj->note:' ') . '</td>';
|
||||
print '<td align="center">' . $pos_name[$obj->position] . '</td>';
|
||||
$hasnext=true;
|
||||
$hasprevious=true;
|
||||
if ($foundrupture) { $hasprevious=false; $foundrupture=0; }
|
||||
if (! $objnext || $obj->position != $objnext->position) { $hasnext=false; $foundrupture=1; }
|
||||
print '<td align="center">'.$box_order.'</td>';
|
||||
print '<td align="center">';
|
||||
print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objnext->rowid.'">'.img_down().'</a> ':'');
|
||||
print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$obj->rowid.'&switchto='.$objprevious->rowid.'">'.img_up().'</a>':'');
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="boxes.php?rowid='.$obj->rowid.'&action=delete">'.img_delete().'</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
|
||||
$box_order++;
|
||||
|
||||
if (! $foundrupture) $objprevious = $obj;
|
||||
else $box_order=1;
|
||||
$obj=$objnext;
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
@ -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"]);
|
||||
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Éric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -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++;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -463,7 +463,7 @@ function left_menu($menu_array, $help_url='', $form_search='')
|
||||
if ($helpbaseurl) print '<div class="help"><a class="help" target="_blank" href="'.sprintf($helpbaseurl,$help_url).'">'.$langs->trans("Help").'</a></div>';
|
||||
}
|
||||
|
||||
if (MAIN_SHOW_BUGTRACK_LINK == 1)
|
||||
if ($conf->global->MAIN_SHOW_BUGTRACK_LINK == 1)
|
||||
{
|
||||
// Lien vers le bugtrack
|
||||
$bugbaseurl='http://savannah.nongnu.org/bugs/?';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user