ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjTestVerificationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once ('./Services/Object/classes/class.ilObject2GUI.php');
6 
18 {
19  public function getType()
20  {
21  return "tstv";
22  }
23 
27  public function create()
28  {
29  global $ilTabs;
30 
31  $this->lng->loadLanguageModule("tstv");
32 
33  $ilTabs->setBackTarget($this->lng->txt("back"),
34  $this->ctrl->getLinkTarget($this, "cancel"));
35 
36  include_once "Modules/Test/classes/tables/class.ilTestVerificationTableGUI.php";
37  $table = new ilTestVerificationTableGUI($this, "create");
38  $this->tpl->setContent($table->getHTML());
39  }
40 
44  public function save()
45  {
46  global $ilUser;
47 
48  $test_id = $_REQUEST["tst_id"];
49  if($test_id)
50  {
51  include_once "Modules/Test/classes/class.ilObjTest.php";
52  $test = new ilObjTest($test_id, false);
53 
54  include_once "Modules/Test/classes/class.ilObjTestVerification.php";
55  $newObj = ilObjTestVerification::createFromTest($test, $ilUser->getId());
56  if($newObj)
57  {
59  $this->node_id = null;
60  $this->putObjectInTree($newObj, $parent_id);
61 
62  $this->afterSave($newObj);
63  }
64  else
65  {
66  ilUtil::sendFailure($this->lng->txt("msg_failed"));
67  }
68  }
69  else
70  {
71  ilUtil::sendFailure($this->lng->txt("select_one"));
72  }
73  $this->create();
74  }
75 
76  public function deliver()
77  {
78  $file = $path.$this->object->getFilePath();
79  if($file)
80  {
81  ilUtil::deliverFile($file, $this->object->getTitle().".pdf");
82  }
83  }
84 
91  public function render($a_return = false, $a_url = false)
92  {
93  global $ilUser;
94 
95  if(!$a_return)
96  {
97  $this->deliver();
98  }
99  else
100  {
101  $tree = new ilWorkspaceTree($ilUser->getId());
102  $wsp_id = $tree->lookupNodeId($this->object->getId());
103 
104  $caption = $this->object->getTitle();
105 
106  $valid = true;
107  if(!file_exists($this->object->getFilePath()))
108  {
109  $valid = false;
110  $message = $lng->txt("url_not_found");
111  }
112  else if(!$a_url)
113  {
114  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
116  if(!$access_handler->checkAccess("read", "", $wsp_id))
117  {
118  $valid = false;
119  $message = $lng->txt("permission_denied");
120  }
121  }
122 
123  if($valid)
124  {
125  if(!$a_url)
126  {
127  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
128  }
129  return '<div><a href="'.$a_url.'">'.$caption.'</a></div>';
130  }
131  else
132  {
133  return '<div>'.$caption.' ('.$message.')</div>';
134  }
135  }
136  }
137 
139  {
140  global $ilErr;
141 
142  include_once "Services/COPage/classes/class.ilPCVerification.php";
143  if(ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId()))
144  {
145  $this->deliver();
146  }
147 
148  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
149  }
150 
151  function _goto($a_target)
152  {
153  $id = explode("_", $a_target);
154 
155  $_GET["baseClass"] = "ilsharedresourceGUI";
156  $_GET["wsp_id"] = $id[0];
157  include("ilias.php");
158  exit;
159  }
160 }
161 
162 ?>