ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPortfolioTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16  protected $user_id;
17  protected $shared;
18 
22  function __construct($a_parent_obj, $a_parent_cmd, $a_user_id, $a_shared = false)
23  {
24  global $ilCtrl, $lng;
25 
26  $this->user_id = (int)$a_user_id;
27  $this->shared = (bool)$a_shared;
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30 
31  $this->setTitle($lng->txt("prtf_portfolios"));
32 
33  if(!$this->shared)
34  {
35  $this->addColumn($this->lng->txt(""), "", "1");
36  }
37  $this->addColumn($this->lng->txt("title"), "title", "50%");
38  if(!$this->shared)
39  {
40  $this->addColumn($this->lng->txt("online"), "is_online");
41  $this->addColumn($this->lng->txt("prtf_default_portfolio"), "is_default");
42  }
43  $this->addColumn($this->lng->txt("actions"));
44 
45  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
46  $this->setRowTemplate("tpl.portfolio_row.html", "Services/Portfolio");
47 
48  if(!$this->shared)
49  {
50  $this->addMultiCommand("confirmPortfolioDeletion", $lng->txt("delete"));
51  $this->addCommandButton("saveTitles",
52  $lng->txt("prtf_save_status_and_titles"));
53  }
54 
55  $this->getItems();
56 
57  $lng->loadLanguageModule("wsp");
58 
59  include_once('./Services/Link/classes/class.ilLink.php');
60  }
61 
62  protected function getItems()
63  {
64  global $ilUser;
65 
66  include_once "Services/Portfolio/classes/class.ilPortfolioAccessHandler.php";
67  $access_handler = new ilPortfolioAccessHandler();
68 
69  include_once "Services/Portfolio/classes/class.ilObjPortfolio.php";
71 
72  // remove all portfolios which are not shared
73  if($this->shared)
74  {
75  $other = $access_handler->getSharedObjects($this->user_id);
76  foreach($data as $idx => $item)
77  {
78  if(!in_array($item["id"], $other))
79  {
80  unset($data[$idx]);
81  }
82  else
83  {
84  // #9848: flag if current share access is password-protected
85  $perms = $access_handler->getPermissions($item["id"]);
86  $data[$idx]["password"] = (!in_array($ilUser->getId(), $perms) &&
88  !in_array(ilWorkspaceAccessGUI::PERMISSION_ALL, $perms) &&
90  }
91  }
92  }
93  else
94  {
95  $this->shared_objects = $access_handler->getObjectsIShare();
96  }
97 
98  $this->setData($data);
99  }
100 
104  protected function fillRow($a_set)
105  {
106  global $lng, $ilCtrl;
107 
108  // owner
109  if(!$this->shared)
110  {
111  $this->tpl->setCurrentBlock("title_form");
112  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
113  $this->tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($a_set["title"]));
114  $this->tpl->parseCurrentBlock();
115 
116  if(in_array($a_set["id"], $this->shared_objects))
117  {
118  $this->tpl->setCurrentBlock("shared");
119  $this->tpl->setVariable("TXT_SHARED", $lng->txt("wsp_status_shared"));
120  $this->tpl->parseCurrentBlock();
121  }
122 
123  $this->tpl->setCurrentBlock("chck");
124  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
125  $this->tpl->parseCurrentBlock();
126 
127  $this->tpl->setCurrentBlock("edit");
128  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
129  $this->tpl->setVariable("STATUS_ONLINE",
130  ($a_set["is_online"]) ? " checked=\"checked\"" : "");
131  $this->tpl->setVariable("VAL_DEFAULT",
132  ($a_set["is_default"]) ? $lng->txt("yes") : "");
133  $this->tpl->parseCurrentBlock();
134 
135  $ilCtrl->setParameter($this->parent_obj, "prt_id", $a_set["id"]);
136  $this->tpl->setCurrentBlock("action");
137 
138  $this->tpl->setVariable("URL_ACTION",
139  $ilCtrl->getLinkTarget($this->parent_obj, "preview"));
140  $this->tpl->setVariable("TXT_ACTION", $lng->txt("user_profile_preview"));
141  $this->tpl->parseCurrentBlock();
142 
143  $this->tpl->setVariable("URL_ACTION",
144  $ilCtrl->getLinkTarget($this->parent_obj, "pages"));
145  $this->tpl->setVariable("TXT_ACTION", $lng->txt("prtf_edit_portfolio"));
146  $this->tpl->parseCurrentBlock();
147 
148  if($a_set["is_online"])
149  {
150  if(!$a_set["is_default"])
151  {
152  $this->tpl->setVariable("URL_ACTION",
153  $ilCtrl->getLinkTarget($this->parent_obj, "setDefaultConfirmation"));
154  $this->tpl->setVariable("TXT_ACTION", $lng->txt("prtf_set_as_default"));
155  $this->tpl->parseCurrentBlock();
156  }
157  else
158  {
159  $this->tpl->setVariable("URL_ACTION",
160  $ilCtrl->getLinkTarget($this->parent_obj, "unsetDefault"));
161  $this->tpl->setVariable("TXT_ACTION", $lng->txt("prtf_unset_as_default"));
162  $this->tpl->parseCurrentBlock();
163  }
164  }
165 
166  $ilCtrl->setParameter($this->parent_obj, "prt_id", "");
167  }
168  // shared
169  else
170  {
171  $this->tpl->setCurrentBlock("title_static");
172  $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
173  $this->tpl->parseCurrentBlock();
174 
175  if($a_set["password"])
176  {
177  $this->tpl->setCurrentBlock("shared");
178  $this->tpl->setVariable("TXT_SHARED", $lng->txt("wsp_password_protected_resource"));
179  $this->tpl->parseCurrentBlock();
180  }
181 
182  $link = ilLink::_getStaticLink($a_set["id"], "prtf", true);
183 
184  $this->tpl->setCurrentBlock("action");
185  $this->tpl->setVariable("URL_ACTION", $link);
186  $this->tpl->setVariable("TXT_ACTION", $lng->txt("view"));
187  $this->tpl->parseCurrentBlock();
188  }
189 
190  }
191 
192 }?>