Author: david
Date: Tue Nov 24 14:15:01 2009
New Revision: 3953
Log:
Basic ISDF update working.
Modified:
trunk/apps/qubit/modules/function/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/function/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/function/actions/editAction.class.php Tue Nov
24 13:57:12 2009 (r3952)
+++ trunk/apps/qubit/modules/function/actions/editAction.class.php Tue Nov
24 14:15:01 2009 (r3953)
@@ -148,33 +148,33 @@
}
}
- public function execute($request)
- {
- $this->form = new sfForm;
-
- $this->func = new QubitFunction;
- if (isset($request->id))
+ protected function processField($field)
+ {
+ switch ($name = $field->getName())
{
- $this->func = QubitFunction::getById($request->id);
+ case 'type':
+ case 'descriptionStatus':
+ case 'descriptionDetail':
+ $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $this->form->getValue($name)));
+ $fieldId = (isset($params['id'])) ? $params['id'] : null;
+ $this->func[$name.'Id'] = $fieldId;
- if (!isset($this->func))
- {
- $this->forward404();
- }
+ break;
- // Add optimistic lock
- $this->form->setDefault('serialNumber', $this->func->serialNumber);
- $this->form->setValidator('serialNumber', new sfValidatorInteger);
- $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
+ default:
+ $this->func[$field->getName()] =
$this->form->getValue($field->getName());
}
+ }
- // HACK: Use static::$NAMES in PHP 5.3,
- // http://php.net/oop5.late-static-bindings
- $class = new ReflectionClass($this);
- foreach ($class->getStaticPropertyValue('NAMES') as $name)
+ protected function processForm()
+ {
+ foreach ($this->form as $field)
{
- $this->addField($name);
+ if (isset($this->request[$field->getName()]))
+ {
+ $this->processField($field);
+ }
}
//Other Forms of Name
@@ -202,45 +202,69 @@
//$this->eventTypes =
QubitTerm::getOptionsForSelectList(QubitTaxonomy::EVENT_TYPE_ID);
//$this->resourceTypeTerms =
array(QubitTerm::getById(QubitTerm::ARCHIVAL_MATERIAL_ID));
- if ($request->isMethod('post'))
+ // TODO
+ //$this->updateTermOneToManyRelations();
+ //$this->updateProperties();
+ //$this->updateActorRelations();
+ //$this->deleteActorRelations();
+ //$this->updateEvents();
+ //$this->deleteEvents();
+ //$this->updateNotes();
+ //$this->deleteNotes();
+
+ // Save function after updating it's attributes
+ $this->func->save();
+ }
+
+ public function execute($request)
+ {
+ $this->form = new sfForm;
+ $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+ $this->func = new QubitFunction;
+
+ if (isset($request->id))
{
- // TODO
- //$this->updateFunctionAttributes();
- //$this->updateTermOneToManyRelations();
- //$this->updateProperties();
- //$this->updateActorRelations();
- //$this->deleteActorRelations();
- //$this->updateEvents();
- //$this->deleteEvents();
- //$this->updateNotes();
- //$this->deleteNotes();
-
- $this->func->save();
-
- //$this->updateOtherNames();
-
- $this->redirect(array('module' => 'function', 'action' => 'edit', 'id'
=> $this->func->getId()));
+ $this->func = QubitFunction::getById($request->id);
+
+ if (!isset($this->func))
+ {
+ $this->forward404();
+ }
+
+ // Add optimistic lock
+ $this->form->setDefault('serialNumber', $this->func->serialNumber);
+ $this->form->setValidator('serialNumber', new sfValidatorInteger);
+ $this->form->setWidget('serialNumber', new sfWidgetFormInputHidden);
}
- }
- public function updateFunctionAttributes()
- {
-
$this->func->setAuthorizedFormOfName($this->getRequestParameter('authorized_form_of_name'));
-
$this->func->setDatesOfExistence($this->getRequestParameter('dates_of_existence'));
-
$this->func->setCorporateBodyIdentifiers($this->getRequestParameter('corporate_body_identifiers'));
- $this->func->setHistory($this->getRequestParameter('history'));
- $this->func->setPlaces($this->getRequestParameter('places'));
- $this->func->setLegalStatus($this->getRequestParameter('legal_status'));
- $this->func->setFunctions($this->getRequestParameter('functions'));
- $this->func->setMandates($this->getRequestParameter('mandates'));
-
$this->func->setInternalStructures($this->getRequestParameter('internal_structures'));
-
$this->func->setGeneralContext($this->getRequestParameter('general_context'));
-
$this->func->setDescriptionIdentifier($this->getRequestParameter('description_identifier'));
-
$this->func->setInstitutionResponsibleIdentifier($this->getRequestParameter('institution_responsible_identifier'));
- $this->func->setRules($this->getRequestParameter('rules'));
- $this->func->setSources($this->getRequestParameter('sources'));
-
$this->func->setRevisionHistory($this->getRequestParameter('revision_history'));
+ // Determine if user has edit priviliges
+ $this->editTaxonomyCredentials = false;
+ if (SecurityPriviliges::editCredentials($this->getUser(), 'term'))
+ {
+ $this->editTaxonomyCredentials = true;
+ }
+
+ // HACK: Use static::$NAMES in PHP 5.3,
+ // http://php.net/oop5.late-static-bindings
+ $class = new ReflectionClass($this);
+ foreach ($class->getStaticPropertyValue('NAMES') as $name)
+ {
+ $this->addField($name);
+ }
+
+ if ($request->isMethod('post'))
+ {
+ $this->form->bind($request->getPostParameters());
+ $this->processForm();
+ if ($this->form->isValid())
+ {
+ $this->processForm();
+
+ $this->redirect(array('module' => 'function', 'action' => 'edit', 'id'
=> $this->func->id));
+ }
+ }
}
public function updateOtherNames()
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.