Вложение может видеть только автор и админ. Вознагарждение за решение

Главные вкладки

Аватар пользователя dancermanz dancermanz 5 августа 2012 в 17:19

Здравствуте, уважаемые пользователи. Прошу помощи. Есть модкль comment upload. Хочу сделать так, что бы только автор комментария и админ или модератор видели вложение к комментарию, а все остальные только текст комментария. Готов заплатить за решение. Спасибо

Комментарии

Аватар пользователя Виктор Степаньков ака RxB Виктор Степаньк... 5 августа 2012 в 17:42

Как-то так, поиграть с префиксом функции,.

function phptemplate_template_preprocess_comment_upload_attachments(&$variables) {
global $user;
$file = array_pop($variables['files'])
$comment = _comment_load($file['cid'])
if(user_access('access administration pages') || $user->uid == $comment->uid)
{
  $row = 0;
  $variables['images'] = array();
  $variables['attachments'] = array();
  foreach ($variables['files'] as $fid => $file) {
    if ($file['list'] && empty($file['remove'])) {
      $text = $file['description'] ? $file['description'] : $file['filename'];

      if ($variables['display_images'] && strpos($file['filemime'], 'image/') === 0) {
        if ($variables['preset']) {
          $variables['images'][$fid]['image'] = theme('imagecache', $variables['preset'], file_create_path($file['filepath']), $text, $text);
        }
        else {
          $variables['images'][$fid]['image'] = theme('image', file_create_path($file['filepath']), $text, $text);
        }
        $variables['images'][$fid]['url'] = check_url(file_create_url($file['filepath']));
      }
      else {
        $variables['attachments'][$fid]['zebra'] = $row % 2 == 0 ? 'odd' : 'even';
        $variables['attachments'][$fid]['text'] = check_plain($text);
        $variables['attachments'][$fid]['url'] = check_url(file_create_url($file['filepath']));
        $variables['attachments'][$fid]['size'] = format_size($file['filesize']);
        $row++;
      }
    }
  }
}
}
<code>