function edit_limit_node_view_alter in Edit Limit 7
File
- ./edit_limit.module, line 290
- edit_limit.module
Primary module file for Edit Limit. This contains all the hooks needed to
run the module.
Code
function edit_limit_node_view_alter(&$build) {
if (!user_access('edit own comments')) {
return FALSE;
}
if (!empty($build['links']['comment']['#links']['comment-add']) && !empty($build['comments']['comments'])) {
if (0) {
$results = db_query("SELECT * FROM {edit_limit_comment_time} WHERE cid = :cid", array(
':cid' => $comment->cid,
));
}
foreach ($build['comments']['comments'] as $key => $comment) {
if (!is_numeric($key)) {
continue;
}
if (!user_access('bypass edit limits') && variable_get('edit_limit_comment_time_enabled', FALSE) && !empty($build['comments']['comments'][$key]['links']['comment']['#links']['comment-edit'])) {
$time_unit = variable_get('edit_limit_comment_time_unit', EDIT_LIMIT_TIME_UNIT_DEFAULT);
$time_limit = $comment['#comment']->created + intval(_unit_to_seconds(variable_get('edit_limit_comment_time', EDIT_LIMIT_COMMENT_TIME), $time_unit));
if ($time_limit < REQUEST_TIME) {
unset($build['comments']['comments'][$key]['links']['comment']['#links']['comment-edit']);
}
else {
drupal_add_js(drupal_get_path('module', 'edit_limit') . '/edit_limit.js');
$build['comments']['comments'][$key]['links']['comment']['#links']['comment-edit']['title'] .= ' <span class="edit-limit-time-unit-' . $time_unit . '">' . t('(%time_limit %time_unit left)', array(
'%time_limit' => $time_limit - REQUEST_TIME,
'%time_unit' => 'seconds',
)) . '</span>';
}
}
}
}
}