set_prefilter('picture_modify', 'plugdphrPT'); $template->assign( array( 'U_DELETEPHIT' => $admin_base_url . '&deletephit', 'U_DELETEPRATE' => $admin_base_url . '&deleteprate', )); } function plugdphrPT($content) { load_language('plugin.lang', PDHR_PATH); $search = "#

#"; $replacement = '

{\'Purge hit of the photo\'|@translate}
{\'Purge rate of the photo\'|@translate}

'; return preg_replace($search, $replacement, $content); } function plugdphrPf2() { if (isset($_GET['deletephit'])) { $admin_base_url=explode('&deletephit', $_SERVER['REQUEST_URI']); $photoid = explode('photo-', $_SERVER['REQUEST_URI']); if(strstr($photoid[1], '-properties')){$photoid = explode('-properties', $photoid[1]);} else if(strstr($photoid[1], '&cat')){$photoid = explode('&cat', $photoid[1]);} else{ $_SESSION['page_infos'] = array('error'); redirect($_SERVER['REQUEST_URI']); } $_SESSION['page_infos'] = $admin_base_url; $query = 'UPDATE ' . IMAGES_TABLE . ' SET hit= \'0\' WHERE id = '.$photoid[0].';'; $result = pwg_query($query); redirect($admin_base_url[0]); } if (isset($_GET['deleteprate'])) { $admin_base_url=explode('&deleteprate', $_SERVER['REQUEST_URI']); $photoid = explode('photo-', $_SERVER['REQUEST_URI']); if(strstr($photoid[1], '-properties')){$photoid = explode('-properties', $photoid[1]);} else if(strstr($photoid[1], '&cat')){$photoid = explode('&cat', $photoid[1]);} else{ $_SESSION['page_infos'] = array('error'); redirect($_SERVER['REQUEST_URI']); } $query = 'UPDATE ' . IMAGES_TABLE . ' SET rating_score = NULL WHERE id = '.$photoid[0].';'; $result = pwg_query($query); $query = 'DELETE FROM ' . RATE_TABLE . ' WHERE element_id = '.$photoid[0].';'; $result = pwg_query($query); redirect($admin_base_url[0]); } } //add prefiltre album add_event_handler('loc_end_cat_modify', 'plugdphrAf'); add_event_handler('loc_end_cat_modify', 'plugdphrAf2'); function plugdphrAf() { global $template; $admin_base_url = $_SERVER['REQUEST_URI']; $template->set_prefilter('album_properties', 'plugdphrAT'); $template->assign( array( 'U_DELETEAHIT' => $admin_base_url . '&deleteahit', 'U_DELETEARATE' => $admin_base_url . '&deletearate', )); } function plugdphrAT($content) { load_language('plugin.lang', PDHR_PATH); $search = '#

#'; $replacement = '
'; return preg_replace($search, $replacement, $content); } function plugdphrAf2() { $admin_base_url = $_SERVER['REQUEST_URI']; if (isset($_GET['deleteahit'])) { $admin_base_url=explode('&deleteahit', $_SERVER['REQUEST_URI']); $albumid = explode('album-', $_SERVER['REQUEST_URI']); if(strstr($albumid[1], '-properties')){ $albumid = explode('-properties', $albumid[1]); $albumid = $albumid[0]; } else if(strstr($albumid[1], '&deleteahit')){ $albumid = explode('&deleteahit', $albumid[1]); $albumid = $albumid[0]; } else{ $_SESSION['page_infos'] = array('error'); redirect($_SERVER['REQUEST_URI']); } $query = 'select image_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = '.$albumid.';'; $result = pwg_query($query); $delval = array(); while($row = pwg_db_fetch_assoc($result)) { array_push($delval, $row['image_id']); } foreach ($delval as $delrate) { $query = 'UPDATE ' . IMAGES_TABLE . ' SET hit= \'0\' WHERE id = \''.$delrate.'\';'; $result = pwg_query($query); } redirect($admin_base_url[0]); } if (isset($_GET['deletearate'])) { $admin_base_url=explode('&deletearate', $_SERVER['REQUEST_URI']); $albumid = explode('album-', $_SERVER['REQUEST_URI']); if(strstr($albumid[1], '-properties')){ $albumid = explode('-properties', $albumid[1]); $albumid = $albumid[0]; } else if(strstr($albumid[1], '&deletearate')){ $albumid = explode('&deletearate', $albumid[1]); $albumid = $albumid[0]; } else{ $_SESSION['page_infos'] = array('error'); redirect($_SERVER['REQUEST_URI']); } $query = 'select image_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE category_id = '.$albumid.';'; $result = pwg_query($query); $delval = array(); while($row = pwg_db_fetch_assoc($result)) { array_push($delval, $row['image_id']); } foreach ($delval as $delrate) { $query = 'UPDATE ' . IMAGES_TABLE . ' SET rating_score = NULL WHERE id = \''.$delrate.'\';'; $result = pwg_query($query); $query = 'DELETE FROM ' . RATE_TABLE . ' WHERE element_id = \''.$delrate.'\';'; $result = pwg_query($query); } redirect($admin_base_url[0]); } } //add prefiltre maintenance add_event_handler('loc_begin_admin_page', 'plugdphrPa'); function plugdphrPa() { global $template; $admin_base_url = $_SERVER['REQUEST_URI']; $template->set_prefilter('maintenance', 'plugdphrPaT'); $template->assign( array( 'U_DELETEHIT' => $admin_base_url . '&deletehit', 'U_DELETERATE' => $admin_base_url . '&deleterate', )); } function plugdphrPaT($content){ $search = '{\'Purge search history\'|@translate}'; $replacement = '{\'Purge all hits on all pictures gallery\'|@translate} {\'Purge all rate on all pictures gallery\'|@translate}'; return str_replace($search, $search.$replacement, $content); } add_event_handler('loc_begin_admin_page', 'plugdphrPa5'); function plugdphrPa5(){ global $template; $template->set_prefilter('maintenance', 'plugdphrPaT5'); } function plugdphrPaT5($content){ $search = '{/footer_script}'; $replacement = ' $(".purge-search-hits").each(function() { const title = \'{"Purge all hits on all pictures gallery"|@translate|@escape:\'javascript\'}\'; $(this).pwg_jconfirm_follow_href({ alert_title: title, alert_confirm: confirm_msg, alert_cancel: cancel_msg }); }); $(".purge-search-rates").each(function() { const title = \'{"Purge all rate on all pictures gallery"|@translate|@escape:\'javascript\'}\'; $(this).pwg_jconfirm_follow_href({ alert_title: title, alert_confirm: confirm_msg, alert_cancel: cancel_msg }); }); '; return str_replace($search, $replacement.$search, $content); } add_event_handler('loc_begin_admin_page', 'plugdphrPaA'); function plugdphrPaA(){ $admin_base_url = $_SERVER['REQUEST_URI']; if (isset($_GET['deletehit'])){ $query = 'UPDATE ' . IMAGES_TABLE . ' SET hit= \'0\';'; pwg_query($query); $_SESSION['page_infos'] = array(l10n('Hit purge completed successfully')); redirect(get_root_url().'admin.php?page=maintenance'); } if (isset($_GET['deleterate'])){ $query = 'UPDATE ' . IMAGES_TABLE . ' SET rating_score=NULL ;'; $result = pwg_query($query); $query = 'TRUNCATE ' . RATE_TABLE . ';'; $result = pwg_query($query); pwg_query($query); $_SESSION['page_infos'] = array(l10n('Rate purge completed successfully')); redirect(get_root_url().'admin.php?page=maintenance'); } } ?>