Author: jablko
Date: Mon Oct 18 20:23:52 2010
New Revision: 8260

Log:
Add ISAAR relationships components

Added:
   
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
      - copied, changed from r8258, 
trunk/apps/qubit/modules/actor/actions/editAction.class.php
   
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedResourceComponent.class.php
      - copied, changed from r8258, 
trunk/apps/qubit/modules/actor/actions/editAction.class.php
Modified:
   trunk/apps/qubit/modules/actor/actions/editAction.class.php
   trunk/apps/qubit/modules/relation/actions/indexAction.class.php
   trunk/apps/qubit/modules/user/actions/loginAction.class.php
   
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/editAction.class.php
   trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/editSuccess.php

Modified: trunk/apps/qubit/modules/actor/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/editAction.class.php Mon Oct 18 
20:05:10 2010        (r8259)
+++ trunk/apps/qubit/modules/actor/actions/editAction.class.php Mon Oct 18 
20:23:52 2010        (r8260)
@@ -119,69 +119,6 @@
 
         break;
 
-      case 'relatedActor[authorizedFormOfName]':
-      case 'relatedResource[informationObject]':
-        $choices = array();
-
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $choices)));
-
-        break;
-
-      case 'relatedActor[type]':
-        $this->form->setValidator('relatedActor[type]', new sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID) as $item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('relatedActor[type]', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
-      case 'relatedResource[type]':
-        $this->form->setValidator('relatedResource[type]', new 
sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::EVENT_TYPE_ID) as 
$item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('relatedResource[type]', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
-      case 'relatedResource[resourceType]':
-        $term = QubitTerm::getById(QubitTerm::ARCHIVAL_MATERIAL_ID);
-
-        $this->form->setValidator('relatedResource[resourceType]', new 
sfValidatorString);
-        $this->form->setDefault('relatedResource[resourceType]', 
$this->context->routing->generate(null, array($term, 'module' => 'term')));
-        $this->form->setWidget('relatedResource[resourceType]', new 
sfWidgetFormSelect(array('choices' => 
array($this->context->routing->generate(null, array($term, 'module' => 'term')) 
=> $term))));
-
-        break;
-
-      case 'relatedActor[dateDisplay]':
-      case 'relatedActor[endDate]':
-      case 'relatedActor[startDate]':
-      case 'relatedResource[dateDisplay]':
-      case 'relatedResource[endDate]':
-      case 'relatedResource[startDate]':
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormInput);
-
-        break;
-
-      case 'relatedActor[description]':
-        $this->form->setValidator('relatedActor[description]', new 
sfValidatorString);
-        $this->form->setWidget('relatedActor[description]', new 
sfWidgetFormTextarea);
-
-        break;
-
       default:
 
         return parent::addField($name);
@@ -216,16 +153,6 @@
     }
   }
 
-  protected function processForm()
-  {
-    $this->updateActorRelations();
-    $this->deleteActorRelations();
-    $this->updateEvents();
-    $this->deleteEvents();
-
-    return parent::processForm();
-  }
-
   public function execute($request)
   {
     parent::execute($request);
@@ -248,185 +175,4 @@
 
     QubitDescription::addAssets($this->response);
   }
