Show
Ignore:
Timestamp:
07/09/08 13:00:01 (4 months ago)
Author:
sidtheduck
Message:

+ Fix for ticket #177 - Deleting albums and collections
+ Fixed errors in "Air" theme comments.php and slideshow.php

Files:
1 modified

Legend:

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

    r555 r556  
    454454        if (!$collection) { 
    455455                return array('errors' => plog_tr('No such collection')); 
    456         }; 
     456        } 
    457457 
    458458        // first delete all albums registered with this album 
     
    461461        while ($row = mysql_fetch_assoc($result)) { 
    462462                delete_album($row['id']); 
    463         }; 
     463        } 
    464464 
    465465        // XXX: un-register collection 
     
    473473 
    474474        $collection_directory = realpath($config['basedir'] . 'plog-content/images/'.$source_collection_name); 
    475         $relative_path = substr($collection_directory,0,strlen($config['basedir'])); 
    476         $collection_path = explode('/',substr($collection_directory,strlen($config['basedir']))); 
    477         // it needs to have 2 parts - images and collection name, if it doesn't, then there is something 
    478         // wrong with collection name and it's probably not safe to try to delete the directory 
    479         if ($relative_path == $config['basedir'] && sizeof($collection_path) == 2) { 
     475        // check to see if the collection_directory is a real directory and then try to delete it 
     476        if (is_dir($collection_directory)){ 
    480477                @chmod($collection_directory,0777); 
    481478                $delete_result = rmdir($collection_directory); 
    482479                if (!$delete_result) { 
    483480                        return array('errors' => plog_tr('Collection directory still contains files after all albums have been deleted.')); 
    484                 }; 
     481                } 
    485482                 
    486483        } else { 
    487484                return array('errors' => plog_tr('Collection has invalid path, not deleting directory')); 
    488         }; 
     485        } 
    489486        return array(); 
    490487} 
     
    718715        if (!$album) { 
    719716                return array('errors' => plog_tr('No such album')); 
    720         }; 
     717        } 
    721718 
    722719        // first delete all pictures registered with this album 
     
    725722        while ($row = mysql_fetch_assoc($result)) { 
    726723                delete_picture($row['id']); 
    727         }; 
     724        } 
    728725 
    729726        // XXX: un-register album 
     
    738735 
    739736        $album_directory = realpath($config['basedir'] . 'plog-content/images/'.$source_collection_name."/".$source_album_name); 
    740         $relative_path = substr($album_directory,0,strlen($config['basedir'])); 
    741         $album_path = explode('/',substr($album_directory,strlen($config['basedir']))); 
    742         // it needs to have 3 parts - images, collection name and album name, if it doesn't, then there is something 
    743         // wrong with either collection or album name and it's probably not safe to try to delete the directory 
    744         if ($relative_path == $config['basedir'] && sizeof($album_path) == 3) { 
     737        // check to see if the album_directory is a real directory and then try to delete it 
     738        if (is_dir($album_directory)){ 
    745739                @chmod($album_directory,0777); 
    746740                $delete_result = rmdir($album_directory); 
    747741                if (!$delete_result) { 
    748742                        return array('errors' => plog_tr('Album directory still contains files after all pictures have been deleted.')); 
    749                 }; 
     743                } 
    750744 
    751745        } else { 
    752746                return array('errors' => plog_tr('Album has invalid path, not deleting directory')); 
    753         }; 
     747        } 
    754748        return array(); 
    755749}