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); }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitTerm(); $title = $this->context->i18n->__('Add new term'); if (isset($this->getRoute()->resource)) { $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(); } // Check authorization if (!QubitAcl::check($this->resource, 'update') && !QubitAcl::check($this->resource, 'translate')) { QubitAcl::forwardUnauthorized(); } // Add optimistic lock $this->form->setDefault('serialNumber', $this->resource->serialNumber); $this->form->setValidator('serialNumber', new sfValidatorInteger()); $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden()); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title)); QubitTreeView::addAssets($this->response); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); }
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::forwardToSecureAction(); } if ('print' == $request->getGetParameter('media', 'screen')) { $this->getResponse()->addStylesheet('print-preview', 'last'); } // Only show link to view/download master copy of digital object if the // user has readMaster permissions OR it's a text object (to allow reading) $this->digitalObjectLink = null; if (0 < count($this->resource->digitalObjects) && (QubitAcl::check($this->resource, 'readMaster') || in_array($this->resource->digitalObjects[0]->mediaTypeId, array(QubitTerm::TEXT_ID, QubitTerm::AUDIO_ID)))) { if (QubitTerm::EXTERNAL_URI_ID == $this->resource->digitalObjects[0]->usageId) { $this->digitalObjectLink = $this->resource->digitalObjects[0]->path; } else { $this->digitalObjectLink = $request->getUriPrefix() . $request->getRelativeUrlRoot() . $this->resource->digitalObjects[0]->getFullPath(); } } QubitImageFlow::addAssets($this->response); QubitTreeView::addAssets($this->response); }
public function execute($request) { parent::execute($request); if ($request->hasParameter('csvimport')) { // if a parent ID is set, use that for parenting $parentId = $request->getParameter('parent', null); if (!empty($parentId)) { $request->getParameterHolder()->remove('parent'); } // make sure we don't pass the import ID $request->getParameterHolder()->remove('id'); $this->form->bind($request->getParameterHolder()->getAll()); if ($this->form->isValid()) { $this->processForm(); if (!empty($parentId)) { $this->resource->parent = QubitInformationObject::getById($parentId); } else { $this->resource->parent = QubitInformationObject::getById(QubitInformationObject::ROOT_ID); } $this->resource->save(); return; // don't bother adding assets etc. for output } } elseif ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $this->processForm(); $this->resource->save(); $this->redirect(array($this->resource, 'module' => 'informationobject')); } } QubitDescription::addAssets($this->response); QubitImageFlow::addAssets($this->response); QubitTreeView::addAssets($this->response); }