ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjExternalFeed.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Object/classes/class.ilObject.php";
5
14{
21 public function __construct($a_id = 0, $a_call_by_reference = true)
22 {
23 global $DIC;
24
25 $this->db = $DIC->database();
26 $this->log = $DIC["ilLog"];
27 $this->type = "feed";
28 parent::__construct($a_id, $a_call_by_reference);
29 }
30
37 public function update()
38 {
39 if (!parent::update()) {
40 return false;
41 }
42
43 // put here object specific stuff
44
45 return true;
46 }
47
56 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
57 {
60
61 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
62 $fb = $this->getFeedBlock();
63
64 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
65 $new_feed_block = new ilExternalFeedBlock();
66 $new_feed_block->setContextObjId($new_obj->getId());
67 $new_feed_block->setContextObjType("feed");
68
69 if (is_object($fb)) {
70 $new_feed_block->setFeedUrl($fb->getFeedUrl());
71 $new_feed_block->setTitle($fb->getTitle());
72 }
73 $new_feed_block->create();
74
75 return $new_obj;
76 }
77
84 public function delete()
85 {
86 // always call parent delete function first!!
87 if (!parent::delete()) {
88 return false;
89 }
90
91 //put here your module specific stuff
92
93 // delete feed block
94 include_once("./Services/Block/classes/class.ilCustomBlock.php");
95 $costum_block = new ilCustomBlock();
96 $costum_block->setContextObjId($this->getId());
97 $costum_block->setContextObjType($this->getType());
98 $c_blocks = $costum_block->queryBlocksForContext();
99
100 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
101 foreach ($c_blocks as $c_block) { // should be usually only one
102 if ($c_block["type"] == "feed") {
103 $fb = new ilExternalFeedBlock($c_block["id"]);
104 $fb->delete();
105 include_once("./Services/Block/classes/class.ilBlockSetting.php");
106 ilBlockSetting::_deleteSettingsOfBlock($c_block["id"], "feed");
107 }
108 }
109
110 //ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
111
112 return true;
113 }
114
115 public function getFeedBlock()
116 {
118
119 // delete feed block
120 include_once("./Services/Block/classes/class.ilCustomBlock.php");
121 $costum_block = new ilCustomBlock();
122 $costum_block->setContextObjId($this->getId());
123 $costum_block->setContextObjType($this->getType());
124 $c_blocks = $costum_block->queryBlocksForContext();
125
126 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
127 foreach ($c_blocks as $c_block) { // should be usually only one
128 if ($c_block["type"] == "feed") {
129 $fb = new ilExternalFeedBlock($c_block["id"]);
130 return $fb;
131 }
132 }
133
134 return false;
135 }
136} // END class.ilObjExternalFeed
An exception for terminatinating execution or to throw for unit testing.
static _deleteSettingsOfBlock($a_block_id, $a_block_type)
Delete block settings of block.
This is the super class of all custom blocks.
Custom block for external feeds.
Class ilObjExternalFeed.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
update()
update object data
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
getId()
get object id @access public
update($pash, $contents, Config $config)
global $DIC
Definition: saml.php:7
global $ilDB