modere.php 8.92 KB
Newer Older
Ayolo's avatar
Ayolo committed
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
<?php
/* Copyright 2006
 * - Julien Etelain < julien at pmad dot net >
 *
 * Ce fichier fait partie du site de l'Association des Étudiants de
 * l'UTBM, http://ae.utbm.fr.
 *
 * 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.
 */
$topdir="../";
require_once("include/sas.inc.php");
require_once($topdir."include/cts/gallery.inc.php");
require_once($topdir."include/cts/sqltable.inc.php");
require_once($topdir."include/cts/video.inc.php");
require_once($topdir."include/entities/asso.inc.php");


$site = new sas();
$site->add_css("css/sas.css");

// Initialisation variables
$photo = new photo($site->db,$site->dbrw);
$photo->id=-1;
$filter="";
$page = "modere.php?";
$error=0;
$phasso = new asso($site->db);
$ptasso = new asso($site->db);

// Permet de restreindre le travail à une catégorie
$cat = new catphoto($site->db,$site->dbrw);
if ( isset($_REQUEST["id_catph"]))
{
  $cat->load_by_id($_REQUEST["id_catph"]);
  if ( $cat->id > 0 )
  {
    $page .= "id_catph=".$cat->id."&";
    $filter = " AND `id_catph`='".intval($cat->id)."'";
  }
}
else
  $cat->id = -1;

if ( $_REQUEST["mode"] == "adminzone" )
{
  if ( $cat->id > 0 )
    $id_groupe_admin = $cat->id_groupe_admin;
  else
    $id_groupe_admin = intval($_REQUEST["id_groupe_admin"]);

  if ( !$site->user->is_in_group_id($id_groupe_admin) && !$site->user->is_in_group("gestion_ae") && !$site->user->is_in_group("sas_admin"))
65
    $site->error_forbidden("sas","group",$id_groupe_admin);
66

Ayolo's avatar
Ayolo committed
67
68
69
70
71
72
  $page .= "mode=adminzone&id_groupe_admin=".$id_groupe_admin;
  $filter .= " AND `id_groupe_admin` ='".$id_groupe_admin."'";
}
else
{
  if ( !$site->user->is_in_group("gestion_ae") && !$site->user->is_in_group("sas_admin"))
73
    $site->error_forbidden("sas","group",9);
74

Ayolo's avatar
Ayolo committed
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
  $page .= "mode=full";
}

$site->start_page("sas","Modération",true);
$cts = new contents("Modérer et completer les noms");


if ( $_REQUEST["action"] == "modere" )
{
  $photo->load_by_id($_REQUEST["id_photo"]);


  if ( $photo->id > 0 && $photo->is_right($site->user,DROIT_ECRITURE))
  {
    if ( isset($_REQUEST["delete"]))
    {
      $photo->remove_photo();
    }
    else
    {
      $incomplet=!isset($_REQUEST["complet"]);

      $req = new requete($site->db,"SELECT `id_utilisateur`,`modere_phutl` FROM `sas_personnes_photos` WHERE `id_photo`='".$photo->id."'");
      while ( list($id,$modere) = $req->get_row() )
      {
100
        if ( !isset($_REQUEST["yet|$id"]) )
Ayolo's avatar
Ayolo committed
101
102
          $photo->remove_personne($id);
        elseif ( $modere == 0 )
103
          $photo->modere_personne($id);
Ayolo's avatar
Ayolo committed
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
      }

      $utl = new utilisateur($site->db);
      foreach( $_REQUEST["id_utilisateur"] as $id )
      {
        if ( !empty($id ) )
        {
          $utl->load_by_id($id);
          if ( $utl->id > 0 )
            $photo->add_personne($utl,true);
          else
          {
            $incomplet|=true;
            $error++;
          }
        }
      }


      if ( !$incomplet )
        $photo->set_incomplet(false);

      $photo->set_modere(true,$site->user->id);

      if ( $_REQUEST["restrict"] == "limittogroup" )
      {
        $photo->droits_acces = 0x310;
        $photo->id_groupe = $_REQUEST["id_group"];
      }
      else
        $photo->droits_acces = 0x311;
135

Ayolo's avatar
Ayolo committed
136
137
      $phasso->load_by_id($_REQUEST["id_asso"]);
      $ptasso->load_by_id($_REQUEST["id_asso_photographe"]);
138

Ayolo's avatar
Ayolo committed
139
140
141
142
143
144
145
146
      $photo->update_photo(
        $photo->date_prise_vue,
        $photo->commentaire,
        NULL,
        $phasso->id,
        $_REQUEST["titre"],
        $ptasso->id
        );
147

Feu's avatar
Feu committed
148
      $photo->set_tags($_REQUEST["tags"]);
Ayolo's avatar
Ayolo committed
149
150
151
152
153
154
155
156
157
158
159
160
    }
  }

}
elseif ( $_REQUEST["action"] == "moderecat" )
{
  $catmod = new catphoto($site->db,$site->dbrw);
  $catmod->load_by_id($_REQUEST["id_catph_modere"]);
  if ($catmod->id > 0 && $catmod->is_right($site->user,DROIT_ECRITURE) )
  {
    if ( isset($_REQUEST["delete"]))
    {
jlaval's avatar
jlaval committed
161
      $catmod->remove_cat($site);
Ayolo's avatar
Ayolo committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
    }
    else
    {
      $catmod->set_modere();
    }
  }
}

