source: extensions/GuestBook/admin/pending.php @ 26065

Last change on this file since 26065 was 26065, checked in by mistic100, 7 years ago

update for Piwigo 2.6 + code clean

File size: 2.7 KB
Line 
1<?php
2if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!');
3
4include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
5
6// +-----------------------------------------------------------------------+
7// |                                actions                                |
8// +-----------------------------------------------------------------------+
9
10if (!empty($_POST))
11{
12  if (empty($_POST['comments']))
13  {
14    $page['errors'][] =l10n('Select at least one comment');
15  }
16  else
17  {
18    include_once(GUESTBOOK_PATH .'include/functions_comment.inc.php');
19    check_input_parameter('comments', $_POST, true, PATTERN_ID);
20   
21    if (isset($_POST['validate']))
22    {
23      validate_user_comment_guestbook($_POST['comments']);
24
25      $page['infos'][] = l10n_dec(
26        '%d user comment validated', '%d user comments validated',
27        count($_POST['comments'])
28        );
29    }
30
31    if (isset($_POST['reject']))
32    {
33      delete_user_comment_guestbook($_POST['comments']);
34
35      $page['infos'][] =l10n_dec(
36        '%d user comment rejected', '%d user comments rejected',
37        count($_POST['comments'])
38        );
39    }
40  }
41}
42
43
44// +-----------------------------------------------------------------------+
45// |                           comments display                            |
46// +-----------------------------------------------------------------------+
47include(GUESTBOOK_PATH .'include/functions.inc.php');
48
49$list = array();
50
51$query = '
52SELECT
53    c.id,
54    c.date,
55    c.author,
56    '.$conf['user_fields']['username'].' AS username,
57    c.content,
58    c.website,
59    c.email,
60    c.rate
61  FROM '.GUESTBOOK_TABLE.' AS c
62    LEFT JOIN '.USERS_TABLE.' AS u
63      ON u.'.$conf['user_fields']['id'].' = c.author_id
64  WHERE validated = \'false\'
65  ORDER BY c.date DESC
66;';
67$result = pwg_query($query);
68
69while ($row = pwg_db_fetch_assoc($result))
70{
71  if (empty($row['author_id'])) 
72  {
73    $author_name = $row['author'];
74  }
75  else
76  {
77    $author_name = stripslashes($row['username']);
78  }
79 
80  $template->append(
81    'comments',
82    array(
83      'ID' => $row['id'],
84      'AUTHOR' => trigger_event('render_comment_author', $author_name),
85      'DATE' => format_date($row['date'], true),
86      'CONTENT' => trigger_event('render_comment_content',$row['content']),
87      'EMAIL' => $row['email'],
88      'WEBSITE' => $row['website'],
89      'WEBSITE_NAME' => preg_replace('#^(https?:\/\/)#i', null, $row['website']),
90      'STARS' => get_stars($row['rate'], GUESTBOOK_PATH .'template/jquery.raty/'),
91      'RATE' => $row['rate'],
92      )
93    );
94
95  $list[] = $row['id'];
96}
97
98
99$template->assign(array(
100  'LIST' => implode(',', $list),
101  'F_ACTION' => GUESTBOOK_ADMIN . '-pending',
102  ));
103
104$template->set_filename('guestbook', realpath(GUESTBOOK_PATH . 'admin/template/pending.tpl'));
Note: See TracBrowser for help on using the repository browser.