*/ class ems_followup_followup extends ems_framework_datamodelbase implements ems_followup_interface_followup { protected $ds; protected $id; protected $tableDefID; protected $refID; protected $parent; protected $originalPosterID; protected $originalPoster; protected $ownerID; protected $owner; protected $contentID; protected $contentText; protected $contentName; protected $categoryID; protected $category; protected $followupDate; protected $isPublic; protected $whenCompleted; /** * The constructor object for the followup object. * * @param ems_framework_registry $param * @access public */ public function __construct(ems_framework_registry $param) { parent::__construct($param); $this->setDefaultValues(); } /** * Sets the default values for the followup. * * @access private * @return void */ private function setDefaultValues() { $this->ds = $this->param->factory->ds->createFollowup(); $this->id = null; $this->tableDefID = null; $this->refID = null; $this->parent = null; $this->originalPosterID = null; $this->originalPoster = null; $this->ownerID = null; $this->owner = null; $this->contentID = null; $this->contentName = null; $this->contentText = null; $this->categoryID = null; $this->category = null; $this->followupDate = $this->param->factory->system->createEmptyDateTime(); $this->isPublic = false; $this->whenCompleted = $this->param->factory->system->createEmptyDateTime(); } /** * Sets the datasource to use internally * * @param ems_datasource_interface_followup $ds * @access public */ public function setDataSource(ems_datasource_interface_followup $ds) { $this->ds = $ds; } /** * Loads data for a followup, based on the ID provided * * @param integer $id * @access public * @return boolean Whether or not the load operation was successful. */ public function getData($id) { $this->checkDS("getData"); $data = $this->ds->getFollowup($id); if (is_array($data)) { $this->setID($data['followup_id']); $this->setTableDefID($data['followup_table_def_id']); $this->setRefID($data['followup_ref_id']); $this->setOriginalPosterID($data['followup_original_poster_id']); $this->setOwnerID($data['followup_owner_id']); $this->setContentID($data['followup_content_id']); $this->setContentName($data['followup_content_name']); $this->setContentText($data['followup_content_text']); $this->setCategoryID($data['followup_category_id']); $this->setFollowupDate($data['followup_follow_up_date']); $this->setIsPublic($data['followup_is_public']); $this->setWhenCompleted($data['followup_when_completed']); $this->setCreated($data['followup_date_created']); $this->setEdited($data['followup_date_last_edited']); $this->getDataRun = true; } return $this->getDataRun; } /** * Marks the followup as complete * * @access public * @return void */ public function complete() { $this->whenCompleted = $this->param->factory->system->createDateTime(); } // property getter functions public function getID() { return $this->id; } public function getTableDefID() { return $this->tableDefID; } public function getRefID() { return $this->refID; } public function getParent() { if (!$this->parent && $this->tableDefID && $this->refID) { $this->parent = $this->param->factory->createObj($this->tableDefID); $this->parent->getData($this->refID); } return $this->parent; } public function getOriginalPosterID() { if (!$this->originalPosterID && $this->originalPoster) { $this->setOriginalPosterID($this->originalPoster->getID()); } return $this->originalPosterID; } public function getOriginalPoster() { if (!$this->originalPoster && $this->originalPosterID) { $this->originalPoster = $this->param->factory->person->createPerson(); $this->originalPoster->getData($this->originalPosterID); } return $this->originalPoster; } public function getOwnerID() { if (!$this->ownerID && $this->owner) { $this->setOwnerID($this->owner->getID()); } return $this->ownerID; } public function getOwner() { if (!$this->owner && $this->ownerID) { $this->owner = $this->param->factory->person->createPerson(); $this->owner->getData($this->ownerID); } return $this->owner; } public function getContentID() { return $this->contentID; } public function getContentName() { return $this->contentName; } public function getContentText() { return $this->contentText; } public function getCategoryID() { return $this->categoryID; } public function getCategory() { if (!$this->category && $this->categoryID) $this->setCategory($this->getCategoryValue($this->getCategoryID())); return $this->category; } public function getFollowupDate() { return $this->followupDate; } public function getIsPublic() { return $this->isPublic; } public function getWhenCompleted() { return $this->whenCompleted; } public function isCurrentUserOwner() { if ($this->param->getUser()->getID() == $this->getOwnerID()) { return true; } else { return false; } } // property setter functions public function setID($value) { $this->id = null; if (is_numeric($value)) $this->id = $value; } public function setTableDefID($value) { $this->tableDefID = null; if (is_numeric($value)) $this->tableDefID = $value; } public function setRefID($value) { $this->refID = null; if (is_numeric($value)) $this->refID = $value; } public function setParent($value) { $this->parent = null; if ($value) $this->parent = $value; } public function setOriginalPosterID($value) { $this->originalPosterID = null; if (is_numeric($value)) $this->originalPosterID = $value; } public function setOwnerID($value) { $this->ownerID = null; if (is_numeric($value)) $this->ownerID = $value; } public function setOriginalPoster(ems_person_interface_person $value) { $this->originalPoster = $value; } public function setOwner(ems_person_interface_person $value) { $this->owner = $value; } public function setContentID($value) { $this->contentID = null; if (is_numeric($value)) $this->contentID = $value; } public function setContentName($value) { $this->contentName = null; if ($value) $this->contentName = $value; } public function setContentText($value) { $this->contentText = null; if ($value) $this->contentText = $value; } public function setCategoryID($value) { $this->categoryID = null; if (is_numeric($value)) $this->categoryID = $value; } public function setCategory($value) { $this->category = null; if ($value) $this->category = $value; } public function setFollowupDate($value) { $this->followupDate = $this->param->factory->system->createEmptyDateTime(); if ($value) $this->followupDate = $this->param->factory->system->createDateTime($value); } public function setWhenCompleted($value) { $this->whenCompleted = $this->param->factory->system->createEmptyDateTime(); if ($value) $this->whenCompleted = $this->param->factory->system->createDateTime($value); } public function setIsPublic($value) { if ($value) { $this->isPublic = true; } else { $this->isPublic = false; } } /** * Saves the followup through the datasource * * @access public * @return boolean Whether or not the save operation succeeded. */ public function save() { $this->checkDS("save"); if ($this->ds->saveFollowup($this)) { return true; } else { return false; } } /** * Deletes the followup through the datasource * * @access public * @return boolean Whether or not the delete operation succeeded. */ public function delete() { $this->checkDS("delete"); if ($this->ds->deleteFollowup($this)) { return true; } else { return false; } } } ?>