Author: mcantelon
Date: Thu Jan 19 15:46:26 2012
New Revision: 10723
Log:
Added function to create contact information objects.
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Thu Jan 19 13:10:25 2012
(r10722)
+++ trunk/lib/QubitFlatfileImport.class.php Thu Jan 19 15:46:26 2012
(r10723)
@@ -816,6 +816,57 @@
}
/**
+ * Create Qubit contract information for an actor or, if it already exists,
+ * fetch it
+ *
+ * @param integer $actorId ID of actor
+ * @param string $options contact information creation properties
+ *
+ * @return QubitContactInformation created or fetched contact info
+ */
+ public function createOrFetchContactInformation($actorId, $options)
+ {
+ $query = "SELECT id FROM contact_information WHERE actor_id=?";
+
+ $statement = QubitFlatfileImport::sqlQuery($query, array($actorId));
+ $result = $statement->fetch(PDO::FETCH_OBJ);
+
+ if ($result)
+ {
+ return QubitContactInformation::getById($result->id);
+ } else {
+ return $this->createContactInformation($actorId, $options);
+ }
+ }
+
+ /**
+ * Create Qubit contact information for an actor
+ *
+ * @param string $actorId ID of actor
+ * @param string $options property values for new object
+ *
+ * @return QubitContactInformation created contact information
+ */
+ public function createContactInformation($actorId, $options)
+ {
+ $info = new QubitContactInformation;
+ $info->actorId = $actorId;
+
+ $allowedProperties = array(
+ 'email',
+ 'telephone',
+ 'streetAddress',
+ 'city',
+ 'region'
+ );
+
+ $this->setPropertiesFromArray($info, $options, $allowedProperties);
+ $info->save();
+
+ return $info;
+ }
+
+ /**
* Create a Qubit term or, if it already exists, fetch it
*
* @param integer $taxonomyId term taxonomy
@@ -998,7 +1049,6 @@
);
$this->setPropertiesFromArray($right, $options, $allowedProperties);
-
$right->save();
// add relation
--
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.