public function execute($request) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'read')) { QubitAcl::forwardToSecureAction(); } if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->date = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Acquisition date - This is a mandatory element.'))); $values['date'] = $this->resource->date; $validatorSchema->sourceOfAcquisition = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Source of acquisition - This is a mandatory element.'))); $values['sourceOfAcquisition'] = $this->resource->getSourceOfAcquisition(array('culltureFallback' => true)); $validatorSchema->locationInformation = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Location information - This is a mandatory element.'))); $values['locationInformation'] = $this->resource->getLocationInformation(array('culltureFallback' => true)); try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
public function execute($request) { parent::execute($request); $this->isaar = new sfIsaarPlugin($this->resource); if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Authorized form of name%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>')))); $values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('cultureFallback' => true)); $validatorSchema->datesOfExistence = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Dates of existence%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>')))); $values['datesOfExistence'] = $this->resource->getDatesOfExistence(array('cultureFallback' => true)); $validatorSchema->descriptionIdentifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Description identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.4.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>')))); $values['descriptionIdentifier'] = $this->resource->descriptionIdentifier; $validatorSchema->entityType = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Type of entity%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-2#5.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-2#4.7">', '%4%' => '</a>')))); $values['entityType'] = $this->resource->entityType; try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Get related information object by first grabbing top-level digital // object $parent = $this->resource->parent; if (isset($parent)) { $this->informationObject = $parent->informationObject; } else { $this->informationObject = $this->resource->informationObject; if (!isset($this->informationObject)) { $this->forward404(); } } // Check user authorization if (!QubitAcl::check($this->informationObject, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { // Delete the digital object record from the database $this->resource->delete(); // Redirect to edit page for parent Info Object if (isset($parent)) { $this->redirect(array($parent, 'module' => 'digitalobject', 'action' => 'edit')); } else { $this->redirect(array($this->informationObject, 'module' => 'informationobject')); } } }
public function execute($request) { parent::execute($request); $this->dc = new sfDcPlugin($this->resource); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a mandatory element.', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-identifier">', '%2%' => '</a>')))); $values['identifier'] = $this->resource->identifier; $validatorSchema->title = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Title%2% - This is a mandatory element.', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-title">', '%2%' => '</a>')))); $values['title'] = $this->resource->getTitle(array('cultureFallback' => true)); $validatorSchema->repository = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Relation%2% (%3%isLocatedAt%4%) - This is a mandatory element for this resource or one its higher descriptive levels (if part of a collection hierarchy).', array('%1%' => '<a href="http://dublincore.org/documents/dcmi-terms/#elements-relation">', '%2%' => '</a>', '%3%' => '<a href="http://dublincore.org/groups/collections/collection-application-profile/#colcldisLocatedAt">', '%4%' => '</a>')))); foreach ($this->resource->ancestors->andSelf() as $item) { $values['repository'] = $item->repository; if (isset($values['repository'])) { break; } } try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitActor(); // Make root actor the parent of new actors $this->resource->parentId = QubitActor::ROOT_ID; if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Add optimistic lock $this->form->setDefault('serialNumber', $this->resource->serialNumber); $this->form->setValidator('serialNumber', new sfValidatorInteger()); $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden()); } else { // Check user authorization against Actor ROOT if (!QubitAcl::check(QubitActor::getById(QubitActor::ROOT_ID), 'create')) { QubitAcl::forwardUnauthorized(); } } $this->form->setDefault('next', $this->request->getReferer()); $this->form->setValidator('next', new sfValidatorString()); $this->form->setWidget('next', new sfWidgetFormInputHidden()); }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Don't delete protected terms if ($this->resource->isProtected()) { $this->forward('admin', 'termPermission'); } // Check user authorization if (!QubitAcl::check($this->resource, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as $item) { if (QubitAcl::check($item, 'delete')) { $item->delete(); } } if (isset($this->resource->taxonomy)) { $this->redirect(array($this->resource->taxonomy, 'module' => 'taxonomy')); } $this->redirect(array('module' => 'taxonomy', 'action' => 'list')); } }
public function execute($request) { $this->resource = $this->getRoute()->resource; if (!$this->resource instanceof QubitTerm) { $this->forward404(); } // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->name = new sfValidatorCallback(array('callback' => array($this, 'checkForRepeatedNames'))); $values['name'] = $this->resource->getName(array('cultureFallback' => true)); try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } QubitTreeView::addAssets($this->response); }
public function execute($request) { $this->form = new sfForm(); $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = $this->getRoute()->resource; // Check that object exists and that it is not the root if (!isset($this->resource) || !isset($this->resource->parent)) { $this->forward404(); } // Check if already exists a digital object if (null !== ($digitalObject = $this->resource->getDigitalObject())) { $this->redirect(array($digitalObject, 'module' => 'digitalobject', 'action' => 'edit')); } // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Check repository file upload limit $repo = $this->resource->getRepository(array('inherit' => true)); if (null !== $repo && $repo->uploadLimit != -1 && $repo->getDiskUsage(array('units' => 'G')) >= floatval($repo->uploadLimit)) { $this->redirect(array($repo, 'module' => 'repository', 'action' => 'uploadLimitExceeded')); } // Add form fields $this->addFields($request); // Process form if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters(), $request->getFiles()); if ($this->form->isValid()) { $this->processForm(); $this->resource->save(); $this->redirect(array($this->resource, 'module' => 'informationobject')); } } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { $parent = $this->resource->parent; foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as $item) { // Delete related digitalObjects foreach ($item->digitalObjects as $digitalObject) { $digitalObject->informationObjectId = null; $digitalObject->delete(); } $item->delete(); } if (isset($parent->parent)) { $this->redirect(array($parent, 'module' => 'informationobject')); } $this->redirect(array('module' => 'informationobject', 'action' => 'browse')); } }
public function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitAccession(); if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } } else { // Check user authorization if (!QubitAcl::check($this->resource, 'create')) { QubitAcl::forwardUnauthorized(); } } $title = $this->context->i18n->__('Add new accession record'); if (isset($this->getRoute()->resource)) { if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title)); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); $this->relatedDonorComponent = new AccessionRelatedDonorComponent($this->context, 'accession', 'relatedDonor'); $this->relatedDonorComponent->resource = $this->resource; $this->relatedDonorComponent->execute($this->request); $this->rightEditComponent = new RightEditComponent($this->context, 'right', 'edit'); $this->rightEditComponent->resource = $this->resource; $this->rightEditComponent->execute($this->request); }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitDonor(); if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Add optimistic lock $this->form->setDefault('serialNumber', $this->resource->serialNumber); $this->form->setValidator('serialNumber', new sfValidatorInteger()); $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden()); } else { // Check user authorization if (!QubitAcl::check($this->resource, 'create')) { QubitAcl::forwardUnauthorized(); } } $title = $this->context->i18n->__('Add new donor'); if (isset($this->getRoute()->resource)) { if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title)); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); $this->contactInformationEditComponent = new ContactInformationEditComponent($this->context, 'contactinformation', 'editContactInformation'); $this->contactInformationEditComponent->resource = $this->resource; $this->contactInformationEditComponent->execute($this->request); }
public function execute($request) { parent::execute($request); $this->isdiah = new sfEhriIsdiahPlugin($this->resource); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $valuess = array(); $validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Authorized form of name%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>')))); $values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('culltureFallback' => true)); $validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>')))); $values['identifier'] = $this->resource->identifier; $validatorSchema->primaryContact = new sfValidatorAnd(array(new QubitValidatorCountable(), new sfValidatorOr(array(new sfValidatorSchema(array('city' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('countryCode' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('postalCode' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('region' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true)), new sfValidatorSchema(array('streetAddress' => new sfValidatorString(array('required' => true))), array('allow_extra_fields' => true))), array('required' => true), array('invalid' => $this->context->i18n->__('%1%Contact information%2% - You %3%must%4% at least include one of the following location or address fields: city, country, postal code, region or street address.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>'))))), array('required' => true), array('required' => $this->context->i18n->__('%1%Contact information%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-3#5.2.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-3#4.7">', '%4%' => '</a>')))); if (null !== $this->resource->getPrimaryContact()) { $values['primaryContact']['city'] = $this->resource->getPrimaryContact()->getCity(array('culltureFallback' => true)); $values['primaryContact']['countryCode'] = $this->resource->getPrimaryContact()->countryCode; $values['primaryContact']['postalCode'] = $this->resource->getPrimaryContact()->postalCode; $values['primaryContact']['region'] = $this->resource->getPrimaryContact()->getRegion(array('culltureFallback' => true)); $values['primaryContact']['streetAddress'] = $this->resource->getPrimaryContact()->streetAddress; } try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
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'))); } } }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { $accession = $this->resource->accession; $this->resource->delete(); $this->redirect(array($accession, 'module' => 'accession')); } }
public function execute($request) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource->informationObject, 'update')) { QubitAcl::forwardUnauthorized(); } // Set the digital object's attributes $this->resource->usageId = $request->usage_id; $this->resource->mediaTypeId = $request->media_type_id; // Save the digital object $this->resource->save(); // Return to edit page $this->redirect('digitalobject/edit?id=' . $this->resource->id); }
public function execute($request) { $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'read')) { QubitAcl::forwardUnauthorized(); } $criteria = new Criteria(); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID); $this->functions = QubitFunction::get($criteria); }
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')); }
/** * Show digital object representation * * @param sfWebRequest $request * * @todo add components for non-image digital objects */ public function execute($request) { // If type of display not specified, show a thumbnail if (!isset($this->usageType)) { $this->usageType = QubitTerm::THUMBNAIL_ID; } if (QubitTerm::REFERENCE_ID == $this->usageType && !QubitAcl::check($this->resource->informationObject, 'readReference')) { return sfView::NONE; } // Figure out which show component to call switch ($this->resource->mediaTypeId) { case QubitTerm::IMAGE_ID: if ($this->resource->showAsCompoundDigitalObject()) { $this->showComponent = 'showCompound'; } else { if ($this->resource->isWebCompatibleImageFormat()) { $this->showComponent = 'showImage'; } else { $this->showComponent = 'showDownload'; } } break; case QubitTerm::AUDIO_ID: $this->showComponent = 'showAudio'; break; case QubitTerm::VIDEO_ID: $this->showComponent = 'showVideo'; break; case QubitTerm::TEXT_ID: if ($this->resource->showAsCompoundDigitalObject()) { $this->showComponent = 'showCompound'; } else { $this->showComponent = 'showText'; } break; default: $this->showComponent = 'showDownload'; break; } if (!isset($this->link)) { $this->link = null; } if (!isset($this->iconOnly)) { $this->iconOnly = false; } }
public function execute($request) { parent::execute($request); $this->isad = new sfIsadPlugin($this->resource); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); // Function relations $criteria = new Criteria(); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID); $this->functionRelations = QubitRelation::get($criteria); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->creators = new QubitValidatorCountable(array('required' => true), array('required' => $this->context->i18n->__('This archival description, or one of its higher levels, %1%requires%2% at least one %3%creator%4%.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#3.2.1">', '%4%' => '</a>')))); foreach ($this->resource->ancestors->andSelf()->orderBy('rgt') as $item) { $values['creators'] = $item->getCreators(); if (0 < count($values['creators'])) { break; } } $validatorSchema->dateRange = new QubitValidatorIsadDates(array(), array('invalid' => $this->context->i18n->__('%1%Date(s)%2% - are not consistent with %3%higher levels%2%.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.3">', '%2%' => '</a>', '%3%' => '<a href="%ancestor%">')))); $values['dateRange'] = $this->resource; $validatorSchema->dates = new QubitValidatorCountable(array('required' => true), array('required' => $this->context->i18n->__('%1%Date(s)%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.3">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['dates'] = $this->resource->getDates(); $validatorSchema->extentAndMedium = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Extent and medium%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.5">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['extentAndMedium'] = $this->resource->getExtentAndMedium(array('cultureFallback' => true)); $validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['identifier'] = $this->resource->identifier; $this->addField($validatorSchema, 'levelOfDescription'); $validatorSchema->levelOfDescription->setMessage('forbidden', $this->context->i18n->__('%1%Level of description%2% - Value "%value%" is not consistent with higher levels.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.4">', '%2%' => '</a>'))); $validatorSchema->levelOfDescription->setMessage('required', $this->context->i18n->__('%1%Level of description%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.4">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>'))); if (isset($this->resource->levelOfDescription)) { $values['levelOfDescription'] = $this->resource->levelOfDescription->getName(array('sourceCulture' => true)); } $validatorSchema->title = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Title%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['title'] = $this->resource->getTitle(array('cultureFallback' => true)); try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { foreach ($this->resource->deaccessions as $item) { $item->delete(); } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'accession', 'action' => 'list')); } }
public function execute($request) { $this->group = QubitAclGroup::getById($request->id); if (!isset($this->group)) { $this->forward404(); } $criteria = new Criteria(); $criteria->add(QubitAclPermission::GROUP_ID, $this->group->id); $criteria->add(QubitAclPermission::ACTION, 'translate'); $criteria->add(QubitAclPermission::GRANT_DENY, 1); $this->translate = 'No'; if (null !== QubitAclPermission::getOne($criteria)) { $this->translate = 'Yes'; } // Require administrator credentials if (!QubitAcl::check($this->group, 'read')) { $this->redirect('admin/secure'); } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that object exists and that it is not the root if (!isset($this->resource) || !isset($this->resource->parent)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Add javascript libraries $this->response->addJavaScript('/vendor/yui/logger/logger', 'last'); $this->response->addJavaScript('/vendor/yui/uploader/uploader-min', 'last'); $this->response->addJavaScript('multiFileUpload', 'last'); // Get max upload size limits $this->maxUploadSize = QubitDigitalObject::getMaxUploadSize(); // Paths for uploader javascript $this->uploadSwfPath = "{$this->request->getRelativeUrlRoot()}/vendor/yui/uploader/assets/uploader.swf"; $this->uploadResponsePath = "{$this->context->routing->generate(null, array('module' => 'digitalobject', 'action' => 'upload'))}?" . http_build_query(array(session_name() => session_id())); $this->uploadTmpDir = "{$this->request->getRelativeUrlRoot()}/uploads/tmp"; // Build form $this->form->setValidator('files', new QubitValidatorCountable(array('required' => true))); $this->form->setValidator('title', new sfValidatorString()); $this->form->setWidget('title', new sfWidgetFormInput()); $this->form->setDefault('title', 'image %dd%'); $this->form->setValidator('levelOfDescription', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::LEVEL_OF_DESCRIPTION_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('levelOfDescription', new sfWidgetFormSelect(array('choices' => $choices))); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters(), $request->getFiles()); if ($this->form->isValid()) { $this->processForm(); } } }
public function execute($request) { $this->form = new sfForm(); $this->group = QubitAclGroup::getById($request->id); // Check that object exists if (!isset($this->group)) { $this->forward404(); } // Check if group is protected if ($this->group->isProtected()) { $this->forward('aclGroup', 'protected'); } // Check user authorization if (!QubitAcl::check($this->group, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { $this->group->delete(); $this->redirect(array('module' => 'aclGroup', 'action' => 'list')); } }
public function execute($request) { $this->form = new sfForm(); $this->timer = new QubitTimer(); $this->terms = array(); $this->termsPerPage = intval(sfConfig::get('app_hits_per_page')); $this->taxonomy = null; $this->parent = QubitTerm::getById(QubitTerm::ROOT_ID); if (isset($this->getRoute()->resource)) { $resource = $this->getRoute()->resource; if ('QubitTaxonomy' == $resource->className) { $this->taxonomy = QubitTaxonomy::getById($resource->id); } else { $this->parent = QubitTerm::getById($resource->id); $this->taxonomy = $this->parent->taxonomy; } } if (!isset($this->taxonomy)) { $this->forward404(); } // Check user authorization if (!QubitAcl::check($this->parent, 'create')) { QubitAcl::forwardUnauthorized(); } $this->form->setWidget('file', new sfWidgetFormInputFile()); $this->form->setValidator('file', new sfValidatorFile()); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters(), $request->getFiles()); if ($this->form->isValid()) { if (null !== ($file = $this->form->getValue('file'))) { $doc = new domDocument(); $doc->substituteEntities = true; $doc->load($file->getTempName()); $this->skos = sfSkosPlugin::parse($doc, array('taxonomy' => $this->taxonomy, 'parent' => $this->parent)); } } } else { $this->setTemplate('importSelect'); } }
/** * Show a representation of a digital object image. * * @param sfWebRequest $request * */ public function execute($request) { switch ($this->usageType) { case QubitTerm::REFERENCE_ID: $this->representation = $this->resource->getRepresentationByUsage(QubitTerm::REFERENCE_ID); break; case QubitTerm::THUMBNAIL_ID: $this->representation = $this->resource->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID); break; case QubitTerm::MASTER_ID: default: $this->representation = QubitDigitalObject::getGenericRepresentation($this->resource->mimeType, $this->usageType); } // If no representation found, then default to generic rep if (!$this->representation) { $this->representation = QubitDigitalObject::getGenericRepresentation($this->resource->mimeType, $this->usageType); } // Build a fully qualified URL to this digital object asset if ((QubitTerm::IMAGE_ID != $this->resource->mediaTypeId || QubitTerm::REFERENCE_ID == $this->usageType) && QubitAcl::check($this->resource->informationObject, 'readMaster')) { $this->link = public_path($this->resource->getFullPath(), true); } }
public function execute($request) { $this->group = QubitAclGroup::getById($request->id); $this->forward404Unless($this->group); // Check authorization if (!QubitAcl::check($this->group, 'read')) { $this->redirect('admin/secure'); } // Add roles $this->roles = array(); foreach ($this->group->ancestors->andSelf()->orderBy('lft') as $group) { // Omit ROOT group if (1 < $group->id) { $this->roles[] = $group->id; } } // Table width $this->tableCols = count($this->roles) + 3; // Get permissions for this group and parents $criteria = new Criteria(); $criteria->add(QubitAclPermission::GROUP_ID, $this->roles, Criteria::IN); // Add actor criteria $criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN); $c1 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor'); $c2 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL); $c1->addOr($c2); $criteria->add($c1); // Build ACL $this->acl = array(); if (0 < count($permissions = QubitAclPermission::get($criteria))) { foreach ($permissions as $permission) { // In this context permissions for all objects (null) and root actor // object are equivalent $objectId = QubitActor::ROOT_ID != $permission->objectId ? $permission->objectId : null; $this->acl[$objectId][$permission->action][$permission->groupId] = $permission; } } }
public function execute($request) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'read')) { QubitAcl::forwardUnauthorized(); } if (1 > strlen($title = $this->resource->__toString())) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Authorized form of name - This is a mandatory element.'))); $values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('cultureFallback' => true)); try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitRepository(); if (isset($this->getRoute()->resource)) { $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // Add optimistic lock $this->form->setDefault('serialNumber', $this->resource->serialNumber); $this->form->setValidator('serialNumber', new sfValidatorInteger()); $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden()); } else { // Check user authorization if (!QubitAcl::check($this->resource, 'create')) { QubitAcl::forwardUnauthorized(); } } $this->contactInformationEditComponent = new ContactInformationEditComponent($this->context, 'contactinformation', 'editContactInformation'); $this->contactInformationEditComponent->resource = $this->resource; $this->contactInformationEditComponent->execute($this->request); }
public function execute($request) { parent::execute($request); $this->isdf = new sfIsdfPlugin($this->resource); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->type = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Type%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-4#Type_of_description">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%' => '</a>')))); $values['type'] = $this->resource->type; $validatorSchema->authorizedFormOfName = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Authorized form of name%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-4#Authorised_name">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%' => '</a>')))); $values['authorizedFormOfName'] = $this->resource->getAuthorizedFormOfName(array('cultureFallback' => true)); $validatorSchema->descriptionIdentifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Description identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-4#Function.2Factivity_description_identifier">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-4#Structure_and_use_4.7">', '%4%' => '</a>')))); $values['descriptionIdentifier'] = $this->resource->descriptionIdentifier; try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }