Author: jablko
Date: Tue Oct 12 16:46:28 2010
New Revision: 8073
Log:
Process event only if user typed something
Modified:
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php
==============================================================================
---
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php
Tue Oct 12 16:34:58 2010 (r8072)
+++
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php
Tue Oct 12 16:46:28 2010 (r8073)
@@ -39,71 +39,80 @@
foreach ($updatedEvents as $item)
{
- $event = new QubitEvent;
- if (isset($item['id']) && !isset($this->request->sourceId))
- {
- $params = $this->context->routing->parse(Qubit::pathInfo($item['id']));
- $event = $params['_sf_route']->resource;
- }
-
- $this->form->bind($item);
- if ($this->form->isValid())
+ if (0 < strlen($item['actor'])
+ || 0 < strlen($item['dateDisplay'])
+ || 0 < strlen($item['description'])
+ || 0 < strlen($item['endDate'])
+ || 0 < strlen($item['place'])
+ || 0 < strlen($item['startDate'])
+ || 0 < strlen($item['type']))
{
- // Use existing actor if one is selected (overrides new actor creation)
- if (0 < strlen($item['actor']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($item['actor']));
- $event->actorId = $params['id'];
- }
-
- $event->startDate = $item['startDate'];
- $event->endDate = $item['endDate'];
- $event->dateDisplay = $item['dateDisplay'];
-
- if (0 < strlen($item['type']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($item['type']));
- $event->typeId = $params['id'];
- }
-
- if (0 < strlen($item['description']))
+ $event = new QubitEvent;
+ if (isset($item['id']) && !isset($this->request->sourceId))
{
- $event->description = $item['description'];
- }
- else
- {
- unset($event->description);
+ $params =
$this->context->routing->parse(Qubit::pathInfo($item['id']));
+ $event = $params['_sf_route']->resource;
}
- // Save the event if it's valid (has an actor OR date)
- if (0 < strlen($item['actor'])
- || 0 < strlen($item['startDate'])
- || 0 < strlen($item['endDate'])
- || 0 < strlen($item['dateDisplay']))
+ $this->form->bind($item);
+ if ($this->form->isValid())
{
- // Update the "place" object term relation object
- if (0 < strlen($item['place']))
+ // Use existing actor if one is selected (overrides new actor
creation)
+ if (0 < strlen($item['actor']))
{
- // If this event didn't exist or didn't have a 'place' associated
- if (null === $event->id || null === ($place =
QubitObjectTermRelation::getOneByObjectId($event->id)))
- {
- $place = new QubitObjectTermRelation;
- }
+ $params =
$this->context->routing->parse(Qubit::pathInfo($item['actor']));
+ $event->actorId = $params['id'];
+ }
- $params =
$this->context->routing->parse(Qubit::pathInfo($item['place']));
- $place->termId = $params['id'];
+ $event->startDate = $item['startDate'];
+ $event->endDate = $item['endDate'];
+ $event->dateDisplay = $item['dateDisplay'];
- $event->objectTermRelationsRelatedByobjectId[] = $place;
+ if (0 < strlen($item['type']))
+ {
+ $params =
$this->context->routing->parse(Qubit::pathInfo($item['type']));
+ $event->typeId = $params['id'];
}
- // Or delete an existing "place" object term relation, if it's no
- // longer needed
- else if (0 < $event->getId() && null !== ($place =
QubitObjectTermRelation::getOneByObjectId($event->getId())))
+ if (0 < strlen($item['description']))
{
- $place->delete();
+ $event->description = $item['description'];
}
+ else
+ {
+ unset($event->description);
+ }
+
+ // Save the event if it's valid (has an actor OR date)
+ if (0 < strlen($item['actor'])
+ || 0 < strlen($item['startDate'])
+ || 0 < strlen($item['endDate'])
+ || 0 < strlen($item['dateDisplay']))
+ {
+ // Update the "place" object term relation object
+ if (0 < strlen($item['place']))
+ {
+ // If this event didn't exist or didn't have a 'place' associated
+ if (null === $event->id || null === ($place =
QubitObjectTermRelation::getOneByObjectId($event->id)))
+ {
+ $place = new QubitObjectTermRelation;
+ }
+
+ $params =
$this->context->routing->parse(Qubit::pathInfo($item['place']));
+ $place->termId = $params['id'];
+
+ $event->objectTermRelationsRelatedByobjectId[] = $place;
+ }
- $this->resource->events[] = $event;
+ // Or delete an existing "place" object term relation, if it's no
+ // longer needed
+ else if (0 < $event->getId() && null !== ($place =
QubitObjectTermRelation::getOneByObjectId($event->getId())))
+ {
+ $place->delete();
+ }
+
+ $this->resource->events[] = $event;
+ }
}
}
}
--
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.