ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCourseVerificationGUI.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 "crsv";
22  }
23 
27  public function create()
28  {
29  global $ilTabs;
30 
31  if($this->id_type == self::WORKSPACE_NODE_ID)
32  {
33  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
35  {
36  $this->lng->loadLanguageModule("file");
37  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
38  $this->ctrl->redirect($this, "cancel");
39  }
40  }
41 
42  $this->lng->loadLanguageModule("crsv");
43 
44  $ilTabs->setBackTarget($this->lng->txt("back"),
45  $this->ctrl->getLinkTarget($this, "cancel"));
46 
47  include_once "Modules/Course/classes/Verification/class.ilCourseVerificationTableGUI.php";
48  $table = new ilCourseVerificationTableGUI($this, "create");
49  $this->tpl->setContent($table->getHTML());
50  }
51 
55  public function save()
56  {
57  global $ilUser;
58 
59  $course_id = $_REQUEST["crs_id"];
60  if($course_id)
61  {
62  include_once "Modules/Course/classes/class.ilObjCourse.php";
63  $course = new ilObjCourse($course_id, false);
64 
65  include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
66  $newObj = ilObjCourseVerification::createFromCourse($course, $ilUser->getId());
67  if($newObj)
68  {
70  $this->node_id = null;
71  $this->putObjectInTree($newObj, $parent_id);
72 
73  $this->afterSave($newObj);
74  }
75  else
76  {
77  ilUtil::sendFailure($this->lng->txt("msg_failed"));
78  }
79  }
80  else
81  {
82  ilUtil::sendFailure($this->lng->txt("select_one"));
83  }
84  $this->create();
85  }
86 
87  public function deliver()
88  {
89  $file = $this->object->getFilePath();
90  if($file)
91  {
92  ilUtil::deliverFile($file, $this->object->getTitle().".pdf");
93  }
94  }
95 
102  public function render($a_return = false, $a_url = false)
103  {
104  global $ilUser, $lng;
105 
106  if(!$a_return)
107  {
108  $this->deliver();
109  }
110  else
111  {
112  $tree = new ilWorkspaceTree($ilUser->getId());
113  $wsp_id = $tree->lookupNodeId($this->object->getId());
114 
115  $caption = $lng->txt("wsp_type_crsv").' "'.$this->object->getTitle().'"';
116 
117  $valid = true;
118  if(!file_exists($this->object->getFilePath()))
119  {
120  $valid = false;
121  $message = $lng->txt("url_not_found");
122  }
123  else if(!$a_url)
124  {
125  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
127  if(!$access_handler->checkAccess("read", "", $wsp_id))
128  {
129  $valid = false;
130  $message = $lng->txt("permission_denied");
131  }
132  }
133 
134  if($valid)
135  {
136  if(!$a_url)
137  {
138  $a_url = $this->getAccessHandler()->getGotoLink($wsp_id, $this->object->getId());
139  }
140  return '<div><a href="'.$a_url.'">'.$caption.'</a></div>';
141  }
142  else
143  {
144  return '<div>'.$caption.' ('.$message.')</div>';
145  }
146  }
147  }
148 
150  {
151  global $ilErr;
152 
153  include_once "Services/COPage/classes/class.ilPCVerification.php";
154  if(ilPCVerification::isInPortfolioPage($a_page, $this->object->getType(), $this->object->getId()))
155  {
156  $this->deliver();
157  }
158 
159  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
160  }
161 
162  function _goto($a_target)
163  {
164  $id = explode("_", $a_target);
165 
166  $_GET["baseClass"] = "ilsharedresourceGUI";
167  $_GET["wsp_id"] = $id[0];
168  include("ilias.php");
169  exit;
170  }
171 }
172 
173 ?>