ILIAS  Release_4_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 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "./classes/class.ilObject.php";
25 
34 {
41  function ilObjExternalFeed($a_id = 0,$a_call_by_reference = true)
42  {
43  $this->type = "feed";
44  $this->ilObject($a_id,$a_call_by_reference);
45  }
46 
53  function update()
54  {
55  if (!parent::update())
56  {
57  return false;
58  }
59 
60  // put here object specific stuff
61 
62  return true;
63  }
64 
73  public function cloneObject($a_target_id,$a_copy_id = 0)
74  {
75  global $ilDB, $ilLog;
76 
77  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
78  $fb = $this->getFeedBlock();
79 
80  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
81  $new_feed_block = new ilExternalFeedBlock();
82  $new_feed_block->setContextObjId($new_obj->getId());
83  $new_feed_block->setContextObjType("feed");
84 
85  if (is_object($fb))
86  {
87  $new_feed_block->setFeedUrl($fb->getFeedUrl());
88  $new_feed_block->setTitle($fb->getTitle());
89  }
90  $new_feed_block->create();
91 
92  return $new_obj;
93  }
94 
101  function delete()
102  {
103  // always call parent delete function first!!
104  if (!parent::delete())
105  {
106  return false;
107  }
108 
109  //put here your module specific stuff
110 
111  // delete feed block
112  include_once("./Services/Block/classes/class.ilCustomBlock.php");
113  $costum_block = new ilCustomBlock();
114  $costum_block->setContextObjId($this->getId());
115  $costum_block->setContextObjType($this->getType());
116  $c_blocks = $costum_block->queryBlocksForContext();
117 
118  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
119  foreach($c_blocks as $c_block) // should be usually only one
120  {
121  if ($c_block["type"] == "feed")
122  {
123  $fb = new ilExternalFeedBlock($c_block["id"]);
124  $fb->delete();
125  include_once("./Services/Block/classes/class.ilBlockSetting.php");
126  ilBlockSetting::_deleteSettingsOfBlock($c_block["id"], "feed");
127  }
128  }
129 
130  //ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
131 
132  return true;
133  }
134 
135  function getFeedBlock()
136  {
137  global $ilLog;
138 
139  // delete feed block
140  include_once("./Services/Block/classes/class.ilCustomBlock.php");
141  $costum_block = new ilCustomBlock();
142  $costum_block->setContextObjId($this->getId());
143  $costum_block->setContextObjType($this->getType());
144  $c_blocks = $costum_block->queryBlocksForContext();
145 
146  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
147  foreach($c_blocks as $c_block) // should be usually only one
148  {
149  if ($c_block["type"] == "feed")
150  {
151  $fb = new ilExternalFeedBlock($c_block["id"]);
152  return $fb;
153  }
154  }
155 
156  return false;
157  }
158 
168  function initDefaultRoles()
169  {
170  global $rbacadmin;
171 
172  // create a local role folder
173  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
174 
175  // create moderator role and assign role to rolefolder...
176  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
177  //$roles[] = $roleObj->getId();
178 
179  //unset($rfoldObj);
180  //unset($roleObj);
181 
182  return $roles ? $roles : array();
183  }
184 
198  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
199  {
200  global $tree;
201 
202  switch ($a_event)
203  {
204  case "link":
205 
206  //var_dump("<pre>",$a_params,"</pre>");
207  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
208  //exit;
209  break;
210 
211  case "cut":
212 
213  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
214  //exit;
215  break;
216 
217  case "copy":
218 
219  //var_dump("<pre>",$a_params,"</pre>");
220  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
221  //exit;
222  break;
223 
224  case "paste":
225 
226  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
227  //exit;
228  break;
229 
230  case "new":
231 
232  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
233  //exit;
234  break;
235  }
236 
237  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
238  if ($a_node_id==$_GET["ref_id"])
239  {
240  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
241  $parent_type = $parent_obj->getType();
242  if($parent_type == $this->getType())
243  {
244  $a_node_id = (int) $tree->getParentId($a_node_id);
245  }
246  }
247 
248  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
249  }
250 
251 } // END class.ilObjExternalFeed
252 ?>