function edit_limit_comment_access in Edit Limit 7
Same name and namespace in other branches
- 6 edit_limit.module \edit_limit_comment_access()
Access check function to see if the user can still edit the comment or not. It must, at minimum, perform the comment module's access checks first.
1 string reference to 'edit_limit_comment_access'
- edit_limit_menu_alter in ./
edit_limit.module - Implements hook_menu_alter().
File
- ./
edit_limit.module, line 187 - edit_limit.module Primary module file for Edit Limit. This contains all the hooks needed to run the module.
Code
function edit_limit_comment_access($edit = NULL, $comment = NULL) {
if (user_access('post comments')) {
if (user_access('bypass edit limits')) {
return TRUE;
}
$return = comment_access($edit, $comment);
// Only limit edits if content type is in the list.
$node = node_load($comment->nid);
if (!in_array($node->type, variable_get('edit_limit_comments', array()))) {
return $return;
}
if (variable_get('edit_limit_comment_time_enabled', FALSE)) {
$time_unit = variable_get('edit_limit_comment_time_unit', EDIT_LIMIT_TIME_UNIT_DEFAULT);
// By this point, we want to return false if the time has passed.
if ($comment->created + intval(_unit_to_seconds(variable_get('edit_limit_comment_time', EDIT_LIMIT_COMMENT_TIME), $time_unit)) < REQUEST_TIME) {
$return = FALSE;
}
else {
static $time_left;
if (empty($time_left)) {
drupal_add_js(drupal_get_path('module', 'edit_limit') . '/edit_limit.js');
$time_left = $comment->created + intval(_unit_to_seconds(variable_get('edit_limit_comment_time', EDIT_LIMIT_COMMENT_TIME), $time_unit)) - REQUEST_TIME;
}
if (user_access('edit own comments')) {
$type = 'status';
$message = '<span class="edit-limit-time-unit-' . check_plain($time_unit) . '">' . t('You have %time_left %time_unit left to edit this comment.', array(
'%time_left' => $time_left,
'%time_unit' => 'seconds',
)) . '</span>';
drupal_set_message(filter_xss($message, array(
'em',
'span',
)), $type, FALSE);
}
}
}
return $return;
}
return FALSE;
}