| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @copyright Copyright (c) 2018 Robin Appelman <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @license GNU AGPL version 3 or any later version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * This program is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * it under the terms of the GNU Affero General Public License as | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * published by the Free Software Foundation, either version 3 of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * You should have received a copy of the GNU Affero General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | namespace OCA\Files_Trashbin\Trash; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use OCP\Files\FileInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use OCP\IUser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | class TrashItem implements ITrashItem { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	/** @var ITrashBackend */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	private $backend; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	/** @var string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	private $orignalLocation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	/** @var int */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	private $deletedTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	/** @var string */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	private $trashPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	/** @var FileInfo */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	private $fileInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	/** @var IUser */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	private $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		ITrashBackend $backend, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		string $originalLocation, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		int $deletedTime, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		string $trashPath, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		FileInfo $fileInfo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		IUser $user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		$this->backend = $backend; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		$this->orignalLocation = $originalLocation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$this->deletedTime = $deletedTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$this->trashPath = $trashPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$this->fileInfo = $fileInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->user = $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	public function getTrashBackend(): ITrashBackend { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		return $this->backend; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	public function getOriginalLocation(): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		return $this->orignalLocation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	public function getDeletedTime(): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		return $this->deletedTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	public function getTrashPath(): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		return $this->trashPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	public function isRootItem(): bool { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		return substr_count($this->getTrashPath(), '/') === 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	public function getUser(): IUser { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		return $this->user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	public function getEtag() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		return $this->fileInfo->getEtag(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	public function getSize($includeMounts = true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		return $this->fileInfo->getSize($includeMounts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	public function getMtime() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		return $this->fileInfo->getMtime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	public function getName() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		return $this->fileInfo->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	public function getInternalPath() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		return $this->fileInfo->getInternalPath(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	public function getPath() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		return $this->fileInfo->getPath(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	public function getMimetype() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		return $this->fileInfo->getMimetype(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	public function getMimePart() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		return $this->fileInfo->getMimePart(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 	public function getStorage() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		return $this->fileInfo->getStorage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	public function getId() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		return $this->fileInfo->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	public function isEncrypted() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		return $this->fileInfo->isEncrypted(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	public function getPermissions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		return $this->fileInfo->getPermissions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	public function getType() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		return $this->fileInfo->getType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	public function isReadable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		return $this->fileInfo->isReadable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	public function isUpdateable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 		return $this->fileInfo->isUpdateable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	public function isCreatable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		return $this->fileInfo->isCreatable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	public function isDeletable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		return $this->fileInfo->isDeletable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	public function isShareable() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		return $this->fileInfo->isShareable(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	public function isShared() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		return $this->fileInfo->isShared(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	public function isMounted() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		return $this->fileInfo->isMounted(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  | 	public function getMountPoint() { | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  | 		return $this->fileInfo->getMountPoint(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	public function getOwner() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		return $this->fileInfo->getOwner(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	public function getChecksum() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		return $this->fileInfo->getChecksum(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	public function getExtension(): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 		return $this->fileInfo->getExtension(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	public function getTitle(): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 		return $this->getOriginalLocation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	public function getCreationTime(): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		return $this->fileInfo->getCreationTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 	public function getUploadTime(): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		return $this->fileInfo->getUploadTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 188 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 189 |  |  |  |