Objet : devel-adl
Archives de la liste
- From: svn AT agendadulibre.org
- To: devel AT agendadulibre.org
- Subject: [Devel] r275 - branches/dui
- Date: Sun, 20 May 2007 11:29:13 +0200 (CEST)
- List-archive: <http://lolut.utbm.info/pipermail/devel>
- List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>
Author: ldayot
Date: Sun May 20 11:29:11 2007
New Revision: 275
Log:
Ajout d'un script pour administrer les tags et les categories de tags.
Ajout de deux liens pour les moderateurs en bas de page.
Added:
branches/dui/moderatetags.php
Modified:
branches/dui/funcs.inc.php
Modified: branches/dui/funcs.inc.php
==============================================================================
--- branches/dui/funcs.inc.php (original)
+++ branches/dui/funcs.inc.php Sun May 20 11:29:11 2007
@@ -115,10 +115,13 @@
function put_footer ()
{
+ echo "\n</div>\n<div class=\"footer\">\n<p>";
+ if (isset($_COOKIE["agenda_libre_id"]) ||
isset($_SESSION["agenda_libre_id"]))
+ { // moderateur
+ echo "<a href=\"moderate.php\">Mod�rer les �v�nements</a> - <a
href=\"moderatetags.php\">G�rer les tags</a><br />\n";
+ }
?>
-</div>
-<div class="footer">
-<p><a href="submit.php">Proposer un �v�nement</a> - <a
href="rsslist.php">Flux RSS</a> - <a href="icallist.php">Calendriers iCal</a>
- <a href="map.php">Carte</a> - <a href="tags.php">Tags</a> - <a
href="infos.php">Informations</a> - <a href="stats.php">Statistiques</a> - <a
href="mailto:moderateurs CHEZ agendadulibre POINT org">Contact</a></p>
+<a href="submit.php">Proposer un �v�nement</a> - <a href="rsslist.php">Flux
RSS</a> - <a href="icallist.php">Calendriers iCal</a> - <a
href="map.php">Carte</a> - <a href="tags.php">Tags</a> - <a
href="infos.php">Informations</a> - <a href="stats.php">Statistiques</a> - <a
href="mailto:moderateurs CHEZ agendadulibre POINT org">Contact</a></p>
</div>
</body>
</html>
Added: branches/dui/moderatetags.php
==============================================================================
--- (empty file)
+++ branches/dui/moderatetags.php Sun May 20 11:29:11 2007
@@ -0,0 +1,626 @@
+<?php
+/* Copyright 2004-2007
+ * - M�lanie Bats <melanie POINT bats CHEZ utbm POINT fr>
+ * - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
+ * - Loic Dayot <ldayot CHEZ ouvaton POINT org>
+ *
+ * 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.
+ *
+ * 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 GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * $Id: top.inc.php,v 1.51 2007/03/10 16:22:12 ldayot Exp $
+ */
+
+include("bd.inc.php");
+include("funcs.inc.php");
+include("diff.inc.php");
+
+$db = new db();
+include("session.inc.php");
+
+put_header("Manage tags");
+
+
+function tagCategoryListHTML()
+{
+ global $db;
+
+ $return = "<ul>\n";
+
+ $catQuery = "SELECT COUNT(*) as n FROM tags WHERE category_id=0 GROUP BY
category_id";
+ $catResult = $db->query($catQuery);
+ while ($catRecord = $db->fetchObject($catResult))
+ $return .= " <li><a href='moderatetags.php?op=catListTag&id=0'
title=\"". sprintf(_("Liste des tags de la cat�gorie %s"), _("sans
cat�gorie")). "\">". sprintf(_("%03s tags"), $catRecord->n). "</a> <strong>".
_("sans cat�gorie"). "</strong></li>\n";
+ $db->freeResult($catResult);
+
+ $catQuery = "SELECT COUNT(tags.id) as n, tags_categories.* FROM
tags_categories LEFT JOIN tags ON tags_categories.id=category_id GROUP BY
tags_categories.id ORDER BY tags_categories.name";
+ $catResult = $db->query($catQuery);
+
+ while ($catRecord = $db->fetchObject($catResult))
+ {
+ $return .= " <li><a
href='moderatetags.php?op=catListTag&id={$catRecord->id}' title=\"".
sprintf(_("Liste des tags de la cat�gorie %s"), $catRecord->name). "\">".
sprintf(_("%03s tags"), $catRecord->n). "</a>
<strong>{$catRecord->name}</strong> <sapn
class='description'>{$catRecord->description}</span>";
+ if ($catRecord->id>0) $return .= " - <a
href='moderatetags.php?op=catEdit&id={$catRecord->id}' title=\"".
sprintf(_("Modifier la cat�gorie %s"), $catRecord->name). "\">".
_("Modifier"). "</a>";
+ if ($catRecord->n==0) $return .= " - <a
href='moderatetags.php?op=catDel&id={$catRecord->id}' title=\"".
sprintf(_("Supprimer la cat�gorie %s"), $catRecord->name). "\">".
_("Supprimer"). "</a>";
+ $return .= "</li>\n";
+ }
+
+ $db->freeResult($catResult);
+
+ $return .= "<li><a href='moderatetags.php?op=catNew'>". _("Nouvelle
cat�gorie de tags"). "</a></li>\n";
+
+ $return .= "</ul>\n";
+
+ return $return;
+} // end function tagCategoryListHTML
+
+function tagCategoryFormHTML($id)
+{
+ $return = "<form action=\"moderatetags.php\" method=\"post\"
enctype=\"multipart/form-data\" name=\"tagCategoryForm\">\n";
+ $return .= "<input type=\"hidden\" name=\"op\" value=\"catUpdate\" />\n";
+
+ if (isset($_POST["tagCat"]))
+ { // We came from form
+ $tagCat = $_POST["tagCat"];
+ $tagCat["name"] = stripslashes(strip_tags($tagCat["name"]));
+ $tagCat["description"] = stripslashes(strip_tags($tagCat["description"],
"<p><b><i><br/><a><ul><li><ol>"));
+ } // end if
+ else
+ {
+ if ($id>0)
+ { // edit
+ global $db;
+ $res = $db->query("SELECT * FROM tags_categories WHERE id='{$id}'");
+ if (! $tagCat = $db->fetchArray($res)) return error(_("Enregistrement
introuvable"));
+ $return .= "<input type=\"hidden\" name=\"id\"
value=\"{$tagCat['id']}\" />\n";
+ $db->freeResult($res);
+ $tagCat['name'] = escape_form_string($tagCat['name']);
+ $tagCat['description'] = escape_form_string($tagCat['description'],
"<p><b><i><br/><a><ul><li><ol>");
+ } // end if
+ else
+ { // new
+ $tagCat = array("name"=>null, "description"=>null);
+ } // end else
+ } // end else
+
+ $return .= "<table>";
+ $return .= "<tr><th colspan='2'>". _("�dition d'une cat�gorie de tags").
"</th></tr>\n";
+ $return .= "<tr><th>". _("Intitul�*"). "</th> <td><input type=\"text\"
name=\"tagCat[name]\" value=\"{$tagCat['name']}\" size='40' /></td></tr>\n";
+ $return .= "<tr><th>". _("Description"). "</th> <td><textarea
name=\"tagCat[description]\" rows=\"4\"
cols=\"70\">{$tagCat['description']}</textarea></td></tr>\n";
+
+ $return .= "<tr><th colspan='2'><input type=\"submit\" name=\"submit\"
value=\"". _("Valider"). "\" /></th></tr>\n";
+
+ $return .= "</table>\n</form>\n";
+
+ return $return;
+} // end function tagCategoryFormHTML
+
+
+function tagCategoryUpdate($id)
+{
+ global $db;
+ if (!isset($_POST["tagCat"]))
+ return error(_("Ne venant pas du formulaire"));
+ $tagCat = $_POST["tagCat"];
+ if (!is_array($tagCat) || !isset($tagCat["name"], $tagCat["description"]))
+ return error(_("Ne venant pas du bon formulaire"));;
+ if (strlen($tagCat["name"])<4)
+ return error(_("Intitul� indispensable d'au moins 4 caract�res"));
+
+ $tagCat["name"] = stripslashes(strip_tags($tagCat["name"]));
+ $tagCat["description"] = stripslashes(strip_tags($tagCat["description"],
"<p><b><i><br/><a><ul><li><ol>"));
+
+ // Detect double
+ $res = $db->query("SELECT * FROM tags_categories WHERE name LIKE ".
$db->quote_smart($tagCat['name']). ($id>0 ? " AND id<>$id" : ""));
+ if ($db->fetchObject($res))
+ { // tag already exists
+ return error(sprintf(_("La cat�gorie de tags %s existe d�j�"),
$tagCat["name"]));
+ }
+
+ $query = "tags_categories SET name=". $db->quote_smart($tagCat['name']).
", description=". $db->quote_smart($tagCat['description']);
+ $query = ($id==0 ? "INSERT INTO ". $query : "UPDATE ". $query. " WHERE
id='$id'");
+ $ok = $db->query($query);
+ if ($ok && $id==0) $_REQUEST['id'] = $db->insertid();
+
+ return $ok;
+}
+
+function catDelConfirmFormHTML($id)
+{
+ if ($id==0) return error(_("Cat�gorie de tags non s�lectionn�"));
+
+ global $db;
+ $res = $db->query("SELECT * FROM tags_categories WHERE id='{$id}'");
+ if (! $cat = $db->fetchArray($res)) return error(_("Cat�gorie de tags
introuvable"));
+ $db->freeResult($res);
+
+ $return = "<form action=\"moderatetags.php\" method=\"post\"
enctype=\"multipart/form-data\" name=\"tagCategoryForm\">\n";
+ $return .= "<input type=\"hidden\" name=\"op\" value=\"catDelete\" />\n";
+
+ $return .= "<input type=\"hidden\" name=\"id\" value=\"{$cat['id']}\"
/>\n";
+ $return .= "<p>". sprintf(_("Vous �tes sur le point de supprimer la
cat�gorie de tags %s"), "<strong>{$cat['name']}</strong>"). "</p>\n";
+ $return .= "<p><label for=\"confirm\">". _("Confirmer la suppression").
"<input type=\"checkbox\" id=\"confirm\" name=\"confirm\" value=\"yes\"
/></label></p>";
+
+ $return .= "<p><input type=\"submit\" name=\"submit\" value=\"".
_("Valider"). "\" /></p>\n";
+
+ $return .= "</form>\n";
+
+ return $return;
+} // end function catDelConfirmForm
+
+function catDelete($id)
+{
+ global $db;
+ if (!isset($_POST["id"]))
+ return error(_("Ne venant pas du bon formulaire"));;
+ if (!isset($_POST["confirm"]) || $_POST["confirm"]!="yes")
+ return error(_("Supression non confirm�e"));
+
+ // Find cat
+ $res = $db->query("SELECT * FROM tags_categories WHERE id=".
$db->quote_smart($_POST['id']));
+ if (! $cat=$db->fetchArray($res))
+ { // tag already exists
+ return error(_("Enregistrement introuvable"));
+ }
+ $db->freeresult($res);
+
+ // Is tag used ?
+ $res = $db->query("SELECT * FROM tags WHERE category_id=".
$db->quote_smart($_POST['id']));
+ if ($db->fetchObject($res))
+ { // tag already exists
+ $db->freeresult($res);
+ return error(sprintf(_("La cat�gories %s comporte des tags"),
$cat["name"]));
+ }
+
+ $query = "DELETE FROM tags_categories WHERE id=".
$db->quote_smart($cat['id']);
+ if ($ok = $db->query($query))
+ echo "<p>". _("Cat�gorie de tags supprim�e")."</p>\n";
+ else
+ error(_("Impossible de supprimer la cat�gorie de tags"));
+
+ return $ok;
+} // end function catDelete()
+
+function tagListHTML($id)
+{
+ global $db;
+ if ($id>0)
+ {
+ $res = $db->query("SELECT * FROM tags_categories WHERE id='{$id}'");
+ if (! $tagCat = $db->fetchObject($res)) return error(_("Enregistrement
introuvable"));
+ $db->freeResult($res);
+ $return ="<h3>{$tagCat->name}</h3>\n";
+ $return .= "<p class=\"description\">{$tagCat->description}</p>";
+ }
+ else
+ {
+ $return ="<h3>". _("Sans cat�gorie"). "</h3>\n";
+ }
+
+ $return .= "<ul>\n";
+
+ $res = $db->query("SELECT tags.*, COUNT(event_id) AS n FROM tags LEFT JOIN
tags_events ON tags.id=tag_id WHERE category_id='{$id}' GROUP BY tags.id
ORDER BY tags.name");
+ while ($tag = $db->fetchObject($res))
+ {
+ $return .= " <li>". sprintf("%03s", $tag->n). " <a
href=\"listevents.php?tag={$tag->name}\" title=\"". sprintf(_("Liste des
�v�nements portant le tag %s"), $tag->name). "\">{$tag->name}</a> <span
class='description'>{$tag->description}</span>";
+ $return .= " - <a href='moderatetags.php?op=tagEdit&id={$tag->id}'
title=\"". sprintf(_("Modifier le tag %s"), $tag->name). "\">".
_("Modifier"). "</a>";
+ if ($tag->n==0)
+ $return .= " - <a href='moderatetags.php?op=tagDel&id={$tag->id}'
title=\"". sprintf(_("Supprimer le tag %s"), $tag->name). "\">".
_("Supprimer"). "</a>";
+ else
+ $return .= " - <a href='moderatetags.php?op=tagTr&id={$tag->id}'
title=\"". sprintf(_("Transf�rer le tag %s vers un autre tag"), $tag->name).
"\">". _("Transf�rer"). "</a>";
+ $return .= "</li>\n";
+ } // end while
+
+ if ($id>0) $return .= "<li><a
href='moderatetags.php?op=tagNew&id={$tagCat->id}' title=\"".
sprintf(_("Nouveau tag dans la cat�gorie %s"), $tagCat->name). "\">".
_("Nouveau tag"). "</a></li>";
+ $return .= "</ul>\n";
+
+ if ($id>0) $return .= "<a
href='moderatetags.php?op=catEdit&id={$tagCat->id}' title=\"".
sprintf(_("Modifier la cat�gorie %s"), $tagCat->name). "\">". _("Modifier").
"</a>";
+ if ($db->numRows($res)==0) $return .= " - <a
href='moderatetags.php?op=catDel&id={$tagCat->id}' title=\"".
sprintf(_("Supprimer la cat�gorie %s"), $tagCat->name). "\">".
_("Supprimer"). "</a>";
+
+ $db->freeResult($res);
+
+ return $return;
+} // end function tagListHTML
+
+function selectTagCategoryHTML($id, $field="category_id")
+// Function to choose tag category ($id)
+// $id is (int) tag category or (int) 0
+// $field (string) name of select form
+// output if HTML string select part of form
+{
+ global $db;
+ $ret = $db->query ("SELECT * FROM tags_categories");
+ if ($ret == FALSE)
+ {
+ error ("Erreur lors de la recherche des cat�gories de tags");
+ put_footer();
+ exit;
+ }
+ $return = "<select name='$field'>";
+ $return .= " <option value='0' ". ($id==0 ? "selected='selected' " : "").
">". _("(aucune)"). "</option>";
+ while ($row = $db->fetchObject($ret))
+ {
+ $return .= " <option value='{$row->id}' ". ($row->id==$id ?
"selected='selected' " : ""). ">{$row->name}</option>";
+ }
+ $db->freeResult($ret);
+ $return .= " </select>\n";
+ return $return;
+} // end function selectPlaceHTML()
+
+function tagFormHTML($id, $category_id)
+{
+ $return = "<form action=\"moderatetags.php\" method=\"post\"
enctype=\"multipart/form-data\" name=\"tagCategoryForm\">\n";
+ $return .= "<input type=\"hidden\" name=\"op\" value=\"tagUpdate\" />\n";
+
+ if (isset($_POST["tag"]))
+ { // We came from form
+ $tag = $_POST["tag"];
+ } // end if
+ else
+ {
+ if ($id>0)
+ { // edit
+ global $db;
+ $res = $db->query("SELECT * FROM tags WHERE id='{$id}'");
+ if (! $tag = $db->fetchArray($res)) return error(_("Enregistrement
introuvable"));
+ $return .= "<input type=\"hidden\" name=\"id\" value=\"{$tag['id']}\"
/>\n";
+ $db->freeResult($res);
+ $tag['name'] = escape_form_string($tag['name']);
+ $tag['description'] = escape_form_string($tag['description'],
"<p><b><i><br/><a><ul><li><ol>");
+ } // end if
+ else
+ { // new
+ $tag = array("name"=>null, "description"=>null,
"category_id"=>$category_id);
+ } // end else
+ } // end else
+
+ $return .= "<table>";
+ $return .= "<tr><th colspan='2'>". _("�dition d'un tag"). "</th></tr>\n";
+ $return .= "<tr><th>". _("Intitul�*"). "</th> <td><input type=\"text\"
name=\"tag[name]\" value=\"{$tag['name']}\" size='40' /></td></tr>\n";
+ $return .= "<tr><th>". _("Cat�gorie*"). "</th> <td>".
selectTagCategoryHTML($tag['category_id'], "tag[category_id]").
"</td></tr>\n";
+ $return .= "<tr><th>". _("Description"). "</th> <td><textarea
name=\"tag[description]\" rows=\"4\"
cols=\"70\">{$tag['description']}</textarea></td></tr>\n";
+
+ $return .= "<tr><th colspan='2'><input type=\"submit\" name=\"submit\"
value=\"". _("Valider"). "\" /></th></tr>\n";
+
+ $return .= "</table>\n</form>\n";
+
+ return $return;
+} // end function tagFormHTML
+
+function tagUpdate($id)
+{
+ global $db;
+ if (!isset($_POST["tag"]))
+ return error(_("Ne venant pas du formulaire"));
+ $tag = $_POST["tag"];
+ if (!is_array($tag) || !isset($tag["name"], $tag["category_id"],
$tag["description"]))
+ return error(_("Ne venant pas du bon formulaire"));;
+ if (strlen($tag["name"])<4)
+ return error(_("Intitul� indispensable d'au moins 4 caract�res"));
+
+ $tagCat["name"] = stripslashes(strip_tags($tag["name"]));
+ $tagCat["description"] = stripslashes(strip_tags($tag["description"],
"<p><b><i><br/><a><ul><li><ol>"));
+
+ // Detect double
+ $res = $db->query("SELECT * FROM tags WHERE name LIKE ".
$db->quote_smart($tag['name']). ($id>0 ? " AND id<>$id" : ""));
+ if ($db->fetchObject($res))
+ { // tag already exists
+ return error(sprintf(_("Le tag %s existe d�j�"), $tag["name"]));
+ }
+
+ $query = "tags SET name=". $db->quote_smart($tag['name']). ",
category_id=". $db->quote_smart($tag['category_id']). ", description=".
$db->quote_smart($tag['description']);
+ $query = ($id==0 ? "INSERT INTO ". $query : "UPDATE ". $query. " WHERE
id='$id'");
+ $ok = $db->query($query);
+ if ($ok && $id==0) $_REQUEST['id'] = $db->insertid();
+
+ return $ok;
+}
+
+function tagDelConfirmFormHTML($id)
+{
+ if ($id==0) return error(_("Tag non s�lectionn�"));
+
+ global $db;
+ $res = $db->query("SELECT * FROM tags WHERE id='{$id}'");
+ if (! $tag = $db->fetchArray($res)) return error(_("Tag introuvable"));
+ $db->freeResult($res);
+
+ $return = "<form action=\"moderatetags.php\" method=\"post\"
enctype=\"multipart/form-data\" name=\"tagDelConfirmForm\">\n";
+ $return .= "<input type=\"hidden\" name=\"op\" value=\"tagDelete\" />\n";
+
+ $return .= "<input type=\"hidden\" name=\"id\" value=\"{$tag['id']}\"
/>\n";
+ $return .= "<input type=\"hidden\" name=\"category_id\"
value=\"{$tag['category_id']}\" />\n";
+ $return .= "<p>". sprintf(_("Vous �tes sur le point de supprimer le tag
%s"), "<strong>{$tag['name']}</strong>"). "</p>\n";
+ $return .= "<p><label for=\"confirm\">". _("Confirmer la suppression").
"<input type=\"checkbox\" id=\"confirm\" name=\"confirm\" value=\"yes\"
/></label></p>";
+
+ $return .= "<p><input type=\"submit\" name=\"submit\" value=\"".
_("Valider"). "\" /></p>\n";
+
+ $return .= "</form>\n";
+
+ return $return;
+} // end function tagDelConfirmForm
+
+function tagDelete($id)
+{
+ global $db;
+ if (!isset($_POST["id"], $_POST["category_id"]))
+ return error(_("Ne venant pas du bon formulaire"));;
+ if (!isset($_POST["confirm"]) || $_POST["confirm"]!="yes")
+ return error(_("Supression non confirm�e"));
+
+ // Find tag
+ $res = $db->query("SELECT * FROM tags WHERE id=".
$db->quote_smart($_POST['id']));
+ if (! $tag=$db->fetchArray($res))
+ { // tag already exists
+ return error(_("Enregistrement introuvable"));
+ }
+ $db->freeresult($res);
+
+ // Is tag used ?
+ $res = $db->query("SELECT * FROM tags_events WHERE tag_id=".
$db->quote_smart($_POST['id']));
+ if ($db->fetchObject($res))
+ { // tag already exists
+ $db->freeresult($res);
+ return error(sprintf(_("Le tag %s est utilis�"), $tag["name"]));
+ }
+
+ $query = "DELETE FROM tags WHERE id=". $db->quote_smart($tag['id']);
+ if ($ok = $db->query($query))
+ echo "<p>". _("Tag supprim�")."</p>\n";
+ else
+ error(_("Impossible de supprimer le tag"));
+
+ return $ok;
+}
+
+// Function to choose tags
+// $aTags is an array (category_id=>tag_name)
+// output if HTML string select part of form
+function selectTagHTML($id, $field="tag_id", $category_id=null)
+{
+ global $db;
+ // TODO Select only tags used twice or more.
+ // Or sort and class tags in alphabetical optgroup
+ $ret = $db->query ("SELECT tags.id AS id, tags.name AS tag,
tags.description AS tag_description, tags_categories.id AS category_id,
tags_categories.name AS category, tags_categories.description as description
FROM tags LEFT JOIN tags_categories ON tags_categories.id=category_id GROUP
BY category_id, tags.id ORDER BY tags_categories.name, tags.name");
+ if ($ret == FALSE)
+ {
+ error (_("Erreur lors de la recherche des tags"));
+ put_footer();
+ exit;
+ }
+ $category_id=-1;
+ $return = "<select name=\"$field\">";
+ $return .= " <option></option>";
+ while ($row = $db->fetchObject($ret))
+ {
+ if ($category_id!=$row->category_id)
+ {
+ if ($category_id!=-1) $return .= "<optgroup>\n";
+ $return .= " <optgroup label=\"{$row->category}".
($row->description>"" ? " - {$row->description}" : ""). "\">";
+ $category_id = $row->category_id;
+ } // end if
+ $return .= " <option value='{$row->id}'". ($id==$row->id ? "
selected='selected'" : ""). ">{$row->tag}". ($row->tag_description>"" ? " -
{$row->tag_description}" : ""). "</option>";
+ } // end while
+ $db->freeResult($ret);
+ $return .= "</select>\n";
+
+ return $return;
+} // end function selectTagHTML()
+
+function tagTransferFormHTML($id)
+{
+ if ($id==0) return error(_("Tag non s�lectionn�"));
+
+ global $db;
+
+ // find tag
+ $res = $db->query("SELECT * FROM tags WHERE id='{$id}'");
+ if (! $tag = $db->fetchArray($res)) return error(_("Tag introuvable"));
+ $db->freeResult($res);
+
+ // How many events with this tag
+ $res = $db->query("SELECT event_id AS n FROM tags_events WHERE
tag_id='{$id}'");
+ $tagevent = $db->numRows($res);
+ $db->freeResult($res);
+
+ $return = "<form action=\"moderatetags.php\" method=\"post\"
enctype=\"multipart/form-data\" name=\"tagTransferForm\">\n";
+ $return .= "<input type=\"hidden\" name=\"op\" value=\"tagTransfer\" />\n";
+ $return .= "<input type=\"hidden\" name=\"id\" value=\"{$tag['id']}\"
/>\n";
+ $return .= "<input type=\"hidden\" name=\"category_id\"
value=\"{$tag['category_id']}\" />\n";
+
+ $return .= "<p>". sprintf(_("Vous souhaitez retirer le tag %s des %s
�v�nements"), $tag['name'], $tagevent);
+
+ $return .= "<br />". _("et les marquer avec le nouveau tag*"). " ".
selectTagHTML($id, "tag_id"). "</p>\n";
+
+ $return .= "<p><label for=\"confirm\">". _("Confirmer le transfert").
"<input type=\"checkbox\" id=\"confirm\" name=\"confirm\" value=\"yes\"
/></label></p>";
+
+ $return .= "<p><input type=\"submit\" name=\"submit\" value=\"".
_("Valider"). "\" /></p>\n";
+
+ $return .= "</form>\n";
+
+ return $return;
+}
+
+// Unmark events with $id_from tag
+// and mark with $id_to tag
+function tagTransfer($id_from, $id_to)
+{
+ if ($id_from==0 || $id_to==0) return error(_("Tag non s�lectionn�"));
+
+ global $db;
+
+ // find from tag
+ $res = $db->query("SELECT * FROM tags WHERE id='{$id_from}'");
+ if (! $tag_from = $db->fetchObject($res)) return error(_("Tag
introuvable"));
+ $db->freeResult($res);
+
+ // find to tag
+ $res = $db->query("SELECT * FROM tags WHERE id='{$id_to}'");
+ if (! $tag_to = $db->fetchObject($res)) return error(_("Tag introuvable"));
+ $db->freeResult($res);
+
+ // select events
+ $query = "SELECT event_id FROM tags_events WHERE tag_id=".
$db->quote_smart($id_from);
+ $res = $db->query($query);
+ $ok = $res;
+ $aEvents = array();
+ while ($rec = $db->fetchObject($res)) $aEvents[] = $rec->event_id;
+ $db->freeResult($res);
+
+ if (count($aEvents)>0) {
+ $lEvents = implode(",", $aEvents);
+ // remove mark events from
+ $query = "DELETE FROM tags_events WHERE tag_id=".
$db->quote_smart($id_from). " AND event_id IN (". $lEvents. ")";
+ $res = $db->query($query);
+ $ok &= $res;
+
+ // mark events to
+ $query = "REPLACE INTO tags_events (event_id, tag_id) VALUES ";
+ foreach ($aEvents as $event) $query.= " (". $event. ", ". $id_to. ")";
+ $res = $db->query($query);
+ $ok &= $res;
+ } // end if
+
+ return $ok;
+} // end function tagTransfer($id_from, $id_to)
+
+/*
+ *
+ * Main page
+ *
+ */
+
+$op = (isset($_REQUEST["op"]) ? $_REQUEST["op"] : null);
+
+switch ($op) // compute
+{
+
+ case "tagUpdate" :
+ {
+ if ($ret = tagUpdate(isset($_POST["id"]) ? $_POST["id"] : 0))
+ { // good, return to tag list
+ $op = "catListTag";
+ $_REQUEST['id'] = $_POST["tag"]['category_id'];
+ }
+ else
+ { // error return to tag form
+ $op = (isset($_POST["id"]) ? "tagEdit" : "tagNew");
+ }
+ break;
+ }
+
+ case "tagDelete" :
+ {
+ $ret = tagDelete($_POST["id"]);
+ $op = "catListTag";
+ $_REQUEST['id'] = $_POST["category_id"];
+ break;
+ }
+
+ case "tagTransfer" :
+ {
+ if (isset($_POST["confirm"]) && $_POST["confirm"]=="yes")
+ $ret = tagTransfer($_POST["id"], $_POST["tag_id"]);
+ $op = "catListTag";
+ $_REQUEST['id'] = $_POST["category_id"];
+ break;
+ }
+
+ case "catUpdate" :
+ {
+ $ret = tagCategoryUpdate(isset($_POST["id"]) ? $_POST["id"] : 0);
+ $op = ( $ret ? "catList" : (isset($_POST["id"]) ? "catEdit" : "catNew")
);
+ break;
+ }
+
+ case "catDelete" :
+ {
+ $ret = catDelete($_POST["id"]);
+ $op = "catList";
+ break;
+ }
+
+} // end switch compute
+
+
+switch ($op) // display
+{
+
+ case "tagDel" :
+ {
+ echo tagDelConfirmFormHTML($_REQUEST["id"]);
+ break;
+ }
+
+ case "tagNew" :
+ {
+ echo tagFormHTML(0, isset($_REQUEST["id"]) ? $_REQUEST["id"] : 0);
+ break;
+ }
+
+ case "tagEdit" :
+ {
+ echo tagFormHTML($_REQUEST["id"], 0);
+ break;
+ }
+
+ case "tagTr" :
+ {
+ echo tagTransferFormHTML($_REQUEST["id"]);
+ break;
+ }
+
+ case "catDel" :
+ {
+ echo catDelConfirmFormHTML($_REQUEST["id"]);
+ break;
+ }
+
+ case "catNew" :
+ {
+ echo tagCategoryFormHTML(0);
+ break;
+ }
+
+ case "catEdit" :
+ {
+ echo tagCategoryFormHTML($_REQUEST["id"]);
+ break;
+ }
+
+ case "catDel" :
+ {
+ echo tagCategoryDelHTML($_REQUEST["id"]);
+ break;
+ }
+
+ case "catListTag" :
+ {
+ echo tagListHTML($_REQUEST["id"]);
+ break;
+ }
+
+ default : // list categories
+ {
+ // showTagCategoryList
+ echo tagCategoryListHTML();
+ break;
+ }
+
+} // end switch display
+
+if ($op!="" && $op!="catList") echo "<p><a href=\"moderatetags.php\">".
_("Liste des cat�gories de tags"). "</a></p>\n";
+
+put_footer();
+
+?>
- [Devel] r275 - branches/dui, svn, 20/05/2007
- Re: [Devel] r275 - branches/dui, David MENTRE, 25/05/2007
- Re: [Devel] r275 - branches/dui, Loïc Dayot, 27/05/2007
- Re: [Devel] r275 - branches/dui, David MENTRE, 25/05/2007
Archives gérées par MHonArc 2.6.16.