/[drupal]/contributions/modules/filefield_paths/filefield_paths.module
ViewVC logotype

Diff of /contributions/modules/filefield_paths/filefield_paths.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.19.2.16, Sun Apr 19 22:49:05 2009 UTC revision 1.19.2.17, Fri May 1 03:53:58 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: filefield_paths.module,v 1.19.2.15 2009/04/17 03:53:22 deciphered Exp $  // $Id: filefield_paths.module,v 1.19.2.16 2009/04/19 22:49:05 deciphered Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 457  function filefield_paths_nodeapi(&$node, Line 457  function filefield_paths_nodeapi(&$node,
457    
458        // Cleanup temporary paths        // Cleanup temporary paths
459        if ($ffp['#settings']) {        if ($ffp['#settings']) {
460          foreach ($ffp['#settings'] as $field) {          foreach ($ffp['#settings'] as $name => $field) {
461            $paths = explode('/', $field['filepath']['value']);            $paths = explode('/', $field['filepath']['value']);
462              filefield_paths_cleanup_temp($paths);
463    
464            while ($paths) {            // Check for ImageFields
465              if (@rmdir(file_directory_path() .'/'. implode('/', $paths)) === TRUE) {            $imagefield = FALSE;
466                array_pop($paths);            foreach ($ffp['#files'] as $file) {
467                continue;              if ($file['name'] == $name) {
468                  if ($file['widget'] == 'imagefield') {
469                    $imagefield = TRUE;
470                  }
471                  break;
472              }              }
473              break;            }
474              // Cleanup ImageFields temporary thumbnail paths
475              if ($imagefield) {
476                array_unshift($paths, 'imagefield_thumbs');
477                filefield_paths_cleanup_temp($paths);
478            }            }
479          }          }
480        }        }
# Line 474  function filefield_paths_nodeapi(&$node, Line 483  function filefield_paths_nodeapi(&$node,
483    }    }
484  }  }
485    
486    function filefield_paths_cleanup_temp($paths) {
487      while ($paths) {
488        if (@rmdir(file_directory_path() .'/'. implode('/', $paths)) === TRUE) {
489          array_pop($paths);
490          continue;
491        }
492        break;
493      }
494    }
495    
496  function filefield_paths_get_fields(&$node, $op = NULL) {  function filefield_paths_get_fields(&$node, $op = NULL) {
497    $ffp = array();    $ffp = array();
498    
# Line 583  function filefield_paths_filefield_paths Line 602  function filefield_paths_filefield_paths
602          }          }
603    
604          // Move ImageField thumbnail          // Move ImageField thumbnail
605          if ($file['widget'] == 'imagefield' &&          if ($file['widget'] == 'imagefield' && file_exists($thumbnail_source = imagefield_file_admin_thumb_path(array('filepath' => $file['filepath']['old'])))) {
606              file_exists($thumnail_source = imagefield_file_admin_thumb_path(array('filepath' => $file['filepath']['old'])))) {            file_delete($thumbnail_source);
           file_move($thumnail_source, imagefield_file_admin_thumb_path($file['field']), FILE_EXISTS_RENAME);  
607          }          }
608    
609          // Store new filename in file Array          // Store new filename in file Array

Legend:
Removed from v.1.19.2.16  
changed lines
  Added in v.1.19.2.17

  ViewVC Help
Powered by ViewVC 1.1.2