コード例 #1
0
ファイル: addmedia.php プロジェクト: pal-saugstad/webtrees
     break;
 }
 $messages = false;
 $move_file = false;
 // Move files on disk (if we can) to reflect the change to the GEDCOM data
 if (!$media->isExternal()) {
     $oldServerFile = $media->getServerFilename('main');
     $oldServerThumb = $media->getServerFilename('thumb');
     $newmedia = new Media("xxx", "0 @xxx@ OBJE\n1 FILE " . $newFilename, null, $WT_TREE);
     $newServerFile = $newmedia->getServerFilename('main');
     $newServerThumb = $newmedia->getServerFilename('thumb');
     // We could be either renaming an existing file, or updating a record (with no valid file) to point to a new file
     if ($oldServerFile !== $newServerFile) {
         //-- check if the file is used in more than one gedcom
         //-- do not allow it to be moved or renamed if it is
         if (!$media->isExternal() && FunctionsDb::isMediaUsedInOtherTree($media->getFilename(), $WT_TREE->getTreeId())) {
             FlashMessages::addMessage(I18N::translate('This file is linked to another family tree on this server. It cannot be deleted, moved, or renamed until these links have been removed.'));
             break;
         }
         $move_file = true;
         if (!file_exists($newServerFile) || md5_file($oldServerFile) === md5_file($newServerFile)) {
             try {
                 rename($oldServerFile, $newServerFile);
                 FlashMessages::addMessage(I18N::translate('The media file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
             } catch (\ErrorException $ex) {
                 FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
             }
             $messages = true;
         }
         if (!file_exists($newServerFile)) {
             FlashMessages::addMessage(I18N::translate('The media file %s does not exist.', Html::filename($newFilename)));