Пример #1
0
 private function retrieveRecord($app, $databox, $token, $record_id, $subdef)
 {
     if (in_array($subdef, [\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL]) && $app['EM']->getRepository('Phraseanet:FeedItem')->isRecordInPublicFeed($app, $databox->get_sbas_id(), $record_id)) {
         $record = $databox->get_record($record_id);
     } else {
         $record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
         if (!$record instanceof \record_adapter) {
             throw new NotFoundHttpException('Wrong token.');
         }
     }
     return $record;
 }
Пример #2
0
 /**
  * @param \databox $databox
  * @param string   $token
  * @param int      $record_id
  * @param string   $subdef
  * @return \record_adapter
  */
 private function retrieveRecord(\databox $databox, $token, $record_id, $subdef)
 {
     try {
         $record = new \record_adapter($this->app, $databox->get_sbas_id(), $record_id);
         $subDefinition = new \media_subdef($this->app, $record, $subdef);
         $permalink = new \media_Permalink_Adapter($this->app, $databox, $subDefinition);
     } catch (\Exception $exception) {
         throw new NotFoundHttpException('Wrong token.', $exception);
     }
     if (!$permalink->get_is_activated()) {
         throw new NotFoundHttpException('This token has been disabled.');
     }
     /** @var FeedItemRepository $feedItemsRepository */
     $feedItemsRepository = $this->app['repo.feed-items'];
     if (in_array($subdef, [\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL]) && $feedItemsRepository->isRecordInPublicFeed($databox->get_sbas_id(), $record_id)) {
         return $record;
     } elseif ($permalink->get_token() == (string) $token) {
         return $record;
     }
     throw new NotFoundHttpException('Wrong token.');
 }
Пример #3
0
 /**
  * @expectedException \Alchemy\Phrasea\Exception\RuntimeException
  */
 public function testCreateAPermalinkAlreadyCreated()
 {
     media_Permalink_Adapter::create(self::$DI['app'], self::$DI['record_1']->get_databox(), self::$DI['record_1']->get_subdef('document'));
 }
Пример #4
0
 /**
  * Retrieve detailled information about one permalink
  *
  * @param media_Permalink_Adapter $permalink
  *
  * @return type
  */
 private function list_permalink(\media_Permalink_Adapter $permalink)
 {
     $downloadUrl = $permalink->get_url();
     $downloadUrl->getQuery()->set('download', '1');
     return ['created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), 'label' => $permalink->get_label(), 'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM), 'page_url' => $permalink->get_page(), 'download_url' => (string) $downloadUrl, 'url' => (string) $permalink->get_url()];
 }
Пример #5
0
 /**
  * Retrieve detailled information about one permalink
  *
  * @param media_Permalink_Adapter $permalink
  *
  * @return type
  */
 protected function list_permalink(media_Permalink_Adapter $permalink)
 {
     return ['created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), 'label' => $permalink->get_label(), 'updated_on' => $permalink->get_last_modified()->format(DATE_ATOM), 'page_url' => $permalink->get_page(), 'download_url' => $permalink->get_url() . '&download', 'url' => $permalink->get_url()];
 }
Пример #6
0
 public function testPermalinkRouteNotAuthenticatedIsOkInPublicFeed()
 {
     /** @var Feed $feed */
     $feed = self::$DI['app']['orm.em']->find('Phraseanet:Feed', 2);
     /** @var FeedEntry $entry */
     $entry = $feed->getEntries()->first();
     /** @var FeedItem $item */
     $item = $entry->getItems()->first();
     $record = $item->getRecord(self::$DI['app']);
     // Ensure permalink is created
     \media_Permalink_Adapter::getPermalink(self::$DI['app'], $record->get_databox(), $record->get_subdef('preview'));
     $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', ['sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'subdef' => 'preview']);
     self::$DI['app']['authentication']->closeAccount();
     self::$DI['client']->request('GET', $path);
     $this->assertTrue(self::$DI['client']->getResponse()->isOk());
 }
Пример #7
0
 /**
  *
  * @return media_Permalink_Adapter
  */
 public function get_permalink()
 {
     if (!$this->permalink && $this->is_physically_present()) {
         $this->permalink = media_Permalink_Adapter::getPermalink($this->app, $this->record->get_databox(), $this);
     }
     return $this->permalink;
 }