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

Last change on this file since 11618 was 11417, checked in by mistic100, 13 years ago

minor change according to new ReplyTo method

File size: 5.4 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('COA_comments_photos'), get_root_url().'admin.php?page=comments');
24$tabsheet->add('albums', l10n('COA_comments_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      check_input_parameter('comments', $_POST, true, PATTERN_ID);
49
50      if (isset($_POST['validate_albums'])) 
51      {
52        $query = '
53UPDATE '.COA_TABLE.'
54  SET validated = \'true\',
55      validation_date = NOW()
56  WHERE id IN ('.implode(',', $_POST['comments']).')
57;';
58        pwg_query($query);
59
60        array_push(
61          $page['infos'], 
62          l10n_dec(
63            '%d user comment validated', '%d user comments validated',
64            count($_POST['comments'])
65            )
66          );
67      }
68
69      if (isset($_POST['reject_albums'])) 
70      {
71        $query = '
72DELETE
73  FROM '.COA_TABLE.'
74  WHERE id IN ('.implode(',', $_POST['comments']).')
75;';
76        pwg_query($query);
77
78        array_push(
79          $page['infos'], 
80          l10n_dec(
81            '%d user comment rejected', '%d user comments rejected',
82            count($_POST['comments'])
83            )
84          );
85      }
86    }
87  }
88
89  // +-----------------------------------------------------------------------+
90  // |                             template init                             |
91  // +-----------------------------------------------------------------------+
92
93  $template->set_filename('comments', dirname(__FILE__) .'/../template/admin_comments.tpl');
94
95  $template->assign(
96    array(
97      'F_ACTION' => get_root_url().'admin.php?page=comments&amp;section=albums'
98      )
99    );
100   
101  if (count($page['infos']) != 0) 
102  {
103    $template->assign('infos', $page['infos']);
104  }
105
106  // +-----------------------------------------------------------------------+
107  // |                           comments display                            |
108  // +-----------------------------------------------------------------------+
109  $list = array();
110
111  $query = '
112SELECT
113    com.id,
114    com.category_id,
115    com.date,
116    com.author,
117    u.'.$conf['user_fields']['username'].' AS username,
118    com.content,
119    cat.name,
120    img.id AS image_id,
121    img.path,
122    img.tn_ext
123  FROM '.COA_TABLE.' AS com
124    LEFT JOIN '.CATEGORIES_TABLE.' AS cat
125      ON cat.id = com.category_id
126    LEFT JOIN '.USERS_TABLE.' AS u
127      ON u.'.$conf['user_fields']['id'].' = com.author_id
128    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
129      ON ucc.cat_id = com.category_id AND ucc.user_id = '.$user['id'].'
130    LEFT JOIN '.IMAGES_TABLE.' AS img
131      ON img.id = ucc.user_representative_picture_id
132  WHERE validated = \'false\'
133  ORDER BY com.date DESC
134;';
135  $result = pwg_query($query);
136
137  while ($row = pwg_db_fetch_assoc($result)) 
138  {
139    // author
140    if (empty($row['author_id'])) 
141    {
142      $author_name = $row['author'];
143    } 
144    else 
145    {
146      $author_name = stripslashes($row['username']);
147    }
148   
149    // thumbnail
150    $row['thumb'] = get_thumbnail_url(
151      array(
152        'id' => $row['image_id'],
153        'path' => $row['path'],
154        'tn_ext' => @$row['tn_ext'],
155        )
156     );
157   
158    // comment content
159    $template->append(
160      'comments', 
161      array(
162        'ID' => $row['id'],
163        'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$row['category_id'],
164        'CAT_NAME' => trigger_event('render_category_name', $row['name']),
165        'TN_SRC' => $row['thumb'],
166        'AUTHOR' => trigger_event('render_comment_author', $author_name),
167        'DATE' => format_date($row['date'], true),
168        'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
169        )
170      );
171
172    array_push($list, $row['id']);
173  }
174
175  $template->assign('LIST', implode(',', $list));
176
177  // +-----------------------------------------------------------------------+
178  // |                           sending html code                           |
179  // +-----------------------------------------------------------------------+
180
181  $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
182
183}
184
185?>
Note: See TracBrowser for help on using the repository browser.