$is_admin = $inUser->is_admin || $inUser->id == $club['admin_id']; $is_moder = $model->checkUserRightsInClub('moderator'); $is_member = $model->checkUserRightsInClub('member'); $is_karma_enabled = $inUser->karma >= $club['photo_min_karma'] && $is_member ? true : false; if (!$is_admin && !$is_moder && !$is_karma_enabled) { header("HTTP/1.1 500 File Upload Error"); exit(0); } // Массив с первого шага $photo = cmsUser::sessionGet('mod'); if (!$photo) { header("HTTP/1.1 500 Internal Server Error"); exit(0); } // Загружаем фото $file = $model->initUploadClass()->uploadPhoto(); if ($file) { if (!cmsCore::inRequest('upload')) { $last_id = $inDB->get_field('cms_photo_files', 'published=1 ORDER BY id DESC', 'id'); } $photo['album_id'] = $album['id']; $photo['file'] = $file['filename']; $photo['title'] = $photo['title'] ? $photo['title'] . $last_id : $file['realfile']; $photo['published'] = $is_admin || $is_moder ? 1 : (int) (!$club['photo_premod']); $photo['owner'] = 'club' . $club['id']; $photo['user_id'] = $inUser->id; $photo_id = $inPhoto->addPhoto($photo); if ($photo['published']) { $description = $club['clubtype'] == 'private' ? '' : '<a href="/clubs/photo' . $photo_id . '.html" class="act_photo"><img border="0" src="/images/photos/small/' . $photo['file'] . '" /></a>'; cmsActions::log('add_photo_club', array('object' => $photo['title'], 'object_url' => '/clubs/photo' . $photo_id . '.html', 'object_id' => $photo_id, 'target' => $club['title'], 'target_id' => $photo['album_id'], 'target_url' => '/clubs/' . $club['id'], 'description' => $description)); }