-
Notifications
You must be signed in to change notification settings - Fork 2
/
edit_entry_types.php
158 lines (145 loc) · 5.86 KB
/
edit_entry_types.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* edit_entry_types.php
* Page "Ajax" utilisée pour générer les types
* Ce script fait partie de l'application GRR
* Dernière modification : $Date: 2010-04-07 17:49:56 $
* @author Laurent Delineau <[email protected]>
* @copyright Copyright 2003-2008 Laurent Delineau
* @link http://www.gnu.org/licenses/licenses.html
* @package root
* @version $Id: edit_entry_types.php,v 1.10 2010-04-07 17:49:56 grr Exp $
* @filesource
*
* This file is part of GRR.
*
* GRR 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.
*
* GRR 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 GRR; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* $Log: edit_entry_types.php,v $
* Revision 1.10 2010-04-07 17:49:56 grr
* *** empty log message ***
*
* Revision 1.9 2010-03-03 14:41:34 grr
* *** empty log message ***
*
* Revision 1.8 2009-06-04 15:30:17 grr
* *** empty log message ***
*
* Revision 1.7 2009-04-14 12:59:17 grr
* *** empty log message ***
*
* Revision 1.6 2009-03-24 13:30:07 grr
* *** empty log message ***
*
* Revision 1.5 2008-11-16 22:00:58 grr
* *** empty log message ***
*
* Revision 1.4 2008-11-11 22:01:14 grr
* *** empty log message ***
*
*
*/
include "include/admin.inc.php";
/* Ce script a besoin de trois arguments passés par la méthode GET :
$id : l'identifiant de la réservation (0 si nouvelle réservation)
$areas : l'identifiant du domaine
$room : l'identifiant de la ressource
*/
// Initialisation
if (isset($_GET["type"])) {
$type = $_GET["type"];
} else die();
if (isset($_GET['areas'])) {
$areas = $_GET['areas'];
settype($areas,"integer");
}
else die();
if (isset($_GET['room'])) {
$room = $_GET['room'];
if ($room != "") settype($room,"integer");
}
else die();
if ((authGetUserLevel(getUserName(),-1) < 2) and (auth_visiteur(getUserName(),$room) == 0))
{
showAccessDenied("","","","","");
exit();
}
if(authUserAccesArea(getUserName(), $areas)==0)
{
showAccessDenied("","","","","");
exit();
}
// Type de réservation
$qui_peut_reserver_pour = grr_sql_query1("select qui_peut_reserver_pour from grr_room where id='".$room."'");
$aff_default=((authGetUserLevel(getUserName(),-1,"room") >= $qui_peut_reserver_pour) or (authGetUserLevel(getUserName(),$areas,"area") >= $qui_peut_reserver_pour));
$aff_type=max(authGetUserLevel(getUserName(),-1,"room"),authGetUserLevel(getUserName(),$areas,"area"));
// Avant d'afficher la liste déroulante des types, on stocke dans $display_type et on teste le nombre de types à afficher
// Si ne nombre est égal à 1, on ne laisse pas le choix
$nb_type = 0;
$type_nom_unique = "??";
$type_id_unique = "??";
$display_type = "<table width=100%><tr><td class=\"E\"><B>".get_vocab("type")." *".get_vocab("deux_points")."</B></td></tr>\n";
$affiche_mess_asterisque=true;
$display_type .= "<tr><td class=\"CL\">";
$display_type .= "<select id=\"type\" name=\"type\" size=\"1\" onclick=\"setdefault('type_default','')\">\n";
$display_type .= "<option value='0'>".get_vocab("choose")."\n";
$sql = "SELECT DISTINCT t.type_name, t.type_letter, t.id FROM ".TABLE_PREFIX."_type_area t
LEFT JOIN ".TABLE_PREFIX."_j_type_area j on j.id_type=t.id
WHERE (j.id_area IS NULL or j.id_area != '".$areas."') and (t.disponible<='".$aff_type."')
ORDER BY t.order_display";
$res = grr_sql_query($sql);
if ($res)
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
// La requête sql précédente laisse passer les cas où un type est non valide
// dans le domaine concerné ET au moins dans un autre domaine, d'où le test suivant
$test = grr_sql_query1("select id_type from ".TABLE_PREFIX."_j_type_area where id_type = '".$row[2]."' and id_area='".$areas."'");
if ($test == -1)
{
$nb_type ++;
$type_nom_unique = $row[0];
$type_id_unique = $row[1];
$display_type .= "<option value=\"".$row[1]."\" ";
// Modification d'une réservation
if ($type != "") {
if ($type == $row[1]) {
$display_type .= " selected=\"selected\"";
}
} else {
// Nouvelle réservation
$id_type_par_defaut = grr_sql_query1("select id_type_par_defaut from ".TABLE_PREFIX."_area where id = '".$areas."'");
//Récupère le cookie par defaut
if($aff_default and isset($_COOKIE['type_default'])) $cookie = $_COOKIE['type_default']; else $cookie="";
if ((!$cookie and ($id_type_par_defaut == $row[2])) or ($cookie and $cookie==$row[0])) $display_type .= " selected=\"selected\"";
}
$display_type .= " >".my_htmlspecialcharacters(removeMailUnicode($row[0]))."</option>\n";
}
}
$display_type .= "</select>";
if($aff_default)
$display_type .= " <input type=\"button\" value=\"".get_vocab("definir par defaut")."\" onclick=\"setdefault('type_default',document.getElementById('main').type.options[document.getElementById('main').type.options.selectedIndex].text)\" />";
$display_type .= "</td></tr></table>\n";
if ($unicode_encoding)
header("Content-Type: text/html;charset=utf-8");
else
header("Content-Type: text/html;charset=".$charset_html);
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
if ($nb_type > 1) {
echo $display_type;
} else {
echo "<table width=100%><tr><td class=\"E\"><b>".get_vocab("type").get_vocab("deux_points").my_htmlspecialcharacters(removeMailUnicode($type_nom_unique))."</b>"."<input name=\"type\" type=\"hidden\" value=\"".$type_id_unique."\" /></td></tr></table>\n";
}
?>