Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 jpm 1
<?
2
//------------------------------------------------------------------------------
3
// FICHIER : $RCSfile: adsi_squelette.fonct.php,v $
4
// AUTEUR  : $Author: jpm $
5
// VERSION : $Revision: 1.1 $
6
// DATE    : $Date: 2004-06-16 14:28:53 $
7
//------------------------------------------------------------------------------
8
// GSite - Web site management in PHP - gus module
9
//
10
// Copyright (C) 2001 COUDOUNEAU Laurent (lc@gsite.org)
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
//------------------------------------------------------------------------------
26
//------------------------------------------------------------------------------
27
 
28
//==============================================================================
29
//==============================================================================
30
 
31
function updatePresentation ($db, $link, $project, $locale,
32
                             $baseURL, $baseURLjs, $baseHidden,
33
                             $managedProject) {
34
  //----------------------------------------------------------------------------
35
  // JavaScript.
36
 
37
  $not_empty = gs_getLabel ($db, $link, 'not_empty', $locale, false);
38
 
39
  js_register ('validateAndSubmit',
40
    "  function validateAndSubmit (oForm) {"."\n".
41
    "    if (oForm.guspresP_LOOK_NAME.value == '') {"."\n".
42
    "      alert ('P_LOOK_NAME : $not_empty');"."\n".
43
    "      return;"."\n".
44
    "    }"."\n".
45
    "    "."\n".
46
    "    oForm.submit ();"."\n".
47
    "  }"."\n"
48
  );
49
 
50
  //----------------------------------------------------------------------------
51
  // Query project : get presentation.
52
 
53
  $query = "select * from $db.PROJECT where GS_PROJECT='$managedProject'";
54
 
55
  $result = mysql_query ($query, $link);
56
 
57
  if (! $result) {
58
    die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
59
  }
60
 
61
  $button = '';
62
  $text   = '';
63
  $pres   = '';
64
  $msg    = '';
65
  $title  = '';
66
 
67
  if (mysql_num_rows ($result) != 1) {
68
    //--------------------------------------------------------------------------
69
    // Unknown project.
70
 
71
    $msg = gs_getLabel ($db, $link, 'gus_unknown_prj', $locale, 'gus')." ($managedProject)";
72
 
73
    $button =
74
      gs_genericButtons ($db, $link, $locale,
75
                         array (
76
                           array (
77
                             'text' => 'back',
78
                             'appl' => 'gsite',
79
                             'url'  => $baseURL)),
80
                         false);
81
 
82
  } else {
83
    //--------------------------------------------------------------------------
84
    // Get row.
85
 
86
    $row  = mysql_fetch_object ($result);
87
    $pres = $row->GS_PRESENTATION;
88
 
89
    //--------------------------------------------------------------------------
90
    // Get presentation.
91
 
92
    $query = "select * from $db.".$pres."_PRESENTATION where P_LOOK_NAME='$row->GS_LOOK_NAME'";
93
 
94
    $PRESresult = mysql_query ($query, $link);
95
 
96
    if (! $PRESresult) {
97
      die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
98
    }
99
 
100
    $numFields = mysql_num_fields ($PRESresult);
101
 
102
    //-- We already have a presentation ?
103
 
104
    $title .= '&nbsp;: ';
105
 
106
    if (mysql_num_rows ($PRESresult) == 0) {
107
      $title .= gs_getLabel ($db, $link, 'gus_title5_not_exist', $locale, 'gus');
108
 
109
    } else {
110
      $title .= gs_getLabel ($db, $link, 'gus_title5_exist', $locale, 'gus');
111
    }
112
 
113
    //-- Get infos about fields.
114
 
115
    $metaArray = array ();
116
 
117
    for ($i = 0; $i < $numFields; $i++) {
118
      $metaArray[$i] = mysql_fetch_field ($PRESresult);
119
    }
120
 
121
    //-- Get result.
122
 
123
    $PRESrow = mysql_fetch_row ($PRESresult);
124
 
125
    $dataArray = array ();
126
 
127
    for ($i = 0; $i < $numFields; $i++) {
128
      $dataArray[$i] = $PRESrow[$i];
129
    }
130
 
131
    //--------------------------------------------------------------------------
132
    // Dump form.
133
 
134
    $text = '';
135
 
136
    $text .= "\n".'<FORM name="gform" action="document.php" method="post">';
137
 
138
    $text .= "\n".'  <TABLE cellspacing="0" cellpadding="0" border="0" summary="">';
139
 
140
    for ($i = 0; $i < $numFields; $i++) {
141
      $text .= "\n".'    <TR>';
142
      $text .= "\n".'      <TD class="gusLabel">'.htmlentities ($metaArray[$i]->name).'&nbsp;:&nbsp;</TD>';
143
 
144
      $text .= "\n".'      <TD class="gusInput"><INPUT';
145
      $text .= "\n".'         class="gusInput"';
146
      $text .= "\n".'         type="text"';
147
      $text .= "\n".'         name="guspres'.$metaArray[$i]->name.'"';
148
      $text .= "\n".'         size="48"';
149
      $text .= "\n".'         maxlength="255"';
150
      $text .= "\n".'         value="'.htmlentities ((($dataArray[$i] == '') && ($metaArray[$i]->name == 'P_LOOK_NAME')
151
                                                     ? $row->GS_LOOK_NAME
152
                                                     : $dataArray[$i])).'"></TD>';
153
      $text .= "\n".'    </TR>';
154
    }
155
 
156
    $text .= "\n".'    <TR>';
157
    $text .= "\n".'      <TD align="center" colspan="2"><TABLE border="0" summary="" width="100%" cellpadding="0" cellspacing="0">';
158
    $text .= "\n".'          <TR>';
159
    $text .= "\n".'            <TD align="center"><INPUT type="image" src="Local/icons/validate.gif"></TD>';
160
    $text .= "\n".'            <TD align="center"><A href="'.$baseURL.'"><IMG '.
161
                                'border="0" src="Local/icons/cancel.gif" alt="" width="16" height="16"></A></TD>';
162
    $text .= "\n".'          </TR>';
163
    $text .= "\n".'        </TABLE></TD>';
164
    $text .= "\n".'    </TR>';
165
 
166
    $text .= "\n".'  </TABLE>';
167
 
168
    $text .= "\n".'  <INPUT type="hidden" name="gusprjid"   value="'.htmlentities ($managedProject).'">';
169
    $text .= "\n".'  <INPUT type="hidden" name="gusprsid"   value="'.htmlentities ($row->GS_LOOK_NAME).'">';
170
    $text .= "\n".'  <INPUT type="hidden" name="gusprjpres" value="'.htmlentities ($row->GS_PRESENTATION).'">';
171
    $text .= "\n".'  <INPUT type="hidden" name="guscmd"     value="commitupdpres">';
172
    $text .= $baseHidden;
173
 
174
    $text .= "\n".'</FORM>';
175
  }
176
 
177
  mysql_free_result ($result);
178
 
179
  //----------------------------------------------------------------------------
180
  // Build page.
181
 
182
  $title =
183
    $managedProject.
184
    (empty ($pres) ? '' : ' / '.$pres).
185
    $title;
186
 
187
  return
188
    buildPage (
189
      $button, '',
190
      $title,
191
      $text,
192
      $msg);
193
}
194
 
