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->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 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')); } } }
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 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) { 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->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 (!$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) { $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')); } } }
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 ($this->resource->isProtected()) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { $this->resource->delete(); $this->redirect(array('module' => 'staticpage', 'action' => 'list')); } }
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->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->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'); } }
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(); $criteria->addDescendingOrderByColumn(QubitObject::UPDATED_AT); if (isset($request->subquery)) { $criteria->add(QubitAccession::IDENTIFIER, "%{$request->subquery}%", Criteria::LIKE); } else { $this->redirect(array('module' => 'function', 'action' => 'browse')); } // Page results $this->pager = new QubitPager('QubitAccession'); $this->pager->setCriteria($criteria); $this->pager->setMaxPerPage($request->limit); $this->pager->setPage($request->page); $this->accessions = $this->pager->getResults(); }
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; } } }
public function execute($request) { $this->resource = $this->getRoute()->resource; if (!isset($this->resource)) { $this->forward404(); } if (!$this->getUser()->isAuthenticated()) { QubitAcl::forwardUnauthorized(); } $criteria = new Criteria(); $criteria->setDistinct(); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_EQUAL); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_EQUAL); $criteria->add(QubitRelation::TYPE_ID, QubitTerm::HAS_PHYSICAL_OBJECT_ID); $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitPhysicalObject::ID); $this->physicalObjects = QubitPhysicalObject::get($criteria); if (0 == count($this->physicalObjects)) { return sfView::ERROR; } $c2 = clone $criteria; $this->foundcount = BasePeer::doCount($c2)->fetchColumn(0); }
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'); } 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' => 'donor', 'action' => 'browse')); } $query->addSubquery(QubitSearch::getInstance()->addTerm('QubitDonor', 'className'), true); $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(QubitDonor::ID, $ids, Criteria::IN); $this->donors = QubitDonor::get($criteria); }
/** * Executes index action * */ public function execute($request) { if (!QubitAcl::check('userInterface', 'translate')) { QubitAcl::forwardUnauthorized(); } $user = $this->context->user; $error = array(); $status = array(); $messageSource = $this->context->i18n->getMessageSource(); $sourceMessages = $request->getParameter('source', array()); $targetMessages = $request->getParameter('target', array()); foreach ($sourceMessages as $key => $sourceMessage) { if (!$messageSource->update($sourceMessage, $targetMessages[$key], null)) { $error[] = $sourceMessage . $targetMessages[$key]; } else { $status[] = $sourceMessage . $targetMessages[$key]; } } if (!empty($error)) { $this->forward($user->getAttribute('moduleName', 'default', 'sfHistoryPlugin'), $user->getAttribute('actionName', 'index', 'sfHistoryPlugin')); } $messageSource->getCache()->clean(); $this->redirect($request->getReferer()); }
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 static function searchFilterByRepository($query, $action) { $repositoryAccess = QubitAcl::getRepositoryAccess($action); if (1 == count($repositoryAccess)) { // If all repositories are denied access, re-route user to login if (QubitAcl::DENY == $repositoryAccess[0]['access']) { QubitAcl::forwardUnauthorized(); } } else { while ($repo = array_shift($repositoryAccess)) { if ('*' == $repo['id']) { if (QubitAcl::DENY == $repo['access']) { // Require repos to be specifically allowed (all others prohibited) $query->addSubquery(QubitSearch::getInstance()->addTerm($repo['id'], 'repositoryId'), true); } else { // Prohibit specified repos (all others allowed) $query->addSubquery(QubitSearch::getInstance()->addTerm($repo['id'], 'repositoryId'), false); } } } } return $query; }
public function execute($request) { // Default items per page if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that the object exists and that it is not the root if (!isset($this->resource) || !isset($this->resource->parent)) { $this->forward404(); } // Check authorization if (!QubitAcl::check($this->resource, 'update')) { QubitAcl::forwardUnauthorized(); } // "parent" form field $this->form->setValidator('parent', new sfValidatorString(array('required' => true))); $this->form->setWidget('parent', new sfWidgetFormInputHidden()); // Root is default parent if ($this->resource instanceof QubitInformationObject) { $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitInformationObject::getById(QubitInformationObject::ROOT_ID), 'module' => 'informationobject')))); } else { if ($this->resource instanceof QubitTerm) { $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term')))); } } if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue())); // In term treeview, root node links (href) to taxonomy, but it represents the term root object if ($this->resource instanceof QubitTerm && QubitObject::getById($params['_sf_route']->resource->id) instanceof QubitTaxonomy) { $this->resource->parentId = QubitTerm::ROOT_ID; } else { $this->resource->parentId = $params['_sf_route']->resource->id; } $this->resource->save(); if ($request->isXmlHttpRequest()) { return $this->renderText(''); } else { if ($this->resource instanceof QubitInformationObject) { $this->redirect(array($this->resource, 'module' => 'informationobject')); } else { if ($this->resource instanceof QubitTerm) { $this->redirect(array($this->resource, 'module' => 'term')); } } } } } $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue())); $this->parent = QubitObject::getById($params['_sf_route']->resource->id); $query = QubitSearch::getInstance()->addTerm($this->parent->slug, 'parent'); if (isset($request->query)) { $query = $request->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(QubitObject::ID, $ids, Criteria::IN); $this->results = QubitObject::get($criteria); }
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')); }
public function execute($request) { $this->form = new sfForm(); $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = $this->getRoute()->resource; // Check that resource exists if (!isset($this->resource)) { $this->forward404(); } $this->informationObject = $this->resource->informationObject; // Check user authorization if (!QubitAcl::check($this->informationObject, 'update')) { QubitAcl::forwardUnauthorized(); } // Get representations $this->representations = array(QubitTerm::REFERENCE_ID => $this->resource->getChildByUsageId(QubitTerm::REFERENCE_ID), QubitTerm::THUMBNAIL_ID => $this->resource->getChildByUsageId(QubitTerm::THUMBNAIL_ID)); $this->addFormFields(); // Process forms if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters(), $request->getFiles()); if ($this->form->isValid()) { $this->processForm(); $this->resource->save(); $this->redirect(array($this->informationObject, 'module' => 'informationobject')); } } }
protected function earlyExecute() { $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); $this->resource = new QubitInformationObject(); // Edit 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::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()); } else { if (isset($this->request->source)) { $this->resource = QubitInformationObject::getById($this->request->source); // 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, 'create')) { QubitAcl::forwardUnauthorized(); } // Store source label $this->sourceInformationObjectLabel = new sfIsadPlugin($this->resource); // Remove identifier unset($this->resource->identifier); // Inherit parent level $this->form->setDefault('parent', $this->context->routing->generate(null, array($this->resource->parent, 'module' => 'informationobject'))); $this->form->setValidator('parent', new sfValidatorString()); $this->form->setWidget('parent', new sfWidgetFormInputHidden()); // Add id of the information object source $this->form->setDefault('sourceId', $this->request->source); $this->form->setValidator('sourceId', new sfValidatorInteger()); $this->form->setWidget('sourceId', new sfWidgetFormInputHidden()); // Set publication status to "draft" $this->resource->setPublicationStatus(sfConfig::get('app_defaultPubStatus', QubitTerm::PUBLICATION_STATUS_DRAFT_ID)); } else { $this->form->setValidator('parent', new sfValidatorString()); $this->form->setWidget('parent', new sfWidgetFormInputHidden()); $getParams = $this->request->getGetParameters(); if (isset($getParams['parent'])) { $params = $this->context->routing->parse(Qubit::pathInfo($getParams['parent'])); $this->parent = $params['_sf_route']->resource; $this->form->setDefault('parent', $getParams['parent']); } else { // Root is default parent $this->parent = QubitInformationObject::getById(QubitInformationObject::ROOT_ID); $this->form->setDefault('parent', $this->context->routing->generate(null, array($this->parent, 'module' => 'informationobject'))); } // Check authorization if (!QubitAcl::check($this->parent, 'create')) { QubitAcl::forwardUnauthorized(); } } } }