コード例 #1
0
ファイル: record.php プロジェクト: romainneutron/Phraseanet
 /**
  *
  * @param Application      $app
  * @param record_Interface $record
  * @param databox          $databox
  *
  * @return caption_record
  */
 public function __construct(Application $app, record_Interface $record, databox $databox)
 {
     $this->app = $app;
     $this->sbas_id = $record->get_sbas_id();
     $this->record = $record;
     $this->databox = $databox;
     return $this;
 }
コード例 #2
0
ファイル: ACL.php プロジェクト: nlegoff/Phraseanet
 public function has_access_to_subdef(record_Interface $record, $subdef_name)
 {
     if ($subdef_name == 'thumbnail') {
         return true;
     }
     if ($record->is_grouping()) {
         return true;
     }
     try {
         $subdef_class = $record->get_databox()->get_subdef_structure()->get_subdef($record->get_type(), $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->get_base_id(), '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->get_base_id(), '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($this->app, $record->get_sbas_id(), $record->get_record_id())) {
         $granted = true;
     }
     return $granted;
 }
コード例 #3
0
ファイル: abstract.php プロジェクト: nlegoff/Phraseanet
 /**
  *
  * @param  record_Interface $record
  * @return set
  */
 public function remove_element(record_Interface $record)
 {
     $key = $record->get_serialize_key();
     if (isset($this->elements[$key])) {
         unset($this->elements[$key]);
     }
     return $this;
 }
コード例 #4
0
ファイル: Value.php プロジェクト: romainneutron/Phraseanet
 public static function create(Application $app, databox_field $databox_field, record_Interface $record, $value, Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null)
 {
     $connbas = $databox_field->get_connection();
     /**
      * Check consistency
      */
     if (!$databox_field->is_multi()) {
         try {
             $field = $record->get_caption()->get_field($databox_field->get_name());
             $values = $field->get_values();
             $caption_field_value = array_pop($values);
             /* @var $value \caption_Field_Value */
             $caption_field_value->set_value($value);
             if (!$vocabulary || !$vocabularyId) {
                 $caption_field_value->removeVocabulary();
             } else {
                 $caption_field_value->setVocab($vocabulary, $vocabularyId);
             }
             return $caption_field_value;
         } catch (\Exception $e) {
         }
     }
     $sql_ins = 'INSERT INTO metadatas
   (id, record_id, meta_struct_id, value, VocabularyType, VocabularyId)
   VALUES
   (null, :record_id, :field, :value, :VocabType, :VocabId)';
     $params = [':record_id' => $record->get_record_id(), ':field' => $databox_field->get_id(), ':value' => $value, ':VocabType' => $vocabulary ? $vocabulary->getType() : null, ':VocabId' => $vocabulary ? $vocabularyId : null];
     $stmt_ins = $connbas->prepare($sql_ins);
     $stmt_ins->execute($params);
     $stmt_ins->closeCursor();
     $meta_id = $connbas->lastInsertId();
     $caption_field_value = new self($app, $databox_field, $record, $meta_id);
     $caption_field_value->update_cache_value($value);
     $record->get_caption()->delete_data_from_cache();
     $databox_field->delete_data_from_cache();
     $caption_field_value->delete_data_from_cache();
     return $caption_field_value;
 }
コード例 #5
0
ファイル: subdef.php プロジェクト: romainneutron/Phraseanet
 public static function create(Application $app, record_Interface $record, $name, MediaInterface $media)
 {
     $databox = $record->get_databox();
     $connbas = $databox->get_connection();
     $path = $media->getFile()->getPath();
     $newname = $media->getFile()->getFilename();
     $params = [':path' => $path, ':file' => $newname, ':width' => 0, ':height' => 0, ':mime' => $media->getFile()->getMimeType(), ':size' => $media->getFile()->getSize(), ':dispatched' => 1];
     if (method_exists($media, 'getWidth') && null !== $media->getWidth()) {
         $params[':width'] = $media->getWidth();
     }
     if (method_exists($media, 'getHeight') && null !== $media->getHeight()) {
         $params[':height'] = $media->getHeight();
     }
     try {
         $sql = 'SELECT subdef_id FROM subdef
                 WHERE record_id = :record_id AND name = :name';
         $stmt = $connbas->prepare($sql);
         $stmt->execute([':record_id' => $record->get_record_id(), ':name' => $name]);
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
         $stmt->closeCursor();
         if (!$row) {
             throw new \Exception_Media_SubdefNotFound('Require the real one');
         }
         $sql = "UPDATE subdef\n              SET path = :path, file = :file\n                  , width = :width , height = :height, mime = :mime\n                  , size = :size, dispatched = :dispatched, updated_on = NOW()\n              WHERE subdef_id = :subdef_id";
         $params[':subdef_id'] = $row['subdef_id'];
     } catch (\Exception_Media_SubdefNotFound $e) {
         $sql = "INSERT INTO subdef\n              (record_id, name, path, file, width\n                , height, mime, size, dispatched, created_on, updated_on)\n              VALUES (:record_id, :name, :path, :file, :width, :height\n                , :mime, :size, :dispatched, NOW(), NOW())";
         $params[':record_id'] = $record->get_record_id();
         $params[':name'] = $name;
     }
     $stmt = $connbas->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
     $subdef = new self($app, $record, $name);
     $subdef->delete_data_from_cache();
     if ($subdef->get_permalink() instanceof media_Permalink_Adapter) {
         $subdef->get_permalink()->delete_data_from_cache();
     }
     unset($media);
     return $subdef;
 }