-
-  /**
-   * Update actor relationships
-   */
-  protected function updateActorRelations()
-  {
-    if (isset($this->request->relatedActors))
-    {
-      // JavaScript (multiple) update
-      $relationsData = $this->request->relatedActors;
-    }
-    else if (isset($this->request->relatedActor))
-    {
-      // Non-JavaScript (single) update
-      $relationsData = array($this->request->relatedActor);
-    }
-    else
-    {
-      return;
-    }
-
-    // Loop through related actors
-    foreach ($relationsData as $relationData)
-    {
-      // Get related actor
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['authorizedFormOfName']));
-      $relatedObjectId = (isset($params['id'])) ? $params['id'] : null;
-      if (null === $relatedObject = QubitActor::getById($relatedObjectId))
-      {
-        continue; // If no related object, skip update
-      }
-
-      // Get relation
-      if (isset($relationData['id']))
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
-        if (null === $relation = QubitRelation::getById($params['id']))
-        {
-          // If a relation id is passed, but relation object doesn't exist then
-          // skip this row
-          continue;
-        }
-      }
-      else
-      {
-        $relation = new QubitRelation;
-      }
-
-      // Set category (typeId)
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['type']));
-      $typeId = (isset($params['id'])) ? $params['id'] : null;
-      $relation->typeId = $typeId;
-
-      $relation->startDate = $relationData['startDate'];
-      $relation->endDate = $relationData['endDate'];
-
-      // Add notes
-      $relation->updateNote($relationData['description'], 
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
-      $relation->updateNote($relationData['dateDisplay'], 
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
-      // Default to current actor as the subject of the relationship
-      if ($relation->subjectId == $this->resource->id || null == 
$relation->subjectId)
-      {
-        $relation->object = $relatedObject;
-        $this->resource->relationsRelatedBysubjectId[] = $relation;
-      }
-      else
-      {
-        $relation->subject = $relatedObject;
-        $this->resource->relationsRelatedByobjectId[] = $relation;
-      }
-    }
-
-    return $this;
-  }
-
-  protected function deleteActorRelations()
-  {
-    if (isset($this->request->deleteRelations))
-    {
-      foreach ((array) $this->request->deleteRelations as $relationId => 
$value)
-      {
-        $relation = QubitRelation::getById($relationId);
-        $relation->delete();
-      }
-    }
-  }
-
-  /**
-   * Add or update events related to this actor
-   *
-   * @return ActorEditAction this object
-   */
-  protected function updateEvents()
-  {
-    if (isset($this->request->relatedResources))
-    {
-      // The "updateEvents" array is created by the actorEventDialog.js
-      $updateEvents = $this->request->relatedResources;
-    }
-    else if (isset($this->request->relatedResource))
-    {
-      // The "newEvent" array means a non-JavaScript form submission
-      $updateEvents = array($this->request->relatedResource);
-    }
-    else
-    {
-      return;
-    }
-
-    // Loop through actor events
-    foreach ($updateEvents as $eventFormData)
-    {
-      // Create new event or update an existing one
-      if (isset($eventFormData['id']))
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['id']));
-        if (null === $event = QubitEvent::getById($params['id']))
-        {
-          continue; // If we can't find the object, then skip this row
-        }
-      }
-      else
-      {
-        $event = new QubitEvent;
-      }
-
-      // Assign resource to event
-      if (0 == strlen($eventFormData['informationObject']))
-      {
-        continue; // If no resource name, don't update event
-      }
-      else
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['informationObject']));
-
-        // Assign resource to event
-        $event->informationObjectId = $params['id'];
-      }
-
-      // Set type
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['type']));
-
-      unset($event->type);
-      if (isset($params['id']))
-      {
-        $event->typeId = $params['id'];
-      }
-
-      // Update other event properties
-      $event->dateDisplay = $eventFormData['dateDisplay'];
-      $event->startDate = $eventFormData['startDate'];
-      $event->endDate = $eventFormData['endDate'];
-
-      $this->resource->events[] = $event;
-    }
-
-    return $this;
-  }
-
-  /**
-   * Delete related events that are marked for deletion.
-   *
-   * @return ActorEditAction $this object
-   */
-  public function deleteEvents()
-  {
-    if (is_array($deleteEvents = $this->request->deleteEvents))
-    {
-      foreach ($deleteEvents as $deleteId => $doDelete)
-      {
-        if (null !== $event = QubitEvent::getById($deleteId))
-        {
-          $event->delete();
-        }
-      }
-    }
-
-    return $this;
-  }
 }

Modified: trunk/apps/qubit/modules/relation/actions/indexAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/relation/actions/indexAction.class.php     Mon Oct 
18 20:05:10 2010        (r8259)
+++ trunk/apps/qubit/modules/relation/actions/indexAction.class.php     Mon Oct 
18 20:23:52 2010        (r8260)
@@ -50,17 +50,17 @@
 
     if (isset($this->resource->object))
     {
-      $value['object'] = $this->context->routing->generate(null, 
array($this->resource->object, 'module' => 'default'));
+      $value['object'] = $this->context->routing->generate(null, 
array($this->resource->object));
     }
 
     if (isset($this->resource->subject))
     {
-      $value['subject'] = $this->context->routing->generate(null, 
array($this->resource->subject, 'module' => 'default'));
+      $value['subject'] = $this->context->routing->generate(null, 
array($this->resource->subject));
     }
 
     if (isset($this->resource->type))
     {
-      $value['type'] = $this->context->routing->generate(null, 
array($this->resource->type));
+      $value['type'] = $this->context->routing->generate(null, 
array($this->resource->type, 'module' => 'term'));
     }
 
     return $this->renderText(json_encode($value));

