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

Last change on this file since 14113 was 12601, checked in by mistic100, 13 years ago

some more modifications for Subscribe_to_comments

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');
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    img.tn_ext
113  FROM '.COA_TABLE.' AS com
114    LEFT JOIN '.CATEGORIES_TABLE.' AS cat
115      ON cat.id = com.category_id
116    LEFT JOIN '.USERS_TABLE.' AS u
117      ON u.'.$conf['user_fields']['id'].' = com.author_id
118    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
119      ON ucc.cat_id = com.category_id AND ucc.user_id = '.$user['id'].'
120    LEFT JOIN '.IMAGES_TABLE.' AS img
121      ON img.id = ucc.user_representative_picture_id
122  WHERE validated = \'false\'
123  ORDER BY com.date DESC
124;';
125  $result = pwg_query($query);
126
127  while ($row = pwg_db_fetch_assoc($result)) 
128  {
129    // author
130    if (empty($row['author_id'])) 
131    {
132      $author_name = $row['author'];
133    } 
134    else 
135    {
136      $author_name = stripslashes($row['username']);
137    }
138   
139    // thumbnail
140    $row['thumb'] = get_thumbnail_url(
141      array(
142        'id' => $row['image_id'],
143        'path' => $row['path'],
144        'tn_ext' => @$row['tn_ext'],
145        )
146     );
147   
148    // comment content
149    $template->append(
150      'comments', 
151      array(
152        'ID' => $row['id'],
153        'CAT_URL' => PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$row['category_id'],
154        'CAT_NAME' => trigger_event('render_category_name', $row['name']),
155        'TN_SRC' => $row['thumb'],
156        'AUTHOR' => trigger_event('render_comment_author', $author_name),
157        'DATE' => format_date($row['date'], true),
158        'CONTENT' => trigger_event('render_comment_content', $row['content'], 'album'),
159        )
160      );
161
162    array_push($list, $row['id']);
163  }
164
165  $template->assign('LIST', implode(',', $list));
166
167  // +-----------------------------------------------------------------------+
168  // |                           sending html code                           |
169  // +-----------------------------------------------------------------------+
170
171  $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
172
173}
174
175?>
Note: See TracBrowser for help on using the repository browser.