Show
Ignore:
Timestamp:
07/15/08 13:36:59 (5 months ago)
Author:
sidtheduck
Message:

+ Fix for ticket #169 - no duplicate album names within the same collection
+ Extended the duplicate collection name verification
+ Fixed issues with move_picture to behave more like add_picture (adds a (#) at the end of the filename if duplicate filenames)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-admin/plog-upload.php

    r557 r558  
    108108                        if ($_REQUEST["destination_radio"] == "new"){ 
    109109                                // Create the new album 
    110                                 $result = add_album(mysql_real_escape_string($_REQUEST["new_album_name"]), NULL, $_REQUEST["collections_menu"]); 
    111                                 $album_id = $result["id"]; 
     110                                $result = add_album(mysql_real_escape_string($_REQUEST['new_album_name']), NULL, $_REQUEST['collections_menu']); 
     111                                if (!$result['errors']) { 
     112                                        // no errors, add uploaded image to new album 
     113                                        $album_id = $result['id']; 
     114                                } else { 
     115                                        // errors exist, let's find out what they are 
     116                                        if (isset($result['output']) && $result['output'] == "existing" && isset($result['id'])) { 
     117                                                // album already exists so try insert images into the existing album 
     118                                                // and alert the user that their "new" album is already existing 
     119                                                $album_id = $result['id']; 
     120                                                // get the collection name for display 
     121                                                $sql = "SELECT `name` FROM ".TABLE_PREFIX."collections WHERE id = ".intval($_REQUEST['collections_menu']); 
     122                                                $result = run_query($sql); 
     123                                                $row = mysql_fetch_assoc($result); 
     124                                                $output .= "\n\t" . '<p class="actions">'.sprintf(plog_tr('Album already exists. Uploading file to existing album `%s` in collection `%s`'), $_REQUEST['new_album_name'], $row['name']).'</p>' . "\n"; 
     125                                        } else { 
     126                                                // error has nothing to do with an existing album, show the returned error 
     127                                                $album_id = ''; 
     128                                                $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n"; 
     129                                        } 
     130                                } 
    112131                        } else { 
     132                                // use an existing album 
    113133                                $album_id = $_REQUEST["albums_menu"]; 
    114134                        } 
    115135 
    116                         $result = add_picture($album_id,$_FILES["userfile"]["tmp_name"],$_FILES["userfile"]["name"],$_REQUEST["caption"], $_REQUEST["description"]); 
    117                         $output .= "\n\t" . '<p class="actions">'.$result["output"].'</p>' . "\n"; 
     136                        if ($album_id){ 
     137                                $result = add_picture($album_id,$_FILES["userfile"]["tmp_name"],$_FILES["userfile"]["name"],$_REQUEST["caption"], $_REQUEST["description"]); 
     138                                if (!$result['errors']) { 
     139                                        // added uploaded image successfully 
     140                                        $output .= "\n\t" . '<p class="actions">'.$result['output'].'</p>' . "\n"; 
     141                                } else { 
     142                                        // errors adding the image, show the returned error 
     143                                        $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n"; 
     144                                } 
     145                        } 
    118146 
    119147                }