source: extensions/Comments_on_Albums/include/coa_admin_comments.php @ 18696

Last change on this file since 18696 was 14528, checked in by mistic100, 13 years ago

update for 2.4
delete useless admin page
now compatible with RV Thumb Scroller

File size: 5.2 KB
Line 
1<?php
2/* Code adapted from admin/comments.php */
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $template, $conf, $user;
6load_language('plugin.lang', COA_PATH);
7
8// +-----------------------------------------------------------------------+
9// |                               tabsheet                                |
10// +-----------------------------------------------------------------------+
11include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
12
13if (isset($_GET['section']) and $_GET['section'] == 'albums')
14{
15  $page['tab'] = 'albums';
16} 
17else 
18{
19  $page['tab'] = 'pictures';
20}
21
22$tabsheet = new tabsheet();
23$tabsheet->add('pictures', l10n('Comments on photos'), get_root_url().'admin.php?page=comments');
24$tabsheet->add('albums', l10n('Comments on albums'), get_root_url().'admin.php?page=comments&amp;section=albums');
25$tabsheet->select($page['tab']);
26$tabsheet->assign();
27
28
29if ($page['tab'] == 'albums') 
30{
31  // clear template sended by original page
32  $template->clear_assign(array('ADMIN_CONTENT', 'comments', 'LIST', 'F_ACTION'));
33
34  // +-----------------------------------------------------------------------+
35  // |                                actions                                |
36  // +-----------------------------------------------------------------------+
37  if (!empty($_POST)) 
38  {
39    if (empty($_POST['comments']))
40    {
41      array_push(
42        $page['errors'],
43        l10n('Select at least one comment')
44        );
45    }
46    else
47    {
48      include_once(COA_PATH.'include/functions_comment.inc.php'); // custom functions
49      check_input_parameter('comments', $_POST, true, PATTERN_ID);
50
51      if (isset($_POST['validate_albums'])) 
52      {
53        validate_user_comment_albums($_POST['comments']);
54
55        array_push(
56          $page['infos'], 
57          l10n_dec(
58            '%d user comment validated', '%d user comments validated',
59            count($_POST['comments'])
60            )
61          );
62      }
63
64      if (isset($_POST['reject_albums'])) 
65      {
66        delete_user_comment_albums($_POST['comments']);
67
68        array_push(
69          $page['infos'], 
70          l10n_dec(
71            '%d user comment rejected', '%d user comments rejected',
72            count($_POST['comments'])
73            )
74          );
75      }
76    }
77  }
78
79  // +-----------------------------------------------------------------------+
80  // |                             template init                             |
81  // +-----------------------------------------------------------------------+
82
83  $template->set_filename('comments', dirname(__FILE__) .'/../template/admin_comments.tpl');
84
85  $template->assign(
86    array(
87      'F_ACTION' => get_root_url().'admin.php?page=comments&amp;section=albums'
88      )
89    );
90   
91  if (count($page['infos']) != 0) 
92  {
93    $template->assign('infos', $page['infos']);
94  }
95
96  // +-----------------------------------------------------------------------+
97  // |                           comments display                            |
98  // +-----------------------------------------------------------------------+
99  $list = array();
100
101  $query = '
102SELECT
103    com.id,
104    com.category_id,
105    com.date,
106    com.author,
107    u.'.$conf['user_fields']['username'].' AS username,
108    com.content,
109    cat.name,
110    img.id AS image_id,
111    img.path
112  FROM '.COA_TABLE.' AS com
113    LEFT JOIN '.CATEGORIES_TABLE.' AS cat
114      ON cat.id = com.category_id
115    LEFT JOIN '.USERS_TABLE.' AS u
116      ON u.'.$conf['user_fields']['id'].' = com.author_id
117    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
118      ON ucc.cat_id = com.category_id AND ucc.user_id = '.$user['id'].'
119    LEFT JOIN '.IMAGES_TABLE.' AS img
120      ON img.id = ucc.user_representative_picture_id
121  WHERE validated = \'false\'
122  ORDER BY com.date DESC
123;';
124  $result = pwg_query($query);
125
126  while ($row = pwg_db_fetch_assoc($result)) 
127  {
128    // author
129    if (empty($row['author_id'])) 
130    {
131      $author_name = $row['author'];
132    } 
133    else 
134    {
135      $author_name = stripslashes($row['username']);
136    }
137   
138    // thumbnail
139    $row['thumb'] = DerivativeImage::thumb_url(
140      array(
141        'id'=>$row['image_id'],
142        'path'=>$row['path'],
143        )
144     );
145
146    // comment content
147    $template->append(
148      'comments', 
149      array(
150        'ID' => $row['id'],
151        'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=album-'.$row['category_id'],
152        'CAT_NAME' => trigger_event('render_category_name', $row['name']),
153        'TN_SRC' => $row['thumb'],
154        'AUTHOR' => trigger_event('render_comment_author', $author_name),
155        'DATE' => format_date($row['date'], true),
156        'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
157        )
158      );
159
160    array_push($list, $row['id']);
161  }
162
163  $template->assign('LIST', implode(',', $list));
164
165  // +-----------------------------------------------------------------------+
166  // |                           sending html code                           |
167  // +-----------------------------------------------------------------------+
168
169  $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
170
171}
172
173?>
Note: See TracBrowser for help on using the repository browser.