[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / discuter.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 include_spip('inc/forum');
16 include_spip('inc/presentation');
17
18 // http://doc.spip.org/@formulaire_discuter
19 function formulaire_discuter($script, $args, $debut, $pas, $ancre, $total, $objet)
20 {
21 $nav = '';
22 $e = (_SPIP_AJAX === 1);
23 for ($tranche = 0; $tranche < $total; $tranche += $pas){
24 $y = $tranche + $pas - 1;
25 if ($tranche == $debut)
26 $nav .= "<span class='spip_medium'><b>[$tranche-$y]</b></span> ";
27 else {
28 $h = "$args&debut=$tranche";
29 if (!$e) {
30 $h = generer_url_ecrire($script, $h);
31 } else {
32 $h .= "&script=$script";
33 if ($objet) $h .= "&objet=$objet";
34 $h = generer_url_ecrire('discuter', $h);
35 $e = "\nonclick=" . ajax_action_declencheur($h,$ancre);
36 }
37 $nav .= "[<a href='$h#$ancre'$e>$tranche-$y</a>] ";
38 }
39 }
40 return "<div class='serif2 centered'>$nav</div>";
41 }
42
43 // http://doc.spip.org/@inc_discuter_dist
44 function inc_discuter_dist($id, $script, $objet, $statut='prive', $debut=NULL, $pas=NULL, $id_parent = 0)
45 {
46 if ($GLOBALS['meta']['forum_prive_objets'] == 'non')
47 return '';
48
49 $debut = intval($debut);
50 if (!$pas = intval($pas)) $pas = 10;
51 $id = intval($id);
52 $args = ($objet ? "$objet=$id&" : '') . "statut=$statut";
53 $ancre = "poster_forum_prive" . ($objet ? '' : "-$id");
54
55 if ($id_parent) {
56 $id_t = sql_getfetsel('id_thread', 'spip_forum', "id_forum=$id_parent");
57 $query = array('SELECT' => "*", 'FROM' => "spip_forum", 'WHERE' => "id_forum=$id_t");
58
59 $res = afficher_forum($query, $script, $args);
60
61 } else {
62 $clic = _T('icone_poster_message');
63 $logo = ($script == 'forum_admin') ?
64 "forum-admin-24.gif" : "forum-interne-24.gif";
65 $lien = generer_url_ecrire("poster_forum_prive", "statut=$statut&id=$id&script=$script");
66 $res = icone_inline($clic, $lien, $logo, "creer.gif",'center', $ancre);
67
68 $where = ((!$objet OR !$id) ? '' : ($objet . "=" . sql_quote($id) . " AND "))
69 . "id_parent=0 AND statut=" . sql_quote($statut);
70
71 $n = sql_countsel('spip_forum', $where);
72 if ($n) {
73
74 $nav = ($n <= $pas) ? '' :
75 formulaire_discuter($script, "id=$id&$objet=$id&statut=$statut", $debut, $pas, $ancre, $n, $objet);
76
77 $query = array('SELECT' => "*", 'FROM' => "spip_forum", 'WHERE' => $where, 'ORDER BY' => "date_heure DESC", 'LIMIT' => "$debut,$pas");
78 $q = afficher_forum($query, $script, $args, false);
79 $res .= $nav . $q . "<br />" . $nav;
80 }
81 }
82 return ajax_action_greffe($ancre, '', $res);
83 }
84 ?>