Changeset 21802
- Timestamp:
- Mar 23, 2013, 11:50:57 AM (11 years ago)
- Location:
- trunk/include
- Files:
-
- 3 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); -
trunk/include/functions_user.inc.php
r21801 r21802 827 827 { 828 828 $cache['default_user'] = pwg_db_fetch_assoc($result); 829 829 830 830 unset($cache['default_user']['user_id']); 831 831 unset($cache['default_user']['status']); … … 1126 1126 { 1127 1127 require_once(PHPWG_ROOT_PATH.'include/passwordhash.class.php'); 1128 1128 1129 1129 // We use the portable hash feature from phpass because we can't be sure 1130 1130 // Piwigo runs on PHP 5.3+ (and won't run on an older version in the … … 1132 1132 $pwg_hasher = new PasswordHash(13, true); 1133 1133 } 1134 1134 1135 1135 return $pwg_hasher->HashPassword($password); 1136 1136 } … … 1161 1161 $check = ($hash == md5($password)); 1162 1162 } 1163 1163 1164 1164 if ($check and isset($user_id) and !$conf['external_authentification']) 1165 1165 { … … 1180 1180 { 1181 1181 require_once(PHPWG_ROOT_PATH.'include/passwordhash.class.php'); 1182 1182 1183 1183 // We use the portable hash feature 1184 1184 $pwg_hasher = new PasswordHash(13, true); … … 1201 1201 function pwg_login($success, $username, $password, $remember_me) 1202 1202 { 1203 if ($success===true) 1203 if ($success===true) 1204 1204 { 1205 1205 return true; 1206 1206 } 1207 1207 1208 1208 // we force the session table to be clean 1209 1209 pwg_session_gc(); … … 1232 1232 { 1233 1233 global $conf; 1234 1234 1235 1235 trigger_action('user_logout', @$_SESSION['pwg_uid']); 1236 1236 1237 1237 $_SESSION = array(); 1238 1238 session_unset(); … … 1555 1555 } 1556 1556 1557 /** @return the sql condition to show recent photos/albums based on user preferences and latest available photo.*/ 1558 function get_recent_photos_sql($db_field) 1559 { 1560 global $user; 1561 if (!isset($user['last_photo_date'])) 1562 { 1563 return '0=1'; 1564 } 1565 return $db_field.'>=LEAST(' 1566 .pwg_db_get_recent_period_expression($user['recent_period']) 1567 .','.pwg_db_get_recent_period_expression(1,$user['last_photo_date']).')'; 1568 } 1569 1557 1570 /** 1558 1571 * search an available activation_key -
trunk/include/section_init.inc.php
r20453 r21802 453 453 FROM '.IMAGES_TABLE.' 454 454 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 455 WHERE 456 date_available >= '.pwg_db_get_recent_period_expression($user['recent_period']).'457 '.$forbidden.'458 '.$conf['order_by'].'455 WHERE ' 456 .get_recent_photos_sql('date_available').' 457 '.$forbidden 458 .$conf['order_by'].' 459 459 ;'; 460 460
Note: See TracChangeset
for help on using the changeset viewer.