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 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);
 }
Ejemplo n.º 3
0
 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);
 }
 public function execute($request)
 {
     $criteria = new Criteria();
     $criteria = QubitTaxonomy::addEditableTaxonomyCriteria($criteria);
     $criteria->addJoin(QubitTaxonomy::ID, QubitTaxonomyI18n::ID);
     $criteria->add(QubitTaxonomyI18n::CULTURE, $this->context->user->getCulture());
     // Narrow results by query
     if (0 < strlen($request->query)) {
         $criteria->add(QubitTaxonomyI18n::NAME, "{$request->query}%", Criteria::LIKE);
     }
     // Limit results by ACL
     $criterion = QubitAcl::getFilterCriterion($criteria, QubitTaxonomy::getById(QubitTaxonomy::ROOT_ID), 'createTerm');
     if (isset($criterion) && true !== $criterion) {
         $criteria->addAnd($criterion);
     } else {
         if (false === $criterion) {
             // If access denied to all taxonomies, then return nothing
             return sfView::NONE;
         }
     }
     // Sort by name
     $criteria->addAscendingOrderByColumn(QubitTaxonomyI18n::NAME);
     // Show first 10 results
     $criteria->setLimit(10);
     $this->taxonomies = QubitTaxonomy::get($criteria);
 }
 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)
 {
     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)
 {
     if (!$this->context->user->hasCredential(array('contributor', 'editor', 'administrator'), false)) {
         QubitAcl::forwardUnauthorized();
     }
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $criteria = new Criteria();
     switch ($request->sort) {
         case 'nameDown':
             $criteria->addDescendingOrderByColumn('identifier');
             break;
         case 'nameUp':
             $criteria->addAscendingOrderByColumn('identifier');
             break;
         case 'updatedDown':
             $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
             break;
         case 'updatedUp':
             $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT);
             break;
         default:
             if (!$this->getUser()->isAuthenticated()) {
                 $criteria->addAscendingOrderByColumn('authorized_form_of_name');
             } else {
                 $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
             }
     }
     // Page results
     $this->pager = new QubitPager('QubitAccession');
     $this->pager->setCriteria($criteria);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
 }
 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;
         }
     }
 }
Ejemplo n.º 9
0
 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)
 {
     if (!$this->getUser()->isAuthenticated()) {
         QubitAcl::forwardUnauthorized();
     }
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $criteria = new Criteria();
     // Do source culture fallback
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitPhysicalObject');
     switch ($request->sort) {
         case 'nameDown':
             $criteria->addDescendingOrderByColumn('name');
             break;
         case 'locationDown':
             $criteria->addDescendingOrderByColumn('location');
             break;
         case 'locationUp':
             $criteria->addAscendingOrderByColumn('location');
             break;
         case 'nameUp':
         default:
             $request->sort = 'nameUp';
             $criteria->addAscendingOrderByColumn('name');
     }
     // Page results
     $this->pager = new QubitPager('QubitPhysicalObject');
     $this->pager->setCriteria($criteria);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
 }
 public function execute($request)
 {
     $this->resource = $request->getAttribute('sf_route')->resource;
     $criteria = new Criteria();
     $criteria->add(QubitEvent::ACTOR_ID, $this->resource->id);
     $criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID, QubitInformationObject::ID);
     $criteria->addAscendingOrderByColumn(QubitEvent::TYPE_ID);
     // Sort info objects alphabetically (w/ fallback)
     $criteria->addAscendingOrderByColumn('title');
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitInformationObject');
     // Filter draft descriptions
     $criteria = QubitAcl::addFilterDraftsCriteria($criteria);
     $this->relatedInfoObjects = array();
     foreach (QubitEvent::get($criteria) as $item) {
         $this->relatedInfoObjects[$item->type->getRole()][] = $item->informationObject;
     }
     // Get "subject of" information objects (name access point)
     $criteria = new Criteria();
     $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
     $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
     $this->subjectInfoObjects = array();
     foreach (QubitRelation::get($criteria) as $item) {
         $this->subjectInfoObjects[] = $item->subject;
     }
 }
