source: branches/branch-1_5/admin/comments.php @ 1005

Last change on this file since 1005 was 1005, checked in by nikrou, 18 years ago

Revert to revision 1002

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-01-15 13:49:29 +0000 (Sun, 15 Jan 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1005 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28if (!defined('PHPWG_ROOT_PATH'))
29{
30  die ("Hacking attempt!");
31}
32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33
34// +-----------------------------------------------------------------------+
35// |                                actions                                |
36// +-----------------------------------------------------------------------+
37
38if (isset($_POST))
39{
40  $to_validate = array();
41  $to_reject = array();
42 
43  if (isset($_POST['submit']))
44  {   
45    foreach (explode(',', $_POST['list']) as $comment_id)
46    {
47      if (isset($_POST['action-'.$comment_id]))
48      {
49        switch ($_POST['action-'.$comment_id])
50        {
51          case 'reject' :
52          {
53            array_push($to_reject, $comment_id);
54            break;
55          }
56          case 'validate' :
57          {
58            array_push($to_validate, $comment_id);
59            break;
60          }
61        }
62      }
63    }
64  }
65  else if (isset($_POST['validate-all']))
66  {
67    $to_validate = explode(',', $_POST['list']);
68  }
69  else if (isset($_POST['reject-all']))
70  {
71    $to_reject = explode(',', $_POST['list']);
72  }
73
74  if (count($to_validate) > 0)
75  {
76    $query = '
77UPDATE '.COMMENTS_TABLE.'
78  SET validated = \'true\'
79    , validation_date = NOW()
80  WHERE id IN ('.implode(',', $to_validate).')
81;';
82    pwg_query($query);
83
84    array_push(
85      $page['infos'],
86      sprintf(
87        l10n('%d user comments validated'),
88        count($to_validate)
89        )
90      );
91  }
92
93  if (count($to_reject) > 0)
94  {
95    $query = '
96DELETE
97  FROM '.COMMENTS_TABLE.'
98  WHERE id IN ('.implode(',', $to_reject).')
99;';
100    pwg_query($query);
101
102    array_push(
103      $page['infos'],
104      sprintf(
105        l10n('%d user comments rejected'),
106        count($to_reject)
107        )
108      );
109  }
110}
111
112// +-----------------------------------------------------------------------+
113// |                             template init                             |
114// +-----------------------------------------------------------------------+
115
116$template->set_filenames(array('comments'=>'admin/comments.tpl'));
117
118$template->assign_vars(
119  array(
120    'F_ACTION' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=comments')
121    )
122  );
123
124// +-----------------------------------------------------------------------+
125// |                           comments display                            |
126// +-----------------------------------------------------------------------+
127
128$list = array();
129
130$query = '
131SELECT c.id, c.image_id, c.date, c.author, c.content, i.path, i.tn_ext
132  FROM '.COMMENTS_TABLE.' AS c
133    INNER JOIN '.IMAGES_TABLE.' AS i
134      ON i.id = c.image_id
135  WHERE validated = \'false\'
136;';
137$result = pwg_query($query);
138while ($row = mysql_fetch_array($result))
139{
140  $template->assign_block_vars(
141    'comment',
142    array(
143      'U_PICTURE' =>
144        add_session_id(
145          PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
146          '&amp;image_id='.$row['image_id']
147          ),
148      'ID' => $row['id'],
149      'TN_SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),
150      'AUTHOR' => $row['author'],
151      'DATE' => format_date($row['date'],'mysql_datetime',true),
152      'CONTENT' => parse_comment_content($row['content'])
153      )
154    );
155
156  array_push($list, $row['id']);
157}
158
159$template->assign_vars(
160  array(
161    'LIST' => implode(',', $list)
162    )
163  );
164
165// +-----------------------------------------------------------------------+
166// |                           sending html code                           |
167// +-----------------------------------------------------------------------+
168
169$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
170
171?>
Note: See TracBrowser for help on using the repository browser.