public function getRecordFlags(RecordInterface $record)
 {
     $recordStatuses = [];
     /** @var \appbox $appbox */
     $appbox = $this->app['phraseanet.appbox'];
     $databox = $appbox->get_databox($record->getDataboxId());
     $structure = $databox->getStatusStructure()->toArray();
     if (!$this->isGrantedOnCollection($record->getBaseId(), 'chgstatus')) {
         $structure = array_filter($structure, function ($status) {
             return (bool) $status['printable'];
         });
     }
     $bitValue = $record->getStatusBitField();
     foreach ($structure as $status) {
         $on = \databox_status::bitIsSet($bitValue, $status['bit']);
         if (null === ($on ? $status['img_on'] : $status['img_off'])) {
             continue;
         }
         $recordStatuses[] = ['path' => $on ? $status['img_on'] : $status['img_off'], 'labels' => $on ? $status['labels_on_i18n'] : $status['labels_off_i18n']];
     }
     return $recordStatuses;
 }
示例#2
0
 public function has_access_to_subdef(RecordInterface $record, $subdef_name)
 {
     if ($subdef_name == 'thumbnail') {
         return true;
     }
     if ($record->isStory()) {
         return true;
     }
     $databox = $this->app->findDataboxById($record->getDataboxId());
     try {
         $subdef_class = $databox->get_subdef_structure()->get_subdef($record->getType(), $subdef_name)->get_class();
     } catch (\Exception $e) {
         return false;
     }
     $granted = false;
     if ($subdef_class == databox_subdef::CLASS_THUMBNAIL) {
         $granted = true;
     } elseif ($subdef_class == databox_subdef::CLASS_PREVIEW && $this->has_right_on_base($record->getBaseId(), 'candwnldpreview')) {
         $granted = true;
     } elseif ($subdef_class == databox_subdef::CLASS_PREVIEW && $this->has_preview_grant($record)) {
         $granted = true;
     } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_right_on_base($record->getBaseId(), 'candwnldhd')) {
         $granted = true;
     } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_hd_grant($record)) {
         $granted = true;
     }
     if (false === $granted && $this->app['repo.feed-items']->isRecordInPublicFeed($record->getDataboxId(), $record->getRecordId())) {
         $granted = true;
     }
     return $granted;
 }