private function formatCollId($value) { return phrasea::bas_labels(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app); }
protected function load() { try { $datas = $this->get_data_from_cache(); $this->mime = $datas['mime']; $this->sha256 = $datas['sha256']; $this->bitly_link = $datas['bitly_link']; $this->original_name = $datas['original_name']; $this->type = $datas['type']; $this->grouping = $datas['grouping']; $this->uuid = $datas['uuid']; $this->modification_date = $datas['modification_date']; $this->creation_date = $datas['creation_date']; $this->base_id = $datas['base_id']; return $this; } catch (\Exception $e) { } $connbas = $this->databox->get_connection(); $sql = 'SELECT coll_id, record_id,credate , uuid, moddate, parent_record_id , type, originalname, bitly, sha256, mime FROM record WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); $stmt->execute([':record_id' => $this->record_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if (!$row) { throw new Exception_Record_AdapterNotFound('Record ' . $this->record_id . ' on database ' . $this->databox->get_sbas_id() . ' not found '); } $this->base_id = (int) phrasea::baseFromColl($this->databox->get_sbas_id(), $row['coll_id'], $this->app); $this->creation_date = new DateTime($row['credate']); $this->modification_date = new DateTime($row['moddate']); $this->uuid = $row['uuid']; $this->grouping = $row['parent_record_id'] == '1'; $this->type = $row['type']; $this->original_name = $row['originalname']; $this->bitly_link = $row['bitly']; $this->sha256 = $row['sha256']; $this->mime = $row['mime']; $datas = ['mime' => $this->mime, 'sha256' => $this->sha256, 'bitly_link' => $this->bitly_link, 'original_name' => $this->original_name, 'type' => $this->type, 'grouping' => $this->grouping, 'uuid' => $this->uuid, 'modification_date' => $this->modification_date, 'creation_date' => $this->creation_date, 'base_id' => $this->base_id]; $this->set_data_to_cache($datas); return $this; }
/** * @param array $row */ public function mapFromData(array $row) { if (!isset($row['base_id'])) { $row['base_id'] = phrasea::baseFromColl($this->get_sbas_id(), $row['collection_id'], $this->app); } $this->collection_id = (int) $row['collection_id']; $this->base_id = (int) $row['base_id']; $this->created = new DateTime($row['created']); $this->updated = new DateTime($row['updated']); $this->uuid = $row['uuid']; $this->isStory = $row['isStory'] == '1'; $this->type = $row['type']; $this->original_name = $row['originalName']; $this->sha256 = $row['sha256']; $this->mime = $row['mime']; }
/** * * @return Array */ public function get_short_history() { if (!is_null($this->short_history)) { return $this->short_history; } $tab = []; $report = $this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($this->get_base_id(), 'canreport'); $databox = $this->app['phraseanet.appbox']->get_databox($this->get_sbas_id()); $connsbas = $databox->get_connection(); $sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site FROM log_docs d, log l WHERE d.log_id = l.id AND d.record_id = :record_id '; $params = [':record_id' => $this->get_record_id()]; if (!$report) { $sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; $params[':usr_id'] = $this->app['authentication']->getUser()->getId(); $params[':site'] = $this->app['conf']->get(['main', 'key']); } $sql .= 'ORDER BY d.date, usrid DESC'; $stmt = $connsbas->prepare($sql); $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { $hour = $this->app['date-formatter']->getPrettyString(new DateTime($row['date'])); if (!isset($tab[$hour])) { $tab[$hour] = []; } $site = $row['site']; if (!isset($tab[$hour][$site])) { $tab[$hour][$site] = []; } $action = $row['action']; if (!isset($tab[$hour][$site][$action])) { $tab[$hour][$site][$action] = []; } if (!isset($tab[$hour][$site][$action][$row['usr_id']])) { $tab[$hour][$site][$action][$row['usr_id']] = ['final' => [], 'comment' => [], 'user' => $row['usr_id'] ? $this->app['repo.users']->find($row['usr_id']) : null]; } if (!in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) { if ($action == 'collection') { $tab[$hour][$site][$action][$row['usr_id']]['final'][] = phrasea::baseFromColl($this->get_sbas_id(), $row['final'], $this->app); } else { $tab[$hour][$site][$action][$row['usr_id']]['final'][] = $row['final']; } } if (!in_array($row['comment'], $tab[$hour][$site][$action][$row['usr_id']]['comment'])) { $tab[$hour][$site][$action][$row['usr_id']]['comment'][] = $row['comment']; } } $this->short_history = array_reverse($tab); return $this->short_history; }
private function mapCollectionStatus($databoxId, $collectionId, $status) { $baseId = \phrasea::baseFromColl($databoxId, $collectionId, $this->app); return array("databox_id" => $databoxId, "base_id" => $baseId, "collection_id" => $collectionId, "status" => $status); }