| 1 |
<?php |
<?php |
| 2 |
// $Id: hidden.action-pages.inc,v 1.2 2008/12/12 19:23:35 ekes Exp $ |
// $Id: hidden.action-pages.inc,v 1.3 2008/12/13 18:42:43 ekes Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 21 |
* @see hidden_hide_submit() |
* @see hidden_hide_submit() |
| 22 |
*/ |
*/ |
| 23 |
function hidden_hide(&$form_state, $type, $id) { |
function hidden_hide(&$form_state, $type, $id) { |
|
if (! user_access('mark as hidden')) { |
|
|
drupal_access_denied(); |
|
|
} |
|
|
|
|
| 24 |
global $user; |
global $user; |
| 25 |
$type = (string) $type; |
$type = (string) $type; |
| 26 |
$id = (int) $id; |
$id = (int) $id; |
| 31 |
} |
} |
| 32 |
|
|
| 33 |
drupal_set_title(t('Hide @title', array('@title' => $item->title))); |
drupal_set_title(t('Hide @title', array('@title' => $item->title))); |
| 34 |
|
$form = _hidden_hide_form($user, $hidden); |
| 35 |
|
$form['#content_type'] = $item->type; |
| 36 |
|
$form['#content_id'] = $item->id; |
| 37 |
|
|
| 38 |
|
$form['submit'] = array( |
| 39 |
|
'#type' => 'submit', |
| 40 |
|
'#value' => t('Hide'), |
| 41 |
|
); |
| 42 |
|
|
| 43 |
|
return $form; |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
/** |
| 47 |
|
* Form fields for hide form. |
| 48 |
|
* |
| 49 |
|
* Separated to allow embedding into the filter form as well to create the reason for |
| 50 |
|
* filter hiding. |
| 51 |
|
*/ |
| 52 |
|
function _hidden_hide_form($user, $hidden = StdClass) { |
| 53 |
|
$form = array(); |
| 54 |
|
|
| 55 |
if (user_access('administer hidden')) { |
if (user_access('administer hidden')) { |
| 56 |
$form['user'] = array( |
$form['user'] = array( |
| 70 |
); |
); |
| 71 |
} |
} |
| 72 |
|
|
| 73 |
|
// @todo change these to rid, publicnote and privatenote as they are stored in the db |
| 74 |
|
// alos in hidden_report_form() |
| 75 |
$reasons = _hidden_reasons_get_options(); |
$reasons = _hidden_reasons_get_options(); |
| 76 |
$form['reason'] = array( |
$form['reason'] = array( |
| 77 |
'#type' => 'radios', |
'#type' => 'radios', |
| 99 |
'#description' => t("Optional - notes that can only be seen by other users who can (un)hide content."), |
'#description' => t("Optional - notes that can only be seen by other users who can (un)hide content."), |
| 100 |
); |
); |
| 101 |
|
|
|
$form['#content_type'] = $item->type; |
|
|
$form['#content_id'] = $item->id; |
|
|
|
|
|
$form['submit'] = array( |
|
|
'#type' => 'submit', |
|
|
'#value' => t('Hide'), |
|
|
); |
|
|
|
|
| 102 |
return $form; |
return $form; |
| 103 |
} |
} |
|
|
|
| 104 |
/** |
/** |
| 105 |
* Menu callback; form to report a node or comment. |
* Menu callback; form to report a node or comment. |
| 106 |
* |
* |
| 130 |
|
|
| 131 |
drupal_set_title(t('Report @title', array('@title' => $item->title))); |
drupal_set_title(t('Report @title', array('@title' => $item->title))); |
| 132 |
|
|
| 133 |
$form['user'] = array( |
$form = _hidden_hide_form($user); |
| 134 |
'#type' => 'textfield', |
unset($form['privatetext']); |
|
'#title' => t('Reported by'), |
|
|
'#value' => check_plain($user->name), |
|
|
'#disabled' => TRUE, |
|
|
); |
|
|
|
|
|
$reasons = _hidden_reasons_get_options(); |
|
|
$form['reason'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Preset Reason'), |
|
|
'#default_value' => 0, |
|
|
'#options' => $reasons, |
|
|
'#description' => t('Preset reason why this item should be hidden.'), |
|
|
); |
|
|
|
|
|
$form['publictext'] = array( |
|
|
'#type' => 'textarea', |
|
|
'#title' => t('Your Public notes'), |
|
|
'#rows' => 5, |
|
|
'#maxlength' => 128, |
|
|
'#description' => t("Optional - type your reason why this item should be hidden."), |
|
|
); |
|
|
|
|
| 135 |
$form['#content_type'] = $item->type; |
$form['#content_type'] = $item->type; |
| 136 |
$form['#content_id'] = $item->id; |
$form['#content_id'] = $item->id; |
| 137 |
|
|
| 243 |
} |
} |
| 244 |
|
|
| 245 |
$rid = (int) $form_state['values']['reason']; |
$rid = (int) $form_state['values']['reason']; |
| 246 |
$rid = _hidden_reason_check($rid) ? $rid : 0; |
$rid = hidden_reason_check($rid) ? $rid : 0; |
| 247 |
$public = (string) $form_state['values']['publictext']; |
$public = (string) $form_state['values']['publictext']; |
| 248 |
$private = (string) $form_state['values']['privatetext']; |
$private = (string) $form_state['values']['privatetext']; |
| 249 |
|
|
| 291 |
$uid = $user->uid; |
$uid = $user->uid; |
| 292 |
|
|
| 293 |
$rid = (int) $form_state['values']['reason']; |
$rid = (int) $form_state['values']['reason']; |
| 294 |
$rid = _hidden_reason_check($rid) ? $rid : 0; |
$rid = hidden_reason_check($rid) ? $rid : 0; |
| 295 |
$public = (string) $form_state['values']['publictext']; |
$public = (string) $form_state['values']['publictext']; |
| 296 |
|
|
| 297 |
$t_args = array('%type' => $type); |
$t_args = array('%type' => $type); |