ILIAS  Release_4_2_x_branch Revision 61807
 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 "./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 
148  function initDefaultRoles()
149  {
150  global $rbacadmin;
151 
152  // create a local role folder
153  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
154 
155  // create moderator role and assign role to rolefolder...
156  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
157  //$roles[] = $roleObj->getId();
158 
159  //unset($rfoldObj);
160  //unset($roleObj);
161 
162  return $roles ? $roles : array();
163  }
164 
178  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
179  {
180  global $tree;
181 
182  switch ($a_event)
183  {
184  case "link":
185 
186  //var_dump("<pre>",$a_params,"</pre>");
187  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
188  //exit;
189  break;
190 
191  case "cut":
192 
193  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
194  //exit;
195  break;
196 
197  case "copy":
198 
199  //var_dump("<pre>",$a_params,"</pre>");
200  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
201  //exit;
202  break;
203 
204  case "paste":
205 
206  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
207  //exit;
208  break;
209 
210  case "new":
211 
212  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
213  //exit;
214  break;
215  }
216 
217  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
218  if ($a_node_id==$_GET["ref_id"])
219  {
220  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
221  $parent_type = $parent_obj->getType();
222  if($parent_type == $this->getType())
223  {
224  $a_node_id = (int) $tree->getParentId($a_node_id);
225  }
226  }
227 
228  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
229  }
230 
231 } // END class.ilObjExternalFeed
232 ?>