/** * Image Controller * Route: gallery/image_id/{image_id} * * @param int $image_id Image ID * @return Symfony\Component\HttpFoundation\Response A Symfony Response object */ public function base($image_id, $page = 0) { $this->user->add_lang_ext('phpbbgallery/core', array('gallery')); try { $sql = 'SELECT * FROM ' . $this->table_images . ' WHERE image_id = ' . (int) $image_id; $result = $this->db->sql_query($sql); $this->data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$this->data) { // Image does not exist throw new \OutOfBoundsException('INVALID_IMAGE'); } $this->loader->load($this->data['image_album_id']); } catch (\Exception $e) { return $this->error($e->getMessage(), 404); } $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->display->generate_navigation($album_data); 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 . ' SET image_view_count = image_view_count + 1 WHERE image_id = ' . $image_id; $this->db->sql_query($sql); } // Do stuff here $page_title = $this->data['image_name']; if ($page > 1) { $page_title .= ' - ' . $this->user->lang('PAGE_TITLE_NUMBER', $page); } $s_allowed_delete = $s_allowed_edit = $s_allowed_status = false; if (($this->gallery_auth->acl_check('m_', $album_id, $album_data['album_user_id']) || $this->data['image_user_id'] == $this->user->data['user_id']) && $this->user->data['user_id'] != ANONYMOUS) { //$s_user_allowed = (($this->data['image_user_id'] == $this->user->data['user_id']) && ($album_data['album_status'] != phpbb_ext_gallery_core_album::STATUS_LOCKED)); $s_user_allowed = $this->data['image_user_id'] == $this->user->data['user_id'] && $album_data['album_status'] != 1; $s_allowed_delete = $this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id']); $s_allowed_edit = $this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) && $s_user_allowed || $this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id']); $s_quick_mod = $s_allowed_delete || $s_allowed_edit || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']); $this->user->add_lang_ext('phpbbgallery/core', 'gallery_mcp'); $this->template->assign_vars(array('S_MOD_ACTION' => $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)), 'S_QUICK_MOD' => $s_quick_mod, 'S_QM_MOVE' => $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']), 'S_QM_EDIT' => $s_allowed_edit, 'S_QM_DELETE' => $s_allowed_delete, 'S_QM_REPORT' => $this->gallery_auth->acl_check('m_report', $album_id, $album_data['album_user_id']), 'S_QM_STATUS' => $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']), 'S_IMAGE_REPORTED' => $this->data['image_reported'] ? true : false, 'U_IMAGE_REPORTED' => $this->data['image_reported'] ? $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)) : '', 'S_STATUS_APPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_APPROVED, 'S_STATUS_UNAPPROVED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_UNAPPROVED, 'S_STATUS_LOCKED' => $this->data['image_status'] == \phpbbgallery\core\image\image::STATUS_LOCKED)); } $image_desc = generate_text_for_display($this->data['image_desc'], $this->data['image_desc_uid'], $this->data['image_desc_bitfield'], 7); // Let's see if we can get next end prev $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']); if (in_array($sort_key, array('r', 'ra'))) { $sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'ASC' : 'DESC'); } else { $sql_help_sort = ', image_id ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); } $limit_days = array(); $sort_by_text = array('t' => $this->user->lang['TIME'], 'n' => $this->user->lang['IMAGE_NAME'], 'vc' => $this->user->lang['GALLERY_VIEWS'], 'u' => $this->user->lang['SORT_USERNAME']); $sort_by_sql = array('t' => 'image_time', 'n' => 'image_name_clean', 'vc' => 'image_view_count', 'u' => 'image_username_clean'); if ($this->config['phpbb_gallery_allow_rates']) { $sort_by_text['ra'] = $this->user->lang['RATING']; $sort_by_sql['ra'] = 'image_rate_points'; $sort_by_text['r'] = $this->user->lang['RATES_COUNT']; $sort_by_sql['r'] = 'image_rates'; } if ($this->config['phpbb_gallery_allow_comments']) { $sort_by_text['c'] = $this->user->lang['COMMENTS']; $sort_by_sql['c'] = 'image_comments'; $sort_by_text['lc'] = $this->user->lang['NEW_COMMENT']; $sort_by_sql['lc'] = 'image_last_comment'; } gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); $sql_sort_order .= $sql_help_sort; // Let's see if there is prieveus image $sql = 'SELECT * FROM ' . $this->table_images . ' WHERE image_album_id = ' . (int) $album_id . "\n\t\t\t\tAND image_status <> 3\n\t\t\tORDER BY {$sql_sort_order}" . $sql_help_sort; $result = $this->db->sql_query($sql); $images_array = array(); while ($row = $this->db->sql_fetchrow($result)) { $images_array[] = $row; } $cur = 0; foreach ($images_array as $id => $var) { if ($var['image_id'] == $image_id) { $cur = $id; } } $next = $prev = false; if (count($images_array) > $cur + 1) { $next = array('image_id' => $images_array[$cur + 1]['image_id'], 'image_name' => $images_array[$cur + 1]['image_name']); } if ($cur > 0) { $prev = array('image_id' => $images_array[$cur - 1]['image_id'], 'image_name' => $images_array[$cur - 1]['image_name']); } $this->db->sql_freeresult($result); $this->template->assign_vars(array('UC_NEXT_IMAGE' => $next ? $this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $next['image_id'])) . '" alt="' . $next['image_name'] . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id'])) . '">' . $next['image_name'] . ' »» </a>' : '', 'UC_PREV_IMAGE' => $prev ? $this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $prev['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $prev['image_id'])) . '" alt="' . $prev['image_name'] . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_image', array('image_id' => $prev['image_id'])) . '">«« ' . $prev['image_name'] . '</a>' : '', 'U_VIEW_ALBUM' => $this->helper->route('phpbbgallery_album', array('album_id' => $album_id)), 'UC_IMAGE' => $this->helper->route('phpbbgallery_image_file_medium', array('image_id' => $image_id)), 'U_DELETE' => $s_allowed_delete ? $this->helper->route('phpbbgallery_image_delete', array('image_id' => $image_id)) : '', 'U_EDIT' => $s_allowed_edit ? $this->helper->route('phpbbgallery_image_edit', array('image_id' => $image_id)) : '', 'U_REPORT' => $this->gallery_auth->acl_check('i_report', $album_id, $album_data['album_user_id']) && $this->data['image_user_id'] != $this->user->data['user_id'] ? $this->helper->route('phpbbgallery_image_report', array('image_id' => $image_id)) : '', 'U_STATUS' => $s_allowed_status ? $this->helper->route('phpbbgallery_moderate_image', array('image_id' => $image_id)) : '', 'CONTEST_RANK' => $this->data['image_contest_rank'] ? $this->user->lang('CONTEST_RESULT_' . $this->data['image_contest_rank']) : '', 'IMAGE_NAME' => $this->data['image_name'], 'IMAGE_DESC' => $image_desc, 'IMAGE_BBCODE' => $this->config['allow_bbcode'] ? '[image]' . $image_id . '[/image]' : '', 'IMAGE_IMGURL_BBCODE' => $this->config['phpbb_gallery_disp_image_url'] ? '[url=' . $this->url->get_uri($this->helper->route('phpbbgallery_image', array('image_id' => $image_id))) . '][img]' . $this->url->get_uri($this->helper->route('phpbbgallery_image_file_mini', array('image_id' => $image_id))) . '[/img][/url]' : '', 'IMAGE_URL' => $this->config['phpbb_gallery_disp_image_url'] ? $this->url->get_uri($this->helper->route('phpbbgallery_image', array('image_id' => $image_id))) : '', 'IMAGE_TIME' => $this->user->format_date($this->data['image_time']), 'IMAGE_VIEW' => $this->data['image_view_count'], 'POSTER_IP' => $this->auth->acl_get('a_') ? $this->data['image_user_ip'] : '', 'U_POSTER_WHOIS' => $this->auth->acl_get('a_') ? append_sid('mcp', 'mode=whois&ip=' . $this->data['image_user_ip']) : '', 'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_image', array('image_id' => $image_id)), 'U_RETURN_LINK' => $this->helper->route('phpbbgallery_album', array('album_id' => $album_id)), 'S_RETURN_LINK' => $this->user->lang('RETURN_TO', $album_data['album_name']))); switch ($this->gallery_config->get('link_imagepage')) { case 'image': $this->template->assign_vars(array('UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_image_file_source', array('image_id' => $image_id)))); break; case 'next': if ($next) { $this->template->assign_vars(array('UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_image', array('image_id' => $next['image_id'])))); } break; } $image_data = $this->data; /** * Event view image * * @event phpbbgallery.core.viewimage * @var int image_id id of the image we are viewing * @var array image_data All the data related to the image * @var array album_data All the data related to the album image is part of * @var string page_title Page title * @since 1.2.0 */ $vars = array('image_id', 'image_data', 'album_data', 'page_title'); extract($this->dispatcher->trigger_event('phpbbgallery.core.viewimage', compact($vars))); $this->data = $image_data; $user_id = $this->data['image_user_id']; $sql = $this->db->sql_build_query('SELECT', array('SELECT' => 'u.*, gu.personal_album_id, gu.user_images', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array($this->table_users => 'gu'), 'ON' => 'gu.user_id = u.user_id')), 'WHERE' => 'u.user_id = ' . $this->data['image_user_id'])); $result = $this->db->sql_query($sql); $user_cache = array(); while ($row = $this->db->sql_fetchrow($result)) { \phpbbgallery\core\user::add_user_to_cache($user_cache, $row); } $this->db->sql_freeresult($result); $user_cache[$user_id]['username'] = $this->data['image_username'] ? $this->data['image_username'] : $this->user->lang['GUEST']; $this->template->assign_vars(array('POSTER_FULL' => get_username_string('full', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_COLOUR' => get_username_string('colour', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_USERNAME' => get_username_string('username', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'U_POSTER' => get_username_string('profile', $user_id, $user_cache[$user_id]['username'], $user_cache[$user_id]['user_colour']), 'POSTER_SIGNATURE' => $user_cache[$user_id]['sig'], 'POSTER_RANK_TITLE' => $user_cache[$user_id]['rank_title'], 'POSTER_RANK_IMG' => $user_cache[$user_id]['rank_image'], 'POSTER_RANK_IMG_SRC' => $user_cache[$user_id]['rank_image_src'], 'POSTER_JOINED' => $user_cache[$user_id]['joined'], 'POSTER_POSTS' => $user_cache[$user_id]['posts'], 'POSTER_AVATAR' => $user_cache[$user_id]['avatar'], 'POSTER_WARNINGS' => $user_cache[$user_id]['warnings'], 'POSTER_AGE' => $user_cache[$user_id]['age'], 'POSTER_ONLINE_IMG' => $user_id == ANONYMOUS || !$this->config['load_onlinetrack'] ? '' : ($user_cache[$user_id]['online'] ? $this->user->img('icon_user_online', 'ONLINE') : $this->user->img('icon_user_offline', 'OFFLINE')), 'S_POSTER_ONLINE' => $user_id == ANONYMOUS || !$this->config['load_onlinetrack'] ? false : ($user_cache[$user_id]['online'] ? true : false), 'U_POSTER_PROFILE' => $user_cache[$user_id]['profile'], 'U_POSTER_SEARCH' => $user_cache[$user_id]['search'], 'U_POSTER_PM' => $user_id != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($user_cache[$user_id]['allow_pm'] || $this->auth->acl_gets('a_', 'm_')) ? append_sid('./ucp.php', 'i=pm&mode=compose&u=' . $user_id) : '', 'U_POSTER_EMAIL' => $this->auth->acl_gets('a_') || !$this->config['board_hide_emails'] ? $user_cache[$user_id]['email'] : false, 'U_POSTER_JABBER' => $user_cache[$user_id]['jabber'], 'U_POSTER_GALLERY' => $user_cache[$user_id]['gallery_album'], 'POSTER_GALLERY_IMAGES' => $user_cache[$user_id]['gallery_images'], 'U_POSTER_GALLERY_SEARCH' => $user_cache[$user_id]['gallery_search'])); // Add ratings if ($this->gallery_config->get('allow_rates')) { $rating = new \phpbbgallery\core\rating($image_id, $image_data, $album_data); $user_rating = $rating->get_user_rating($this->user->data['user_id']); // Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in if (!$user_rating && $rating->is_allowed()) { $rating->display_box(); } $this->template->assign_vars(array('IMAGE_RATING' => $rating->get_image_rating($user_rating), 'S_ALLOWED_TO_RATE' => !$user_rating && $rating->is_allowed(), 'S_VIEW_RATE' => $this->gallery_auth->acl_check('i_rate', $album_id, $album_data['album_user_id']) ? true : false, 'S_RATE_ACTION' => $this->helper->route('phpbbgallery_image_rate', array('image_id' => $image_id)))); unset($rating); } /** * Posting comment */ $comments_disabled = !$this->gallery_config->get('allow_comments') || $this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments']; if (!$comments_disabled && $this->gallery_auth->acl_check('c_post', $album_id, $album_data['album_user_id']) && $album_data['album_status'] != $this->album->get_status_locked() && ($image_data['image_status'] != $this->image->get_status_locked() || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']))) { add_form_key('gallery'); $this->user->add_lang('posting'); $this->url->_include('functions_posting', 'phpbb'); $bbcode_status = $this->config['allow_bbcode'] ? true : false; $smilies_status = $this->config['allow_smilies'] ? true : false; $img_status = $bbcode_status ? true : false; $url_status = $this->config['allow_post_links'] ? true : false; $flash_status = false; $quote_status = true; include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; // Build custom bbcodes array display_custom_bbcodes(); // Build smilies array generate_smilies('inline', 0); //$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false; $s_hide_comment_input = false; $this->template->assign_vars(array('S_ALLOWED_TO_COMMENT' => true, 'S_HIDE_COMMENT_INPUT' => $s_hide_comment_input, 'BBCODE_STATUS' => $bbcode_status ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], 'S_SIGNATURE_CHECKED' => $this->user->optionget('attachsig') ? ' checked="checked"' : '', 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'L_COMMENT_LENGTH' => sprintf($this->user->lang['COMMENT_LENGTH'], $this->gallery_config->get('comment_length')))); if ($this->misc->display_captcha('comment')) { global $phpbb_container; $captcha = $phpbb_container->get('captcha.factory')->get_instance($this->config['captcha_plugin']); $captcha->init(CONFIRM_POST); $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template())); } // Different link, when we rate and dont comment if (!$s_hide_comment_input) { //$this->template->assign_var('S_COMMENT_ACTION', append_sid($this->url->path('full') . 'comment/' . $image_id . '/add/0')); $this->template->assign_var('S_COMMENT_ACTION', $this->helper->route('phpbbgallery_comment_add', array('image_id' => $image_id, 'comment_id' => 0))); } } else { if ($this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments']) { $this->template->assign_var('S_COMMENTS_DISABLED', true); } } /** * Listing comment */ if ($this->gallery_config->get('allow_comments') && $this->gallery_auth->acl_check('c_read', $album_id, $album_data['album_user_id'])) { $this->display_comments($image_id, $this->data, $album_id, $album_data, ($page - 1) * $this->gallery_config->get('items_per_page'), $this->gallery_config->get('items_per_page')); } return $this->helper->render('gallery/viewimage_body.html', $page_title); }
public function rate($image_id) { $this->user->add_lang_ext('phpbbgallery/core', array('gallery')); add_form_key('gallery'); $submit = $this->request->variable('submit', false); $error = $message = ''; // load Image Data $image_data = $this->image->get_image_data($image_id); $album_id = (int) $image_data['image_album_id']; $album_data = $this->loader->get($album_id); $this->display->generate_navigation($album_data); $page_title = $image_data['image_name']; $image_backlink = $this->helper->route('phpbbgallery_image', array('image_id' => $image_id)); $album_backlink = $this->helper->route('phpbbgallery_album', array('album_id' => $album_id)); $image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id={$album_id}&image_id={$image_id}"); $this->gallery_auth->load_user_premissions($this->user->data['user_id']); $rating = new \phpbbgallery\core\rating($image_id, $image_data, $album_data); if (!($this->gallery_config->get('allow_rates') && $rating->is_able())) { // The user is unable to rate. $this->misc->not_authorised($image_backlink, $image_loginlink); } $this->user->add_lang('posting'); include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext; $bbcode_status = $this->config['allow_bbcode'] ? true : false; $smilies_status = $this->config['allow_smilies'] ? true : false; $img_status = $bbcode_status ? true : false; $url_status = $this->config['allow_post_links'] ? true : false; $flash_status = false; $quote_status = true; include_once $this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext; // Build custom bbcodes array display_custom_bbcodes(); // Build smilies array generate_smilies('inline', 0); /** * Rating-System: now you can comment and rate in one form */ $s_user_rated = false; if ($this->gallery_config->get('allow_rates')) { $user_rating = $rating->get_user_rating($this->user->data['user_id']); // Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in if (!$user_rating && $rating->is_allowed()) { $rating->display_box(); // User just rated the image, so we store it $rate_point = $this->request->variable('rating', 0); if ($rating->rating_enabled && $rate_point > 0) { $rating->submit_rating(); $s_user_rated = true; $message .= $this->user->lang['RATING_SUCCESSFUL'] . '<br />'; } $this->template->assign_vars(array('S_ALLOWED_TO_RATE' => $rating->is_allowed())); } } $message .= '<br />' . sprintf($this->user->lang['CLICK_RETURN_IMAGE'], '<a href="' . $image_backlink . '">', '</a>'); $message .= '<br />' . sprintf($this->user->lang['CLICK_RETURN_ALBUM'], '<a href="' . $album_backlink . '">', '</a>'); $this->url->meta_refresh(3, $image_backlink); trigger_error($message); return $this->helper->render('gallery/comment_body.html', $page_title); }
/** * Delete an image completly. * * @param array $images Array with the image_id(s) * @param array $filenames Array with filenames for the image_ids. If a filename is missing it's queried from the database. * Format: $image_id => $filename * @param bool $skip_files If set to true, we won't try to delete the source files. */ public function delete_images($images, $filenames = array(), $resync_albums = true, $skip_files = false) { global $phpbb_container, $table_prefix, $phpbb_dispatcher, $db; $image_tools = $phpbb_container->get('phpbbgallery.core.file.tool'); $album = $phpbb_container->get('phpbbgallery.core.album'); $phpbb_gallery_image_rating = new \phpbbgallery\core\rating($images); $phpbb_gallery_comment = $phpbb_container->get('phpbbgallery.core.comment'); $phpbb_gallery_notification = new \phpbbgallery\core\notification(); $phpbb_gallery_report = $phpbb_container->get('phpbbgallery.core.report'); $phpbb_gallery_contest = new \phpbbgallery\core\contest(); if (empty($images)) { return; } if (!$skip_files) { // Delete the files from the disc... $need_filenames = array(); foreach ($images as $image) { if (!isset($filenames[$image])) { $need_filenames[] = $image; } } $filenames = array_merge($filenames, self::get_filenames($need_filenames)); $image_tools->delete($filenames); } // Delete the ratings... $phpbb_gallery_image_rating->delete_ratings($images); $phpbb_gallery_comment->delete_images($images); $phpbb_gallery_notification->delete_images($images); $phpbb_gallery_report->delete_images($images); /** * Event delete images * * @event phpbbgallery.core.image.delete_images * @var array images array of the image ids we are deleting * @var array filenames array of the image filenames * @since 1.2.0 */ $vars = array('images', 'filenames'); extract($phpbb_dispatcher->trigger_event('phpbbgallery.core.image.delete_images', compact($vars))); $sql = 'SELECT image_album_id, image_contest_rank FROM ' . $table_prefix . 'gallery_images WHERE ' . $db->sql_in_set('image_id', $images) . ' GROUP BY image_album_id, image_contest_rank'; $result = $db->sql_query($sql); $resync_album_ids = $resync_contests = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['image_contest_rank']) { $resync_contests[] = (int) $row['image_album_id']; } $resync_album_ids[] = (int) $row['image_album_id']; } $db->sql_freeresult($result); $resync_contests = array_unique($resync_contests); $resync_album_ids = array_unique($resync_album_ids); $sql = 'DELETE FROM ' . $table_prefix . 'gallery_images WHERE ' . $db->sql_in_set('image_id', $images); $db->sql_query($sql); // The images need to be deleted, before we grab the new winners. $phpbb_gallery_contest->resync_albums($resync_contests); if ($resync_albums) { foreach ($resync_album_ids as $album_id) { $album->update_info($album_id); } } return true; }