Ignore:
Timestamp:
Nov 19, 2013, 9:19:36 PM (10 years ago)
Author:
plg
Message:

feature 3001: new link "add photos" on album edition page. Patch by msakik

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/photos_add_direct_prepare.inc.php

    r25018 r25593  
    162162$selected_category = array();
    163163
    164 $query = '
     164if (isset($_GET['album']))
     165{
     166  // set the category from get url or ...
     167  check_input_parameter('album', $_GET, false, PATTERN_ID);
     168 
     169  // test if album really exists
     170  $query = '
     171SELECT id
     172  FROM '.CATEGORIES_TABLE.'
     173  WHERE id = '.$_GET['album'].'
     174;';
     175  $result = pwg_query($query);
     176  if (pwg_db_num_rows($result) == 1)
     177  {
     178    $selected_category = array($_GET['album']);
     179   
     180    // lets put in the session to persist in case of upload method switch
     181    $_SESSION['selected_category'] = $selected_category;
     182  }
     183  else
     184  {
     185    fatal_error('[Hacking attempt] the album id = "'.$_GET['album'].'" is not valid');
     186  }
     187}
     188else if (isset($_SESSION['selected_category']))
     189{
     190  $selected_category = $_SESSION['selected_category'];
     191}
     192else
     193{
     194  // we need to know the category in which the last photo was added
     195  $query = '
    165196SELECT category_id
    166197  FROM '.IMAGES_TABLE.' AS i
     
    169200  ORDER BY i.id DESC
    170201  LIMIT 1
    171 ;';
    172 $result = pwg_query($query);
    173 if (pwg_db_num_rows($result) > 0)
    174 {
    175   $row = pwg_db_fetch_assoc($result);
    176  
    177   $selected_category = array($row['category_id']);
     202;
     203';
     204  $result = pwg_query($query);
     205  if (pwg_db_num_rows($result) > 0)
     206  {
     207    $row = pwg_db_fetch_assoc($result);
     208    $selected_category = array($row['category_id']);
     209  }
    178210}
    179211
Note: See TracChangeset for help on using the changeset viewer.