Modified: trunk/apps/qubit/modules/user/actions/loginAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/user/actions/loginAction.class.php Mon Oct 18 
20:05:10 2010        (r8259)
+++ trunk/apps/qubit/modules/user/actions/loginAction.class.php Mon Oct 18 
20:23:52 2010        (r8260)
@@ -48,7 +48,6 @@
     if ($request->isMethod('post'))
     {
       $this->form->bind($request->getPostParameters());
-
       if ($this->form->isValid())
       {
         if ($this->getUser()->authenticate($this->form->getValue('email'), 
$this->form->getValue('password')))

Modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/editAction.class.php
==============================================================================
--- 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/editAction.class.php  
    Mon Oct 18 20:05:10 2010        (r8259)
+++ 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/editAction.class.php  
    Mon Oct 18 20:23:52 2010        (r8260)
@@ -49,18 +49,6 @@
       'otherName',
       'parallelName',
       'places',
-      'relatedActor[authorizedFormOfName]',
-      'relatedActor[dateDisplay]',
-      'relatedActor[endDate]',
-      'relatedActor[description]',
-      'relatedActor[startDate]',
-      'relatedActor[type]',
-      'relatedResource[dateDisplay]',
-      'relatedResource[endDate]',
-      'relatedResource[informationObject]',
-      'relatedResource[resourceType]',
-      'relatedResource[startDate]',
-      'relatedResource[type]',
       'revisionHistory',
       'rules',
       'script',
@@ -85,6 +73,14 @@
     }
 
     $this->response->setTitle("$title - {$this->response->getTitle()}");
+
+    $this->relatedAuthorityRecordComponent = new 
sfIsaarPluginRelatedAuthorityRecordComponent($this->context, 'sfIsaarPlugin', 
'relatedAuthorityRecord');
+    $this->relatedAuthorityRecordComponent->resource = $this->resource;
+    $this->relatedAuthorityRecordComponent->execute($this->request);
+
+    $this->relatedResourceComponent = new 
sfIsaarPluginRelatedResourceComponent($this->context, 'sfIsaarPlugin', 
'relatedResource');
+    $this->relatedResourceComponent->resource = $this->resource;
+    $this->relatedResourceComponent->execute($this->request);
   }
 
   protected function addField($name)
@@ -118,4 +114,12 @@
         return parent::processField($field);
     }
   }
+
+  protected function processForm()
+  {
+    $this->relatedAuthorityRecordComponent->processForm();
+    $this->relatedResourceComponent->processForm();
+
+    return parent::processForm();
+  }
 }

