1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | /* $item = array('verso_id', 'categories'); */ |
---|
5 | function back2front_restaure_categories($item) |
---|
6 | { |
---|
7 | global $conf; |
---|
8 | |
---|
9 | /* catch current verso categories */ |
---|
10 | $versos_infos = pwg_query("SELECT category_id FROM ".IMAGE_CATEGORY_TABLE." WHERE image_id = ".$item['verso_id'].";"); |
---|
11 | $item['current_verso_cats'] = array(); |
---|
12 | while (list($verso_cat) = pwg_db_fetch_row($versos_infos)) |
---|
13 | { |
---|
14 | $item['current_verso_cats'][] = $verso_cat; |
---|
15 | } |
---|
16 | |
---|
17 | /* if verso 'versos' cat only */ |
---|
18 | if (count($item['current_verso_cats']) == 1 AND $item['current_verso_cats'][0] == $conf['back2front'][0]) |
---|
19 | { |
---|
20 | foreach (explode(',',$item['categories']) as $cat) |
---|
21 | { |
---|
22 | $datas[] = array( |
---|
23 | 'image_id' => $item['verso_id'], |
---|
24 | 'category_id' => $cat, |
---|
25 | ); |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | if (isset($datas)) |
---|
30 | { |
---|
31 | mass_inserts( |
---|
32 | IMAGE_CATEGORY_TABLE, |
---|
33 | array('image_id', 'category_id'), |
---|
34 | $datas |
---|
35 | ); |
---|
36 | } |
---|
37 | |
---|
38 | pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." |
---|
39 | WHERE image_id = ".$item['verso_id']." AND category_id = ".$conf['back2front'][0].";"); |
---|
40 | } |
---|
41 | |
---|
42 | function picture_exists($id) |
---|
43 | { |
---|
44 | if (!preg_match('#([0-9]{1,})#', $id) OR $id == '0') return false; |
---|
45 | |
---|
46 | $query = "SELECT id FROM ".IMAGES_TABLE." WHERE id = ".$id.";"; |
---|
47 | $result = pwg_query($query); |
---|
48 | |
---|
49 | if (pwg_db_num_rows($result)) return true; |
---|
50 | else return false; |
---|
51 | } |
---|
52 | |
---|
53 | if (!function_exists('stripslashes_deep')) |
---|
54 | { |
---|
55 | function stripslashes_deep($value) |
---|
56 | { |
---|
57 | return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | ?> |
---|