public function execute($request) { if (null === ($this->resource = $this->getRoute()->resource)) { return $this->generateResponse(404, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Not found'))); } $this->user = $request->getAttribute('user'); if ($request->isMethod('post')) { if (QubitAcl::check(QubitInformationObject::getRoot(), 'create')) { return $this->generateResponse(403, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Forbidden'))); } $this->packageFormat = $request->getHttpHeader('X-Packaging'); $this->packageContentType = $request->getContentType(); // Check if the packaging format is supported if (!in_array($this->packageFormat, qtSwordPluginConfiguration::$packaging)) { return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $this->context->i18n->__('The supplied format is not supported by this server'))); } // Check if the content type is supported if (!in_array($this->packageContentType, qtSwordPluginConfiguration::$mediaRanges)) { return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $this->context->i18n->__('The supplied content type is not supported by this server'))); } // Save the file temporary $filename = qtSwordPlugin::saveRequestContent(); // Package name if (null !== $request->getHttpHeader('Content-Disposition')) { $this->packageName = substr($request->getHttpHeader('Content-Disposition'), 9); } // TODO see [RFC2183] $this->packageName = $filename; // Calculated MD5 check does not match the value provided by the client if (md5(file_get_contents($filename)) != $request->getHttpHeader('Content-MD5')) { return $this->generateResponse(412, 'error/ErrorChecksumMismatchSuccess', array('summary' => $this->context->i18n->__('Checksum sent does not match the calculated checksum'))); } try { $extractor = qtPackageExtractorFactory::build($this->packageFormat, array('filename' => $filename, 'name' => $this->packageName, 'format' => $this->packageFormat, 'resource' => $this->resource, 'type' => $this->packageContentType)); } catch (Exception $e) { return $this->generateResponse(415, 'error/ErrorContent', array('summary' => $e->getMessage())); } // Open package and XML document $extractor->extract(); // Parse and create objects $extractor->process(); $this->informationObject = $extractor->informationObject; // Remove temporary files $extractor->clean(); return $this->generateResponse(201, 'deposit', array('headers' => array('Location' => $this->context->routing->generate(null, array($this->informationObject, 'module' => 'informationobject'))))); } else { if ($request->isMethod('put') || $request->isMethod('delete')) { return $this->generateResponse(501, 'error/ErrorNotImplemented', array('summary' => $this->context->i18n->__('Not implemented'))); } else { return $this->generateResponse(400, 'error/ErrorBadRequest', array('summary' => $this->context->i18n->__('Bad request'))); } } }
public function execute($request) { $this->resource = $request->getAttribute('sf_route')->resource; // Get tree (limit 10 siblings and children) $this->treeViewObjects = $this->resource->getFullYuiTree(10); // Check if tree view worth it if (1 > count($this->treeViewObjects)) { return sfView::NONE; } $this->treeViewExpands = array(); foreach ($this->resource->ancestors->andSelf()->orderBy('lft') as $item) { $this->treeViewExpands[$item->id] = $item->id; } // Is it draggable? $this->treeViewDraggable = json_encode(QubitAcl::check(QubitInformationObject::getRoot(), 'update')); }
public static function addFilterDraftsCriteria($criteria) { $criteria->addJoin(QubitInformationObject::ID, QubitStatus::OBJECT_ID, Criteria::LEFT_JOIN); // Either object must be published, or $ct1 = $criteria->getNewCriterion(QubitStatus::TYPE_ID, QubitTerm::STATUS_TYPE_PUBLICATION_ID); $ct2 = $criteria->getNewCriterion(QubitStatus::STATUS_ID, QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID); $ct1->addAnd($ct2); // The user has view drafts permission $ct3 = self::getFilterCriterion($criteria, QubitInformationObject::getRoot(), 'viewDraft'); if (!isset($ct3) || false === $ct3) { // Show ONLY published descriptions return $criteria->addAnd($ct1); } else { if (true === $ct3) { // Show ALL drafts and published descriptions (don't add to criteria) return $criteria; } else { // Show a limited set of draft descriptions + all published descriptions $ct1->addOr($ct3); return $criteria->addAnd($ct1); } } }
</h1> <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 'user', 'action' => 'editInformationObjectAcl')), array('id' => 'editForm')); ?> <fieldset class="collapsible" id="allInfoObjectsArea"> <legend><?php echo __('Permissions for all %1%', array('%1%' => sfConfig::get('app_ui_label_informationobject'))); ?> </legend> <div class="form-item"> <?php echo get_component('aclGroup', 'aclTable', array('object' => QubitInformationObject::getRoot(), 'permissions' => $root, 'actions' => $basicActions)); ?> </div> </fieldset> <!-- /#allInfoObjectsArea --> <fieldset class="collapsible collapsed" id="informationObjectArea"> <legend><?php echo __('Permissions by %1%', array('%1%' => sfConfig::get('app_ui_label_informationobject'))); ?> </legend> <?php if (0 < count($informationObjects)) { ?>
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')); }