Copied and modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
 (from r8258, trunk/apps/qubit/modules/actor/actions/editAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/editAction.class.php Mon Oct 18 
18:50:20 2010        (r8258, copy source)
+++ 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
 Mon Oct 18 20:23:52 2010        (r8260)
@@ -17,110 +17,13 @@
  * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/**
- * Controller for editing actor information.
- *
- * @package    qubit
- * @subpackage actor
- * @version    svn: $Id$
- * @author     Peter Van Garderen <[email protected]>
- * @author     Jack Bates <[email protected]>
- * @author     David Juhasz <[email protected]>
- */
-class ActorEditAction extends DefaultEditAction
+class sfIsaarPluginRelatedAuthorityRecordComponent extends 
RelationEditComponent
 {
-  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);
-  }
-
   protected function addField($name)
   {
     switch ($name)
     {
-      case 'entityType':
-        $this->form->setDefault('entityType', 
$this->context->routing->generate(null, array($this->resource->entityType, 
'module' => 'term')));
-        $this->form->setValidator('entityType', new sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach 
(QubitTaxonomy::getTaxonomyTerms(QubitTaxonomy::ACTOR_ENTITY_TYPE_ID) as $item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('entityType', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
-      case 'authorizedFormOfName':
-      case 'corporateBodyIdentifiers':
-      case 'datesOfExistence':
-      case 'descriptionIdentifier':
-      case 'institutionResponsibleIdentifier':
-        $this->form->setDefault($name, $this->resource[$name]);
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormInput);
-
-        break;
-
-      case 'functions':
-      case 'generalContext':
-      case 'history':
-      case 'internalStructures':
-      case 'legalStatus':
-      case 'mandates':
-      case 'places':
-      case 'revisionHistory':
-      case 'rules':
-      case 'sources':
-        $this->form->setDefault($name, $this->resource[$name]);
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormTextarea);
-
-        break;
-
       case 'relatedActor[authorizedFormOfName]':
-      case 'relatedResource[informationObject]':
         $choices = array();
 
         $this->form->setValidator($name, new sfValidatorString);
@@ -142,35 +45,9 @@
 
         break;
 
-      case 'relatedResource[type]':
-        $this->form->setValidator('relatedResource[type]', new 
sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::EVENT_TYPE_ID) as 
$item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('relatedResource[type]', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
-      case 'relatedResource[resourceType]':
-        $term = QubitTerm::getById(QubitTerm::ARCHIVAL_MATERIAL_ID);
-
-        $this->form->setValidator('relatedResource[resourceType]', new 
sfValidatorString);
-        $this->form->setDefault('relatedResource[resourceType]', 
$this->context->routing->generate(null, array($term, 'module' => 'term')));
-        $this->form->setWidget('relatedResource[resourceType]', new 
sfWidgetFormSelect(array('choices' => 
array($this->context->routing->generate(null, array($term, 'module' => 'term')) 
=> $term))));
-
-        break;
-
       case 'relatedActor[dateDisplay]':
       case 'relatedActor[endDate]':
       case 'relatedActor[startDate]':
-      case 'relatedResource[dateDisplay]':
-      case 'relatedResource[endDate]':
-      case 'relatedResource[startDate]':
         $this->form->setValidator($name, new sfValidatorString);
         $this->form->setWidget($name, new sfWidgetFormInput);
 
@@ -188,67 +65,24 @@
     }
   }
 
-  /**
-   * Process form fields
-   *
-   * @param $field mixed symfony form widget
-   * @return void
-   */
   protected function processField($field)
   {
     switch ($field->getName())
     {
-      case 'entityType':
-        unset($this->resource->entityType);
-
-        $value = $this->form->getValue('entityType');
-        if (isset($value))
-        {
-          $params = $this->context->routing->parse(Qubit::pathInfo($value));
-          $this->resource->entityType = $params['_sf_route']->resource;
-        }
-
-        break;
-
       default:
 
         return parent::processField($field);
     }
   }
 
-  protected function processForm()
+  public function processForm()
   {
     $this->updateActorRelations();
     $this->deleteActorRelations();
-    $this->updateEvents();
-    $this->deleteEvents();
 
     return parent::processForm();
   }
 
-  public function execute($request)
-  {
-    parent::execute($request);
-
-    if ($request->isMethod('post'))
-    {
-      $this->form->bind($request->getPostParameters());
-      if ($this->form->isValid())
-      {
-        $this->processForm();
-
-        if (isset($request->id) && (0 < strlen($next = 
$this->form->getValue('next'))))
-        {
-          $this->redirect($next);
-        }
-
-        $this->redirect(array($this->resource, 'module' => 'actor'));
-      }
-    }
-
-    QubitDescription::addAssets($this->response);
-  }
-
   /**
    * Update actor relationships
    */
@@ -336,97 +170,4 @@
       }
     }
   }
-
-  /**
-   * Add or update events related to this actor
-   *
-   * @return ActorEditAction this object
-   */
-  protected function updateEvents()
-  {
-    if (isset($this->request->relatedResources))
-    {
-      // The "updateEvents" array is created by the actorEventDialog.js
-      $updateEvents = $this->request->relatedResources;
-    }
-    else if (isset($this->request->relatedResource))
-    {
-      // The "newEvent" array means a non-JavaScript form submission
-      $updateEvents = array($this->request->relatedResource);
-    }
-    else
-    {
-      return;
-    }
-
-    // Loop through actor events
-    foreach ($updateEvents as $eventFormData)
-    {
-      // Create new event or update an existing one
-      if (isset($eventFormData['id']))
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['id']));
-        if (null === $event = QubitEvent::getById($params['id']))
-        {
-          continue; // If we can't find the object, then skip this row
-        }
-      }
-      else
-      {
-        $event = new QubitEvent;
-      }
-
-      // Assign resource to event
-      if (0 == strlen($eventFormData['informationObject']))
-      {
-        continue; // If no resource name, don't update event
-      }
-      else
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['informationObject']));
-
-        // Assign resource to event
-        $event->informationObjectId = $params['id'];
-      }
-
-      // Set type
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($eventFormData['type']));
-
-      unset($event->type);
-      if (isset($params['id']))
-      {
-        $event->typeId = $params['id'];
-      }
-
-      // Update other event properties
-      $event->dateDisplay = $eventFormData['dateDisplay'];
-      $event->startDate = $eventFormData['startDate'];
-      $event->endDate = $eventFormData['endDate'];
-
-      $this->resource->events[] = $event;
-    }
-
-    return $this;
-  }
-
-  /**
-   * Delete related events that are marked for deletion.
-   *
-   * @return ActorEditAction $this object
-   */
-  public function deleteEvents()
-  {
-    if (is_array($deleteEvents = $this->request->deleteEvents))
-    {
-      foreach ($deleteEvents as $deleteId => $doDelete)
-      {
-        if (null !== $event = QubitEvent::getById($deleteId))
-        {
-          $event->delete();
-        }
-      }
-    }
-
-    return $this;
-  }
 }

