<?php

/**
 * @group pholio
 */
final class PholioInlineThumbController extends PholioController {

  private $imageid;

  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();
    }

    $file = id(new PhabricatorFile())->loadOneWhere(
      'phid = %s',
      $image->getFilePHID());

    return id(new AphrontRedirectResponse())->setURI($file->getThumb60x45URI());
  }

}

<?php

/**
 * @group pholio
 */
final class PholioInlineThumbController extends PholioController {

  private $imageid;

  public function shouldAllowPublic() {
    return true;
  }

  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();
    }

    $file = id(new PhabricatorFile())->loadOneWhere(
      'phid = %s',
      $image->getFilePHID());

    return id(new AphrontRedirectResponse())->setURI($file->getThumb60x45URI());
  }

}

Make Pholio mock image thumbnails publicly visible
Make Pholio mock image thumbnails publicly visible

Summary:
Refs T2652 - This should make all of Pholio mocks publicly visible

The rest that is to be done is more generic, like the ActionListView etc.

Test Plan: set mock to public, visited it in another browser without user session

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2652

Differential Revision: https://secure.phabricator.com/D5454
