diff --git a/core/acp/albums_module.php b/core/acp/albums_module.php index c39738a1..41af23d3 100644 --- a/core/acp/albums_module.php +++ b/core/acp/albums_module.php @@ -149,7 +149,7 @@ function main($id, $mode) extract($phpbb_dispatcher->trigger_event('phpbbgallery.core.acp.albums.request_data', compact($vars))); // Categories are not able to be locked... - if ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CAT) + if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT) { $album_data['album_status'] = \phpbbgallery\core\block::ALBUM_OPEN; } @@ -330,7 +330,7 @@ function main($id, $mode) $album_data['left_id'] = $row['left_id']; $album_data['right_id'] = $row['right_id']; } - if ($row['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { $contest_data = $phpbb_gallery_contest->get_contest($album_id, 'album'); } @@ -454,7 +454,7 @@ function main($id, $mode) $album_sort_dir_options .= '" . $this->language->lang('SORT_DESCENDING') . ''; $album_sort_dir_options .= '" . $this->language->lang('SORT_ASCENDING') . ''; - $statuslist = ''; + $statuslist = ''; $sql = 'SELECT album_id FROM ' . $table_prefix . 'gallery_albums @@ -540,12 +540,12 @@ function main($id, $mode) 'S_PARENT_OPTIONS' => $parents_list, 'S_ALBUM_OPTIONS' => $phpbb_ext_gallery_core_album->get_albumbox(true, '', ($action == 'add') ? $album_data['parent_id'] : false, false, ($action == 'edit') ? $album_data['album_id'] : false), - 'S_ALBUM_ORIG_UPLOAD' => (isset($old_album_type) && $old_album_type == \phpbbgallery\core\block::TYPE_UPLOAD) ? true : false, - 'S_ALBUM_ORIG_CAT' => (isset($old_album_type) && $old_album_type == \phpbbgallery\core\block::TYPE_CAT) ? true : false, - 'S_ALBUM_ORIG_CONTEST' => (isset($old_album_type) && $old_album_type == \phpbbgallery\core\block::TYPE_CONTEST) ? true : false, - 'S_ALBUM_UPLOAD' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_UPLOAD) ? true : false, - 'S_ALBUM_CAT' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CAT) ? true : false, - 'S_ALBUM_CONTEST' => ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) ? true : false, + 'S_ALBUM_ORIG_UPLOAD' => (isset($old_album_type) && $old_album_type == (int) \phpbbgallery\core\block::TYPE_UPLOAD) ? true : false, + 'S_ALBUM_ORIG_CAT' => (isset($old_album_type) && $old_album_type == (int) \phpbbgallery\core\block::TYPE_CAT) ? true : false, + 'S_ALBUM_ORIG_CONTEST' => (isset($old_album_type) && $old_album_type == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? true : false, + 'S_ALBUM_UPLOAD' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_UPLOAD) ? true : false, + 'S_ALBUM_CAT' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT) ? true : false, + 'S_ALBUM_CONTEST' => ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? true : false, 'ALBUM_UPLOAD' => \phpbbgallery\core\block::TYPE_UPLOAD, 'ALBUM_CAT' => \phpbbgallery\core\block::TYPE_CAT, 'ALBUM_CONTEST' => \phpbbgallery\core\block::TYPE_CONTEST, @@ -675,7 +675,7 @@ function main($id, $mode) { $album_type = $row['album_type']; - if ($row['album_status'] == \phpbbgallery\core\block::ALBUM_LOCKED) + if ($row['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED) { $folder_image = '' . $user->lang['LOCKED'] . ''; } diff --git a/core/album/album.php b/core/album/album.php index 587415bc..928fb4de 100644 --- a/core/album/album.php +++ b/core/album/album.php @@ -236,7 +236,7 @@ public function get_albumbox($ignore_personals, $select_name, $select_id = false ((is_array($ignore_id) && in_array($row['album_id'], $ignore_id)) || $row['album_id'] == $ignore_id) || // Need upload permissions (for moving) - (($requested_permission == 'm_move') && (($row['album_type'] == \phpbbgallery\core\block::TYPE_CAT) || (!$this->gallery_auth->acl_check('i_upload', $row['album_id'], $row['album_user_id']) && !$this->gallery_auth->acl_check('m_move', $row['album_id'], $row['album_user_id'])))) + (($requested_permission == 'm_move') && (($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT) || (!$this->gallery_auth->acl_check('i_upload', $row['album_id'], $row['album_user_id']) && !$this->gallery_auth->acl_check('m_move', $row['album_id'], $row['album_user_id'])))) || // album_type does not fit ($check_album_type && ($row['album_type'] != $requested_album_type)) diff --git a/core/album/loader.php b/core/album/loader.php index b211b75e..cddedac1 100644 --- a/core/album/loader.php +++ b/core/album/loader.php @@ -67,7 +67,7 @@ public function load($album_id) { throw new \OutOfBoundsException('INVALID_ALBUM'); } - if ($row['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { $album_contest_data = $this->contest->get_contest($row['album_id'], 'album'); $row = array_merge($row, $album_contest_data); diff --git a/core/album/manage.php b/core/album/manage.php index b6700363..3cda5681 100644 --- a/core/album/manage.php +++ b/core/album/manage.php @@ -211,7 +211,7 @@ public function update_album_data(&$album_data, &$contest_data) } }*/ // Validate the contest timestamps: - if ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { if ($this->user->data['user_timezone'] == '') { @@ -386,7 +386,7 @@ public function update_album_data(&$album_data, &$contest_data) $album_data['album_id'] = (int) $this->db->sql_nextid(); // Type is contest, so create it... - if ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { $contest_data_sql = $contest_data; $contest_data_sql['contest_album_id'] = $album_data['album_id']; @@ -408,28 +408,28 @@ public function update_album_data(&$album_data, &$contest_data) $row = $this->gallery_album->get_info($album_data_sql['album_id']); $reset_marked_images = false; - if ($row['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] != \phpbbgallery\core\block::TYPE_CONTEST) + if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] != \phpbbgallery\core\block::TYPE_CONTEST) { // Changing a contest to album? No! // Changing a contest to category? No! $errors[] = $this->language->lang('ALBUM_WITH_CONTEST_NO_TYPE_CHANGE'); return $errors; } - else if ($row['album_type'] != \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + else if ($row['album_type'] != \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { // Changing a album to contest? No! // Changing a category to contest? No! $errors[] = $this->language->lang('ALBUM_NO_TYPE_CHANGE_TO_CONTEST'); return $errors; } - else if ($row['album_type'] == \phpbbgallery\core\block::TYPE_CAT && $album_data_sql['album_type'] == \phpbbgallery\core\block::TYPE_UPLOAD) + else if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT && $album_data_sql['album_type'] == (int) \phpbbgallery\core\block::TYPE_UPLOAD) { // Changing a category to a album? Yes! // Reset the data (you couldn't upload directly in a cat, you must use a album) $album_data_sql['album_images'] = $album_data_sql['album_images_real'] = $album_data_sql['album_last_image_id'] = $album_data_sql['album_last_user_id'] = $album_data_sql['album_last_image_time'] = $album_data_sql['album_contest'] = 0; $album_data_sql['album_last_username'] = $album_data_sql['album_last_user_colour'] = $album_data_sql['album_last_image_name'] = ''; } - else if ($row['album_type'] == \phpbbgallery\core\block::TYPE_UPLOAD && $album_data_sql['album_type'] == \phpbbgallery\core\block::TYPE_CAT) + else if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_UPLOAD && $album_data_sql['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT) { // Changing a album to a category? Yes! // we're turning a uploadable album into a non-uploadable album @@ -455,13 +455,13 @@ public function update_album_data(&$album_data, &$contest_data) return array($this->language->lang('NO_ALBUM_ACTION')); } } - else if ($row['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + else if ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST && $album_data_sql['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { // Changing a contest to contest? Yes! // We need to check for the contest_data $row_contest = $this->gallery_contest->get_contest($album_data['album_id'], 'album'); $contest_data['contest_id'] = $row_contest['contest_id']; - if ($row_contest['contest_marked'] == \phpbbgallery\core\block::NO_CONTEST) + if ($row_contest['contest_marked'] == (int) \phpbbgallery\core\block::NO_CONTEST) { // If the old contest is finished, but the new one isn't, we need to remark the images! // If we change it the other way round, the album.php will do the end on the first visit! @@ -520,14 +520,14 @@ public function update_album_data(&$album_data, &$contest_data) $contest_id = $contest_data['contest_id']; unset($contest_data['contest_id']); - $sql = 'UPDATE ' . GALLERY_CONTESTS_TABLE . ' + $sql = 'UPDATE ' . $this->contests_table . ' SET ' . $db->sql_build_array('UPDATE', $contest_data) . ' WHERE contest_id = ' . (int) $contest_id; $db->sql_query($sql); if ($reset_marked_images) { // If the old contest is finished, but the new one isn't, we need to remark the images! - $sql = 'UPDATE ' . GALLERY_IMAGES_TABLE . ' + $sql = 'UPDATE ' . $this->images_table . ' SET image_contest_rank = 0, image_contest_end = 0, image_contest = ' . phpbb_ext_gallery_core_image::IN_CONTEST . ' diff --git a/core/auth/level.php b/core/auth/level.php index bdc14e81..089cbac8 100644 --- a/core/auth/level.php +++ b/core/auth/level.php @@ -62,7 +62,7 @@ public function __construct(\phpbbgallery\core\auth\auth $auth, \phpbb\config\co } /** - * User authorisation levels output + * User authorization levels output * * @param int $album_id The current album the user is in. * @param int $album_status The albums status bit. diff --git a/core/controller/album.php b/core/controller/album.php index 06cf9b90..eacc862f 100644 --- a/core/controller/album.php +++ b/core/controller/album.php @@ -66,6 +66,15 @@ class album /* @var string */ protected $table_images; + const ALBUM_SHOW_IP = 128; + const ALBUM_SHOW_RATINGS = 64; + const ALBUM_SHOW_USERNAME = 32; + const ALBUM_SHOW_VIEWS = 16; + const ALBUM_SHOW_TIME = 8; + const ALBUM_SHOW_IMAGENAME = 4; + const ALBUM_SHOW_COMMENTS = 2; + const ALBUM_SHOW_ALBUM = 1; + /** * Constructor * @@ -141,7 +150,7 @@ public function base($album_id, $page = 0) $album_data = $this->loader->get($album_id); - if ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { if ($album_data['contest_id'] && $album_data['contest_marked'] && (($album_data['contest_start'] + $album_data['contest_end']) < time())) { @@ -184,6 +193,7 @@ public function base($album_id, $page = 0) array('album_id' => (int) $album_id) )); } + if ((!$album_data['album_user_id'] || $album_data['album_user_id'] == $this->user->data['user_id']) && ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_check('i_upload', $album_id, $album_data['album_user_id']))) { @@ -208,13 +218,13 @@ public function base($album_id, $page = 0) $this->template->assign_vars(array( 'S_IS_POSTABLE' => $album_data['album_type'] != \phpbbgallery\core\block::TYPE_CAT, - 'S_IS_LOCKED' => $album_data['album_status'] == \phpbbgallery\core\block::ALBUM_LOCKED, + 'S_IS_LOCKED' => $album_data['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED, 'U_RETURN_LINK' => $this->helper->route('phpbbgallery_core_index'), 'L_RETURN_LINK' => $this->language->lang('RETURN_TO_GALLERY'), 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_id)), 'S_IS_WATCHED' => $this->notifications_helper->get_watched_album($album_id) ? true : false, - 'U_WATCH_TOGLE' => $this->helper->route('phpbbgallery_core_album_watch', array('album_id' => (int) $album_id)), + 'U_WATCH_TOGGLE' => $this->helper->route('phpbbgallery_core_album_watch', array('album_id' => (int) $album_id)), )); if ($album_data['album_type'] != \phpbbgallery\core\block::TYPE_CAT @@ -240,13 +250,31 @@ protected function display_images($album_id, $album_data, $start, $limit) $sort_key = $this->request->variable('sk', ($album_data['album_sort_key']) ? $album_data['album_sort_key'] : $this->config['phpbb_gallery_default_sort_key']); $sort_dir = $this->request->variable('sd', ($album_data['album_sort_dir']) ? $album_data['album_sort_dir'] : $this->config['phpbb_gallery_default_sort_dir']); - $image_status_check = ' AND image_status <> ' . \phpbbgallery\core\block::STATUS_UNAPPROVED; + $image_status_check = ' AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED; + $image_counter = $album_data['album_images']; - if ($this->auth->acl_check('m_status', $album_id, $album_data['album_user_id'])) + + $user_id = $this->user->data['user_id']; + $album_owner_id = $album_data['album_user_id']; + + if ($this->auth->acl_check('m_status', $album_id, $album_owner_id)) { $image_status_check = ''; $image_counter = $album_data['album_images_real']; } + else + { + $image_status_check = " AND (image_status <> " . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . " OR image_user_id = $user_id)"; + + $sql = 'SELECT COUNT(*) AS total_images + FROM ' . $this->table_images . ' + WHERE image_album_id = ' . (int) $album_id . " + AND (image_status <> " . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . " OR image_user_id = $user_id) + AND image_status <> " . (int) \phpbbgallery\core\block::STATUS_ORPHAN; + $result = $this->db->sql_query($sql); + $image_counter = (int) $this->db->sql_fetchfield('total_images'); + $this->db->sql_freeresult($result); + } if (in_array($sort_key, array('r', 'ra'))) { @@ -292,7 +320,7 @@ protected function display_images($album_id, $album_data, $start, $limit) 'BLOCK_NAME' => $album_data['album_name'], )); - $images = array(); + $images = []; $sql = 'SELECT * FROM ' . $this->table_images . ' WHERE image_album_id = ' . (int) $album_id . " @@ -303,52 +331,19 @@ protected function display_images($album_id, $album_data, $start, $limit) // Now let's get display options $show_ip = $show_ratings = $show_username = $show_views = $show_time = $show_imagename = $show_comments = $show_album = false; - $show_options = $this->gallery_config->get('album_display'); - if ($show_options >= 128) - { - $show_ip = true; - $show_options = $show_options - 128; - } - if ($show_options >= 64) - { - $show_ratings = true; - $show_options = $show_options - 64; - } - if (isset($album_data['contest_marked'])) - { - if ($album_data['contest_marked']) - { - $show_ratings = false; - } - } - if ($show_options >= 32) - { - $show_username = true; - $show_options = $show_options - 32; - } - if ($show_options >= 16) - { - $show_views = true; - $show_options = $show_options - 16; - } - if ($show_options >= 8) - { - $show_time = true; - $show_options = $show_options - 8; - } - if ($show_options >= 4) - { - $show_imagename = true; - $show_options = $show_options - 4; - } - if ($show_options >= 2) - { - $show_comments = true; - $show_options = $show_options - 2; - } - if ($show_options == 1) + $show_options = (int) $this->gallery_config->get('album_display'); + $show_ip = ($show_options & self::ALBUM_SHOW_IP) !== 0; + $show_ratings = ($show_options & self::ALBUM_SHOW_RATINGS) !== 0; + $show_username = ($show_options & self::ALBUM_SHOW_USERNAME) !== 0; + $show_views = ($show_options & self::ALBUM_SHOW_VIEWS) !== 0; + $show_time = ($show_options & self::ALBUM_SHOW_TIME) !== 0; + $show_imagename = ($show_options & self::ALBUM_SHOW_IMAGENAME) !== 0; + $show_comments = ($show_options & self::ALBUM_SHOW_COMMENTS) !== 0; + $show_album = ($show_options & self::ALBUM_SHOW_ALBUM) !== 0; + + if (!empty($album_data['contest_marked']) && $album_data['contest_marked']) { - $show_album = true; + $show_ratings = false; } while ($row = $this->db->sql_fetchrow($result)) @@ -394,17 +389,17 @@ protected function display_images($album_id, $album_data, $start, $limit) $s_username_hidden = $image_data['image_contest'] && !$this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && ($this->user->data['user_id'] != $image_data['image_user_id'] || $image_data['image_user_id'] == ANONYMOUS); $this->template->assign_block_vars('imageblock.image', array( - 'IMAGE_ID' => $image_data['image_id'], + 'IMAGE_ID' => (int) $image_data['image_id'], 'U_IMAGE' => $action_image, 'UC_IMAGE_NAME' => $show_imagename ? htmlspecialchars_decode($image_data['image_name'], ENT_COMPAT) : false, 'U_ALBUM' => $show_album ? $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_data['album_id'])) : false, 'ALBUM_NAME' => $show_album ? $album_data['album_name'] : false, - 'IMAGE_VIEWS' => $show_views ? $image_data['image_view_count'] : -1, + 'IMAGE_VIEWS' => $show_views ? (int) $image_data['image_view_count'] : -1, //'UC_THUMBNAIL' => 'self::generate_link('thumbnail', $phpbb_ext_gallery->config->get('link_thumbnail'), $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id']), 'UC_THUMBNAIL' => $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $image_data['image_id'])), 'UC_THUMBNAIL_ACTION' => $action, - 'S_UNAPPROVED' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED)) ? true : false, - 'S_LOCKED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, + 'S_UNAPPROVED' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED)) ? true : false, + 'S_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, 'S_REPORTED' => ($this->auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported']) ? true : false, 'POSTER' => ($show_username) ? (($s_username_hidden) ? $this->language->lang('CONTEST_USERNAME') : get_username_string('full', $image_data['image_user_id'], $image_data['image_username'], $image_data['image_user_colour'])) : false, 'TIME' => $show_time ? $this->user->format_date($image_data['image_time']) : false, @@ -418,14 +413,15 @@ protected function display_images($album_id, $album_data, $start, $limit) 'U_USER_IP' => $show_ip && $this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) ? $image_data['image_user_ip'] : false, 'S_IMAGE_REPORTED' => $image_data['image_reported'], 'U_IMAGE_REPORTED' => '',//($image_data['image_reported']) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported']) : '', - 'S_STATUS_APPROVED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_APPROVED), - 'S_STATUS_UNAPPROVED' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, - 'S_STATUS_UNAPPROVED_ACTION' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => $image_data['image_id'])) : '', - 'S_STATUS_LOCKED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_LOCKED), + 'S_STATUS_APPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? true : false, + 'S_STATUS_UNAPPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, + 'S_STATUS_UNAPPROVED_ACTION' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => $image_data['image_id'])) : '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, + 'S_STATUS_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, 'U_REPORT' => ($this->auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported']) ? '123'/*$this->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported'])*/ : '', 'U_STATUS' => '',//($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id)) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=queue_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_id']) : '', - 'L_STATUS' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->language->lang('APPROVE_IMAGE') : (($image_data['image_status'] == \phpbbgallery\core\block::STATUS_APPROVED) ? $this->language->lang('CHANGE_IMAGE_STATUS') : $this->language->lang('UNLOCK_IMAGE')), + 'L_STATUS' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->language->lang('APPROVE_IMAGE') : (($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? $this->language->lang('CHANGE_IMAGE_STATUS') : $this->language->lang('UNLOCK_IMAGE')), 'S_CONTEST_RANK' => $image_data['image_contest_rank'], )); diff --git a/core/controller/file.php b/core/controller/file.php index 8783f038..a6075632 100644 --- a/core/controller/file.php +++ b/core/controller/file.php @@ -273,7 +273,7 @@ public function check_auth() $this->auth->load_user_permissions($this->user->data['user_id']); $zebra_array = $this->auth->get_user_zebra($this->user->data['user_id']); // Check permissions - if (($this->data['image_user_id'] != $this->user->data['user_id']) && ($this->data['image_status'] == \phpbbgallery\core\block::STATUS_ORPHAN)) + if (($this->data['image_user_id'] != $this->user->data['user_id']) && ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_ORPHAN)) { // The image is currently being uploaded // trigger_error('NOT_AUTHORISED'); @@ -287,7 +287,11 @@ public function check_auth() $this->data['image_filemissing'] = 0; $this->data['album_watermark'] = 0; } - if ((!$this->auth->acl_check('i_view', $this->data['album_id'], $this->data['album_user_id'])) || (!$this->auth->acl_check('m_status', $this->data['album_id'], $this->data['album_user_id']) && ($this->data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED))) + if (!$this->auth->acl_check('i_view', $this->data['album_id'], $this->data['album_user_id']) || ( + !$this->auth->acl_check('m_status', $this->data['album_id'], $this->data['album_user_id']) + && $this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED + && $this->data['image_user_id'] != $this->user->data['user_id'] + )) { // Missing permissions // trigger_error('NOT_AUTHORISED'); diff --git a/core/controller/image.php b/core/controller/image.php index 3e78be52..712d8f29 100644 --- a/core/controller/image.php +++ b/core/controller/image.php @@ -258,8 +258,19 @@ public function base($image_id, $page = 0) $album_id = (int) $this->data['image_album_id']; $album_data = $this->loader->get($album_id); - $this->check_permissions($album_id, $album_data['album_user_id'], $this->data['image_status'], $album_data['album_auth_access']); + $this->check_permissions($album_id, $album_data['album_user_id'], $this->data['image_status'], $album_data['album_auth_access'], $this->data); $this->display->generate_navigation($album_data); + + if ($this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id'])) + { + $image_status_check = ''; + } + else + { + $user_id = (int) $this->user->data['user_id']; + $image_status_check = ' AND (image_status = ' . \phpbbgallery\core\block::STATUS_APPROVED . ' OR image_user_id = ' . $user_id . ')'; + } + if (!$this->user->data['is_bot'] && isset($this->user->data['session_page']) && (strpos($this->user->data['session_page'], '&image_id=' . $image_id) === false || isset($this->user->data['session_created']))) { $sql = 'UPDATE ' . $this->table_images . ' @@ -297,9 +308,9 @@ public function base($image_id, $page = 0) 'S_IMAGE_REPORTED' => $this->data['image_reported'] ? true : false, 'U_IMAGE_REPORTED' => ($this->data['image_reported']) ? $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => (int) $image_id)) : '', - 'S_STATUS_APPROVED' => ($this->data['image_status'] == \phpbbgallery\core\block::STATUS_APPROVED), - 'S_STATUS_UNAPPROVED' => ($this->data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED), - 'S_STATUS_LOCKED' => ($this->data['image_status'] == \phpbbgallery\core\block::STATUS_LOCKED), + 'S_STATUS_APPROVED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED), + 'S_STATUS_UNAPPROVED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED), + 'S_STATUS_LOCKED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED), )); } $image_desc = generate_text_for_display($this->data['image_desc'], $this->data['image_desc_uid'], $this->data['image_desc_bitfield'], 7); @@ -352,9 +363,10 @@ public function base($image_id, $page = 0) // Let's see if there is prieveus image $sql = 'SELECT * FROM ' . $this->table_images . ' - WHERE image_album_id = ' . (int) $album_id . " - AND image_status <> 3 - ORDER BY $sql_sort_order" . $sql_help_sort; + WHERE image_album_id = ' . (int) $album_id . ' + AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_ORPHAN . ' + ' . $image_status_check . ' + ORDER BY ' . $sql_sort_order . $sql_help_sort; $result = $this->db->sql_query($sql); $images_array = array(); while ($row = $this->db->sql_fetchrow($result)) @@ -824,7 +836,7 @@ public function edit($image_id) $owner_id = $image_data['image_user_id']; $album_loginlink = './ucp.php?mode=login'; $this->gallery_auth->load_user_permissions($this->user->data['user_id']); - if (!$this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_ORPHAN)) + if (!$this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_ORPHAN)) { if (!$this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id'])) { @@ -1066,7 +1078,7 @@ public function delete($image_id) $image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); $album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id'])); $this->gallery_auth->load_user_permissions($this->user->data['user_id']); - if (!$this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_ORPHAN)) + if (!$this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_ORPHAN)) { if (!$this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id'])) { @@ -1194,11 +1206,11 @@ public function report($image_id) * @param $album_auth_level * @internal param array $album_data */ - protected function check_permissions($album_id, $owner_id, $image_status, $album_auth_level) + protected function check_permissions($album_id, $owner_id, $image_status, $album_auth_level, $user_data) { $this->gallery_auth->load_user_permissions($this->user->data['user_id']); $zebra_array = $this->gallery_auth->get_user_zebra($this->user->data['user_id']); - if (!$this->gallery_auth->acl_check('i_view', $album_id, $owner_id) || ($image_status == \phpbbgallery\core\block::STATUS_ORPHAN) || $this->gallery_auth->get_zebra_state($zebra_array, (int) $owner_id, (int) $album_id) < (int) $album_auth_level) + if (!$this->gallery_auth->acl_check('i_view', $album_id, $owner_id) || ($image_status == (int) \phpbbgallery\core\block::STATUS_ORPHAN) || $this->gallery_auth->get_zebra_state($zebra_array, (int) $owner_id, (int) $album_id) < (int) $album_auth_level) { if ($this->user->data['is_bot']) { @@ -1215,13 +1227,13 @@ protected function check_permissions($album_id, $owner_id, $image_status, $album else { //return $this->error('NOT_AUTHORISED', 403); - redirect('/gallery/album/' . $album_id); + redirect('gallery/album/' . $album_id); } } - if (!$this->gallery_auth->acl_check('m_status', $album_id, $owner_id) && ($image_status == \phpbbgallery\core\block::STATUS_UNAPPROVED)) + if (!$this->gallery_auth->acl_check('m_status', $album_id, $owner_id) && $user_data['image_user_id'] != $this->user->data['user_id'] && ($image_status == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED)) { //return $this->error('NOT_AUTHORISED', 403); - redirect('/gallery/album/' . $album_id); + redirect('gallery/album/' . $album_id); } } diff --git a/core/controller/moderate.php b/core/controller/moderate.php index f7c1b15b..042a7cb5 100644 --- a/core/controller/moderate.php +++ b/core/controller/moderate.php @@ -701,13 +701,13 @@ public function approve($image_id) { $this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); } - $action_ary = $this->request->variable('action', array('' => 0)); + $action_ary = $this->request->variable('action', []); $action_ary = array_keys($action_ary); - $action = $action_ary[0] ?? 'approve'; + $action = isset($action_ary[0]) ? $action_ary[0] : 'approve'; - if ($action == 'disapprove') + if ($action === 'disapprove') { - $redirect = new RedirectResponse($this->helper->route('phpbbgallery_core_image_delete', array('image_id' => $image_id))); + $redirect = new RedirectResponse($this->helper->route('phpbbgallery_core_image_delete', ['image_id' => $image_id])); $redirect->send(); } $show_notify = true; diff --git a/core/controller/search.php b/core/controller/search.php index 71ac3493..69c722bb 100644 --- a/core/controller/search.php +++ b/core/controller/search.php @@ -450,7 +450,7 @@ public function recent($page) /** * Index Controller - * Route: gallery/search/recent/{page} + * Route: gallery/search/commented/{page} * * @param $page * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object diff --git a/core/controller/upload.php b/core/controller/upload.php index ee147faf..a5f53b2e 100644 --- a/core/controller/upload.php +++ b/core/controller/upload.php @@ -159,7 +159,7 @@ public function main($album_id) { $this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); } - if ($album_data['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) + if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) { $contest = array(); $contest = $this->contest->get_contest($album_id, 'album'); diff --git a/core/image/image.php b/core/image/image.php index 31e34cfa..fa5ca8c8 100644 --- a/core/image/image.php +++ b/core/image/image.php @@ -212,7 +212,7 @@ public function delete_images($images, $filenames = array(), $resync_albums = tr $resync_contests[] = (int) $row['image_album_id']; } $resync_album_ids[] = (int) $row['image_album_id']; - if ($row['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) + if ($row['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) { $targets[$row['image_album_id']][$row['image_id']] = $row['image_user_id']; } @@ -602,8 +602,17 @@ public function get_last_image() $sql = 'SELECT * FROM ' . $this->table_images . ' WHERE image_status <> ' . \phpbbgallery\core\block::STATUS_ORPHAN . ' - AND ((' . $this->db->sql_in_set('image_album_id', $this->gallery_auth->acl_album_ids('i_view'), false, true) . ' AND image_status <> ' . \phpbbgallery\core\block::STATUS_UNAPPROVED . ') - OR ' . $this->db->sql_in_set('image_album_id', $this->gallery_auth->acl_album_ids('m_status'), false, true) . ') AND ' . $this->db->sql_in_set('image_album_id', $public, true, true) . ' + AND ( + ( + ' . $this->db->sql_in_set('image_album_id', $this->gallery_auth->acl_album_ids('i_view'), false, true) . ' + AND ( + image_status <> ' . \phpbbgallery\core\block::STATUS_UNAPPROVED . ' + OR image_user_id = ' . (int) $this->user->data['user_id'] . ' + ) + ) + OR ' . $this->db->sql_in_set('image_album_id', $this->gallery_auth->acl_album_ids('m_status'), false, true) . ' + ) + AND ' . $this->db->sql_in_set('image_album_id', $public, true, true) . ' ORDER BY ' . $sql_order; $result = $this->db->sql_query_limit($sql, $sql_limit); @@ -661,8 +670,8 @@ public function assign_block($image_block_name, $image_data, $display_option = 0 //'UC_THUMBNAIL' => 'self::generate_link('thumbnail', $phpbb_ext_gallery->config->get('link_thumbnail'), $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id']), 'UC_THUMBNAIL' => $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => (int) $image_data['image_id'])), 'UC_THUMBNAIL_ACTION' => $action, - 'S_UNAPPROVED' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED)) ? true : false, - 'S_LOCKED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, + 'S_UNAPPROVED' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED)) ? true : false, + 'S_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, 'S_REPORTED' => ($this->gallery_auth->acl_check('m_report', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_reported']) ? true : false, 'POSTER' => $show_username ? get_username_string('full', $image_data['image_user_id'], $image_data['image_username'], $image_data['image_user_colour']) : false, 'TIME' => $show_time ? $this->user->format_date($image_data['image_time']) : false, @@ -676,14 +685,15 @@ public function assign_block($image_block_name, $image_data, $display_option = 0 'S_IMAGE_REPORTED' => $image_data['image_reported'], 'U_IMAGE_REPORTED' => '',//($image_data['image_reported']) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported']) : '', - 'S_STATUS_APPROVED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_APPROVED), - 'S_STATUS_UNAPPROVED' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, - 'S_STATUS_UNAPPROVED_ACTION' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => (int) $image_data['image_id'])) : '', - 'S_STATUS_LOCKED' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_LOCKED), + 'S_STATUS_APPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? true : false, + 'S_STATUS_UNAPPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, + 'S_STATUS_UNAPPROVED_ACTION' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => (int) $image_data['image_id'])) : '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => ($this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, + 'S_STATUS_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, 'U_REPORT' => ($this->gallery_auth->acl_check('m_report', $image_data['image_album_id'], $image_data['album_user_id']) && $image_data['image_reported']) ? '123'/*$this->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported'])*/ : '', 'U_STATUS' => '',//($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id)) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=queue_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_id']) : '', - 'L_STATUS' => ($image_data['image_status'] == \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->language->lang('APPROVE_IMAGE') : (($image_data['image_status'] == \phpbbgallery\core\block::STATUS_APPROVED) ? $this->language->lang('CHANGE_IMAGE_STATUS') : $this->language->lang('UNLOCK_IMAGE')), + 'L_STATUS' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->language->lang('APPROVE_IMAGE') : (($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? $this->language->lang('CHANGE_IMAGE_STATUS') : $this->language->lang('UNLOCK_IMAGE')), )); } } diff --git a/core/language/bg/gallery.php b/core/language/bg/gallery.php index 0e863d7a..ee889fd1 100644 --- a/core/language/bg/gallery.php +++ b/core/language/bg/gallery.php @@ -150,6 +150,7 @@ 'IMAGE_LOCKED' => 'Съжаляваме, но това изображение е заключено. Вече не можете да го коментирате.', 'IMAGE_NAME' => 'Име на изображение', 'IMAGE_NOT_EXIST' => 'Това изображение не съществува.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% от всички изображения', 'IMAGE_STATUS' => 'Статус', 'IMAGE_URL' => 'Image-URL', diff --git a/core/language/de/gallery.php b/core/language/de/gallery.php index 36f8e2bf..e910351a 100644 --- a/core/language/de/gallery.php +++ b/core/language/de/gallery.php @@ -151,6 +151,7 @@ 'IMAGE_LOCKED' => 'Entschuldigung, aber dieses Bild wurde gesperrt. Du kannst für dieses Bild keine Kommentare mehr abgeben.', 'IMAGE_NAME' => 'Bildname', 'IMAGE_NOT_EXIST' => 'Dieses Bild existiert nicht', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% aller Bilder', 'IMAGE_STATUS' => 'Status', 'IMAGE_URL' => 'Bildlink', diff --git a/core/language/en/gallery.php b/core/language/en/gallery.php index 3eab3177..a644f09b 100644 --- a/core/language/en/gallery.php +++ b/core/language/en/gallery.php @@ -150,6 +150,7 @@ 'IMAGE_LOCKED' => 'Sorry, this image is locked. You cannot post comments for this image anymore.', 'IMAGE_NAME' => 'Imagename', 'IMAGE_NOT_EXIST' => 'This image does not exist.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% of all images', 'IMAGE_STATUS' => 'Status', 'IMAGE_URL' => 'Image-URL', diff --git a/core/language/es/gallery.php b/core/language/es/gallery.php index 7f7936f7..efaf61e8 100644 --- a/core/language/es/gallery.php +++ b/core/language/es/gallery.php @@ -150,6 +150,7 @@ 'IMAGE_LOCKED' => 'Lo siento, esta imagen está bloqueada. No puedes publicar más comentarios para esta imagen. ', 'IMAGE_NAME' => 'Nombre de imagen', 'IMAGE_NOT_EXIST' => 'Esta imagen no existe.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% de todas las imágenes', 'IMAGE_STATUS' => 'Estado', 'IMAGE_URL' => 'Imagen-URL', diff --git a/core/language/fr/gallery.php b/core/language/fr/gallery.php index ae7d3323..58f208b6 100644 --- a/core/language/fr/gallery.php +++ b/core/language/fr/gallery.php @@ -165,6 +165,7 @@ 'IMAGE_LOCKED' => 'Désolé, cette image est verrouillée. Vous ne pouvez pas publier de commentaires sur cette image.', 'IMAGE_NAME' => 'Nom de l’image', 'IMAGE_NOT_EXIST' => 'Cette image n’existe pas.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% de toutes les images', 'IMAGE_STATUS' => 'Statut', 'IMAGE_URL' => 'Lien', diff --git a/core/language/it/gallery.php b/core/language/it/gallery.php index 80642df4..78b70ab6 100644 --- a/core/language/it/gallery.php +++ b/core/language/it/gallery.php @@ -150,6 +150,7 @@ 'IMAGE_LOCKED' => 'Spiacente, quest’immagine è bloccata. Non si può più commentare quest’immagine.', 'IMAGE_NAME' => 'Nome immagine', 'IMAGE_NOT_EXIST' => 'Quest’immagine non esiste.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% di tutte le immagini', 'IMAGE_STATUS' => 'Stato', 'IMAGE_URL' => 'URL-Immagine', diff --git a/core/language/nl/gallery.php b/core/language/nl/gallery.php index 102f16ff..9417ee5e 100644 --- a/core/language/nl/gallery.php +++ b/core/language/nl/gallery.php @@ -151,6 +151,7 @@ 'IMAGE_LOCKED' => 'Sorry, deze afbeelding is gesloten. Je kan geen reacties meer plaatsen op deze afbeelding.', 'IMAGE_NAME' => 'Afbeeldingsnaam', 'IMAGE_NOT_EXIST' => 'Deze afbeelding bestaat niet.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% van alle afbeeldingen', 'IMAGE_STATUS' => 'Status', 'IMAGE_URL' => 'Afbeeldingslink', diff --git a/core/language/ru/gallery.php b/core/language/ru/gallery.php index 3522bc9f..ef19ef94 100644 --- a/core/language/ru/gallery.php +++ b/core/language/ru/gallery.php @@ -142,6 +142,7 @@ 'IMAGE_LOCKED' => 'Фото блокировано. Вы не можете оставлять к нему комментарии.', 'IMAGE_NAME' => 'Название', 'IMAGE_NOT_EXIST' => 'Фото не найдено.', + 'IMAGE_NOT_APPROVED' => 'For approval', 'IMAGE_PCT' => '%.2f%% всех фотографий', 'IMAGE_STATUS' => 'Статус', 'IMAGE_URL' => 'Ссылка на фото', diff --git a/core/rating.php b/core/rating.php index ecc323c1..c0174845 100644 --- a/core/rating.php +++ b/core/rating.php @@ -307,7 +307,7 @@ public function is_allowed() { return $this->gallery_auth->acl_check('i_rate', $this->album_data('album_id'), $this->album_data('album_user_id')) && ($this->user->data['user_id'] != $this->image_data('image_user_id')) && ($this->user->data['user_id'] != ANONYMOUS) && - ($this->album_data('album_status') != \phpbbgallery\core\block::ALBUM_LOCKED) && ($this->image_data('image_status') == \phpbbgallery\core\block::STATUS_APPROVED); + ($this->album_data('album_status') != \phpbbgallery\core\block::ALBUM_LOCKED) && ($this->image_data('image_status') == (int) \phpbbgallery\core\block::STATUS_APPROVED); } /** diff --git a/core/styles/prosilver/template/gallery/album_body.html b/core/styles/prosilver/template/gallery/album_body.html index 580df607..30bae709 100644 --- a/core/styles/prosilver/template/gallery/album_body.html +++ b/core/styles/prosilver/template/gallery/album_body.html @@ -28,7 +28,7 @@

