| 1 |
<?php
|
| 2 |
// $Id: hidden.display-admin.inc,v 1.1 2008/12/10 23:03:47 ekes Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Hidden administration of hidden content.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Menu callback; Admin list form of hidden comments.
|
| 11 |
*
|
| 12 |
* @ingroup forms
|
| 13 |
* @see hidden_list_admin_comments_validate()
|
| 14 |
* @see hidden_list_admin_comments_submit()
|
| 15 |
* @see theme_hidden_list_admin_comments()
|
| 16 |
*/
|
| 17 |
function hidden_list_admin_comments(&$form_state) {
|
| 18 |
$form = _hidden_list_admin_options();
|
| 19 |
$form['header'] = array(
|
| 20 |
'#type' => 'value',
|
| 21 |
'#value' => array(
|
| 22 |
NULL,
|
| 23 |
array('data' => t('title'), 'field' => 'title'),
|
| 24 |
array('data' => t('author'), 'field' => 'name'),
|
| 25 |
array('data' => t('reason'), 'field' => 'reason'),
|
| 26 |
array('data' => t('hidden by'), 'field' => 'hider'),
|
| 27 |
array('data' => t('hidden'), 'field' => 'date', 'sort' => 'desc'),
|
| 28 |
NULL,
|
| 29 |
)
|
| 30 |
);
|
| 31 |
|
| 32 |
$query = 'SELECT c.nid AS nid, c.cid AS cid, c.subject AS title, c.timestamp AS changed,'.
|
| 33 |
' h.created AS date, h.delay AS delay,'.
|
| 34 |
' r.title AS reason,'.
|
| 35 |
' u1.uid AS uid, u1.name AS name,'.
|
| 36 |
' u2.uid AS huid, u2.name AS hider'.
|
| 37 |
' FROM {hidden_comment} AS h'.
|
| 38 |
' LEFT JOIN {hidden_reasons} AS r ON h.rid=r.rid'.
|
| 39 |
' INNER JOIN ({comments} as c, {users} AS u1, {users} AS u2) ON (c.nid=h.nid AND c.cid=h.cid AND c.uid=u1.uid AND h.uid=u2.uid)';
|
| 40 |
$query .= tablesort_sql($form['header']['#value']);
|
| 41 |
$result = pager_query($query, HIDDEN_PAGER_LIMIT);
|
| 42 |
|
| 43 |
// build a table listing the appropriate nodes
|
| 44 |
while ($comment = db_fetch_object($result)) {
|
| 45 |
$comments[$comment->cid] = '';
|
| 46 |
$form['title'][$comment->cid] = array('#value' => l($comment->title, "node/$comment->nid", NULL, NULL, "comment-$comment->cid"));
|
| 47 |
$form['name'][$comment->cid] = array('#value' => theme('username', $comment));
|
| 48 |
$form['reason'][$comment->cid] = array('#value' => check_plain($comment->reason));
|
| 49 |
$form['hider'][$comment->cid] = array('#value' => theme('username', (object)array('name' => $comment->hider, 'uid' => $comment->huid)));
|
| 50 |
if ($comment->delay != 0) {
|
| 51 |
if ($comment->delay < time() - 29) { // under half a minute for rounding in remaining section
|
| 52 |
$form['date'][$comment->cid] = array('#value' => t('next cron run'));
|
| 53 |
}
|
| 54 |
else {
|
| 55 |
$remaining = $comment->delay - time();
|
| 56 |
$hours = floor($remaining / 3600);
|
| 57 |
$remaining -= $hours * 3600;
|
| 58 |
$minutes = round($remaining / 60);
|
| 59 |
$time = ($hours!=0) ? $hours . format_plural($hours, ' hour ', ' hours ') : '';
|
| 60 |
$time .= ($minutes!=0) ? $minutes . format_plural($minutes, ' minute', ' minutes') : '';
|
| 61 |
$form['date'][$comment->cid] = array('#value' => t('after %time', array('%time' => $time)));
|
| 62 |
}
|
| 63 |
}
|
| 64 |
else {
|
| 65 |
$form['date'][$comment->cid] = array('#value' => format_date($comment->date, 'small'));
|
| 66 |
}
|
| 67 |
$form['operations'][$comment->cid] = array('#value' => l(t('Edit'), "comment/edit/$comment->cid", array('query' => 'destination=admin/content/comment/')));
|
| 68 |
}
|
| 69 |
|
| 70 |
$form['comments'] = array('#type' => 'checkboxes', '#options' => $comments);
|
| 71 |
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
|
| 72 |
|
| 73 |
return $form;
|
| 74 |
}
|
| 75 |
|
| 76 |
/**
|
| 77 |
* Implentation of form API hook; validate hidden_list_admin_comments() form.
|
| 78 |
*/
|
| 79 |
function hidden_list_admin_comments_validate($form, &$form_state) {
|
| 80 |
$form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0));
|
| 81 |
if (count($form_state['values']['comments']) == 0) {
|
| 82 |
form_set_error('', t('Please select one or more comments to perform the update on.'));
|
| 83 |
return 'admin/content/comment/list/hidden';
|
| 84 |
}
|
| 85 |
}
|
| 86 |
|
| 87 |
/**
|
| 88 |
* Implementation of form API hook; submit hidden_list_admin_comments() form.
|
| 89 |
*/
|
| 90 |
function hidden_list_admin_comments_submit($form, &$form_state) {
|
| 91 |
if ($form_state['values']['operation'] == 'UNHIDE') {
|
| 92 |
$unhide = array();
|
| 93 |
$error = array();
|
| 94 |
foreach ($form_state['values']['comments'] as $cid => $value) {
|
| 95 |
$cid = (int)$cid;
|
| 96 |
if ($value) {
|
| 97 |
if (_hidden_hidden_unhide('comment', $cid)) {
|
| 98 |
$unhide[] = $cid;
|
| 99 |
}
|
| 100 |
else {
|
| 101 |
$error[] = $cid;
|
| 102 |
}
|
| 103 |
}
|
| 104 |
}
|
| 105 |
if ($n = count($error)) {
|
| 106 |
$msg = format_plural($n, 'Error unhiding comment.', 'Error unhiding comments.');
|
| 107 |
_hidden_log(HIDDEN_LOG_ERROR, $msg, 'comment', $error);
|
| 108 |
drupal_set_message($msg, 'error');
|
| 109 |
}
|
| 110 |
if ($n = count($unhide)) {
|
| 111 |
$msg = format_plural($n, 'Unhidden comment.', 'Unhidden comments.');
|
| 112 |
_hidden_log(HIDDEN_LOG_UNHIDE, $msg, 'comment', $unhide);
|
| 113 |
drupal_set_message($msg);
|
| 114 |
}
|
| 115 |
}
|
| 116 |
$form_state['redirect'] = 'admin/content/comment/list/hidden';
|
| 117 |
}
|
| 118 |
|
| 119 |
/**
|
| 120 |
* Menu callback; admin list form of reported comments.
|
| 121 |
*
|
| 122 |
* @ingroup forms
|
| 123 |
* @see hidden_list_admin_comments_reported_validate()
|
| 124 |
* @see hidden_list_admin_comments_reported_submit()
|
| 125 |
* @see theme_hidden_list_admin_comments_reported()
|
| 126 |
*/
|
| 127 |
function hidden_list_admin_comments_reported(&$form_state) {
|
| 128 |
$form = _hidden_list_admin_reported_options();
|
| 129 |
$form['header'] = array(
|
| 130 |
'#type' => 'value',
|
| 131 |
'#value' => array(
|
| 132 |
NULL,
|
| 133 |
array('data' => t('title'), 'field' => 'title'),
|
| 134 |
array('data' => t('author'), 'field' => 'name'),
|
| 135 |
array('data' => t('reason'), 'field' => 'reason'),
|
| 136 |
array('data' => t('reported by'), 'field' => 'reporter'),
|
| 137 |
array('data' => t('reported on'), 'field' => 'date', 'sort' => 'desc'),
|
| 138 |
array('data' => t('seen by'), 'field' => 'seen'),
|
| 139 |
array('data' => t('status')),
|
| 140 |
)
|
| 141 |
);
|
| 142 |
|
| 143 |
$query = 'SELECT c.nid AS nid, c.cid AS cid, c.subject AS title, c.timestamp AS changed, c.status AS published,'.
|
| 144 |
' hr.created AS date,'.
|
| 145 |
' r.title AS reason,'.
|
| 146 |
' u1.uid AS uid, u1.name AS name,'.
|
| 147 |
' u2.uid AS ruid, u2.name AS reporter,'.
|
| 148 |
' u3.uid AS suid, u3.name AS seen,'.
|
| 149 |
' h.rid AS hidden'.
|
| 150 |
' FROM {hidden_reported_comment} AS hr'.
|
| 151 |
' LEFT JOIN {hidden_reasons} AS r ON hr.rid=r.rid'.
|
| 152 |
' LEFT JOIN {users} AS u3 ON hr.suid=u3.uid'.
|
| 153 |
' LEFT JOIN {hidden_comment} AS h ON (hr.nid=h.nid AND hr.cid=h.cid)'.
|
| 154 |
' INNER JOIN ({comments} AS c, {users} AS u1, {users} AS u2) ON (c.nid=hr.nid AND c.cid=hr.cid AND c.uid=u1.uid AND hr.uid=u2.uid)';
|
| 155 |
|
| 156 |
$query .= tablesort_sql($form['header']['#value']);
|
| 157 |
$result = pager_query($query, HIDDEN_PAGER_LIMIT);
|
| 158 |
|
| 159 |
// build a table listing the appropriate nodes
|
| 160 |
while ($comment = db_fetch_object($result)) {
|
| 161 |
if ($comment->published==COMMENT_PUBLISHED) {
|
| 162 |
$status = t('published');
|
| 163 |
}
|
| 164 |
elseif ($comment->hidden != NULL) {
|
| 165 |
$status = t('hidden');
|
| 166 |
}
|
| 167 |
else {
|
| 168 |
$status = t('not published');
|
| 169 |
}
|
| 170 |
$comments[$comment->cid] = '';
|
| 171 |
$form['title'][$comment->cid] = array('#value' => l($comment->title, "node/$comment->nid", NULL, NULL, "comment-$comment->cid"));
|
| 172 |
$form['name'][$comment->cid] = array('#value' => theme('username', $comment));
|
| 173 |
$form['reason'][$comment->cid] = array('#value' => check_plain($comment->reason));
|
| 174 |
$form['reporter'][$comment->cid] = array('#value' => theme('username', (object)array('name' => $comment->reporter, 'uid' => $comment->ruid)));
|
| 175 |
$form['date'][$comment->cid] = array('#value' => format_date($comment->date, 'small'));
|
| 176 |
$form['seen'][$comment->cid] = array('#value' => ($comment->suid != 0) ? theme('username', (object)array('name' => $comment->seen, 'uid' => $comment->suid)) : '');
|
| 177 |
$form['status'][$comment->cid] = array('#value' => $status);
|
| 178 |
}
|
| 179 |
|
| 180 |
$form['comments'] = array('#type' => 'checkboxes', '#options' => $comments);
|
| 181 |
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
|
| 182 |
|
| 183 |
return $form;
|
| 184 |
}
|
| 185 |
|
| 186 |
/**
|
| 187 |
* Implentation of form API hook; validate hidden_list_admin_comments_reported() form.
|
| 188 |
*/
|
| 189 |
function hidden_list_admin_comments_reported_validate($form, &$form_state) {
|
| 190 |
$form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0));
|
| 191 |
if (count($form_state['values']['comments']) == 0) {
|
| 192 |
form_set_error('', t('Please select one or more comments to perform the update on.'));
|
| 193 |
}
|
| 194 |
}
|
| 195 |
|
| 196 |
/**
|
| 197 |
* Implementation of form API hook; submit hidden_list_admin_comments_reported() form.
|
| 198 |
*/
|
| 199 |
function hidden_list_admin_comments_reported_submit($form, &$form_state) {
|
| 200 |
global $user;
|
| 201 |
switch ($form_state['values']['operation']) {
|
| 202 |
case 'HIDE':
|
| 203 |
$hide = array();
|
| 204 |
$error = array();
|
| 205 |
foreach ($form_state['values']['comments'] as $cid => $value) {
|
| 206 |
$cid = (int)$cid;
|
| 207 |
if ($value) {
|
| 208 |
// could transfer nid with form, but is there an elegant way?
|
| 209 |
$result = db_query('SELECT nid FROM {comments} WHERE cid=%d', $cid);
|
| 210 |
$nid = db_result($result);
|
| 211 |
if ($nid>0) {
|
| 212 |
// would be nice to transfer reported reason(s) but there maybe more than one
|
| 213 |
if (hidden_hidden_hide('comment', (int)$cid, $user->uid, 1)) {
|
| 214 |
$hide[] = $cid;
|
| 215 |
}
|
| 216 |
else {
|
| 217 |
$error[] = $cid;
|
| 218 |
}
|
| 219 |
}
|
| 220 |
}
|
| 221 |
}
|
| 222 |
if ($n = count($error)) {
|
| 223 |
$msg = format_plural($n, 'Error hiding reported comment', 'Error hiding reported comments');
|
| 224 |
_hidden_log(HIDDEN_LOG_ERROR, $msg, 'comment', $error);
|
| 225 |
drupal_set_message($msg, 'error');
|
| 226 |
}
|
| 227 |
if ($n = count($hide)) {
|
| 228 |
$msg = format_plural($n, 'Hidden reported comment', 'Hidden reported comments');
|
| 229 |
_hidden_log(HIDDEN_LOG_HIDE, $msg, 'comment', $hide, 1);
|
| 230 |
drupal_set_message($msg);
|
| 231 |
}
|
| 232 |
break;
|
| 233 |
case 'SPAM':
|
| 234 |
if (! module_exists('spam')) {
|
| 235 |
break;
|
| 236 |
}
|
| 237 |
$spam = array();
|
| 238 |
foreach ($form_state['values']['comments'] as $cid => $value) {
|
| 239 |
$cid = (int)$cid;
|
| 240 |
if ($value) {
|
| 241 |
$result = db_query('SELECT nid FROM {comments} WHERE cid=%d', $cid);
|
| 242 |
$nid = db_result($result);
|
| 243 |
if ($nid>0) {
|
| 244 |
spam_spam_comment($cid);
|
| 245 |
$spam[] = $cid;
|
| 246 |
}
|
| 247 |
}
|
| 248 |
}
|
| 249 |
if ($n = count($spam)) {
|
| 250 |
$msg = format_plural($n, 'Marked reported comment as spam.', 'Marked reported comments as spam.');
|
| 251 |
_hidden_log(HIDDEN_LOG_SPAM, $msg, 'comment', $cid);
|
| 252 |
drupal_set_message($msg);
|
| 253 |
}
|
| 254 |
case 'SEEN':
|
| 255 |
$seen = array();
|
| 256 |
$error = array();
|
| 257 |
foreach ($form_state['values']['comments'] as $cid => $value) {
|
| 258 |
$cid = (int)$cid;
|
| 259 |
if ($value) {
|
| 260 |
$result = db_query('SELECT nid FROM {comments} WHERE cid=%d', $cid);
|
| 261 |
$nid = db_result($result);
|
| 262 |
if ($nid>0) {
|
| 263 |
if (_hidden_reported_seen('comment', $cid, $user->uid)) {
|
| 264 |
$seen[] = $cid;
|
| 265 |
}
|
| 266 |
else {
|
| 267 |
$error[] = $cid;
|
| 268 |
}
|
| 269 |
}
|
| 270 |
}
|
| 271 |
}
|
| 272 |
if ($n = count($error)) {
|
| 273 |
$msg = format_plural($n, 'Error marking reported comment as seen', 'Error marking reported comments as seen');
|
| 274 |
_hidden_log(HIDDEN_LOG_ERROR, $msg, 'comment', $error);
|
| 275 |
drupal_set_message($msg, 'error');
|
| 276 |
}
|
| 277 |
if ($n = count($seen)) {
|
| 278 |
$msg = format_plural($n, 'Reported comment marked as seen', 'Reported comments marked as seen');
|
| 279 |
_hidden_log(HIDDEN_LOG_SEEN, $msg, 'comment', $seen);
|
| 280 |
drupal_set_message($msg);
|
| 281 |
}
|
| 282 |
break;
|
| 283 |
}
|
| 284 |
}
|
| 285 |
|
| 286 |
/**
|
| 287 |
* Menu callback; Admin list form of hidden nodes.
|
| 288 |
*
|
| 289 |
* @ingroup forms
|
| 290 |
* @see hidden_list_admin_nodes_validate()
|
| 291 |
* @see hidden_list_admin_nodes_submit()
|
| 292 |
* @see theme_hidden_list_admin_nodes()
|
| 293 |
*/
|
| 294 |
function hidden_list_admin_nodes(&$form_state) {
|
| 295 |
$form = _hidden_list_admin_options();
|
| 296 |
$form['header'] = array(
|
| 297 |
'#type' => 'value',
|
| 298 |
'#value' => array(
|
| 299 |
NULL,
|
| 300 |
array('data' => t('title'), 'field' => 'title'),
|
| 301 |
array('data' => t('type'), 'field' => 'type'),
|
| 302 |
array('data' => t('author'), 'field' => 'name'),
|
| 303 |
array('data' => t('reason'), 'field' => 'reason'),
|
| 304 |
array('data' => t('hidden by'), 'field' => 'hider'),
|
| 305 |
array('data' => t('hidden'), 'field' => 'date', 'sort' => 'desc'),
|
| 306 |
NULL,
|
| 307 |
)
|
| 308 |
);
|
| 309 |
|
| 310 |
$query = 'SELECT n.nid AS nid, n.title AS title, n.type AS type, n.changed AS changed,'.
|
| 311 |
' h.created AS date, h.delay AS delay,'.
|
| 312 |
' r.title AS reason,'.
|
| 313 |
' u1.uid AS uid, u1.name AS name,'.
|
| 314 |
' u2.uid AS huid, u2.name AS hider'.
|
| 315 |
' FROM {hidden_node} AS h'.
|
| 316 |
' LEFT JOIN {hidden_reasons} AS r ON h.rid=r.rid'.
|
| 317 |
' INNER JOIN ({node} AS n, {users} AS u1, {users} AS u2) ON (n.nid=h.nid AND n.uid=u1.uid AND h.uid=u2.uid)';
|
| 318 |
|
| 319 |
$query .= tablesort_sql($form['header']['#value']);
|
| 320 |
$result = pager_query($query, HIDDEN_PAGER_LIMIT);
|
| 321 |
|
| 322 |
// build a table listing the appropriate nodes
|
| 323 |
while ($node = db_fetch_object($result)) {
|
| 324 |
$nodes[$node->nid] = '';
|
| 325 |
$form['title'][$node->nid] = array('#value' => l($node->title, "node/$node->nid") .' '. (node_last_viewed($node->nid) < $node->changed ? theme_mark() : ''));
|
| 326 |
$form['type'][$node->nid] = array('#value' => node_get_types('name', $node));
|
| 327 |
$form['name'][$node->nid] = array('#value' => theme('username', $node));
|
| 328 |
$form['reason'][$node->nid] = array('#value' => check_plain($node->reason));
|
| 329 |
$form['hider'][$node->nid] = array('#value' => theme('username', (object)array('name' => $node->hider, 'uid' => $node->huid)));
|
| 330 |
if ($node->delay != 0) {
|
| 331 |
if ($node->delay < time() - 29) { // under half a minute for rounding in remaining section
|
| 332 |
$form['date'][$node->nid] = array('#value' => t('next cron run'));
|
| 333 |
}
|
| 334 |
else {
|
| 335 |
$remaining = $node->delay - time();
|
| 336 |
$hours = floor($remaining / 3600);
|
| 337 |
$remaining -= $hours * 3600;
|
| 338 |
$minutes = round($remaining / 60);
|
| 339 |
$time = ($hours!=0) ? $hours . format_plural($hours, ' hour ', ' hours ') : '';
|
| 340 |
$time .= ($minutes!=0) ? $minutes . format_plural($minutes, ' minute', ' minutes') : '';
|
| 341 |
$form['date'][$node->nid] = array('#value' => t('after %time', array('%time' => $time)));
|
| 342 |
}
|
| 343 |
}
|
| 344 |
else {
|
| 345 |
$form['date'][$node->nid] = array('#value' => format_date($node->date, 'small'));
|
| 346 |
}
|
| 347 |
$form['operations'][$node->nid] = array('#value' => l(t('Edit'), "node/$node->nid/edit"));
|
| 348 |
}
|
| 349 |
|
| 350 |
$form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
|
| 351 |
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
|
| 352 |
|
| 353 |
return $form;
|
| 354 |
}
|
| 355 |
|
| 356 |
/**
|
| 357 |
* Implentation of form API hook; validate hidden_list_admin_nodes() form.
|
| 358 |
*/
|
| 359 |
function hidden_list_admin_nodes_validate($form, &$form_state) {
|
| 360 |
$form_state['values']['nodes'] = array_diff($form_state['values']['nodes'], array(0));
|
| 361 |
if (count($form_state['values']['nodes']) == 0) {
|
| 362 |
form_set_error('', t('Please select one or more nodes to perform the update on.'));
|
| 363 |
}
|
| 364 |
}
|
| 365 |
|
| 366 |
/**
|
| 367 |
* Implementation of form API hook; submit hidden_list_admin_nodes() form.
|
| 368 |
*/
|
| 369 |
function hidden_list_admin_nodes_submit($form, &$form_state) {
|
| 370 |
$nids = array();
|
| 371 |
foreach ($form_state['values']['nodes'] as $nid => $value) {
|
| 372 |
if ($value) {
|
| 373 |
$nids[] = (int)$nid;
|
| 374 |
}
|
| 375 |
}
|
| 376 |
hidden_operations_unhide($nids);
|
| 377 |
}
|
| 378 |
|
| 379 |
/**
|
| 380 |
* Menu callback; Admin list form of reported nodes.
|
| 381 |
*
|
| 382 |
* @ingroup forms
|
| 383 |
* @see hidden_list_admin_nodes_reported_validate()
|
| 384 |
* @see hidden_list_admin_nodes_reported_submit()
|
| 385 |
* @see theme_hidden_list_admin_nodes_reported()
|
| 386 |
*/
|
| 387 |
function hidden_list_admin_nodes_reported(&$form_state) {
|
| 388 |
$form = _hidden_list_admin_reported_options();
|
| 389 |
$form['header'] = array(
|
| 390 |
'#type' => 'value',
|
| 391 |
'#value' => array(
|
| 392 |
NULL,
|
| 393 |
array('data' => t('title'), 'field' => 'title'),
|
| 394 |
array('data' => t('type'), 'field' => 'type'),
|
| 395 |
array('data' => t('author'), 'field' => 'name'),
|
| 396 |
array('data' => t('reason'), 'field' => 'reason'),
|
| 397 |
array('data' => t('reported by'), 'field' => 'reporter'),
|
| 398 |
array('data' => t('reported on'), 'field' => 'date', 'sort' => 'desc'),
|
| 399 |
array('data' => t('seen by'), 'field' => 'seen'),
|
| 400 |
array('data' => t('status')),
|
| 401 |
)
|
| 402 |
);
|
| 403 |
|
| 404 |
$query = 'SELECT n.nid AS nid, n.title AS title, n.type AS type, n.changed AS changed, n.status AS published,'.
|
| 405 |
' hr.created AS date,'.
|
| 406 |
' r.title AS reason,'.
|
| 407 |
' u1.uid AS uid, u1.name AS name,'.
|
| 408 |
' u2.uid AS ruid, u2.name AS reporter,'.
|
| 409 |
' u3.uid AS suid, u3.name AS seen,'.
|
| 410 |
' h.rid AS hidden'.
|
| 411 |
' FROM {hidden_reported_node} AS hr'.
|
| 412 |
' LEFT JOIN {hidden_reasons} AS r ON hr.rid=r.rid'.
|
| 413 |
' LEFT JOIN {users} AS u3 ON hr.suid=u3.uid'.
|
| 414 |
' LEFT JOIN {hidden_node} AS h ON (hr.nid=h.nid)'.
|
| 415 |
' INNER JOIN ({node} AS n, {users} AS u1, {users} AS u2) ON (n.nid=hr.nid AND n.uid=u1.uid AND hr.uid=u2.uid)';
|
| 416 |
|
| 417 |
$query .= tablesort_sql($form['header']['#value']);
|
| 418 |
$result = pager_query($query, HIDDEN_PAGER_LIMIT);
|
| 419 |
|
| 420 |
// build a table listing the appropriate nodes
|
| 421 |
while ($node = db_fetch_object($result)) {
|
| 422 |
if ($node->published) {
|
| 423 |
$status = t('published');
|
| 424 |
}
|
| 425 |
elseif ($node->hidden != NULL) {
|
| 426 |
$status = t('hidden');
|
| 427 |
}
|
| 428 |
else {
|
| 429 |
$status = t('not published');
|
| 430 |
}
|
| 431 |
$nodes[$node->nid] = '';
|
| 432 |
$form['title'][$node->nid] = array('#value' => l($node->title, "node/$node->nid") .' '. (node_last_viewed($node->nid) < $node->changed ? theme_mark() : ''));
|
| 433 |
$form['type'][$node->nid] = array('#value' => node_get_types('name', $node));
|
| 434 |
$form['name'][$node->nid] = array('#value' => theme('username', $node));
|
| 435 |
$form['reason'][$node->nid] = array('#value' => check_plain($node->reason));
|
| 436 |
$form['reporter'][$node->nid] = array('#value' => theme('username', (object)array('name' => $node->reporter, 'uid' => $node->ruid)));
|
| 437 |
$form['date'][$node->nid] = array('#value' => format_date($node->date, 'small'));
|
| 438 |
$form['seen'][$node->nid] = array('#value' => ($node->suid != 0) ? theme('username', (object)array('name' => $node->seen, 'uid' => $node->suid)) : '');
|
| 439 |
$form['status'][$node->nid] = array('#value' => $status);
|
| 440 |
}
|
| 441 |
|
| 442 |
$form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
|
| 443 |
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
|
| 444 |
|
| 445 |
return $form;
|
| 446 |
}
|
| 447 |
|
| 448 |
/**
|
| 449 |
* Implentation of form API hook; validate hidden_list_admin_nodes_reported() form.
|
| 450 |
*/
|
| 451 |
function hidden_list_admin_nodes_reported_validate($form, &$form_state) {
|
| 452 |
$form_state['values']['nodes'] = array_diff($form_state['values']['nodes'], array(0));
|
| 453 |
if (count($form_state['values']['nodes']) == 0) {
|
| 454 |
form_set_error('', t('Please select one or more nodes to perform the update on.'));
|
| 455 |
}
|
| 456 |
}
|
| 457 |
|
| 458 |
/**
|
| 459 |
* Implementation of form API hook; submit hidden_list_admin_nodes_reported() form.
|
| 460 |
*/
|
| 461 |
function hidden_list_admin_nodes_reported_submit($form, &$form_state) {
|
| 462 |
global $user;
|
| 463 |
switch ($form_state['values']['operation']) {
|
| 464 |
case 'HIDE':
|
| 465 |
$hide = array();
|
| 466 |
$error = array();
|
| 467 |
foreach ($form_state['values']['nodes'] as $nid => $value) {
|
| 468 |
$nid = (int)$nid;
|
| 469 |
if ($value) {
|
| 470 |
// would be nice to transfer reported reason(s) but there maybe more than one
|
| 471 |
if (hidden_hidden_hide('node', (int)$nid, $user->uid, 1)) {
|
| 472 |
$hide[] = $nid;
|
| 473 |
}
|
| 474 |
else {
|
| 475 |
$error[] = $nid;
|
| 476 |
}
|
| 477 |
}
|
| 478 |
}
|
| 479 |
if ($n = count($error)) {
|
| 480 |
$msg = format_plural($n, 'Error hiding reported node.', 'Error hiding reported nodes.');
|
| 481 |
_hidden_log(HIDDEN_LOG_ERROR, $msg, 'node', $error);
|
| 482 |
_drupal_set_message($msg, 'error');
|
| 483 |
}
|
| 484 |
if ($n = count($hide)) {
|
| 485 |
$msg = format_plural($n, 'Hidden reported node.', 'Hidden reported nodes.');
|
| 486 |
_hidden_log(HIDDEN_LOG_HIDE, $msg, 'node', $hide, 1);
|
| 487 |
drupal_set_message($msg);
|
| 488 |
}
|
| 489 |
break;
|
| 490 |
case 'SPAM':
|
| 491 |
if (! module_exists('spam')) {
|
| 492 |
break;
|
| 493 |
}
|
| 494 |
$spam = array();
|
| 495 |
foreach ($form_state['values']['nodes'] as $nid => $value) {
|
| 496 |
$nid = (int)$nid;
|
| 497 |
spam_spam_node($nid);
|
| 498 |
$spam[] = $nid;
|
| 499 |
}
|
| 500 |
if ($n = count($spam)) {
|
| 501 |
$msg = format_plural($n, 'Reported node marked as spam.', 'Reported nodes marked as spam.');
|
| 502 |
_hidden_log(HIDDEN_LOG_SPAM, $msg, 'node', $spam);
|
| 503 |
drupal_set_message($msg);
|
| 504 |
}
|
| 505 |
case 'SEEN':
|
| 506 |
$error = array();
|
| 507 |
$seen = array();
|
| 508 |
foreach ($form_state['values']['nodes'] as $nid => $value) {
|
| 509 |
$nid = (int)$nid;
|
| 510 |
if ($value) {
|
| 511 |
if (_hidden_reported_seen('node', (int)$nid, $user->uid)) {
|
| 512 |
$seen[] = $nid;
|
| 513 |
}
|
| 514 |
else {
|
| 515 |
$error[] = $nid;
|
| 516 |
}
|
| 517 |
}
|
| 518 |
}
|
| 519 |
if ($n = count($error)) {
|
| 520 |
$msg = format_plural($n, 'Error marking reported node as seen.', 'Error marking reported nodes as seen.');
|
| 521 |
_hidden_log(HIDDEN_LOG_ERROR, $msg, 'node', $error);
|
| 522 |
drupal_set_message($msg, 'error');
|
| 523 |
}
|
| 524 |
if ($n = count($seen)) {
|
| 525 |
$msg = format_plural($n, 'Marked reported node as seen.', 'Marked reported nodes as seen');
|
| 526 |
_hidden_log(HIDDEN_LOG_SEEN, $msg, 'node', $seen);
|
| 527 |
drupal_set_message($msg);
|
| 528 |
}
|
| 529 |
break;
|
| 530 |
}
|
| 531 |
}
|
| 532 |
/**
|
| 533 |
* Format admin hidden comment list form.
|
| 534 |
*
|
| 535 |
* @ingroup themeable.
|
| 536 |
*/
|
| 537 |
function theme_hidden_list_admin_comments($form) {
|
| 538 |
$output = drupal_render($form['options']);
|
| 539 |
|
| 540 |
if (isset($form['title']) && is_array($form['title'])) {
|
| 541 |
foreach (element_children($form['title']) as $key) {
|
| 542 |
$row = array();
|
| 543 |
$row[] = drupal_render($form['comments'][$key]);
|
| 544 |
$row[] = drupal_render($form['title'][$key]);
|
| 545 |
$row[] = drupal_render($form['name'][$key]);
|
| 546 |
$row[] = drupal_render($form['reason'][$key]);
|
| 547 |
$row[] = drupal_render($form['hider'][$key]);
|
| 548 |
$row[] = drupal_render($form['date'][$key]);
|
| 549 |
$row[] = drupal_render($form['operations'][$key]);
|
| 550 |
$rows[] = $row;
|
| 551 |
}
|
| 552 |
}
|
| 553 |
else {
|
| 554 |
$rows[] = array(array('data' => t('No comments available.'), 'colspan' => '6'));
|
| 555 |
}
|
| 556 |
|
| 557 |
$output .= theme('table', $form['header']['#value'], $rows);
|
| 558 |
if ($form['pager']['#value']) {
|
| 559 |
$output .= drupal_render($form['pager']);
|
| 560 |
}
|
| 561 |
|
| 562 |
$output .= drupal_render($form);
|
| 563 |
|
| 564 |
return $output;
|
| 565 |
}
|
| 566 |
|
| 567 |
/**
|
| 568 |
* Format admin reported node list form hidden_list_admin_comments_reported().
|
| 569 |
*
|
| 570 |
* @ingroup themeable.
|
| 571 |
*/
|
| 572 |
function theme_hidden_list_admin_comments_reported($form) {
|
| 573 |
$output = drupal_render($form['options']);
|
| 574 |
|
| 575 |
if (isset($form['title']) && is_array($form['title'])) {
|
| 576 |
foreach (element_children($form['title']) as $key) {
|
| 577 |
$row = array();
|
| 578 |
$row[] = drupal_render($form['comments'][$key]);
|
| 579 |
$row[] = drupal_render($form['title'][$key]);
|
| 580 |
$row[] = drupal_render($form['name'][$key]);
|
| 581 |
$row[] = drupal_render($form['reason'][$key]);
|
| 582 |
$row[] = drupal_render($form['reporter'][$key]);
|
| 583 |
$row[] = drupal_render($form['date'][$key]);
|
| 584 |
$row[] = drupal_render($form['seen'][$key]);
|
| 585 |
$row[] = drupal_render($form['status'][$key]);
|
| 586 |
$rows[] = $row;
|
| 587 |
}
|
| 588 |
}
|
| 589 |
else {
|
| 590 |
$rows[] = array(array('data' => t('No comments available.'), 'colspan' => '8'));
|
| 591 |
}
|
| 592 |
|
| 593 |
$output .= theme('table', $form['header']['#value'], $rows);
|
| 594 |
if ($form['pager']['#value']) {
|
| 595 |
$output .= drupal_render($form['pager']);
|
| 596 |
}
|
| 597 |
|
| 598 |
$output .= drupal_render($form);
|
| 599 |
return $output;
|
| 600 |
}
|
| 601 |
|
| 602 |
/**
|
| 603 |
* Formats admin hidden node list form.
|
| 604 |
*
|
| 605 |
* @ingroup themeable.
|
| 606 |
*/
|
| 607 |
function theme_hidden_list_admin_nodes($form) {
|
| 608 |
$output = drupal_render($form['options']);
|
| 609 |
|
| 610 |
if (isset($form['title']) && is_array($form['title'])) {
|
| 611 |
foreach (element_children($form['title']) as $key) {
|
| 612 |
$row = array();
|
| 613 |
$row[] = drupal_render($form['nodes'][$key]);
|
| 614 |
$row[] = drupal_render($form['title'][$key]);
|
| 615 |
$row[] = drupal_render($form['type'][$key]);
|
| 616 |
$row[] = drupal_render($form['name'][$key]);
|
| 617 |
$row[] = drupal_render($form['reason'][$key]);
|
| 618 |
$row[] = drupal_render($form['hider'][$key]);
|
| 619 |
$row[] = drupal_render($form['date'][$key]);
|
| 620 |
$row[] = drupal_render($form['operations'][$key]);
|
| 621 |
$rows[] = $row;
|
| 622 |
}
|
| 623 |
}
|
| 624 |
else {
|
| 625 |
$rows[] = array(array('data' => t('No nodes available.'), 'colspan' => '7'));
|
| 626 |
}
|
| 627 |
|
| 628 |
$output .= theme('table', $form['header']['#value'], $rows);
|
| 629 |
if ($form['pager']['#value']) {
|
| 630 |
$output .= drupal_render($form['pager']);
|
| 631 |
}
|
| 632 |
|
| 633 |
$output .= drupal_render($form);
|
| 634 |
|
| 635 |
return $output;
|
| 636 |
}
|
| 637 |
|
| 638 |
/**
|
| 639 |
* Formats admin reported node list form hidden_list_admin_nodes_reported().
|
| 640 |
*
|
| 641 |
* @ingroup themeable.
|
| 642 |
*/
|
| 643 |
function theme_hidden_list_admin_nodes_reported($form) {
|
| 644 |
$output = drupal_render($form['options']);
|
| 645 |
|
| 646 |
if (isset($form['title']) && is_array($form['title'])) {
|
| 647 |
foreach (element_children($form['title']) as $key) {
|
| 648 |
$row = array();
|
| 649 |
$row[] = drupal_render($form['nodes'][$key]);
|
| 650 |
$row[] = drupal_render($form['title'][$key]);
|
| 651 |
$row[] = drupal_render($form['type'][$key]);
|
| 652 |
$row[] = drupal_render($form['name'][$key]);
|
| 653 |
$row[] = drupal_render($form['reason'][$key]);
|
| 654 |
$row[] = drupal_render($form['reporter'][$key]);
|
| 655 |
$row[] = drupal_render($form['date'][$key]);
|
| 656 |
$row[] = drupal_render($form['seen'][$key]);
|
| 657 |
$row[] = drupal_render($form['status'][$key]);
|
| 658 |
$rows[] = $row;
|
| 659 |
}
|
| 660 |
}
|
| 661 |
else {
|
| 662 |
$rows[] = array(array('data' => t('No nodes available.'), 'colspan' => '7'));
|
| 663 |
}
|
| 664 |
|
| 665 |
$output .= theme('table', $form['header']['#value'], $rows);
|
| 666 |
if ($form['pager']['#value']) {
|
| 667 |
$output .= drupal_render($form['pager']);
|
| 668 |
}
|
| 669 |
|
| 670 |
$output .= drupal_render($form);
|
| 671 |
return $output;
|
| 672 |
}
|