ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjExternalFeedGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 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.ilObjectGUI.php";
25 
36 {
41  function ilObjExternalFeedGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
42  {
43  $this->type = "feed";
44  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
45  }
46 
47 
48  function &executeCommand()
49  {
50  global $rbacsystem, $tpl;
51 
52  $next_class = $this->ctrl->getNextClass($this);
53 
54  switch($next_class)
55  {
56  case 'ilpermissiongui':
57  $this->prepareOutput();
58  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
59  $perm_gui =& new ilPermissionGUI($this);
60  $ret =& $this->ctrl->forwardCommand($perm_gui);
61  break;
62 
63  case "ilexternalfeedblockgui":
64  $this->prepareOutput();
65  include_once("./Services/Block/classes/class.ilExternalFeedBlockGUI.php");
66  $fb_gui =& new ilExternalFeedBlockGUI();
67  $fb_gui->setGuiObject($this);
68  if (is_object($this->object))
69  {
70  $fb_gui->setRefId($this->object->getRefId());
71  }
72  $ret =& $this->ctrl->forwardCommand($fb_gui);
73  $tpl->setContent($ret);
74  break;
75 
76  default:
77  $cmd = $this->ctrl->getCmd("view");
78  if ($cmd != "create")
79  {
80  $this->prepareOutput();
81  }
82  $cmd .= "Object";
83  $this->$cmd();
84  break;
85  }
86  return true;
87  }
88 
89  function createObject()
90  {
91  global $ilCtrl;
92  $ilCtrl->setCmdClass("ilexternalfeedblockgui");
93  $ilCtrl->setCmd("create");
94  return $this->executeCommand();
95  }
96 
101  function save($a_feed_block)
102  {
103  global $rbacadmin, $ilUser;
104 
105  // create and insert forum in objecttree
106  $_GET["new_type"] = "feed";
107  $_POST["Fobject"]["title"] = $a_feed_block->getTitle();
108  $_POST["Fobject"]["desc"] = $a_feed_block->getFeedUrl();
109  $newObj = parent::saveObject();
110  $newObj->setOwner($ilUser->getId());
111  $newObj->updateOwner();
112  $a_feed_block->setContextObjId($newObj->getId());
113  $a_feed_block->setContextObjType("feed");
114 
115  // setup rolefolder & default local roles
116  //$roles = $newObj->initDefaultRoles();
117 
118  // ...finally assign role to creator of object
119  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
120 
121  }
122 
127  public function exitSave()
128  {
129  global $ilCtrl;
130 
131  // always send a message
132  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
133  $this->ctrl->returnToParent($this);
134  }
135 
140  function update($a_feed_block)
141  {
142  global $rbacadmin;
143 
144  // update object
145  $_POST["Fobject"]["title"] = $a_feed_block->getTitle();
146  $_POST["Fobject"]["desc"] = $a_feed_block->getFeedUrl();
147  $newObj = parent::updateObject();
148  }
149 
154  public function cancelUpdate()
155  {
156  global $ilCtrl, $tree;
157 
158 
159  $par = $tree->getParentId($_GET["ref_id"]);
160  $_GET["ref_id"] = $par;
161  $this->redirectToRefId($par);
162 
163  //$this->ctrl->returnToParent($this);
164  }
165 
170  public function afterUpdate()
171  {
172  global $ilCtrl, $tree;
173 
174  // always send a message
175  $par = $tree->getParentId($_GET["ref_id"]);
176  $_GET["ref_id"] = $par;
177  $this->redirectToRefId($par);
178 
179  }
180 
186  function getTabs(&$tabs_gui)
187  {
188  global $rbacsystem, $ilCtrl;
189 
190  if (in_array($ilCtrl->getCmd(), array("create", "saveFeedBlock")))
191  {
192  return;
193  }
194 
195  $ilCtrl->setParameterByClass("ilexternalfeedblockgui", "external_feed_block_id",
196  $_GET["external_feed_block_id"]);
197  $ilCtrl->saveParameter($this, "external_feed_block_id");
198 
199  if ($rbacsystem->checkAccess('write', $this->object->getRefId()))
200  {
201  $force_active = ($_GET["cmd"] == "edit" ||
202  $this->ctrl->getNextClass() == "ilexternalfeedblockgui")
203  ? true
204  : false;
205  $tabs_gui->addTarget("edit_properties",
206  $this->ctrl->getLinkTargetByClass("ilexternalfeedblockgui", "editFeedBlock"),
207  "edit", get_class($this),
208  "", $force_active);
209  }
210 
211  if($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
212  {
213  $tabs_gui->addTarget("perm_settings",
214  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), "", "ilpermissiongui");
215  }
216 
217  }
218 } // END class.ilObjExternalFeed
219 ?>