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-import.php

    r555 r558  
    4747//print_r($_POST); 
    4848 
    49 if (isset($_POST['upload'])){ 
     49if (isset($_POST['upload'])) { 
    5050 
    5151        $destinations = isset($_POST['destinations']) ? $_POST['destinations'] : ''; 
     
    5959        $files = get_files($config['basedir'] . 'plog-content/uploads'); 
    6060 
    61         if ($_POST['destination_radio'] == "new" && $_POST["new_album_name"] == ""){ 
     61        if ($_POST['destination_radio'] == "new" && $_POST["new_album_name"] == "") { 
    6262                $output .= "\n\t" . '<p class="errors">' . plog_tr('New album name not specified!') . '</p>' . "\n"; 
    63         } 
    64         else { 
     63        } else { 
    6564 
    6665                if ($_POST["destination_radio"] == "new"){ 
    6766                        // Create the new album 
    68                         $result = add_album($_POST["new_album_name"], NULL, $_POST["collections_menu"]); 
    69                         $album_id = $result["id"]; 
    70                 } 
    71                 else 
    72                 { 
     67                        $result = add_album($_POST['new_album_name'], NULL, $_POST['collections_menu']); 
     68                        if (!$result['errors']) { 
     69                                // no errors, add images to new album 
     70                                $album_id = $result['id']; 
     71                        } else { 
     72                                // errors exist, let's find out what they are 
     73                                if (isset($result['output']) && $result['output'] == "existing" && isset($result['id'])) { 
     74                                        // album already exists so try insert images into the existing album 
     75                                        // and alert the user that their "new" album is already existing 
     76                                        $album_id = $result['id']; 
     77                                        // get the collection name for display 
     78                                        $sql = "SELECT `name` FROM ".TABLE_PREFIX."collections WHERE id = ".intval($_REQUEST['collections_menu']); 
     79                                        $result = run_query($sql); 
     80                                        $row = mysql_fetch_assoc($result); 
     81                                        $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"; 
     82                                } else { 
     83                                        // error has nothing to do with an existing album, show the returned error 
     84                                        $album_id = ''; 
     85                                        $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n"; 
     86                                } 
     87                        } 
     88                } else { 
     89                        // use an existing album 
    7390                        $album_id = $_POST["destination"]; 
    7491                } 
     
    93110                                                        // delete thumbnail file if it exists 
    94111                                                        $thumbpath = $config['basedir'] . 'plog-content/thumbs/import-'.substr($file_key,0,2).'-'.basename($file_name); 
    95                                                         if (is_file($thumbpath) && is_readable($thumbpath)) 
    96                                                         { 
     112                                                        if (is_file($thumbpath) && is_readable($thumbpath)) { 
    97113                                                                unlink($thumbpath); 
    98                                                         }; 
    99                                                 }; 
     114                                                        } 
     115                                                } 
    100116                                        } 
    101117 
    102118                                        $counter++; 
    103                                 }; 
     119                                } 
    104120 
    105121                        } 
     
    108124                        $sql = "SELECT name FROM ".TABLE_PREFIX."albums WHERE id = $album_id"; 
    109125                        $result = run_query($sql); 
    110  
    111126                        $row = mysql_fetch_assoc($result); 
    112127 
    113128                        $output .= "\n\t" . '<p class="actions">'.sprintf(plog_tr('%d picture(s) were successfully imported to album <strong>%s</strong>'),$imported,$row['name']). '</p>' . "\n"; 
    114129 
    115                         if ($imported == 0) 
    116                         $output .= "\n\t" . '<p class="errors">' . plog_tr('Make sure to CHMOD 777 your newly created folders within the \'plog-content/uploads/\' directory or else Plogger cannot access them. Plogger cannot CHMOD the directory for you while PHP is in safe mode.') . '</p>' . "\n"; 
    117                 } 
    118                 else 
    119                 $output .= "\n\t" . '<p class="errors">'.$result['output'].'</p>' . "\n"; 
    120  
     130                        if ($imported == 0) { 
     131                                $output .= "\n\t" . '<p class="errors">' . plog_tr('Make sure to CHMOD 777 your newly created folders within the \'plog-content/uploads/\' directory or else Plogger cannot access them. Plogger cannot CHMOD the directory for you while PHP is in safe mode.') . '</p>' . "\n"; 
     132                        } 
     133                        /* what is this for? 
     134                        else { 
     135                                $output .= "\n\t" . '<p class="errors">'.$result['output'].'</p>' . "\n"; 
     136                        }*/ 
     137                } 
    121138        } 
    122139