\r
namespace Controllers;\r
\r
+use Exception;\r
use Controllers\IDivineController;\r
use Services\Http\IHttpResponse;\r
use Services\Uploads\IUploadManager;\r
use Services\IUserSession;\r
use Services\IZipParser;\r
use Services\ISMOMatcher;\r
+use Services\IStatusReporter;\r
use DataAccess\StepMania\ISimfileRepository;\r
use DataAccess\StepMania\IPackRepository;\r
use DataAccess\IFileRepository;\r
private $_zipParser;\r
private $_smoMatcher;\r
private $_downloadRepository;\r
+ private $_statusReporter;\r
+ private $_userSession;\r
\r
public function __construct(\r
IHttpResponse $response,\r
IUserSession $userSession,\r
IZipParser $zipParser,\r
ISMOMatcher $smoMatcher,\r
- IDownloadRepository $downloadRepository\r
+ IDownloadRepository $downloadRepository,\r
+ IStatusReporter $statusReporter\r
) {\r
$this->_response = $response;\r
$this->_uploadManager = $uploadManager;\r
$this->_zipParser = $zipParser;\r
$this->_smoMatcher = $smoMatcher;\r
$this->_downloadRepository = $downloadRepository;\r
+ $this->_statusReporter = $statusReporter;\r
+ $this->_userSession = $userSession;\r
}\r
\r
public function indexAction() {\r
}\r
\r
public function uploadAction()\r
- { \r
+ {\r
+ if(!$this->_userSession->getCurrentUser()) $this->_statusReporter->error('You must be authenticated to upload files');\r
+ \r
//TODO: Put directory in config ?\r
$files = $this->_uploadManager->setFilesDirectory('../files')\r
->setDestination('StepMania/')\r
{\r
$zipParser = $this->_zipParser;\r
$zipParser->parse($file);\r
- \r
+ \r
+ if(!$zipParser->simfiles()) $this->_statusReporter->error('That zip doesn\'t seem to have any simfiles in it.');\r
+ \r
//save the actual zip in the db\r
$this->findAndAddSmoMirror($file);\r
$this->_fileRepository->save($file); \r
$this->_simfileRepository->save($simfile);\r
}\r
}\r
+ \r
+ $this->_statusReporter->success('Uploaded succesfully');\r
}\r
\r
private function getPackMirrorsArray(IPack $pack)\r