2013-03-20 13:36:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group pholio
|
|
|
|
*/
|
|
|
|
final class PholioInlineThumbController extends PholioController {
|
|
|
|
|
|
|
|
private $imageid;
|
|
|
|
|
2013-03-26 23:01:51 +01:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-20 13:36:53 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->imageid = idx($data, 'imageid');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$image = id(new PholioImage())->load($this->imageid);
|
|
|
|
|
|
|
|
if ($image == null) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$mock = id(new PholioMockQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($image->getMockID()))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$mock) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2013-09-30 18:38:13 +02:00
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->witHPHIDs(array($image->getFilePHID()))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$file) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2013-03-20 13:36:53 +01:00
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($file->getThumb60x45URI());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|