/**
  * Delete relation records linking this physical object to information objects
  */
 public function deleteInformationObjectRelations()
 {
     $informationObjectRelations = QubitRelation::getRelationsBySubjectId($this->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID));
     foreach ($informationObjectRelations as $relation) {
         $relation->delete();
     }
 }
Exemplo n.º 2
0
 public function getRights($options = array())
 {
     return QubitRelation::getRelationsBySubjectId($this->id, array('typeId' => QubitTerm::RIGHT_ID));
 }
Exemplo n.º 3
0
<?php 
echo render_show(__('Source of acquisition'), render_value($resource->getSourceOfAcquisition(array('cultureFallback' => true))));
?>

<?php 
echo render_show(__('Location information'), render_value($resource->getLocationInformation(array('cultureFallback' => true))));
?>

<div class="section" id="donorArea">

  <?php 
echo link_to_if(QubitAcl::check($resource, 'update'), '<h2>' . __('Donor/Transferring body area') . '</h2>', array($resource, 'module' => 'accession', 'action' => 'edit'), array('anchor' => 'donorArea', 'title' => __('Edit donor/transferring body area')));
?>

  <?php 
foreach (QubitRelation::getRelationsBySubjectId($resource->id, array('typeId' => QubitTerm::DONOR_ID)) as $item) {
    ?>

    <?php 
    echo render_show(__('Related donor'), link_to(render_title($item->object), array($item->object, 'module' => 'donor')));
    ?>

    <?php 
    foreach ($item->object->contactInformations as $contactItem) {
        ?>
      <?php 
        echo get_partial('contactinformation/contactInformation', array('contactInformation' => $contactItem));
        ?>
    <?php 
    }
    ?>
 public function execute($request)
 {
     parent::execute($request);
     $this->form->getWidgetSchema()->setNameFormat('relatedDonor[%s]');
     $this->relatedDonorRecord = QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::DONOR_ID));
 }
 protected function processForm()
 {
     // If object is being duplicated
     if (isset($this->request->sourceId)) {
         $sourceInformationObject = QubitInformationObject::getById($this->request->sourceId);
         // Duplicate physical object relations
         foreach ($sourceInformationObject->getPhysicalObjects() as $physicalObject) {
             $this->resource->addPhysicalObject($physicalObject);
         }
         // Duplicate notes
         foreach ($sourceInformationObject->notes as $sourceNote) {
             if (!isset($this->request->delete_notes[$sourceNote->id])) {
                 $note = new QubitNote();
                 $note->content = $sourceNote->content;
                 $note->typeId = $sourceNote->type->id;
                 $note->userId = $this->context->user->getAttribute('user_id');
                 $this->resource->notes[] = $note;
             }
         }
         foreach (QubitRelation::getRelationsBySubjectId($sourceInformationObject->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) {
             $sourceRight = $item->object;
             if (false === array_search($this->context->routing->generate(null, array($sourceRight, 'module' => 'right')), (array) $this->request->deleteRights)) {
                 $right = new QubitRights();
                 $right->act = $sourceRight->act;
                 $right->startDate = $sourceRight->startDate;
                 $right->endDate = $sourceRight->endDate;
                 $right->basis = $sourceRight->basis;
                 $right->restriction = $sourceRight->restriction;
                 $right->copyrightStatus = $sourceRight->copyrightStatus;
                 $right->copyrightStatusDate = $sourceRight->copyrightStatusDate;
                 $right->copyrightJurisdiction = $sourceRight->copyrightJurisdiction;
                 $right->statuteNote = $sourceRight->statuteNote;
                 // Right holder
                 if (isset($sourceRight->rightsHolder)) {
                     $right->rightsHolder = $sourceRight->rightsHolder;
                 }
                 // I18n
                 $right->rightsNote = $sourceRight->rightsNote;
                 $right->copyrightNote = $sourceRight->copyrightNote;
                 $right->licenseIdentifier = $sourceRight->licenseIdentifier;
                 $right->licenseTerms = $sourceRight->licenseTerms;
                 $right->licenseNote = $sourceRight->licenseNote;
                 $right->statuteJurisdiction = $sourceRight->statuteJurisdiction;
                 $right->statuteCitation = $sourceRight->statuteCitation;
                 $right->statuteDeterminationDate = $sourceRight->statuteDeterminationDate;
                 foreach ($sourceRight->rightsI18ns as $sourceRightI18n) {
                     if ($this->context->user->getCulture() == $sourceRightI18n->culture) {
                         continue;
                     }
                     $rightI18n = new QubitRightsI18n();
                     $rightI18n->rightNote = $sourceRightI18n->rightNote;
                     $rightI18n->copyrightNote = $sourceRightI18n->copyrightNote;
                     $rightI18n->licenseIdentifier = $sourceRightI18n->licenseIdentifier;
                     $rightI18n->licenseTerms = $sourceRightI18n->licenseTerms;
                     $rightI18n->licenseNote = $sourceRightI18n->licenseNote;
                     $rightI18n->statuteJurisdiction = $sourceRightI18n->statuteJurisdiction;
                     $rightI18n->statuteCitation = $sourceRightI18n->statuteCitation;
                     $rightI18n->statuteNote = $sourceRightI18n->statuteNote;
                     $rightI18n->culture = $sourceRightI18n->culture;
                     $right->rightsI18ns[] = $rightI18n;
                 }
                 $right->save();
                 $relation = new QubitRelation();
                 $relation->object = $right;
                 $relation->typeId = QubitTerm::RIGHT_ID;
                 $this->resource->relationsRelatedBysubjectId[] = $relation;
             }
         }
         if ('sfIsadPlugin' != $this->request->module) {
             foreach ($sourceInformationObject->events as $sourceEvent) {
                 if (false === array_search($this->context->routing->generate(null, array($sourceEvent, 'module' => 'event')), (array) $this->request->deleteEvents)) {
                     $event = new QubitEvent();
                     $event->actorId = $sourceEvent->actorId;
                     $event->typeId = $sourceEvent->typeId;
                     $event->startDate = $sourceEvent->startDate;
                     $event->endDate = $sourceEvent->endDate;
                     $event->sourceCulture = $sourceEvent->sourceCulture;
                     // I18n
                     $event->name = $sourceEvent->name;
                     $event->description = $sourceEvent->description;
                     $event->date = $sourceEvent->date;
                     foreach ($sourceEvent->eventI18ns as $sourceEventI18n) {
                         if ($this->context->user->getCulture() == $sourceEventI18n->culture) {
                             continue;
                         }
                         $eventI18n = new QubitEventI18n();
                         $eventI18n->name = $sourceEventI18n->name;
                         $eventI18n->description = $sourceEventI18n->description;
                         $eventI18n->date = $sourceEventI18n->date;
                         $eventI18n->culture = $sourceEventI18n->culture;
                         $event->eventI18ns[] = $eventI18n;
                     }
                     // Place
                     if (null !== ($place = QubitObjectTermRelation::getOneByObjectId($sourceEvent->id))) {
                         $termRelation = new QubitObjectTermRelation();
                         $termRelation->term = $place->term;
                         $event->objectTermRelationsRelatedByobjectId[] = $termRelation;
                     }
                     $this->resource->events[] = $event;
                 }
             }
         }
     }
     parent::processForm();
     $this->deleteNotes();
     $this->updateChildLevels();
     $this->updateStatus();
     // Must come after updateChildLevels()
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
     if (isset($this->nameFormat)) {
         $this->form->getWidgetSchema()->setNameFormat($this->nameFormat);
     } else {
         $this->form->getWidgetSchema()->setNameFormat('editRight[%s]');
     }
     foreach ($this::$NAMES as $name) {
         $this->addField($name);
     }
     $this->rights = QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::RIGHT_ID));
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     $this->resource = $this->getRoute()->resource;
     if (!QubitAcl::check(QubitInformationObject::getRoot(), 'update')) {
         QubitAcl::forwardUnauthorized();
     }
     // Create new information object
     $informationObject = new QubitInformationObject();
     $informationObject->setRoot();
     // Populate fields
     $informationObject->title = $this->resource->title;
     $informationObject->physicalCharacteristics = $this->resource->physicalCharacteristics;
     $informationObject->scopeAndContent = $this->resource->scopeAndContent;
     $informationObject->archivalHistory = $this->resource->archivalHistory;
     // Copy (not link) rights
     foreach (QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) {
         $sourceRight = $item->object;
         $right = new QubitRights();
         $right->act = $sourceRight->act;
         $right->startDate = $sourceRight->startDate;
         $right->endDate = $sourceRight->endDate;
         $right->basis = $sourceRight->basis;
         $right->restriction = $sourceRight->restriction;
         $right->copyrightStatus = $sourceRight->copyrightStatus;
         $right->copyrightStatusDate = $sourceRight->copyrightStatusDate;
         $right->copyrightJurisdiction = $sourceRight->copyrightJurisdiction;
         $right->statuteNote = $sourceRight->statuteNote;
         // Right holder
         if (isset($sourceRight->rightsHolder)) {
             $right->rightsHolder = $sourceRight->rightsHolder;
         }
         // I18n
         $right->rightsNote = $sourceRight->rightsNote;
         $right->copyrightNote = $sourceRight->copyrightNote;
         $right->licenseIdentifier = $sourceRight->licenseIdentifier;
         $right->licenseTerms = $sourceRight->licenseTerms;
         $right->licenseNote = $sourceRight->licenseNote;
         $right->statuteJurisdiction = $sourceRight->statuteJurisdiction;
         $right->statuteCitation = $sourceRight->statuteCitation;
         $right->statuteDeterminationDate = $sourceRight->statuteDeterminationDate;
         foreach ($sourceRight->rightsI18ns as $sourceRightI18n) {
             if ($this->context->user->getCulture() == $sourceRightI18n->culture) {
                 continue;
             }
             $rightI18n = new QubitRightsI18n();
             $rightI18n->rightNote = $sourceRightI18n->rightNote;
             $rightI18n->copyrightNote = $sourceRightI18n->copyrightNote;
             $rightI18n->licenseIdentifier = $sourceRightI18n->licenseIdentifier;
             $rightI18n->licenseTerms = $sourceRightI18n->licenseTerms;
             $rightI18n->licenseNote = $sourceRightI18n->licenseNote;
             $rightI18n->statuteJurisdiction = $sourceRightI18n->statuteJurisdiction;
             $rightI18n->statuteCitation = $sourceRightI18n->statuteCitation;
             $rightI18n->statuteNote = $sourceRightI18n->statuteNote;
             $rightI18n->culture = $sourceRightI18n->culture;
             $right->rightsI18ns[] = $rightI18n;
         }
         $right->save();
         $relation = new QubitRelation();
         $relation->object = $right;
         $relation->typeId = QubitTerm::RIGHT_ID;
         $informationObject->relationsRelatedBysubjectId[] = $relation;
     }
     // Populate creators (from QubitRelation to QubitEvent)
     foreach (QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::CREATION_ID)) as $item) {
         $event = new QubitEvent();
         $event->actor = $item->subject;
         $event->typeId = QubitTerm::CREATION_ID;
         $informationObject->events[] = $event;
     }
     // Relationship between the information object and accession record
     $relation = new QubitRelation();
     $relation->object = $this->resource;
     $relation->typeId = QubitTerm::ACCESSION_ID;
     $informationObject->relationsRelatedBysubjectId[] = $relation;
     // Set publication status
     $informationObject->setPublicationStatus(sfConfig::get('app_defaultPubStatus', QubitTerm::PUBLICATION_STATUS_DRAFT_ID));
     $informationObject->save();
     $this->redirect(array($informationObject, 'module' => 'informationobject'));
 }
 public function execute($request)
 {
     $this->accessions = QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::ACCESSION_ID));
 }