apps/activity/lib/FilesHooks.php
/**
	 * Moving a file from one folder to another
	 *
	 * @param string $oldPath
	 * @param string $newPath
	 */
Moving a file from one folder to another
@param string $oldPath
@param string $newPath
Moving a file from one folder to another @param string $oldPath @param string $newPath
protected function fileMoving($oldPath, $newPath) {
		$dirName = dirname($newPath);
		$fileName = basename($newPath);
		$oldFileName = basename($oldPath);
		list(, , $fileId) = $this->getSourcePathAndOwner($newPath);
		list($parentPath, $parentOwner, $parentId) = $this->getSourcePathAndOwner($dirName);
		if ($fileId === 0 || $parentId === 0) {
			return;
		}
		$accessList = $this->getUserPathsFromPath($parentPath, $parentOwner);
		$affectedUsers = $accessList['users'];
		$oldUsers = $this->oldAccessList['users'];
		$beforeUsers = array_keys($oldUsers);
		$afterUsers = array_keys($affectedUsers);
		$deleteUsers = array_diff($beforeUsers, $afterUsers);
		$this->generateDeleteActivities($deleteUsers, $oldUsers, $fileId, $oldFileName);
		$addUsers = array_diff($afterUsers, $beforeUsers);
		$this->generateAddActivities($addUsers, $affectedUsers, $fileId, $fileName);
		$moveUsers = array_intersect($beforeUsers, $afterUsers);
		$this->generateMoveActivities($moveUsers, $oldUsers, $affectedUsers, $fileId, $oldFileName, $parentId, $fileName);
		$beforeRemotes = $this->oldAccessList['remotes'];
		$afterRemotes = $accessList['remotes'];
		$addRemotes = $deleteRemotes = $moveRemotes = [];
		foreach ($afterRemotes as $remote => $info) {
			if (isset($beforeRemotes[$remote])) {
				$info['node_path'] = substr($newPath, strlen($info['node_path']));
				$info['second_path'] = substr($oldPath, strlen($beforeRemotes[$remote]['node_path']));
				$moveRemotes[$remote] = $info;
			} else {
				$info['node_path'] = substr($newPath, strlen($info['node_path']));
				$addRemotes[$remote] = $info;
			}
		}
		foreach ($beforeRemotes as $remote => $info) {
			if (!isset($afterRemotes[$remote])) {
				$info['node_path'] = substr($oldPath, strlen($info['node_path']));
				$deleteRemotes[$remote] = $info;
			}
		}
		$this->generateRemoteActivity($deleteRemotes, Files::TYPE_SHARE_DELETED, time(), $this->currentUser->getCloudId());
		$this->generateRemoteActivity($addRemotes, Files::TYPE_SHARE_CREATED, time(), $this->currentUser->getCloudId());
		$this->generateRemoteActivity($moveRemotes, Files::TYPE_SHARE_CHANGED, time(), $this->currentUser->getCloudId());
	}
protected function fileMoving ( $ oldPath , $ newPath ) { $ dirName = dirname ( $ newPath ) ; $ fileName = basename ( $ newPath ) ; $ oldFileName = basename ( $ oldPath ) ; list ( , , $ fileId ) = $ this -> getSourcePathAndOwner ( $ newPath ) ; list ( $ parentPath , $ parentOwner , $ parentId ) = $ this -> getSourcePathAndOwner ( $ dirName ) ; if ( $ fileId === 0 || $ parentId === 0 ) { return ; } $ accessList = $ this -> getUserPathsFromPath ( $ parentPath , $ parentOwner ) ; $ affectedUsers = $ accessList [ 'users' ] ; $ oldUsers = $ this -> oldAccessList [ 'users' ] ; $ beforeUsers = array_keys ( $ oldUsers ) ; $ afterUsers = array_keys ( $ affectedUsers ) ; $ deleteUsers = array_diff ( $ beforeUsers , $ afterUsers ) ; $ this -> generateDeleteActivities ( $ deleteUsers , $ oldUsers , $ fileId , $ oldFileName ) ; $ addUsers = array_diff ( $ afterUsers , $ beforeUsers ) ; $ this -> generateAddActivities ( $ addUsers , $ affectedUsers , $ fileId , $ fileName ) ; $ moveUsers = array_intersect ( $ beforeUsers , $ afterUsers ) ; $ this -> generateMoveActivities ( $ moveUsers , $ oldUsers , $ affectedUsers , $ fileId , $ oldFileName , $ parentId , $ fileName ) ; $ beforeRemotes = $ this -> oldAccessList [ 'remotes' ] ; $ afterRemotes = $ accessList [ 'remotes' ] ; $ addRemotes = $ deleteRemotes = $ moveRemotes = [ ] ; foreach ( $ afterRemotes as $ remote => $ info ) { if ( isset ( $ beforeRemotes [ $ remote ] ) ) { $ info [ 'node_path' ] = substr ( $ newPath , strlen ( $ info [ 'node_path' ] ) ) ; $ info [ 'second_path' ] = substr ( $ oldPath , strlen ( $ beforeRemotes [ $ remote ] [ 'node_path' ] ) ) ; $ moveRemotes [ $ remote ] = $ info ; } else { $ info [ 'node_path' ] = substr ( $ newPath , strlen ( $ info [ 'node_path' ] ) ) ; $ addRemotes [ $ remote ] = $ info ; } } foreach ( $ beforeRemotes as $ remote => $ info ) { if ( ! isset ( $ afterRemotes [ $ remote ] ) ) { $ info [ 'node_path' ] = substr ( $ oldPath , strlen ( $ info [ 'node_path' ] ) ) ; $ deleteRemotes [ $ remote ] = $ info ; } } $ this -> generateRemoteActivity ( $ deleteRemotes , Files :: TYPE_SHARE_DELETED , time ( ) , $ this -> currentUser -> getCloudId ( ) ) ; $ this -> generateRemoteActivity ( $ addRemotes , Files :: TYPE_SHARE_CREATED , time ( ) , $ this -> currentUser -> getCloudId ( ) ) ; $ this -> generateRemoteActivity ( $ moveRemotes , Files :: TYPE_SHARE_CHANGED , time ( ) , $ this -> currentUser -> getCloudId ( ) ) ; }
Moving a file from one folder to another
 @param string $oldPath
 @param string $newPath
Moving a file from one folder to another @param string $oldPath @param string $newPath
// Could not find the file for the owner ... // Move