{L_ALBUM_NAME}{L_COLON} {A {L_ALBUM_LOCKED} {L_UPLOAD_IMAGE} - {L_UNWATCH_ALBUM}{L_WATCH_ALBUM} + {L_UNWATCH_ALBUM}{L_WATCH_ALBUM} diff --git a/core/styles/prosilver/template/gallery/imageblock_polaroid.html b/core/styles/prosilver/template/gallery/imageblock_polaroid.html index e76dce70..f6fb9dc9 100644 --- a/core/styles/prosilver/template/gallery/imageblock_polaroid.html +++ b/core/styles/prosilver/template/gallery/imageblock_polaroid.html @@ -16,11 +16,16 @@ {imageblock.image.UC_IMAGE_NAME}


- +
+ +

+ {L_IMAGE_NOT_APPROVED} +

+ {imageblock.image.UC_IMAGE_NAME} -

+

diff --git a/core/styles/prosilver/template/gallery/viewimage_body.html b/core/styles/prosilver/template/gallery/viewimage_body.html index 82369ac5..d6c668f2 100644 --- a/core/styles/prosilver/template/gallery/viewimage_body.html +++ b/core/styles/prosilver/template/gallery/viewimage_body.html @@ -1,6 +1,16 @@

{L_IMAGE_NAME}{L_COLON} {IMAGE_NAME}

+ +
+
+
+ {L_IMAGE_NOT_APPROVED} +
+
+
+ +
diff --git a/core/styles/prosilver/theme/gallery.css b/core/styles/prosilver/theme/gallery.css index 0a46930e..5fc8907a 100644 --- a/core/styles/prosilver/theme/gallery.css +++ b/core/styles/prosilver/theme/gallery.css @@ -194,6 +194,23 @@ input.autowidth-gallery { box-sizing: border-box; } +.post > .inner > .unapproved { + text-align: center; + overflow: hidden; + padding: 8px; + font-size: larger; + font-weight: 700; + background-color: #ffcc66; + color: black; + border-radius: 10px; +} + +.polaroid .post-notice.unapproved { + font-weight: 700; + background-color: #ffcc66; + color: black; +} + .trophy-container { position: relative; diff --git a/core/ucp/main_module.php b/core/ucp/main_module.php index 8e5f82f6..9b39b8bc 100644 --- a/core/ucp/main_module.php +++ b/core/ucp/main_module.php @@ -1012,7 +1012,7 @@ function manage_subscriptions() 'UC_IMAGE_NAME' => $phpbb_ext_gallery_core_image->generate_link('image_name', $phpbb_ext_gallery_config->get('link_image_name'), $row['album_last_image_id'], $row['album_last_image_name'], $row['album_id']), 'UC_FAKE_THUMBNAIL' => $phpbb_ext_gallery_core_image->generate_link('fake_thumbnail', $phpbb_ext_gallery_config->get('link_thumbnail'), $row['album_last_image_id'], $row['album_last_image_name'], $row['album_id']), - 'UPLOADER' => (($row['album_type'] == \phpbbgallery\core\block::TYPE_CONTEST) && ($row['contest_marked'] && !$phpbb_ext_gallery_core_auth->acl_check('m_status', $row['album_id'], $row['album_user_id']))) ? $this->language->lang('CONTEST_USERNAME') : get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), + 'UPLOADER' => (($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) && ($row['contest_marked'] && !$phpbb_ext_gallery_core_auth->acl_check('m_status', $row['album_id'], $row['album_user_id']))) ? $this->language->lang('CONTEST_USERNAME') : get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']), 'LAST_IMAGE_TIME' => $user->format_date($row['album_last_image_time']), 'LAST_IMAGE' => $row['album_last_image_id'], 'U_IMAGE' => $phpbb_gallery_url->show_image($row['image_id']), diff --git a/tests/controller/gallery_album_test.php b/tests/controller/gallery_album_test.php index e0758652..c517fddd 100644 --- a/tests/controller/gallery_album_test.php +++ b/tests/controller/gallery_album_test.php @@ -149,6 +149,7 @@ public function test_for_base_clean() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -183,6 +184,7 @@ public function test_for_base_clean() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -217,6 +219,7 @@ public function test_for_base_clean() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -257,7 +260,7 @@ public function test_for_base_clean() 'L_RETURN_LINK' => 'RETURN_TO_GALLERY', 'S_ALBUM_ACTION' => 'phpbbgallery_core_album', 'S_IS_WATCHED' => false, - 'U_WATCH_TOGLE' => 'phpbbgallery_core_album_watch' + 'U_WATCH_TOGGLE' => 'phpbbgallery_core_album_watch' ) ), array( @@ -367,6 +370,7 @@ public function test_for_base_load_modreators_allow_rates_and_comments() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -401,6 +405,7 @@ public function test_for_base_load_modreators_allow_rates_and_comments() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -435,6 +440,7 @@ public function test_for_base_load_modreators_allow_rates_and_comments() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -481,7 +487,7 @@ public function test_for_base_load_modreators_allow_rates_and_comments() 'L_RETURN_LINK' => 'RETURN_TO_GALLERY', 'S_ALBUM_ACTION' => 'phpbbgallery_core_album', 'S_IS_WATCHED' => false, - 'U_WATCH_TOGLE' => 'phpbbgallery_core_album_watch' + 'U_WATCH_TOGGLE' => 'phpbbgallery_core_album_watch' ) ), array( diff --git a/tests/controller/gallery_index_test.php b/tests/controller/gallery_index_test.php index 8d495535..3d152373 100644 --- a/tests/controller/gallery_index_test.php +++ b/tests/controller/gallery_index_test.php @@ -601,6 +601,7 @@ public function test_controller_base_case_4() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', diff --git a/tests/core/core_search_test.php b/tests/core/core_search_test.php index 2a7c20ee..3738b237 100644 --- a/tests/core/core_search_test.php +++ b/tests/core/core_search_test.php @@ -313,6 +313,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -346,6 +347,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -379,6 +381,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -412,6 +415,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -445,6 +449,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -478,6 +483,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -511,6 +517,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -544,6 +551,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -577,6 +585,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -610,6 +619,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -643,6 +653,7 @@ public function rrc_gindex_display_test_data() 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -813,6 +824,7 @@ public function test_link_thumbnail_recent($state, $expect) 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -864,6 +876,7 @@ public function test_link_thumbnail_random($state, $expect) 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -915,6 +928,7 @@ public function test_link_image_name_recent($state, $expect) 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '', @@ -966,6 +980,7 @@ public function test_link_image_name_random($state, $expect) 'S_STATUS_APPROVED' => true, 'S_STATUS_UNAPPROVED' => false, 'S_STATUS_UNAPPROVED_ACTION' => '', + 'S_STATUS_UNAPPROVED_PERMISSIONS' => false, 'S_STATUS_LOCKED' => false, 'U_REPORT' => '', 'U_STATUS' => '',