bos =& $Dippler->backoffice;
if ($id) $this->id = $id;
}
public function create() {
$loaded = $this->bos->createCourseBlogPost($this->course, $this->dataXML());
if ($loaded) {
return $loaded->id[0][0];
}
return 0;
}
public function save() {
return $this->bos->editCourseBlogPost($this->course, $this->dataXML());
}
public function delete() {
return $this->bos->deleteCourseBlogPost($this->course, $this->idXML());
}
public function hide() {
return $this->bos->hideCourseBlogPost($this->course, $this->idXML());
}
public function unhide() {
return $this->bos->unhideCourseBlogPost($this->course, $this->idXML());
}
public function load($loader = false) {
if (!$loader) $loader = $this->bos->loadCourseBlogPost($this->course, $this->idXML());
if ($loader) {
$this->type = "courseblogpost";
$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->course = $loader->course[0][0];
if (isset($loader->tags[0]["tag"])) {
foreach ($loader->tags[0]["tag"] as $tag) {
$this->tags []= $tag["name"][0][0];
}
}
$this->hidden = $loader = in_array(strtolower($loader->hidden[0][0]), array("false", "null")) ? false : true;
}
}
public function getURL() {
return WWW_ROOT."course/announcements/{$this->course}/post/{$this->id}";
}
public function getType() {
return $this->type;
}
public function canEdit() {
if (!is_logged_in()) {
return 0;
}
if (is_admin() || ($this->getOwner() == get_logged_in_user_id()) || $this->getCourseEntity()->canEdit()) {
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 getCourseEntity() {
if (!isset($this->course_entity)) {
$course = new Course($this->course);
$course->load();
$this->course_entity = $course;
return $course;
}
return $this->course_entity;
}
public function getComments() {
$id = $this->bos->listCourseblogComments($this->id, 0, 15);
if ($id) {
return $id;
}
return false;
}
function idXML() {
$data = "";
$data .= "";
$data .= "{$this->id}";
$data .= "";
return $data;
}
function tagsXML() {
$data = "";
foreach ($this->tags as $tag) {
$data .= "";
$data .= "";
$data .= "";
}
return $data;
}
function dataXML() {
$tags = $this->tagsXML();
$data = "";
$data .= "";
$data .= "{$this->id}";
$data .= "title}]]>";
$data .= "body}]]>";
$data .= "{$tags}";
$data .= "";
return $data;
}
function getComment($id) {
$comment = new CourseBlogComment($id);
$comment->load();
if (($comment->getType() == 'courseblogcomment') && ($comment->courseblog_post == $this->id)) {
return $comment;
}
return NULL;
}
}
?>