bos =& $Dippler->backoffice; if ($id) { $this->id = $id; } } public function create() { $created = $this->bos->createResourceFolder($this->dataXML()); if ($created) { $this->id = $created->id[0][0]; return $this->id; } return false; } public function save() { return $this->bos->editResourceFolder($this->dataXML()); } public function delete() { return $this->bos->deleteResourceFolder($this->idXML()); } public function load($loader = false) { if (!$loader) $loader = $this->bos->loadResourceFolder($this->idXML()); if ($loader) { $this->type = "folder"; $this->id = $loader->id[0][0]; $this->title = $loader->title[0][0]; $this->position = $loader->position[0][0]; $this->creator = $loader->creator[0][0]; $this->created = $loader->created[0][0]; if (isset($loader->parent[0][0])) $this->parent = $loader->parent[0][0]; $this->course = $loader->course[0][0]; if (isset($loader->folders[0]["folder"])) { foreach ($loader->folders[0]["folder"] as $folder) { $folder["parent"] = array(array($this->id)); $folder_object = new ResourceFolder(); $folder_object->load((object) $folder); $this->folders []= $folder_object; } } if (isset($loader->resources[0]["learning_resource"])) { foreach ($loader->resources[0]["learning_resource"] as $resource) { $resource["folder"] = array(array($this->id)); $resource_object = new LearningResource(); $resource_object->load((object) $resource); $this->resources []= $resource_object; } } $this->breadcrumbs []= array( 'title'=> _('Learning Resources'), 'getURL' => WWW_ROOT."course/resources/{$this->course}"); if (isset($loader->breadcrumbs[0]["folder"])) { $this->buildBreadcrumb($loader->breadcrumbs[0]["folder"][0], $this->breadcrumbs); //$this->breadcrumbs []= $this; // self } } } public function buildBreadcrumb($folder, &$breadcrumbs) { $daddy_breadcrumb = new ResourceFolder(); $daddy_breadcrumb->load((object) $folder); if (isset($folder["parent"][0]["folder"][0])) { $daddy_breadcrumb->buildBreadcrumb($folder["parent"][0]["folder"][0], $breadcrumbs); } $breadcrumbs []= $daddy_breadcrumb; } public function getURL() { return WWW_ROOT."course/resources/{$this->course}/folder/{$this->id}"; } 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; } public function getId() { return $this->id; } public function getType() { return $this->type; } public function getOwner() { return $this->creator; } public function getOwnerEntity() { if (!isset($this->creator_entity)) { $user = new User($this->creator); $user->load(); $this->creator_entity = $user; return $user; } return $this->creator_entity; } public function getCourse() { return $this->course; } public function getCourseEntity() { if (!isset($this->course_entity)) { $course = new Course($this->course); $course->load(); $this->course_entity = $course; return $course; } return $course_entity; } function idXML() { $data = ""; $data .= ""; $data .= "{$this->id}"; $data .= ""; return $data; } function dataXML() { $data = ""; $data .= ""; $data .= "{$this->id}"; $data .= "<![CDATA[{$this->title}]]>"; $data .= "{$this->parent}"; $data .= "{$this->parent}"; $data .= "{$this->course}"; $data .= "{$this->course}"; $data .= ""; return $data; } function getParentURL() { if (isset($this->parent) && $this->parent != NULL && $this->parent != 0) { return WWW_ROOT."course/resources/{$this->course}/folder/{$this->parent}"; } return WWW_ROOT."course/resources/{$this->course}"; } }