| 182 | | // we have to change the level. |
| 183 | | // |
| 184 | | // the level must equal the minimum level between : |
| 185 | | // * the privacy level of the uploader |
| 186 | | // * the minimum level for photos in the same album |
| 187 | | $category_min_level = null; |
| 188 | | |
| 189 | | $query = ' |
| 190 | | SELECT |
| 191 | | image_id, |
| 192 | | level |
| 193 | | FROM '.IMAGE_CATEGORY_TABLE.' AS ic |
| 194 | | JOIN '.IMAGES_TABLE.' AS i ON ic.image_id = i.id |
| 195 | | WHERE category_id = '.$category_id.' |
| 196 | | ;'; |
| 197 | | $result = pwg_query($query); |
| 198 | | while ($row = pwg_db_fetch_assoc($result)) |
| 199 | | { |
| 200 | | if (in_array($row['image_id'], $image_ids)) |
| 201 | | { |
| 202 | | continue; |
| 203 | | } |
| 204 | | |
| 205 | | if (!isset($category_min_level)) |
| 206 | | { |
| 207 | | $category_min_level = $row['level']; |
| 208 | | } |
| 209 | | |
| 210 | | if ($row['level'] < $category_min_level) |
| 211 | | { |
| 212 | | $category_min_level = $row['level']; |
| 213 | | } |
| 214 | | } |
| 215 | | |
| 216 | | if (!isset($category_min_level)) |
| 217 | | { |
| 218 | | $category_min_level = 0; |
| 219 | | } |
| 220 | | |
| 221 | | $level = min($category_min_level, $user['level']); |
| 222 | | |
| | 182 | // the level of a user upload photo with no moderation is 0 |