Changeset 21802 for trunk/include/category_cats.inc.php
- Timestamp:
- Mar 23, 2013, 11:50:57 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/category_cats.inc.php
r20177 r21802 47 47 { 48 48 $query.= ' 49 WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);49 WHERE '.get_recent_photos_sql('date_last'); 50 50 } 51 51 else … … 67 67 } 68 68 69 $query.= '70 ;';71 72 69 $result = pwg_query($query); 73 70 $categories = array(); … … 84 81 $image_id = $row['user_representative_picture_id']; 85 82 } 86 else 83 elseif (!empty($row['representative_picture_id'])) 87 84 { // if a representative picture is set, it has priority 88 85 $image_id = $row['representative_picture_id']; 89 86 } 90 else if ($conf['allow_random_representative']) 91 { 92 // searching a random representant among elements in sub-categories 87 elseif ($conf['allow_random_representative']) 88 { // searching a random representant among elements in sub-categories 93 89 $image_id = get_random_image_in_category($row); 94 90 } 95 else 91 elseif ($row['count_categories']>0 and $row['count_images']>0) 96 92 { // searching a random representant among representant of sub-categories 97 if ($row['count_categories']>0 and $row['count_images']>0) 98 { 99 $query = ' 100 SELECT representative_picture_id 101 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 102 ON id = cat_id and user_id = '.$user['id'].' 103 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 104 AND representative_picture_id IS NOT NULL' 105 .get_sql_condition_FandF 106 ( 107 array 108 ( 109 'visible_categories' => 'id', 110 ), 111 "\n AND" 112 ).' 113 ORDER BY '.DB_RANDOM_FUNCTION.'() 114 LIMIT 1 115 ;'; 116 $subresult = pwg_query($query); 117 if (pwg_db_num_rows($subresult) > 0) 118 { 119 list($image_id) = pwg_db_fetch_row($subresult); 120 } 121 } 122 } 93 $query = ' 94 SELECT representative_picture_id 95 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' 96 ON id = cat_id and user_id = '.$user['id'].' 97 WHERE uppercats LIKE \''.$row['uppercats'].',%\' 98 AND representative_picture_id IS NOT NULL' 99 .get_sql_condition_FandF 100 ( 101 array 102 ( 103 'visible_categories' => 'id', 104 ), 105 "\n AND" 106 ).' 107 ORDER BY '.DB_RANDOM_FUNCTION.'() 108 LIMIT 1 109 ;'; 110 $subresult = pwg_query($query); 111 if (pwg_db_num_rows($subresult) > 0) 112 { 113 list($image_id) = pwg_db_fetch_row($subresult); 114 } 115 } 116 123 117 124 118 if (isset($image_id)) … … 130 124 131 125 $row['representative_picture_id'] = $image_id; 132 array_push($image_ids, $image_id);133 array_push($categories, $row);134 array_push($category_ids, $row['id']);126 $image_ids[] = $image_id; 127 $categories[] = $row; 128 $category_ids[] = $row['id']; 135 129 } 136 130 unset($image_id);
Note: See TracChangeset
for help on using the changeset viewer.