public static function copyResource($strSource, $strDestination)
	{
		$objDatabase = Database::getInstance();
		$objFile = FilesModel::findByPath($strSource);

		// Add the source entry
		if ($objFile === null)
		{
			$objFile = static::addResource($strSource);
		}

		$strFolder = \dirname($strDestination);

		/** @var FilesModel $objNewFile */
		$objNewFile = clone $objFile->current();

		// Set the new parent ID
		if ($strFolder == Config::get('uploadPath'))
		{
			$objNewFile->pid = null;
		}
		else
		{
			$objFolder = FilesModel::findByPath($strFolder);

			if ($objFolder === null)
			{
				$objFolder = static::addResource($strFolder);
			}

			$objNewFile->pid = $objFolder->uuid;
		}

		// Save the resource
		$objNewFile->tstamp = time();
		$objNewFile->uuid   = $objDatabase->getUuid();
		$objNewFile->path   = $strDestination;
		$objNewFile->name   = basename($strDestination);
		$objNewFile->save();

		// Update all child records
		if ($objFile->type == 'folder')
		{
			$objFiles = FilesModel::findMultipleByBasepath($strSource . '/');

			if ($objFiles !== null)
			{
				while ($objFiles->next())
				{
					/** @var FilesModel $objNew */
					$objNew = clone $objFiles->current();

					$objNew->pid    = $objNewFile->uuid;
					$objNew->tstamp = time();
					$objNew->uuid   = $objDatabase->getUuid();
					$objNew->path   = str_replace($strSource . '/', $strDestination . '/', $objFiles->path);
					$objNew->save();
				}
			}
		}

		// Update the MD5 hash of the parent folders
		if (($strPath = \dirname($strSource)) != Config::get('uploadPath'))
		{
			static::updateFolderHashes($strPath);
		}
		if (($strPath = \dirname($strDestination)) != Config::get('uploadPath'))
		{
			static::updateFolderHashes($strPath);
		}

		return $objNewFile;
	}
public static function copyResource($strSource, $strDestination)
	{
		$objDatabase = Database::getInstance();
		$objFile = FilesModel::findByPath($strSource);

		// Add the source entry
		if ($objFile === null)
		{
			$objFile = static::addResource($strSource);
		}

		$strFolder = \dirname($strDestination);

		/** @var FilesModel $objNewFile */
		$objNewFile = clone $objFile->current();

		// Set the new parent ID
		if ($strFolder == Config::get('uploadPath'))
		{
			$objNewFile->pid = null;
		}
		else
		{
			$objFolder = FilesModel::findByPath($strFolder);

			if ($objFolder === null)
			{
				$objFolder = static::addResource($strFolder);
			}

			$objNewFile->pid = $objFolder->uuid;
		}

		// Save the resource
		$objNewFile->tstamp = time();
		$objNewFile->uuid   = $objDatabase->getUuid();
		$objNewFile->path   = $strDestination;
		$objNewFile->name   = basename($strDestination);
		$objNewFile->save();

		// Update all child records
		if ($objFile->type == 'folder')
		{
			$objFiles = FilesModel::findMultipleByBasepath($strSource . '/');

			if ($objFiles !== null)
			{
				while ($objFiles->next())
				{
					/** @var FilesModel $objNew */
					$objNew = clone $objFiles->current();

					$objNew->pid    = $objNewFile->uuid;
					$objNew->tstamp = time();
					$objNew->uuid   = $objDatabase->getUuid();
					$objNew->path   = str_replace($strSource . '/', $strDestination . '/', $objFiles->path);
					$objNew->save();
				}
			}
		}

		// Update the MD5 hash of the parent folders
		if (($strPath = \dirname($strSource)) != Config::get('uploadPath'))
		{
			static::updateFolderHashes($strPath);
		}
		if (($strPath = \dirname($strDestination)) != Config::get('uploadPath'))
		{
			static::updateFolderHashes($strPath);
		}

		return $objNewFile;
	}
public static function copyResource ( $ strSource , $ strDestination ) { $ objDatabase = Database :: getInstance ( ) ; $ objFile = FilesModel :: findByPath ( $ strSource ) ; // Add the source entry if ( $ objFile === null ) { $ objFile = static :: addResource ( $ strSource ) ; } $ strFolder = \ dirname ( $ strDestination ) ; /** @var FilesModel $objNewFile */ $ objNewFile = clone $ objFile -> current ( ) ; // Set the new parent ID if ( $ strFolder == Config :: get ( 'uploadPath' ) ) { $ objNewFile -> pid = null ; } else { $ objFolder = FilesModel :: findByPath ( $ strFolder ) ; if ( $ objFolder === null ) { $ objFolder = static :: addResource ( $ strFolder ) ; } $ objNewFile -> pid = $ objFolder -> uuid ; } // Save the resource $ objNewFile -> tstamp = time ( ) ; $ objNewFile -> uuid = $ objDatabase -> getUuid ( ) ; $ objNewFile -> path = $ strDestination ; $ objNewFile -> name = basename ( $ strDestination ) ; $ objNewFile -> save ( ) ; // Update all child records if ( $ objFile -> type == 'folder' ) { $ objFiles = FilesModel :: findMultipleByBasepath ( $ strSource . '/' ) ; if ( $ objFiles !== null ) { while ( $ objFiles -> next ( ) ) { /** @var FilesModel $objNew */ $ objNew = clone $ objFiles -> current ( ) ; $ objNew -> pid = $ objNewFile -> uuid ; $ objNew -> tstamp = time ( ) ; $ objNew -> uuid = $ objDatabase -> getUuid ( ) ; $ objNew -> path = str_replace ( $ strSource . '/' , $ strDestination . '/' , $ objFiles -> path ) ; $ objNew -> save ( ) ; } } } // Update the MD5 hash of the parent folders if ( ( $ strPath = \ dirname ( $ strSource ) ) != Config :: get ( 'uploadPath' ) ) { static :: updateFolderHashes ( $ strPath ) ; } if ( ( $ strPath = \ dirname ( $ strDestination ) ) != Config :: get ( 'uploadPath' ) ) { static :: updateFolderHashes ( $ strPath ) ; } return $ objNewFile ; }
Copies a file or folder to a new location

@param string $strSource      The source path
@param string $strDestination The target path

@return FilesModel The files model
Copies a file or folder to a new location