/** * Creates a collection to select files for the given $iddirectory. * The collection checks download perm. Found and accessable files will * be copied to $temp_out_path. Directories are created only if one file exists. * @param integer $iddirectory Current iddirectory * @param string $temp_out_path Path to the temporary download directory * @return void */ protected function _prepareDownloadDirectoryCopyFiles($iddirectory, $temp_out_path) { $filecol = $this->file_sql_collection; $filecol->reset(); // reset to get a fresh collection $filecol->setCfg('perm_nr', $this->file_sql_item->getObjectPermId('download')); $filecol->setPermCheckActive(TRUE); $filecol->setIdclient($this->config_area['idclient']); $filecol->setIdlang($this->config_area['idlang']); $filecol->setFreefilter('iddirectory', $iddirectory); $filecol->setFreefilter('area', $this->config_area['area_name']); $filecol->generate(); if ($filecol->getCount() > 0) { $fsm = sf_api('LIB', 'FilesystemManipulation'); if ($this->directory_sql_item->loadById($iddirectory) == TRUE) { $temp_out_path .= '/' . $this->directory_sql_item->getField('dirname'); $fsm->createDirectory($temp_out_path, FALSE, TRUE); // 3. parameter (TRUE) = create recursively ! $iter = $filecol->getItemsAsIterator(); while ($iter->valid()) { $file = $iter->current(); $fsm->copyFile($file->getPath(), $temp_out_path . $file->getField('filename')); $iter->next(); } } } }