protected static function getGroupOfficeSnapShot(\GO\Files\Model\Folder $folder, $sort = true) { $snapshot = array(); $stmt = $folder->files(); foreach ($stmt as $file) { $snapshot[strtolower($file->path)] = array('mtime' => $file->mtime, 'path' => $file->path); } $stmt = $folder->folders(); foreach ($stmt as $childFolder) { $snapshot[strtolower($childFolder->path)] = array('mtime' => $childFolder->mtime, 'path' => $childFolder->path); $snapshot = array_merge($snapshot, self::getGroupOfficeSnapShot($childFolder, false)); } if ($sort) { ksort($snapshot); } return $snapshot; }
public function copyContentsFrom(Folder $sourceFolder, $mergeFolders = false) { //make sure database is in sync with filesystem. $sourceFolder->syncFilesystem(true); $stmt = $sourceFolder->folders(); while ($subfolder = $stmt->fetch()) { $subfolder->systemSave = true; if (!$mergeFolders) { $subfolder->copy($this); } else { if ($existingFolder = $this->hasFolder($subfolder->name)) { $existingFolder->copyContentsFrom($subfolder, true); } else { $subfolder->copy($this); } } } $stmt = $sourceFolder->files(); while ($file = $stmt->fetch()) { $file->copy($this, false, true); } }