bos =& $Dippler->backoffice;
		if ($id) $this->id = $id;
	}
	public function create() {
		$loaded = $this->bos->createCourseBlogComment($this->courseblog_post, $this->dataXML());
		if ($loaded) {
		    return $loaded->id[0][0];
		}
		return 0;
	}
	public function save() {
		return $this->bos->editCourseBlogComment($this->courseblog_post, $this->dataXML());
	}
	public function delete () {
		return $this->bos->deleteCourseBlogComment($this->courseblog_post, $this->idXML());
	}
    public function hide() {
		return $this->bos->hideCourseBlogComment($this->courseblog_post, $this->idXML());
	}
	public function unhide() {
		return $this->bos->unhideCourseBlogComment($this->courseblog_post, $this->idXML());
	}
	public function load() {
		$loader = $this->bos->loadCourseBlogComment($this->courseblog_post, $this->idXML());
		if ($loader) {
		    $this->type = "courseblogcomment";
			$this->course = $loader->course[0][0];
			$this->courseblog_post = $loader->post[0][0];
			$this->id = $loader->id[0][0];
			$this->title = $loader->title[0][0];
			$this->body = $loader->body[0][0];
			$this->creator = $loader->creator[0][0];
			$this->created = $loader->created[0][0];
			$this->modified = $loader->modified[0][0];
			$this->hidden = $loader = in_array(strtolower($loader->hidden[0][0]), array("false", "null")) ? false : true;
		}
	}
	public function getPostTitle() {
		return $this->getPostEntity()->title;
	}
	public function getURL() {
		return $this->getPostEntity()->getURL();
	}
	public function getType() {
		return $this->type; 
	}
    public function canEdit() {
		if (!is_logged_in()) {
			return 0;
		}
		// Only admin and course owner can edit
        if (is_admin() || $this->getPostEntity()->getCourseEntity()->creator == get_logged_in_user_id()) {
            return 1;
        }
        return 0;
	}
	// XXX needs review
	public function canHide() {
		return $this->canEdit();
	}
	public function getId() {
		return $this->id;
	}
	public function getCreator() {
		return $this->creator;
	}
	public function getCreatorEntity() {
		if (!isset($this->creator_entity)) {
            $user = new User($this->creator);
			$user->load();
			$this->creator_entity = $user;
			return $user;
		}
        return $this->creator_entity;
    }
	public function getOwner() {
		return $this->getCreator();
	}
	public function getOwnerEntity() {
		return $this->getCreatorEntity();
	}
	public function getPostEntity() {
		if (!isset($this->post_entity)) {
			$post = new CourseBlogPost($this->courseblog_post);
			$post->load();
			$this->post_entity = $post;
			return $post;
		}
		return $this->post_entity;
	}
	function idXML() {
		$data = "";
		$data .= "";
		$data .= "{$this->id}";
		$data .= "";
		return $data;
	}
    function dataXML() {
		$data = "";
		$data .= "";
		$data .= "{$this->id}";
		$data .= "title}]]>";
		$data .= "body}]]>";
		$data .= "";
		return $data;
	}
}
?>