ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 require_once "./Services/Object/classes/class.ilObject.php";
5 
14 {
21  function ilObjExternalFeed($a_id = 0,$a_call_by_reference = true)
22  {
23  $this->type = "feed";
24  $this->ilObject($a_id,$a_call_by_reference);
25  }
26 
33  function update()
34  {
35  if (!parent::update())
36  {
37  return false;
38  }
39 
40  // put here object specific stuff
41 
42  return true;
43  }
44 
53  public function cloneObject($a_target_id,$a_copy_id = 0)
54  {
55  global $ilDB, $ilLog;
56 
57  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
58  $fb = $this->getFeedBlock();
59 
60  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
61  $new_feed_block = new ilExternalFeedBlock();
62  $new_feed_block->setContextObjId($new_obj->getId());
63  $new_feed_block->setContextObjType("feed");
64 
65  if (is_object($fb))
66  {
67  $new_feed_block->setFeedUrl($fb->getFeedUrl());
68  $new_feed_block->setTitle($fb->getTitle());
69  }
70  $new_feed_block->create();
71 
72  return $new_obj;
73  }
74 
81  function delete()
82  {
83  // always call parent delete function first!!
84  if (!parent::delete())
85  {
86  return false;
87  }
88 
89  //put here your module specific stuff
90 
91  // delete feed block
92  include_once("./Services/Block/classes/class.ilCustomBlock.php");
93  $costum_block = new ilCustomBlock();
94  $costum_block->setContextObjId($this->getId());
95  $costum_block->setContextObjType($this->getType());
96  $c_blocks = $costum_block->queryBlocksForContext();
97 
98  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
99  foreach($c_blocks as $c_block) // should be usually only one
100  {
101  if ($c_block["type"] == "feed")
102  {
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  function getFeedBlock()
116  {
117  global $ilLog;
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  {
129  if ($c_block["type"] == "feed")
130  {
131  $fb = new ilExternalFeedBlock($c_block["id"]);
132  return $fb;
133  }
134  }
135 
136  return false;
137  }
138 
139 
153  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
154  {
155  global $tree;
156 
157  switch ($a_event)
158  {
159  case "link":
160 
161  //var_dump("<pre>",$a_params,"</pre>");
162  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
163  //exit;
164  break;
165 
166  case "cut":
167 
168  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
169  //exit;
170  break;
171 
172  case "copy":
173 
174  //var_dump("<pre>",$a_params,"</pre>");
175  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
176  //exit;
177  break;
178 
179  case "paste":
180 
181  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
182  //exit;
183  break;
184 
185  case "new":
186 
187  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
188  //exit;
189  break;
190  }
191 
192  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
193  if ($a_node_id==$_GET["ref_id"])
194  {
195  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
196  $parent_type = $parent_obj->getType();
197  if($parent_type == $this->getType())
198  {
199  $a_node_id = (int) $tree->getParentId($a_node_id);
200  }
201  }
202 
203  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
204  }
205 
206 } // END class.ilObjExternalFeed
207 ?>