aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/classes/ElggAnnotation.php10
-rw-r--r--engine/classes/ElggData.php28
-rw-r--r--engine/classes/ElggEntity.php5
-rw-r--r--engine/classes/ElggExtender.php19
-rw-r--r--engine/classes/ElggMetadata.php10
-rw-r--r--engine/classes/ElggRelationship.php2
6 files changed, 48 insertions, 26 deletions
diff --git a/engine/classes/ElggAnnotation.php b/engine/classes/ElggAnnotation.php
index cdcfe363f..d99f5fc9a 100644
--- a/engine/classes/ElggAnnotation.php
+++ b/engine/classes/ElggAnnotation.php
@@ -14,13 +14,19 @@
*/
class ElggAnnotation extends ElggExtender {
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
+
+ $this->attributes['type'] = 'annotation';
+ }
+
/**
* Construct a new annotation, optionally from a given id value or db object.
*
* @param mixed $id The annotation ID
*/
function __construct($id = null) {
- $this->attributes = array();
+ $this->initializeAttributes();
if (!empty($id)) {
if ($id instanceof stdClass) {
@@ -35,8 +41,6 @@ class ElggAnnotation extends ElggExtender {
foreach ($objarray as $key => $value) {
$this->attributes[$key] = $value;
}
-
- $this->attributes['type'] = "annotation";
}
}
}
diff --git a/engine/classes/ElggData.php b/engine/classes/ElggData.php
index fbc11881a..e465913ef 100644
--- a/engine/classes/ElggData.php
+++ b/engine/classes/ElggData.php
@@ -15,8 +15,20 @@ abstract class ElggData implements
*/
protected $attributes = array();
+ /**
+ * Initialize the attributes array.
+ *
+ * This is vital to distinguish between metadata and base parameters.
+ *
+ * @return void
+ */
protected function initializeAttributes() {
- $this->attributes['time_created'] = time();
+ // Create attributes array if not already created
+ if (!is_array($this->attributes)) {
+ $this->attributes = array();
+ }
+
+ $this->attributes['time_created'] = '';
}
/**
@@ -27,6 +39,20 @@ abstract class ElggData implements
abstract public function getURL();
/**
+ * Save this data to the appropriate database table.
+ *
+ * @return bool
+ */
+ abstract public function save();
+
+ /**
+ * Delete this data.
+ *
+ * @return bool
+ */
+ abstract public function delete();
+
+ /**
* Return the guid of the entity's owner.
*
* @return int The owner GUID
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index 86bf0727f..571ef890f 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -86,10 +86,6 @@ abstract class ElggEntity extends ElggData implements
protected function initializeAttributes() {
initialise_entity_cache();
- // Create attributes array if not already created
- if (!is_array($this->attributes)) {
- $this->attributes = array();
- }
if (!is_array($this->temp_metadata)) {
$this->temp_metadata = array();
}
@@ -109,7 +105,6 @@ abstract class ElggEntity extends ElggData implements
$this->attributes['site_guid'] = 0;
$this->attributes['access_id'] = ACCESS_PRIVATE;
- $this->attributes['time_created'] = "";
$this->attributes['time_updated'] = "";
$this->attributes['last_action'] = '';
$this->attributes['enabled'] = "yes";
diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php
index d9a6a52ef..380ba48f5 100644
--- a/engine/classes/ElggExtender.php
+++ b/engine/classes/ElggExtender.php
@@ -20,6 +20,11 @@
abstract class ElggExtender extends ElggData implements
Exportable
{
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
+
+ $this->attributes['type'] = '';
+ }
/**
* Returns an attribute
@@ -85,20 +90,6 @@ abstract class ElggExtender extends ElggData implements
}
/**
- * Save this data to the appropriate database table.
- *
- * @return bool
- */
- abstract public function save();
-
- /**
- * Delete this data.
- *
- * @return bool
- */
- abstract public function delete();
-
- /**
* Returns if a user can edit this extended data.
*
* @param int $user_guid The GUID of the user (defaults to currently logged in user)
diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php
index 851397a93..24365d4d9 100644
--- a/engine/classes/ElggMetadata.php
+++ b/engine/classes/ElggMetadata.php
@@ -8,6 +8,13 @@
* @subpackage Metadata
*/
class ElggMetadata extends ElggExtender {
+
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
+
+ $this->attributes['type'] = "metadata";
+ }
+
/**
* Construct a new site object, optionally from a given id value or row.
*
@@ -16,7 +23,7 @@ class ElggMetadata extends ElggExtender {
* @return void
*/
function __construct($id = null) {
- $this->attributes = array();
+ $this->initializeAttributes();
if (!empty($id)) {
// Create from db row
@@ -31,7 +38,6 @@ class ElggMetadata extends ElggExtender {
foreach ($objarray as $key => $value) {
$this->attributes[$key] = $value;
}
- $this->attributes['type'] = "metadata";
}
}
}
diff --git a/engine/classes/ElggRelationship.php b/engine/classes/ElggRelationship.php
index 4dcdb6297..c14319d35 100644
--- a/engine/classes/ElggRelationship.php
+++ b/engine/classes/ElggRelationship.php
@@ -16,7 +16,7 @@ class ElggRelationship extends ElggData implements
* @param mixed $id ElggRelationship id
*/
function __construct($id = null) {
- $this->attributes = array();
+ $this->initializeAttributes();
if (!empty($id)) {
if ($id instanceof stdClass) {