Esempio n. 1
0
 /**
  * Copy user directory for uploading files
  * 
  * @param string $username 
  * @return bool 
  */
 static function copyUsersUploadDir()
 {
     $config = Zend_Registry::get('config');
     $patchSource = $config['paths']['backup']['dir'] . '/upload';
     $patchSource = Default_Plugin_PathBox::normalize($patchSource);
     $patchDest = APPLICATION_PUBLIC . '/upload';
     $patchDest = Default_Plugin_PathBox::normalize($patchDest);
     //-------------------------
     if (!is_dir($patchDest)) {
         if (!mkdir($patchDest)) {
             throw new Exception("Failed to create folders...'{$patchDest}'.");
         }
         if (is_dir($patchSource)) {
             // Get the FileTree object
             $ft = new Default_Plugin_FileTree($patchSource);
             // Create tree of files
             $ft->readTree();
             // Copy the current fileset to another location
             if ($ft->writeTo($patchDest) === FALSE) {
                 throw new Exception("Could not be copied '{$patchSource}' to '{$patchDest}'.");
             } else {
                 $ft->delFiles();
                 // Delete this source
             }
         } else {
             throw new Exception("There is no this dir '{$patchSource}'.");
         }
     }
 }