$req = new requete($site->db, "SELECT * FROM `sas_cat_photos` ".
      "WHERE `modere_catph`='0' $filter ".
      "ORDER BY `id_catph` " .
      "LIMIT 1");

if ( $req->lines == 1 )
{
  $catpr = new catphoto($site->db);
  $cat->_load($req->get_row());
179
  $path =   $cat->get_html_link();
Ayolo's avatar
Ayolo committed
180
181
182
  $catpr->load_by_id($cat->id_catph_parent);
  while ( $catpr->id > 0 )
  {
183
    $path =   $catpr->get_html_link()." / ".$path;
Ayolo's avatar
Ayolo committed
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
    $catpr->load_by_id($catpr->id_catph_parent);
  }

  $frm = new form("moderecat",$page,false,"POST",$path);
  $frm->add_hidden("id_catph_modere",$cat->id);
  $frm->add_hidden("action","moderecat");
  $frm->add_submit("modere","Accepter");
  $frm->add_submit("delete","Supprimer");
  $cts->add($frm,true);
  $site->add_contents($cts);
  $site->end_page ();
  exit();
}

if ( $error > 0 )
  $req = new requete($site->db, "SELECT * FROM `sas_photos` ".
      "WHERE `id_photo`='".$photo->id."' $filter ".
      "ORDER BY `id_photo` " .
      "LIMIT 1");
else
  $req = new requete($site->db, "SELECT * FROM `sas_photos` ".
      "WHERE `id_photo`>'".$photo->id."' AND `modere_ph`='0' $filter ".
      "ORDER BY `id_photo` " .
      "LIMIT 1");

