bos =& $Dippler->backoffice;
if ($id) {
$this->id = $id;
}
}
public function create() {
//var_dump($this->dataXML());exit;
$created = $this->bos->createLearningResource($this->dataXML());
if ($created) {
$this->id = $created->id[0][0];
return $this->id;
}
return false;
}
public function save() {
return $this->bos->editLearningResource($this->dataXML());
}
public function delete() {
return $this->bos->deleteLearningResource($this->idXML());
}
public function load($loader = false) {
if (!$loader) $loader = $this->bos->loadLearningResource($this->idXML());
if ($loader) {
$this->type = "resource";
$this->id = $loader->id[0][0];
$this->title = $loader->title[0][0];
$this->description = $loader->description[0][0];
$this->subtype = $loader->subtype[0][0];
if (isset($loader->url[0][0])) $this->url = $loader->url[0][0];
if (isset($loader->author[0][0])) $this->author = $loader->author[0][0];
$this->creator = $loader->creator[0][0];
if (isset($loader->licence[0][0])) $this->licence = $loader->licence[0][0];
if (isset($loader->created[0][0])) $this->created = $loader->created[0][0];
if (isset($loader->modified[0][0])) $this->modified = $loader->modified[0][0];
$this->published = $loader->published[0][0];
if ($this->published == 0) {
$this->published = null;
}
$this->position = $loader->position[0][0];
$this->course = $loader->course[0][0];
$this->folder = $loader->folder[0][0];
$this->breadcrumbs []= array( 'title'=> _('Learning Resources'), 'getURL' => WWW_ROOT."course/resources/{$this->course}");
if (isset($loader->categories[0]["category"])) {
foreach ($loader->categories[0]["category"] as $single) {
$cat = new Category();
$cat->load((object) $single);
$this->categories[$cat->id] = $cat;
}
}
if (isset($loader->tags[0]["tag"])) {
foreach ($loader->tags[0]["tag"] as $tag) {
$this->tags []= $tag["name"][0][0];
}
}
}
}
/* REMOVED FUNCTIONALITY
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}/resource/{$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 $this->course_entity;
}
function idXML() {
$data = "";
$data .= "";
$data .= "".$this->id."";
$data .= "";
return $data;
}
function categoriesXML() {
$data = "";
foreach ($this->categories as $cat) {
$data .= "";
$data .= $cat->getId();
$data .= "";
}
return $data;
}
function tagsXML() {
$data = "";
foreach ($this->tags as $tag) {
$data .= "";
$data .= "";
$data .= "";
}
return $data;
}
function dataXML() {
$tags = $this->tagsXML();
$categories = $this->categoriesXML();
$data = "";
$data .= "";
$data .= "".$this->id."";
$data .= "title."]]>";
$data .= "description."]]>";
$data .= "subtype}]]>";
$data .= "url}]]>";
$data .= "author}]]>";
$data .= "licence}]]>";
$data .= "{$this->position}";
$data .= "{$this->course}";
$data .= "{$this->folder}";
$data .= "{$this->published}";
$data .= "{$tags}";
$data .= "{$categories}";
$data .= "";
return $data;
}
// TODO See if this is needed any more
function getFolderURL() {
if (isset($this->folder) && $this->folder != NULL && $this->folder != 0) {
return WWW_ROOT."course/resources/{$this->course}/folder/{$this->folder}";
}
return WWW_ROOT."course/resources/{$this->course}";
}
function getFolder() {
if ($this->folder && $this->folder != 0) {
$folder = new ResourceFolder($this->folder);
$folder->load();
if ($folder && $folder->getType() == 'folder') {
return $folder;
}
}
return false;
}
/*
* Checks if there is a possibility that this resource could be embeddable.
*
* @return bool
*/
function isoEmbeddable() {
if (in_array($this->subtype, array('slideshare', 'youtube', 'lemill'))) {
return true;
}
return false;
}
/*
* Returns URL to tiny icon for the resource.
* Will return URL to default icon as fallback.
*
* @return string
*/
function getTinyIconURL() {
if (in_array($this->subtype, array('slideshare', 'youtube', 'lemill'))) {
return WWW_ROOT . "views/graphics/{$this->subtype}_resource_tiny.png";
}
return WWW_ROOT ."views/graphics/placeholder_icon_tiny.png";
}
}
?>