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; }
public function has_status_access_to_record(RecordInterface $record) { return 0 === (($record->getStatusBitField() ^ $this->get_mask_xor($record->getBaseId())) & $this->get_mask_and($record->getBaseId())); }