if ( $req->lines == 1 )
{
  $photo->_load($req->get_row());

  $cat = new catphoto($site->db);
  $catpr = new catphoto($site->db);

  $cat->load_by_id($photo->id_catph);

218
  $path = $cat->get_html_link()." / ".$photo->get_html_link();
Ayolo's avatar
Ayolo committed
219
220
221
  $catpr->load_by_id($cat->id_catph_parent);
  while ( $catpr->id > 0 )
  {
222
    $path = $catpr->get_html_link()." / ".$path;
Ayolo's avatar
Ayolo committed
223
224
225
226
227
228
229
230
231
232
233
234
235
236
    $catpr->load_by_id($catpr->id_catph_parent);
  }

  $cts->add_title(2,$path);

  $req = new requete($site->db,
    "SELECT `utilisateurs`.`id_utilisateur`, " .
    "CONCAT(`utilisateurs`.`prenom_utl`,' ',`utilisateurs`.`nom_utl`) as `nom_utilisateur` " .
    "FROM `sas_personnes_photos` " .
    "INNER JOIN `utilisateurs` ON `utilisateurs`.`id_utilisateur`=`sas_personnes_photos`.`id_utilisateur` " .
    "WHERE `sas_personnes_photos`.`id_photo`='".$photo->id."' " .
    "ORDER BY `nom_utilisateur`");

  $imgcts = new contents();
237

Ayolo's avatar
Ayolo committed
238
239
240
241
  if ( $photo->type_media == MEDIA_VIDEOFLV )
    $imgcts->add(new flvideo($photo->id,"sas2/images.php?/".$photo->id.".flv"));
  else
    $imgcts->add(new image($photo->id,"images.php?/".$photo->id.".diapo.jpg"));
242

Ayolo's avatar
Ayolo committed
243
244
245
246
247
248
249
250
251
252
253
254
255
256
  $cts->add($imgcts,false,true,"sasimg");

  $subcts = new contents();


  $frm = new form("pasaccord",$page,false,"POST","Photo non acceptable");
  $frm->add_hidden("id_photo",$photo->id);
  $frm->add_hidden("action","modere");
  $frm->add_submit("delete","Supprimer");
  $subcts->add($frm,true);

  $frm = new form("accord",$page,false,"POST","Photo acceptable: informations");
  $frm->add_hidden("id_photo",$photo->id);
  $frm->add_hidden("action","modere");
pedrov's avatar
pedrov committed
257
258
259

  $sfrm = new form("valid",null,null,null,"Validation");
  $sfrm->add_submit("modere","Accepter");
260
    $frm->add($sfrm);
pedrov's avatar
pedrov committed
261

262

Ayolo's avatar
Ayolo committed
263
264
265
266
267
268
  $sfrm = new form("people",null,null,null,"Personnes sur la photo");
  while ( list($id,$nom) = $req->get_row() )
    $sfrm->add_checkbox("yet|$id",$nom,true);
  for ($i=0;$i<7;$i++)
    $sfrm->add_user_fieldv2("id_utilisateur[$i]","");
  $sfrm->add_checkbox("complet","Liste complète",$photo->incomplet?false:true);
269
    $frm->add($sfrm);
Ayolo's avatar
Ayolo committed
270
271
272

  $sfrm = new form("meta",null,null,null,"Meta-informations");
  $sfrm->add_text_field("titre","Titre",$photo->titre);
Feu's avatar
Feu committed
273
  $sfrm->add_text_field("tags","Tags (séparteur: virgule)",$photo->get_tags());
Ayolo's avatar
Ayolo committed
274
275
  $sfrm->add_entity_select("id_asso", "Association/Club lié", $site->db, "asso",$photo->meta_id_asso,true);
  $sfrm->add_entity_select("id_asso_photographe", "Photographe", $site->db, "asso",$photo->id_asso_photographe,true);
276
    $frm->add($sfrm);
Ayolo's avatar
Ayolo committed
277
278
279

  $sfrm = new form("access",null,null,null,"Droits d'accés");
  $ssfrm = new form("restrict",null,null,null,"Accès non restreint");
280
    $sfrm->add($ssfrm,false,true,($photo->droits_acces & 1),"none",false,true);
Ayolo's avatar
Ayolo committed
281
  $ssfrm = new form("restrict",null,null,null,"Limiter l'accés au groupe");
282
283
284
    $ssfrm->add_entity_select( "id_group", "Groupe", $site->db, "group", $photo->id_groupe );
    $sfrm->add($ssfrm,false,true,!($photo->droits_acces & 1),"limittogroup",false,true);
    $frm->add($sfrm);
285

Ayolo's avatar
Ayolo committed
286
287
288
289
290
291
292
293
294
295
296
297
  $subcts->add($frm,true);

  $cts->add($subcts,false,true,"photoinfo");
  $cts->puts("<div class=\"clearboth\"></div>");

}
else
{
  $cts->add_paragraph("Merci de votre aide, vous êtes arrivés à la fin :).");

  $cts->add_paragraph("<a href=\"./\">Retour au SAS</a>");
  if ( $cat->id > 0 )
298
    $cts->add_paragraph("Retour à ".$cat->get_html_link());
Ayolo's avatar
Ayolo committed
299
300
301
302
303
304
}
$site->add_contents($cts);
$site->end_page ();


?>