[9796] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | define('PDHR_DIR' , basename(dirname(__FILE__))); |
---|
| 5 | define('PDHR_PATH' , PHPWG_PLUGINS_PATH . PDHR_DIR . '/'); |
---|
| 6 | load_language('plugin.lang', PDHR_PATH); |
---|
| 7 | |
---|
| 8 | add_event_handler('get_admin_plugin_menu_links', 'dphr_admin_menu'); |
---|
| 9 | function dphr_admin_menu($menu) |
---|
| 10 | { |
---|
| 11 | array_push($menu, array( |
---|
| 12 | 'NAME' => 'Delete Hit Rate', |
---|
| 13 | 'URL' => get_admin_plugin_menu_link(PDHR_PATH . 'admin/admin.php'))); |
---|
| 14 | return $menu; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | //add prefiltre photo |
---|
| 19 | add_event_handler('loc_begin_admin', 'plugdphrPf',60); |
---|
[16548] | 20 | add_event_handler('loc_begin_admin_page', 'plugdphrPf2',60); |
---|
[9796] | 21 | |
---|
| 22 | function plugdphrPf() |
---|
| 23 | { |
---|
| 24 | global $template; |
---|
| 25 | $template->set_prefilter('picture_modify', 'plugdphrPT'); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | function plugdphrPT($content, &$smarty) |
---|
| 29 | { |
---|
| 30 | load_language('plugin.lang', PDHR_PATH); |
---|
[16548] | 31 | $search = '#</form>#'; |
---|
[9796] | 32 | |
---|
| 33 | $replacement = ' |
---|
| 34 | <div> |
---|
| 35 | <form method="post" > |
---|
| 36 | <fieldset> |
---|
[12999] | 37 | <legend>{\'Purge - Plugin Delete Hit/Rate\'|@translate}</legend> |
---|
[9796] | 38 | <div style="text-align:center;"> |
---|
[12999] | 39 | <input class="submit" name="plugdphphoto" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge hit of the photo\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
| 40 | <input class="submit" name="plugdprphoto" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge rate of the photo\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
[9796] | 41 | </div> |
---|
| 42 | </fieldset> |
---|
| 43 | </form> |
---|
| 44 | </div> |
---|
[16548] | 45 | </form>'; |
---|
[9796] | 46 | |
---|
| 47 | return preg_replace($search, $replacement, $content); |
---|
| 48 | } |
---|
[16548] | 49 | |
---|
| 50 | function plugdphrPf2() |
---|
| 51 | { |
---|
[9796] | 52 | if (isset($_POST['plugdphphoto'])) |
---|
| 53 | { |
---|
| 54 | $query = ' |
---|
| 55 | UPDATE ' . IMAGES_TABLE . ' |
---|
| 56 | SET hit= \'0\' |
---|
| 57 | WHERE id = '.$_GET['image_id'].' |
---|
| 58 | ;'; |
---|
| 59 | $result = pwg_query($query); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if (isset($_POST['plugdprphoto'])) |
---|
| 63 | { |
---|
| 64 | $query = ' |
---|
| 65 | UPDATE ' . IMAGES_TABLE . ' |
---|
[12402] | 66 | SET rating_score = \'NULL\' |
---|
[9796] | 67 | WHERE id = '.$_GET['image_id'].' |
---|
| 68 | ;'; |
---|
| 69 | $result = pwg_query($query); |
---|
| 70 | |
---|
| 71 | $query = ' |
---|
| 72 | DELETE FROM ' . RATE_TABLE . ' |
---|
| 73 | WHERE element_id = '.$_GET['image_id'].' |
---|
| 74 | ;'; |
---|
| 75 | $result = pwg_query($query); |
---|
| 76 | } |
---|
[16548] | 77 | } |
---|
[9796] | 78 | |
---|
| 79 | //add prefiltre album |
---|
| 80 | add_event_handler('loc_end_cat_modify', 'plugdphrAf'); |
---|
[16548] | 81 | add_event_handler('loc_end_cat_modify', 'plugdphrAf2'); |
---|
[9796] | 82 | |
---|
| 83 | function plugdphrAf() |
---|
| 84 | { |
---|
| 85 | global $template; |
---|
[16548] | 86 | $template->set_prefilter('album_properties', 'plugdphrAT'); |
---|
[9796] | 87 | } |
---|
| 88 | |
---|
| 89 | function plugdphrAT($content, &$smarty) |
---|
| 90 | { |
---|
| 91 | load_language('plugin.lang', PDHR_PATH); |
---|
[16548] | 92 | $search = '#</form>#'; |
---|
[9796] | 93 | |
---|
[16548] | 94 | $replacement = ' |
---|
[9796] | 95 | <div> |
---|
[16548] | 96 | |
---|
[9796] | 97 | <fieldset> |
---|
[12999] | 98 | <legend>{\'Purge - Plugin Delete Hit/Rate\'|@translate}</legend> |
---|
[9796] | 99 | <div style="text-align:center;"> |
---|
[12999] | 100 | <input class="submit" name="plugdphA" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge hits on all pictures album\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
| 101 | <input class="submit" name="plugdprA" type="submit" onclick="return confirm(\'{\'Are you sure?\'|@translate|@escape:\'javascript\'}\');" value="{\'Purge rates on all pictures album\'|@translate}" {$TAG_INPUT_ENABLED} /> |
---|
[9796] | 102 | </div> |
---|
| 103 | </fieldset> |
---|
[16548] | 104 | |
---|
[9796] | 105 | </div> |
---|
[16548] | 106 | </form> |
---|
[9796] | 107 | '; |
---|
| 108 | |
---|
| 109 | return preg_replace($search, $replacement, $content); |
---|
| 110 | } |
---|
| 111 | |
---|
[16548] | 112 | function plugdphrAf2() |
---|
| 113 | { |
---|
[9796] | 114 | if (isset($_POST['plugdphA'])) |
---|
| 115 | { |
---|
| 116 | $query = ' |
---|
| 117 | select image_id |
---|
| 118 | FROM ' . IMAGE_CATEGORY_TABLE . ' |
---|
| 119 | WHERE category_id = '.$_GET['cat_id'].' |
---|
| 120 | ;'; |
---|
| 121 | $result = pwg_query($query); |
---|
| 122 | |
---|
| 123 | $delval = array(); |
---|
[21160] | 124 | while($row = pwg_db_fetch_assoc($result)) |
---|
[9796] | 125 | { |
---|
| 126 | array_push($delval, $row['image_id']); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | foreach ($delval as $delrate) |
---|
| 130 | { |
---|
| 131 | $query = ' |
---|
| 132 | UPDATE ' . IMAGES_TABLE . ' |
---|
| 133 | SET hit= \'0\' |
---|
| 134 | WHERE id = \''.$delrate.'\' |
---|
| 135 | ;'; |
---|
| 136 | $result = pwg_query($query); |
---|
| 137 | } |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | if (isset($_POST['plugdprA'])) |
---|
| 141 | { |
---|
| 142 | $query = ' |
---|
| 143 | select image_id |
---|
| 144 | FROM ' . IMAGE_CATEGORY_TABLE . ' |
---|
| 145 | WHERE category_id = '.$_GET['cat_id'].' |
---|
| 146 | ;'; |
---|
| 147 | $result = pwg_query($query); |
---|
| 148 | |
---|
| 149 | $delval = array(); |
---|
[21160] | 150 | while($row = pwg_db_fetch_assoc($result)) |
---|
[9796] | 151 | { |
---|
| 152 | array_push($delval, $row['image_id']); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | foreach ($delval as $delrate) |
---|
| 156 | { |
---|
| 157 | $query = ' |
---|
| 158 | UPDATE ' . IMAGES_TABLE . ' |
---|
[12402] | 159 | SET rating_score = \'NULL\' |
---|
[9796] | 160 | WHERE id = \''.$delrate.'\' |
---|
| 161 | ;'; |
---|
| 162 | $result = pwg_query($query); |
---|
| 163 | |
---|
| 164 | $query = ' |
---|
| 165 | DELETE FROM ' . RATE_TABLE . ' |
---|
| 166 | WHERE element_id = \''.$delrate.'\' |
---|
| 167 | ;'; |
---|
| 168 | $result = pwg_query($query); |
---|
| 169 | } |
---|
| 170 | } |
---|
[16548] | 171 | } |
---|
[9796] | 172 | ?> |
---|