Changeset 23177 for extensions/Back2Front/include/functions.inc.php
- Timestamp:
- Jun 13, 2013, 2:01:34 PM (11 years ago)
- Location:
- extensions/Back2Front/include
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/Back2Front/include/functions.inc.php
r23167 r23177 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 /* $item = array('verso_id', 'categories'); */ 4 /* 5 * restore verso to its original categories 6 * criterias : 7 * - verso 'versos' cat only => restore verso to original categories 8 * - otherwise nothing is changed 9 * 10 * $item = array('verso_id', 'categories'); 11 */ 5 12 function back2front_restaure_categories($item) 6 13 { 7 14 global $conf; 8 15 9 16 /* 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 } 17 $query = 'SELECT DISTINCT category_id FROM '.IMAGE_CATEGORY_TABLE.' WHERE image_id = '.$item['verso_id'].';'; 18 $item['current_verso_cats'] = array_from_query($query, 'category_id'); 16 19 17 20 /* if verso 'versos' cat only */ 18 if (count($item['current_verso_cats']) == 1 AND $item['current_verso_cats'][0] == $conf['back2front'][0])21 if (count($item['current_verso_cats']) == 1 && $item['current_verso_cats'][0] == $conf['back2front']['versos_cat']) 19 22 { 20 23 foreach (explode(',',$item['categories']) as $cat) … … 36 39 } 37 40 38 pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." 39 WHERE image_id = ".$item['verso_id']." AND category_id = ".$conf['back2front'][0].";"); 41 $query = ' 42 DELETE FROM '.IMAGE_CATEGORY_TABLE.' 43 WHERE image_id = '.$item['verso_id'].' 44 AND category_id = '.$conf['back2front']['versos_cat'].' 45 ;'; 46 pwg_query($query); 47 } 48 49 function back2front_check_storage() 50 { 51 global $conf; 52 53 if ($conf['back2front']['versos_cat'] != 0) 54 { 55 $query = ' 56 SELECT COUNT(*) FROM '.CATEGORIES_TABLE.' 57 WHERE id = '.$conf['back2front']['versos_cat'].' 58 AND name = "Back2Front private album" 59 ;'; 60 $result = pwg_query($query); 61 62 if (pwg_db_num_rows($result)) 63 { 64 return; 65 } 66 } 67 68 $versos_cat = create_virtual_category('Back2Front private album'); 69 $versos_cat = array( 70 'id' => $versos_cat['id'], 71 'comment' => 'Used by Back2Front to store backsides.', 72 'status' => 'private', 73 'visible' => 'false', 74 'commentable' => 'false', 75 ); 76 77 mass_updates( 78 CATEGORIES_TABLE, 79 array( 80 'primary' => array('id'), 81 'update' => array_diff(array_keys($versos_cat), array('id')) 82 ), 83 array($versos_cat) 84 ); 85 86 $conf['back2front']['versos_cat'] = $versos_cat['id']; 87 conf_update_param('back2front', serialize($conf['back2front'])); 40 88 } 41 89 42 90 function picture_exists($id) 43 91 { 44 if (!preg_match('#([0-9]{1,})#', $id) OR$id == '0') return false;92 if (!preg_match('#([0-9]{1,})#', $id) || $id == '0') return false; 45 93 46 94 $query = "SELECT id FROM ".IMAGES_TABLE." WHERE id = ".$id.";";
Note: See TracChangeset
for help on using the changeset viewer.