Copied and modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedResourceComponent.class.php
 (from r8258, trunk/apps/qubit/modules/actor/actions/editAction.class.php)
==============================================================================
--- trunk/apps/qubit/modules/actor/actions/editAction.class.php Mon Oct 18 
18:50:20 2010        (r8258, copy source)
+++ 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedResourceComponent.class.php
        Mon Oct 18 20:23:52 2010        (r8260)
@@ -17,109 +17,12 @@
  * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/**
- * Controller for editing actor information.
- *
- * @package    qubit
- * @subpackage actor
- * @version    svn: $Id$
- * @author     Peter Van Garderen <[email protected]>
- * @author     Jack Bates <[email protected]>
- * @author     David Juhasz <[email protected]>
- */
-class ActorEditAction extends DefaultEditAction
+class sfIsaarPluginRelatedResourceComponent extends RelationEditComponent
 {
-  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);
-  }
-
   protected function addField($name)
   {
     switch ($name)
     {
-      case 'entityType':
-        $this->form->setDefault('entityType', 
$this->context->routing->generate(null, array($this->resource->entityType, 
'module' => 'term')));
-        $this->form->setValidator('entityType', new sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach 
(QubitTaxonomy::getTaxonomyTerms(QubitTaxonomy::ACTOR_ENTITY_TYPE_ID) as $item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('entityType', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
-      case 'authorizedFormOfName':
-      case 'corporateBodyIdentifiers':
-      case 'datesOfExistence':
-      case 'descriptionIdentifier':
-      case 'institutionResponsibleIdentifier':
-        $this->form->setDefault($name, $this->resource[$name]);
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormInput);
-
-        break;
-
-      case 'functions':
-      case 'generalContext':
-      case 'history':
-      case 'internalStructures':
-      case 'legalStatus':
-      case 'mandates':
-      case 'places':
-      case 'revisionHistory':
-      case 'rules':
-      case 'sources':
-        $this->form->setDefault($name, $this->resource[$name]);
-        $this->form->setValidator($name, new sfValidatorString);
-        $this->form->setWidget($name, new sfWidgetFormTextarea);
-
-        break;
-
-      case 'relatedActor[authorizedFormOfName]':
       case 'relatedResource[informationObject]':
         $choices = array();
 
@@ -128,20 +31,6 @@
 
         break;
 
-      case 'relatedActor[type]':
-        $this->form->setValidator('relatedActor[type]', new sfValidatorString);
-
-        $choices = array();
-        $choices[null] = null;
-        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::ACTOR_RELATION_TYPE_ID) as $item)
-        {
-          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
-        }
-
-        $this->form->setWidget('relatedActor[type]', new 
sfWidgetFormSelect(array('choices' => $choices)));
-
-        break;
-
       case 'relatedResource[type]':
         $this->form->setValidator('relatedResource[type]', new 
sfValidatorString);
 
@@ -165,9 +54,6 @@
 
         break;
 
-      case 'relatedActor[dateDisplay]':
-      case 'relatedActor[endDate]':
-      case 'relatedActor[startDate]':
       case 'relatedResource[dateDisplay]':
       case 'relatedResource[endDate]':
       case 'relatedResource[startDate]':
@@ -176,167 +62,30 @@
 
         break;
 
-      case 'relatedActor[description]':
-        $this->form->setValidator('relatedActor[description]', new 
sfValidatorString);
-        $this->form->setWidget('relatedActor[description]', new 
sfWidgetFormTextarea);
-
-        break;
-
       default:
 
         return parent::addField($name);
     }
   }
 
-  /**
-   * Process form fields
-   *
-   * @param $field mixed symfony form widget
-   * @return void
-   */
   protected function processField($field)
   {
     switch ($field->getName())
     {
-      case 'entityType':
-        unset($this->resource->entityType);
-
-        $value = $this->form->getValue('entityType');
-        if (isset($value))
-        {
-          $params = $this->context->routing->parse(Qubit::pathInfo($value));
-          $this->resource->entityType = $params['_sf_route']->resource;
-        }
-
-        break;
-
       default:
 
         return parent::processField($field);
     }
   }
 