195
//==============================================================================
196
//==============================================================================
197
 
198
function commitUpdatePresentation ($db, $link, $project, $locale,
199
                                   $userLevel, $adminProject,
200
                                   $baseURL, $baseURLjs) {
201
  global $gusprjid;
202
  global $gusprsid;
203
  global $gusprjpres;
204
  global $guspresP_LOOK_NAME;
205
 
206
  //----------------------------------------------------------------------------
207
  // Look name set ?
208
 
209
  $msg = '';
210
 
211
  if (isset ($guspresP_LOOK_NAME) && ($guspresP_LOOK_NAME != '')) {
212
    //--------------------------------------------------------------------------
213
    // This look name already exist ?
214
 
215
    $query = "select * from $db.$gusprjpres"."_PRESENTATION where P_LOOK_NAME='$gusprsid'";
216
 
217
    $result = mysql_query ($query, $link);
218
 
219
    if (! $result) {
220
      die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
221
    }
222
 
223
    $presExist = (mysql_num_rows ($result) == 1);
224
 
225
    mysql_free_result ($result);
226
 
227
    //--------------------------------------------------------------------------
228
    // We have a look name. We get others informations, and build request.
229
 
230
    global $HTTP_POST_VARS;
231
 
232
    $query = '';
233
 
234
    reset ($HTTP_POST_VARS);
235
    while (list ($key, $val) = each ($HTTP_POST_VARS)) {
236
      if (substr ($key, 0, strlen ('guspres')) == 'guspres') {
237
        if ($query != '') $query .= ', ';
238
        $query .= substr ($key, strlen ('guspres'), strlen ($key) - strlen ('guspres'))."='$val'";
239
      }
240
    }
241
 
242
    if ($presExist) {
243
      $query = "update $db.$gusprjpres"."_PRESENTATION set ".$query." where P_LOOK_NAME='$gusprsid'";
244
 
245
    } else {
246
      $query = "insert into $db.$gusprjpres"."_PRESENTATION set ".$query;
247
    }
248
 
249
    //--------------------------------------------------------------------------
250
    // Execute query.
251
 
252
    $result = mysql_query ($query, $link);
253
 
254
    if (! $result) {
255
      die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
256
    }
257
 
258
  } else {
259
    $msg = gs_getLabel ($db, $link, 'gus_pres_noname', $locale, 'gus');
260
  }
261
 
262
  //----------------------------------------------------------------------------
263
  // List all projects.
264
 
265
  return
266
    listProjects ($db, $link, $project, $locale,
267
                  $userLevel, $adminProject,
268
                  $baseURL, $baseURLjs,
269
                  $msg);
270
}
271
 
272
//------------------------------------------------------------------------------
273
// $Log: not supported by cvs2svn $
274
// Revision 1.1  2003/10/10 09:58:21  alex
275
// installation
276
//
277
// Revision 1.1.1.1  2002/10/02 07:32:21  root
278
// initialisation site de Tela
279
//
280
// Revision 1.2  2002/06/14 07:22:38  lc
281
// Bug LC0021 : use js_register
282
//
283
// Revision 1.1  2002/02/25 16:35:57  lc
284
// First revision.
285
//
286
//-- End of source  ------------------------------------------------------------
287
?>