public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; if ($request->isMethod('delete')) { foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'rightsholder', 'action' => 'browse')); } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; if ($request->isMethod('delete')) { foreach ($this->resource->informationObjects as $item) { unset($item->repository); $item->save(); } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'repository', 'action' => 'browse')); } }
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 this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } if ($request->isMethod('delete')) { foreach ($this->resource->events as $item) { if (isset($item->informationObject) && isset($item->type)) { unset($item->actor); $item->save(); } else { $item->delete(); } } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $relation) { $relation->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'actor', 'action' => 'browse')); } }
/** * Override base delete method to unlink related digital assets (thumbnail * and file) * * @param sfConnection A database connection */ public function delete($connection = null) { $criteria = new Criteria(); $criteria->add(QubitDigitalObject::PARENT_ID, $this->id); $children = QubitDigitalObject::get($criteria); // Delete children foreach ($children as $child) { foreach (QubitRelation::getBySubjectOrObjectId($this->id) as $item) { $item->delete(); } $child->delete(); } // Delete digital asset if (file_exists($this->getAbsolutePath())) { unlink($this->getAbsolutePath()); } // Prune asset directory, if empty self::pruneEmptyDirs(sfConfig::get('sf_web_dir') . $this->path); foreach (QubitRelation::getBySubjectOrObjectId($this->id) as $item) { $item->delete(); } // Update search index before deleting self if (!empty($this->informationObjectId)) { QubitSearch::updateInformationObject($this->getInformationObject()); } // Delete self parent::delete($connection); }
?> <?php foreach ($term->getChildren() as $child) { ?> <skos:narrower rdf:resource="<?php echo url_for(array($child, 'module' => 'term'), true); ?> "/> <?php } // children ?> <?php if (0 < count($relations = QubitRelation::getBySubjectOrObjectId($term->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)))) { ?> <?php foreach ($relations as $relation) { ?> <skos:related rdf:resource="<?php echo url_for(array($relation->getOpposedObject($term->id), 'module' => 'term'), true); ?> "/> <?php } ?> <?php } ?>
<div class="field"> <h3><?php echo __('Associated terms'); ?> </h3> <div> <div class="field"> <h3><?php echo render_title($resource); ?> </h3> <div> <ul> <?php foreach (QubitRelation::getBySubjectOrObjectId($resource->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)) as $item) { ?> <li><?php echo __('RT %1%', array('%1%' => link_to(render_title($item->getOpposedObject($resource->id)), array($item->getOpposedObject($resource->id), 'module' => 'term')))); ?> </li> <?php } ?> </ul> </div> </div> </div> </div>
protected function addField($name) { switch ($name) { case 'code': $this->form->setDefault('code', $this->resource->code); $this->form->setValidator('code', new sfValidatorString()); $this->form->setWidget('code', new sfWidgetFormInput()); break; case 'displayNote': case 'scopeNote': case 'sourceNote': $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); switch ($name) { case 'scopeNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SCOPE_NOTE_ID); break; case 'sourceNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SOURCE_NOTE_ID); break; case 'displayNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::DISPLAY_NOTE_ID); break; } $value = $defaults = array(); foreach ($this[$name] = QubitNote::get($criteria) as $item) { $defaults[$value[] = $item->id] = $item; } $this->form->setDefault($name, $value); $this->form->setValidator($name, new sfValidatorPass()); $this->form->setWidget($name, new QubitWidgetFormInputMany(array('defaults' => $defaults, 'fieldname' => 'content'))); break; case 'name': $this->form->setDefault('name', $this->resource->name); $this->form->setValidator('name', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $this->form->setWidget('name', new sfWidgetFormInput()); break; case 'narrowTerms': $this->form->setValidator('narrowTerms', new sfValidatorPass()); $this->form->setWidget('narrowTerms', new QubitWidgetFormInputMany(array('defaults' => array()))); break; case 'parent': $this->form->setDefault('parent', $this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))); $this->form->setValidator('parent', new sfValidatorString()); $choices = array(); if (isset($this->resource->parent)) { $choices[$this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))] = $this->resource->parent; } if (isset($this->request->parent)) { $this->form->setDefault('parent', $this->request->parent); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->parent)); $choices[$this->request->parent] = $params['_sf_route']->resource; } $this->form->setWidget('parent', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'relatedTerms': $value = $choices = array(); foreach ($this->relations = QubitRelation::getBySubjectOrObjectId($this->resource->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)) as $item) { $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'term'))] = $item->object; } $this->form->setDefault('relatedTerms', $value); $this->form->setValidator('relatedTerms', new sfValidatorPass()); $this->form->setWidget('relatedTerms', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true))); break; case 'taxonomy': $this->form->setDefault('taxonomy', $this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))); $this->form->setValidator('taxonomy', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $choices = array(); if (isset($this->resource->taxonomy)) { $choices[$this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))] = $this->resource->taxonomy; } if (isset($this->request->taxonomy)) { $this->form->setDefault('taxonomy', $this->request->taxonomy); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->taxonomy)); $choices[$this->request->taxonomy] = $params['_sf_route']->resource; } $this->form->setWidget('taxonomy', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'useFor': $criteria = new Criteria(); $criteria->add(QubitOtherName::OBJECT_ID, $this->resource->id); $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::ALTERNATIVE_LABEL_ID); $value = $defaults = array(); foreach ($this->useFor = QubitOtherName::get($criteria) as $item) { $defaults[$value[] = $item->id] = $item; } $this->form->setDefault('useFor', $value); $this->form->setValidator('useFor', new sfValidatorPass()); $this->form->setWidget('useFor', new QubitWidgetFormInputMany(array('defaults' => $defaults))); break; default: return parent::addField($name); } }