-  protected function processForm()
+  public function processForm()
   {
-    $this->updateActorRelations();
-    $this->deleteActorRelations();
     $this->updateEvents();
     $this->deleteEvents();
 
     return parent::processForm();
   }
 
-  public function execute($request)
-  {
-    parent::execute($request);
-
-    if ($request->isMethod('post'))
-    {
-      $this->form->bind($request->getPostParameters());
-      if ($this->form->isValid())
-      {
-        $this->processForm();
-
-        if (isset($request->id) && (0 < strlen($next = 
$this->form->getValue('next'))))
-        {
-          $this->redirect($next);
-        }
-
-        $this->redirect(array($this->resource, 'module' => 'actor'));
-      }
-    }
-
-    QubitDescription::addAssets($this->response);
-  }
-
-  /**
-   * Update actor relationships
-   */
-  protected function updateActorRelations()
-  {
-    if (isset($this->request->relatedActors))
-    {
-      // JavaScript (multiple) update
-      $relationsData = $this->request->relatedActors;
-    }
-    else if (isset($this->request->relatedActor))
-    {
-      // Non-JavaScript (single) update
-      $relationsData = array($this->request->relatedActor);
-    }
-    else
-    {
-      return;
-    }
-
-    // Loop through related actors
-    foreach ($relationsData as $relationData)
-    {
-      // Get related actor
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['authorizedFormOfName']));
-      $relatedObjectId = (isset($params['id'])) ? $params['id'] : null;
-      if (null === $relatedObject = QubitActor::getById($relatedObjectId))
-      {
-        continue; // If no related object, skip update
-      }
-
-      // Get relation
-      if (isset($relationData['id']))
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
-        if (null === $relation = QubitRelation::getById($params['id']))
-        {
-          // If a relation id is passed, but relation object doesn't exist then
-          // skip this row
-          continue;
-        }
-      }
-      else
-      {
-        $relation = new QubitRelation;
-      }
-
-      // Set category (typeId)
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['type']));
-      $typeId = (isset($params['id'])) ? $params['id'] : null;
-      $relation->typeId = $typeId;
-
-      $relation->startDate = $relationData['startDate'];
-      $relation->endDate = $relationData['endDate'];
-
-      // Add notes
-      $relation->updateNote($relationData['description'], 
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
-      $relation->updateNote($relationData['dateDisplay'], 
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
-      // Default to current actor as the subject of the relationship
-      if ($relation->subjectId == $this->resource->id || null == 
$relation->subjectId)
-      {
-        $relation->object = $relatedObject;
-        $this->resource->relationsRelatedBysubjectId[] = $relation;
-      }
-      else
-      {
-        $relation->subject = $relatedObject;
-        $this->resource->relationsRelatedByobjectId[] = $relation;
-      }
-    }
-
-    return $this;
-  }
-
-  protected function deleteActorRelations()
-  {
-    if (isset($this->request->deleteRelations))
-    {
-      foreach ((array) $this->request->deleteRelations as $relationId => 
$value)
-      {
-        $relation = QubitRelation::getById($relationId);
-        $relation->delete();
-      }
-    }
-  }
-
   /**
    * Add or update events related to this actor
    *

Modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/editSuccess.php
==============================================================================
--- trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/editSuccess.php 
Mon Oct 18 20:05:10 2010        (r8259)
+++ trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/templates/editSuccess.php 
Mon Oct 18 20:23:52 2010        (r8260)
@@ -1,5 +1,3 @@
-<?php use_helper('Javascript') ?>
-
 <h1><?php echo __('Edit %1% - ISAAR', array('%1%' => 
sfConfig::get('app_ui_label_actor'))) ?></h1>
 
 <h1 class="label"><?php echo render_title($resource) ?></h1>
@@ -86,9 +84,9 @@
 
     <legend><?php echo __('Relationships area') ?></legend>
 
-    <?php echo get_partial('relatedAuthorityRecord') ?>
+    <?php echo get_partial('relatedAuthorityRecord', 
$relatedAuthorityRecordComponent->getVarHolder()->getAll()) ?>
 
-    <?php echo get_partial('relatedResource') ?>
+    <?php echo get_partial('relatedResource', 
$relatedResourceComponent->getVarHolder()->getAll()) ?>
 
   </fieldset>
 

-- 
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.

Reply via email to