*/
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) {
foreach ($objarray as $key => $value) {
$this->attributes[$key] = $value;
}
-
- $this->attributes['type'] = "annotation";
}
}
}
*/
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'] = '';
}
/**
*/
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.
*
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();
}
$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";
abstract class ElggExtender extends ElggData implements
Exportable
{
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
+
+ $this->attributes['type'] = '';
+ }
/**
* Returns an attribute
return get_entity($this->entity_guid);
}
- /**
- * 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.
*
* @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.
*
* @return void
*/
function __construct($id = null) {
- $this->attributes = array();
+ $this->initializeAttributes();
if (!empty($id)) {
// Create from db row
foreach ($objarray as $key => $value) {
$this->attributes[$key] = $value;
}
- $this->attributes['type'] = "metadata";
}
}
}
* @param mixed $id ElggRelationship id
*/
function __construct($id = null) {
- $this->attributes = array();
+ $this->initializeAttributes();
if (!empty($id)) {
if ($id instanceof stdClass) {