Ejemplo n.º 12
0
 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)
 {
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $this->resource = $this->getRoute()->resource;
     // Check that this isn't the root
     if (!isset($this->resource->parent)) {
         $this->forward404();
     }
     $query = QubitSearch::getInstance()->addTerm($this->resource->id, 'parentId');
     if (isset($request->query)) {
         $query = $request->query;
     }
     $query = QubitAcl::searchFilterByRepository($query, 'read');
     $query = QubitAcl::searchFilterDrafts($query);
     $this->pager = new QubitArrayPager();
     $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
     $ids = array();
     foreach ($this->pager->getResults() as $hit) {
         $ids[] = $hit->getDocument()->id;
     }
     $criteria = new Criteria();
     $criteria->add(QubitInformationObject::ID, $ids, Criteria::IN);
     $this->informationObjects = QubitInformationObject::get($criteria);
 }
Ejemplo n.º 15
0
 public function execute($request)
 {
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     if (isset($request->subquery)) {
         try {
             // Parse query string
             $query = QubitSearch::getInstance()->parse($request->subquery);
         } catch (Exception $e) {
             $this->error = $e->getMessage();
             return;
         }
     } else {
         $this->redirect(array('module' => 'actor', 'action' => 'browse'));
     }
     $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitActor', 'className'), true);
     $query = QubitAcl::searchFilterByResource($query, QubitActor::getById(QubitActor::ROOT_ID));
     $this->pager = new QubitArrayPager();
     try {
         $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
     } catch (Exception $e) {
         $this->error = $e->getMessage();
         return;
     }
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
     $ids = array();
     foreach ($this->pager->getResults() as $hit) {
         $ids[] = $hit->getDocument()->id;
     }
     $criteria = new Criteria();
     $criteria->add(QubitActor::ID, $ids, Criteria::IN);
     $this->actors = QubitActor::get($criteria);
 }
 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'));
         }
     }
 }
