ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilPortfolioRepositoryGUI.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 include_once('./Modules/Portfolio/classes/class.ilObjPortfolio.php');
5 
17 {
18  protected $user_id; // [int]
19  protected $access_handler; // [ilPortfolioAccessHandler]
20 
21  public function __construct()
22  {
23  global $lng, $ilUser;
24 
25  $lng->loadLanguageModule("prtf");
26  $lng->loadLanguageModule("user");
27 
28  include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
29  $this->access_handler = new ilPortfolioAccessHandler();
30 
31  $this->user_id = $ilUser->getId();
32  }
33 
34  public function executeCommand()
35  {
36  global $ilCtrl, $lng, $tpl, $ilTabs;
37 
38  $next_class = $ilCtrl->getNextClass($this);
39  $cmd = $ilCtrl->getCmd("show");
40 
41  $tpl->setTitle($lng->txt("portfolio"));
42  $tpl->setTitleIcon(ilUtil::getImagePath("icon_prtf.svg"),
43  $lng->txt("portfolio"));
44 
45  switch($next_class)
46  {
47  case "ilobjportfoliogui":
48  if($cmd != "preview")
49  {
50  $this->setLocator();
51 
52  $ilTabs->setBack2Target($lng->txt("prtf_tab_portfolios"),
53  $ilCtrl->getLinkTarget($this, "show"));
54  }
55  include_once('./Modules/Portfolio/classes/class.ilObjPortfolioGUI.php');
56  $gui = new ilObjPortfolioGUI($_REQUEST["prt_id"]);
57  $ilCtrl->forwardCommand($gui);
58  break;
59 
60  default:
61  $this->setLocator();
62  $this->setTabs();
63  $this->$cmd();
64  break;
65  }
66 
67  return true;
68  }
69 
70  public function setTabs()
71  {
72  global $ilTabs, $lng, $ilCtrl, $ilHelp;
73 
74  $ilHelp->setScreenIdComponent("prtf");
75 
76  $ilTabs->addTab("mypf", $lng->txt("prtf_tab_portfolios"),
77  $ilCtrl->getLinkTarget($this));
78 
79  $ilTabs->addTab("otpf", $lng->txt("prtf_tab_other_users"),
80  $ilCtrl->getLinkTarget($this, "showotherFilter"));
81 
82  $ilTabs->activateTab("mypf");
83  }
84 
85  protected function setLocator()
86  {
87  global $ilLocator, $lng, $ilCtrl, $tpl;
88 
89  $ilLocator->addItem($lng->txt("portfolio"),
90  $ilCtrl->getLinkTarget($this, "show"));
91 
92  $tpl->setLocator();
93  }
94 
95  protected function checkAccess($a_permission, $a_portfolio_id = null)
96  {
97  if($a_portfolio_id)
98  {
99  return $this->access_handler->checkAccess($a_permission, "", $a_portfolio_id);
100  }
101  // currently only object-based permissions
102  return true;
103  }
104 
105 
106  //
107  // LIST INCL. ACTIONS
108  //
109 
110  protected function show()
111  {
112  global $tpl, $lng, $ilToolbar, $ilCtrl;
113 
114  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
115  $button = ilLinkButton::getInstance();
116  $button->setCaption("prtf_add_portfolio");
117  $button->setUrl($ilCtrl->getLinkTargetByClass("ilObjPortfolioGUI", "create"));
118  $ilToolbar->addButtonInstance($button);
119 
120  include_once "Modules/Portfolio/classes/class.ilPortfolioTableGUI.php";
121  $table = new ilPortfolioTableGUI($this, "show", $this->user_id);
122 
123  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
124 
125  $tpl->setContent($table->getHTML().ilDiskQuotaHandler::getStatusLegend());
126  }
127 
128  protected function saveTitles()
129  {
130  global $ilCtrl, $lng;
131 
132  foreach($_POST["title"] as $id => $title)
133  {
134  if(trim($title))
135  {
136  if($this->checkAccess("write", $id))
137  {
138  $portfolio = new ilObjPortfolio($id, false);
139  $portfolio->setTitle(ilUtil::stripSlashes($title));
140 
141  if(is_array($_POST["online"]) && in_array($id, $_POST["online"]))
142  {
143  $portfolio->setOnline(true);
144  }
145  else
146  {
147  $portfolio->setOnline(false);
148  }
149 
150  $portfolio->update();
151  }
152  }
153  }
154 
155  ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
156  $ilCtrl->redirect($this, "show");
157  }
158 
159  protected function confirmPortfolioDeletion()
160  {
161  global $ilCtrl, $tpl, $lng;
162 
163  if (!is_array($_POST["prtfs"]) || count($_POST["prtfs"]) == 0)
164  {
165  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
166  $ilCtrl->redirect($this, "show");
167  }
168  else
169  {
170  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
171  $cgui = new ilConfirmationGUI();
172  $cgui->setFormAction($ilCtrl->getFormAction($this));
173  $cgui->setHeaderText($lng->txt("prtf_sure_delete_portfolios"));
174  $cgui->setCancel($lng->txt("cancel"), "show");
175  $cgui->setConfirm($lng->txt("delete"), "deletePortfolios");
176 
177  foreach ($_POST["prtfs"] as $id)
178  {
179  $cgui->addItem("prtfs[]", $id, ilObjPortfolio::_lookupTitle($id));
180  }
181 
182  $tpl->setContent($cgui->getHTML());
183  }
184  }
185 
186  protected function deletePortfolios()
187  {
188  global $lng, $ilCtrl;
189 
190  if (is_array($_POST["prtfs"]))
191  {
192  foreach ($_POST["prtfs"] as $id)
193  {
194  if($this->checkAccess("write", $id))
195  {
196  $portfolio = new ilObjPortfolio($id, false);
197  if ($portfolio->getOwner() == $this->user_id)
198  {
199  $this->access_handler->removePermission($id);
200  $portfolio->delete();
201  }
202  }
203  }
204  }
205  ilUtil::sendSuccess($lng->txt("prtf_portfolio_deleted"), true);
206  $ilCtrl->redirect($this, "show");
207  }
208 
209 
210  //
211  // DEFAULT PORTFOLIO (aka profile)
212  //
213 
214  protected function unsetDefault()
215  {
216  global $ilCtrl, $lng, $ilUser;
217 
218  if($this->checkAccess("write"))
219  {
220  // #12845
221  $ilUser->setPref("public_profile", "n");
222  $ilUser->writePrefs();
223 
224  ilObjPortfolio::setUserDefault($this->user_id);
225  ilUtil::sendSuccess($lng->txt("prtf_unset_default_share_info"), true);
226  }
227  $ilCtrl->redirect($this, "show");
228  }
229 
233  protected function setDefaultConfirmation()
234  {
235  global $ilCtrl, $lng, $tpl, $ilSetting;
236 
237  $prtf_id = (int)$_REQUEST["prt_id"];
238 
239  if($prtf_id && $this->checkAccess("write"))
240  {
241  // if already shared, no need to ask again
242  if($this->access_handler->hasRegisteredPermission($prtf_id) ||
243  $this->access_handler->hasGlobalPermission($prtf_id))
244  {
245  return $this->setDefault($prtf_id);
246  }
247 
248  $ilCtrl->setParameter($this, "prt_id", $prtf_id);
249 
250  // #20310
251  if(!$ilSetting->get("enable_global_profiles"))
252  {
253  $ilCtrl->redirect($this, "setDefaultRegistered");
254  }
255 
256  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
257  $cgui = new ilConfirmationGUI();
258  $cgui->setFormAction($ilCtrl->getFormAction($this));
259  $cgui->setHeaderText($lng->txt("prtf_set_default_publish_confirmation"));
260  $cgui->setCancel($lng->txt("yes"), "setDefaultGlobal");
261  $cgui->setConfirm($lng->txt("no"), "setDefaultRegistered");
262 
263  $tpl->setContent($cgui->getHTML());
264  return;
265  }
266 
267  $ilCtrl->redirect($this, "show");
268  }
269 
270  protected function setDefaultGlobal()
271  {
272  global $ilCtrl;
273 
274  $prtf_id = (int)$_REQUEST["prt_id"];
275  if($prtf_id && $this->checkAccess("write"))
276  {
277  $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_ALL);
278  $this->setDefault($prtf_id);
279  }
280  $ilCtrl->redirect($this, "show");
281  }
282 
283  protected function setDefaultRegistered()
284  {
285  global $ilCtrl;
286 
287  $prtf_id = (int)$_REQUEST["prt_id"];
288  if($prtf_id && $this->checkAccess("write"))
289  {
290  $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_REGISTERED);
291  $this->setDefault($prtf_id);
292  }
293  $ilCtrl->redirect($this, "show");
294  }
295 
296  protected function setDefault($a_prtf_id)
297  {
298  global $ilCtrl, $lng, $ilUser;
299 
300  if($a_prtf_id && $this->checkAccess("write"))
301  {
302  // #12845
303  if($this->access_handler->hasGlobalPermission($a_prtf_id))
304  {
305  $ilUser->setPref("public_profile", "g");
306  $ilUser->writePrefs();
307  }
308  else if($this->access_handler->hasRegisteredPermission($a_prtf_id))
309  {
310  $ilUser->setPref("public_profile", "y");
311  $ilUser->writePrefs();
312  }
313  else
314  {
315  return;
316  }
317  ilObjPortfolio::setUserDefault($this->user_id, $a_prtf_id);
318  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
319  }
320  $ilCtrl->redirect($this, "show");
321  }
322 
323 
324  //
325  // SHARE
326  //
327 
328  protected function showOtherFilter()
329  {
330  $this->showOther(false);
331  }
332 
333  protected function showOther($a_load_data = true)
334  {
335  global $tpl, $ilTabs;
336 
337  $ilTabs->activateTab("otpf");
338 
339  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
340  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler, null, $a_load_data);
341  $tpl->setContent($tbl->getHTML());
342  }
343 
344  protected function applyShareFilter()
345  {
346  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
347  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
348  $tbl->resetOffset();
349  $tbl->writeFilterToSession();
350 
351  $this->showOther();
352  }
353 
354  protected function resetShareFilter()
355  {
356  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
357  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
358  $tbl->resetOffset();
359  $tbl->resetFilter();
360 
361  $this->showOther();
362  }
363 }
364 
365 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
checkAccess($a_permission, $a_portfolio_id=null)
$_POST['username']
Definition: cron.php:12
static _lookupTitle($a_id)
$cmd
Definition: sahs_server.php:35
Portfolio repository gui class.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Workspace share handler table GUI class.
Portfolio view gui class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
Access handler for portfolio.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
Confirmation screen class.
setDefaultConfirmation()
Confirm sharing when setting default.