Ejemplo n.º 1
0
 public function delete($connection = null)
 {
     // Make sure that the associated QubitRelation object is removed before
     foreach (QubitRelation::getRelationsByObjectId($this->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) {
         $item->delete();
     }
     parent::delete($connection);
 }
Ejemplo n.º 2
0
  <?php 
echo get_component('right', 'relatedRights', array('resource' => $resource));
?>

</div> <!-- /.section#rightsArea -->

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

  <h2><?php 
echo __('Information object area');
?>
</h2>

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

    <div class="field">
      <h3>Information object</h3>
      <div>
        <?php 
    echo link_to(render_title($item->subject), array($item->subject, 'module' => 'informationobject'));
    ?>
      </div>
    </div>

  <?php 
}
?>
 public function execute($request)
 {
     parent::execute($request);
     $this->relations = QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $this->processForm();
             $this->resource->save();
             $this->redirect(array($this->resource, 'module' => 'informationobject'));
         }
     }
 }
 /**
  * Cascade delete child records in q_relation
  *
  */
 protected function deletePhysicalObjectRelations()
 {
     $relations = QubitRelation::getRelationsByObjectId($this->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID));
     foreach ($relations as $relation) {
         $relation->delete();
     }
 }
Ejemplo n.º 5
0
 protected function addField($name)
 {
     switch ($name) {
         case 'acquisitionType':
             $this->form->setDefault('acquisitionType', $this->context->routing->generate(null, array($this->resource->acquisitionType, 'module' => 'term')));
             $this->form->setValidator('acquisitionType', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_ACQUISITION_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('acquisitionType', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'processingPriority':
             $this->form->setDefault('processingPriority', $this->context->routing->generate(null, array($this->resource->processingPriority, 'module' => 'term')));
             $this->form->setValidator('processingPriority', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_PRIORITY_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('processingPriority', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'processingStatus':
             $this->form->setDefault('processingStatus', $this->context->routing->generate(null, array($this->resource->processingStatus, 'module' => 'term')));
             $this->form->setValidator('processingStatus', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_STATUS_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('processingStatus', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'resourceType':
             $this->form->setDefault('resourceType', $this->context->routing->generate(null, array($this->resource->resourceType, 'module' => 'term')));
             $this->form->setValidator('resourceType', new sfValidatorString());
             $choices = array();
             $choices[null] = null;
             foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_RESOURCE_TYPE_ID) as $item) {
                 $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item;
             }
             $this->form->setWidget('resourceType', new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'creators':
             $value = $choices = array();
             foreach ($this->creators = QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::CREATION_ID)) as $item) {
                 $choices[$value[] = $this->context->routing->generate(null, array($item->subject, 'module' => 'actor'))] = $item->subject;
             }
             $this->form->setDefault('creators', $value);
             $this->form->setValidator('creators', new sfValidatorPass());
             $this->form->setWidget('creators', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
             break;
         case 'date':
             $this->form->setDefault('date', Qubit::renderDate($this->resource['date']));
             if (!isset($this->resource->id)) {
                 $dt = new DateTime();
                 $this->form->setDefault('date', $dt->format('Y-m-d'));
             }
             $this->form->setValidator('date', new sfValidatorString());
             $this->form->setWidget('date', new sfWidgetFormInput());
             break;
         case 'identifier':
             $this->form->setDefault('identifier', $this->resource['identifier']);
             if (!isset($this->resource->id)) {
                 $dt = new DateTime();
                 $this->form->setDefault('identifier', QubitAccession::generateAccessionIdentifier());
             }
             $this->form->setValidator('identifier', new sfValidatorString());
             $this->form->setWidget('identifier', new sfWidgetFormInput(array(), array('disabled' => 'disabled')));
             break;
         case 'receivedExtentUnits':
         case 'title':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'appraisal':
         case 'archivalHistory':
         case 'locationInformation':
         case 'physicalCharacteristics':
         case 'processingNotes':
         case 'scopeAndContent':
         case 'sourceOfAcquisition':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormTextarea());
             break;
         default:
             return parent::addField($name);
     }
 }
 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'));
 }