Ejemplo n.º 17
0
 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)
 {
     $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)
 {
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $criteria = new Criteria();
     if (isset($this->getRoute()->resource)) {
         $this->resource = $this->getRoute()->resource;
         $criteria->add(QubitInformationObject::PARENT_ID, $this->resource->id);
     } else {
         $criteria->add(QubitInformationObject::PARENT_ID, QubitInformationObject::ROOT_ID);
     }
     if (isset($request->repositoryId)) {
         $criteria->add(QubitInformationObject::REPOSITORY_ID, $request->repositoryId);
     }
     if (isset($request->collectionType)) {
         $criteria->add(QubitInformationObject::COLLECTION_TYPE_ID, $request->collectionType);
     }
     $fallbackTable = 'QubitInformationObject';
     switch ($request->sort) {
         case 'repositoryDown':
             $fallbackTable = 'QubitActor';
             $criteria->addJoin(QubitInformationObject::REPOSITORY_ID, QubitActor::ID, Criteria::LEFT_JOIN);
             $criteria->addDescendingOrderByColumn('authorized_form_of_name');
             break;
         case 'repositoryUp':
             $fallbackTable = 'QubitActor';
             $criteria->addJoin(QubitInformationObject::REPOSITORY_ID, QubitActor::ID, Criteria::LEFT_JOIN);
             $criteria->addAscendingOrderByColumn('authorized_form_of_name');
             break;
         case 'titleDown':
             $criteria->addDescendingOrderByColumn('title');
             break;
         case 'titleUp':
             $criteria->addAscendingOrderByColumn('title');
             break;
         case 'updatedDown':
             $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
             break;
         case 'updatedUp':
             $criteria->addAscendingOrderByColumn(QubitObject::UPDATED_AT);
             break;
         default:
             if (!$this->getUser()->isAuthenticated()) {
                 $criteria->addAscendingOrderByColumn('title');
             } else {
                 $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT);
             }
     }
     // Do source culture fallback
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, $fallbackTable);
     // Filter drafts
     $criteria = QubitAcl::addFilterDraftsCriteria($criteria);
     // Page results
     $this->pager = new QubitPager('QubitInformationObject');
     $this->pager->setCriteria($criteria);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     if (!$this->context->user->hasCredential('administrator')) {
         QubitAcl::forwardUnauthorized();
     }
     $criteria = new Criteria();
     $criteria->add(QubitSetting::NAME, 'plugins');
     if (1 == count($query = QubitSetting::get($criteria))) {
         $setting = $query[0];
         $this->form->setDefault('enabled', unserialize($setting->__get('value', array('sourceCulture' => true))));
     }
     $configuration = ProjectConfiguration::getActive();
     $pluginPaths = $configuration->getAllPluginPaths();
     foreach (sfPluginAdminPluginConfiguration::$pluginNames as $name) {
         unset($pluginPaths[$name]);
     }
     $this->plugins = array();
     foreach ($pluginPaths as $name => $path) {
         $className = $name . 'Configuration';
         if (sfConfig::get('sf_plugins_dir') == substr($path, 0, strlen(sfConfig::get('sf_plugins_dir'))) && is_readable($classPath = $path . '/config/' . $className . '.class.php')) {
             $this->installPluginAssets($name, $path);
             require_once $classPath;
             $class = new $className($configuration);
             // Build a list of themes
             if (isset($class::$summary) && 1 === preg_match('/theme/i', $class::$summary)) {
                 $this->plugins[$name] = $class;
             }
         }
     }
     if ($request->isMethod('post')) {
         $this->form->setValidators(array('enabled' => new sfValidatorChoice(array('choices' => array_keys($this->plugins), 'empty_value' => array(), 'multiple' => true))));
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             if (1 != count($query)) {
                 $setting = new QubitSetting();
                 $setting->name = 'plugins';
             }
             $settings = unserialize($setting->__get('value', array('sourceCulture' => true)));
             foreach (array_keys($this->plugins) as $item) {
                 if (in_array($item, (array) $this->form->getValue('enabled'))) {
                     $settings[] = $item;
                 } else {
                     if (false !== ($key = array_search($item, $settings))) {
                         unset($settings[$key]);
                     }
                 }
             }
             $setting->__set('value', serialize(array_unique($settings)));
             $setting->save();
             // Clear cache
             $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
             $cacheClear->run();
             $this->redirect(array('module' => 'sfPluginAdminPlugin', 'action' => 'themes'));
         }
     }
 }
 public function disableSecurity()
 {
     QubitAcl::getInstance()->acl = new StubAcl();
     // PHP 5.3 only, but this will soon be a minimum requirement?
     $this->browser->addListener('controller.change_action', function (sfEvent $event) {
         $controller = $event->getSubject();
         // Total HACK, disable sfBasicSecurityFilter
         sfConfig::set('sf_secure_module', $event->module);
         sfConfig::set('sf_secure_action', $event->action);
     });
 }
 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->form = new sfForm();
     $this->resource = $this->getRoute()->resource;
     // Check user authorization
     if ($this->resource->isProtected()) {
         QubitAcl::forwardUnauthorized();
     }
     if ($request->isMethod('delete')) {
         $this->resource->delete();
         $this->redirect(array('module' => 'staticpage', 'action' => 'list'));
     }
 }
 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();
     }
 }
Ejemplo n.º 25
0
 public function filterQuery($query)
 {
     // Limit search to current culture and info. objects
     $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitInformationObject', 'className'), true);
     $query->addSubquery(QubitSearch::getInstance()->addTerm($this->context->user->getCulture(), 'culture'), true);
     $query = QubitAcl::searchFilterByRepository($query, 'read');
     $query = QubitAcl::searchFilterDrafts($query);
     // Limit to a repository if in context
     if (isset($this->getRoute()->resource) && $this->getRoute()->resource instanceof QubitRepository) {
         $query->addSubquery(QubitSearch::getInstance()->addTerm($this->getRoute()->resource->id, 'repositoryId'), true);
         $this->title .= $this->context->i18n->__(' in %1%', array('%1%' => $this->getRoute()->resource->authorizedFormOfName));
     }
     return $query;
 }
 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);
 }
 protected function earlyExecute()
 {
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
     $this->form->getValidatorSchema()->setPostValidator(new sfValidatorSchemaCompare('password', '==', 'confirmPassword', array(), array('invalid' => $this->context->i18n->__('Your password confirmation did not match you password.'))));
     $this->resource = new QubitUser();
     if (isset($this->getRoute()->resource)) {
         $this->resource = $this->getRoute()->resource;
     }
     // Except for administrators, only allow users to reset their own password
     if (!$this->context->user->hasCredential('administrator')) {
         if ($this->resource->id != $this->context->user->getAttribute('user_id')) {
             QubitAcl::forwardToSecureAction();
         }
     }
 }
Ejemplo n.º 29
0
 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'));
 }