ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilCourseArchivesGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 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
36{
39
40 var $tpl;
41 var $ctrl;
42 var $lng;
44
49 function ilCourseArchivesGUI(&$content_gui)
50 {
51 global $tpl,$ilCtrl,$lng,$ilObjDataCache,$ilTabs;
52
53 $this->tpl =& $tpl;
54 $this->ctrl =& $ilCtrl;
55 $this->lng =& $lng;
56 $this->tabs_gui =& $ilTabs;
57
58 $this->content_gui =& $content_gui;
59 $this->content_obj =& $this->content_gui->object;
60
61 $this->__initCourseObject();
62 }
63
64
65
66 function &executeCommand()
67 {
68 switch($this->ctrl->getNextClass($this))
69 {
70 case 'ilobjectcopygui':
71 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
72 $cp = new ilObjectCopyGUI($this);
73 $cp->setType('crs');
74 $this->ctrl->forwardCommand($cp);
75 break;
76
77 default:
78 $cmd = $this->ctrl->getCmd();
79 if (!$cmd = $this->ctrl->getCmd())
80 {
81 $cmd = "view";
82 }
83 $this->$cmd();
84 break;
85 }
86 }
87
88 function view()
89 {
90 global $ilAccess,$ilErr;
91
92 // MINIMUM ACCESS LEVEL = 'write'
93 if(!$ilAccess->checkAccess("read",'',$this->course_obj->getRefId()))
94 {
95 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
96 }
97
98
99 $this->is_tutor = $ilAccess->checkAccess('write','',$this->course_obj->getRefId());
100 $this->download_allowed = ($this->is_tutor or $this->course_obj->getArchiveType() == $this->course_obj->ARCHIVE_DOWNLOAD);
101
102 $this->course_obj->initCourseArchiveObject();
103 $this->course_obj->archives_obj->initCourseFilesObject();
104
105
106 $archives = $this->is_tutor ?
107 $this->course_obj->archives_obj->getArchives() :
108 $this->course_obj->archives_obj->getPublicArchives();
109
110 require_once("./Services/Table/classes/class.ilTableGUI.php");
111 $tbl = new ilTableGUI();
112
113 $this->__showArchivesMenu();
114 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
115 $this->tpl->addBlockfile("TBL_CONTENT","tbl_content","tpl.crs_archives_row.html",'Modules/Course');
116
117 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
118
119 $tbl->setTitle($this->lng->txt("crs_header_archives"));
120
121
122 if($this->download_allowed or $this->is_tutor)
123 {
124 $header_names = array('',
125 $this->lng->txt("type"),
126 $this->lng->txt("crs_file_name"),
127 $this->lng->txt("crs_size"),
128 $this->lng->txt("crs_create_date"),
129 $this->lng->txt("crs_archive_lang"));
130
131 $header_vars = array("",
132 "type",
133 "name",
134 "size",
135 "date",
136 "lang");
137 $column_width = array("1%","9%","30%","20%","20%","20%");
138 $this->tpl->setVariable("COLUMN_COUNTS",6);
139 }
140 else
141 {
142 $header_names = array($this->lng->txt("type"),
143 $this->lng->txt("crs_file_name"),
144 $this->lng->txt("crs_create_date"),
145 $this->lng->txt("crs_size"),
146 $this->lng->txt("crs_archive_lang"));
147
148 $header_vars = array("type",
149 "name",
150 "date",
151 "size",
152 "lang");
153 $column_width = array("10%","30%","20%","20%","20%");
154 $this->tpl->setVariable("COLUMN_COUNTS",5);
155 }
156
157 $tbl->setHeaderNames($header_names);
158 $tbl->setHeaderVars($header_vars,
159 array("ref_id" => $this->course_obj->getRefId(),
160 "cmd" => "view",
161 "cmdClass" => strtolower(get_class($this))));
162 $tbl->setColumnWidth($column_width);
163
164
165 // control
166 $tbl->setOrderColumn($_GET["sort_by"]);
167 $tbl->setOrderDirection($_GET["sort_order"]);
168 $tbl->setLimit($_GET["limit"]);
169 $tbl->setOffset($_GET["offset"]);
170 $tbl->disable("sort");
171
172 if($this->download_allowed)
173 {
174 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
175 if($this->is_tutor)
176 {
177 // delete
178 $this->tpl->setCurrentBlock("tbl_action_btn");
179 $this->tpl->setVariable("BTN_NAME", "confirmDeleteArchives");
180 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
181 $this->tpl->parseCurrentBlock();
182 }
183
184 // download
185 $this->tpl->setCurrentBlock("tbl_action_btn");
186 $this->tpl->setVariable("BTN_NAME", "downloadArchives");
187 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
188 $this->tpl->parseCurrentBlock();
189 }
190
191 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
192 $tbl->setMaxCount(count($archives));
193 $archives = array_slice($archives,$_GET['offset'],$_GET['limit']);
194 $tbl->render();
195
196 if(!count($archives))
197 {
198 $this->tpl->setCurrentBlock("notfound");
199 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
200 $this->tpl->setVariable("NUM_COLS",6);
201 $this->tpl->parseCurrentBlock();
202 }
203
204
205 $counter = 0;
206 foreach($archives as $archive_data)
207 {
208 $this->tpl->setCurrentBlock("tbl_content");
209 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
210
211
212 if($this->download_allowed)
213 {
214 $this->tpl->setVariable("VAL_CHECK",ilUtil::formCheckbox(0,"archives[]",$archive_data['archive_id']));
215 }
216 // Type
217 switch($archive_data["archive_type"])
218 {
219 case $this->course_obj->archives_obj->ARCHIVE_XML:
220 $type = $this->lng->txt("crs_xml");
221 break;
222
223 case $this->course_obj->archives_obj->ARCHIVE_HTML:
224 $type = $this->lng->txt("crs_html");
225 break;
226
227 case $this->course_obj->archives_obj->ARCHIVE_PDF:
228 $type = $this->lng->txt("crs_pdf");
229 break;
230 }
231 $this->tpl->setVariable("VAL_TYPE",$type);
232
233 // Name
234 if($archive_data['archive_type'] == $this->course_obj->archives_obj->ARCHIVE_HTML)
235 {
236 $link = '<a href="'.$this->course_obj->archives_obj->course_files_obj->getOnlineLink($archive_data['archive_name']).'"'.
237 ' target="_blank">'.$archive_data["archive_name"].'</a>';
238 }
239 else
240 {
241 $link = $archive_data['archive_name'];
242 }
243
244 $this->tpl->setVariable("VAL_NAME",$link);
245 $this->tpl->setVariable("VAL_SIZE",$archive_data['archive_size']);
246 $this->tpl->setVariable('VAL_DATE',ilDatePresentation::formatDate(new ilDateTime($archive_data['archive_name'],IL_CAL_UNIX)));
247
248 if($archive_data["archive_lang"])
249 {
250 $this->tpl->setVariable("VAL_LANG",$this->lng->txt('lang_'.$archive_data["archive_lang"]));
251 }
252 else
253 {
254 $this->tpl->setVariable("VAL_LANG",$this->lng->txt('crs_not_available'));
255 }
256 $this->tpl->parseCurrentBlock();
257 }
258 $this->tpl->parseCurrentBlock();
259 }
260
261
263 {
264 global $ilAccess,$ilErr;
265
266 // MINIMUM ACCESS LEVEL = 'write'
267 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
268 {
269 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
270 }
271
272 if(!$_POST['archives'])
273 {
274 ilUtil::sendFailure($this->lng->txt("crs_no_archives_selected"));
275 $this->view();
276 return false;
277 }
278 $_SESSION["crs_archives"] = $_POST["archives"];
279 ilUtil::sendQuestion($this->lng->txt("crs_sure_delete_selected_archives"));
280
281 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_confirm_delete_archives.html','Modules/Course');
282 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
283 $this->tpl->setVariable("TXT_ARCHIVE_NAME",$this->lng->txt('crs_file_name'));
284
285 $this->course_obj->initCourseArchiveObject();
286 $counter = 0;
287
288 foreach($_POST['archives'] as $archive_id)
289 {
290 $archive = $this->course_obj->archives_obj->getArchive($archive_id);
291 $this->tpl->setCurrentBlock("archives");
292
293 $this->tpl->setVariable("ARCHIVE_NAME",$archive['archive_name']);
294 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
295 $this->tpl->parseCurrentBlock();
296 }
297
298 $this->tpl->setVariable("DELETE",$this->lng->txt('delete'));
299 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
300
301 return true;
302 }
303
304 function delete()
305 {
306 global $ilAccess,$ilErr;
307
308 // MINIMUM ACCESS LEVEL = 'write'
309 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
310 {
311 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
312 }
313
314 if(!$_SESSION['crs_archives'])
315 {
316 ilUtil::sendFailure($this->lng->txt("crs_no_archives_selected"));
317 $this->view();
318 }
319
320 $this->course_obj->initCourseArchiveObject();
321 foreach($_SESSION['crs_archives'] as $archive_id)
322 {
323 $this->course_obj->archives_obj->delete($archive_id);
324 }
325
326 ilUtil::sendSuccess($this->lng->txt('crs_archives_deleted'));
327 unset($_SESSION["crs_archives"]);
328
329 $this->view();
330 return true;
331 }
332
337 {
338 global $tpl;
339
340 include_once("./Services/Export/classes/class.ilSubItemSelectionTableGUI.php");
341 $sel_table = new ilSubItemSelectionTableGUI($this, "selectXMlArchiveItems",
342 $this->course_obj->getRefId(), "addXMLArchive",
343 $this->lng->txt("crs_add_archive_xml"));
344 $tpl->setContent($sel_table->getHTML());
345 }
346
347 function addXMLArchive()
348 {
349 global $ilAccess;
350
351 // MINIMUM ACCESS LEVEL = 'write'
352 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
353 {
354 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
355 }
356
357 $this->course_obj->initCourseArchiveObject();
358 $this->course_obj->archives_obj->addXML($_POST["sel"]);
359
360 ilUtil::sendSuccess($this->lng->txt("crs_added_new_archive"));
361 $this->view();
362
363 return true;
364 }
365
367 {
368 global $ilAccess;
369
370 // MINIMUM ACCESS LEVEL = 'write'
371 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
372 {
373 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
374 }
375
376 foreach($this->lng->getInstalledLanguages() as $lang_code)
377 {
378 $actions["$lang_code"] = $this->lng->txt('lang_'.$lang_code);
379
380 if($this->lng->getLangKey() == $lang_code)
381 {
382 $selected = $lang_code;
383 }
384 }
385
386 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_selectLanguage.html",'Modules/Course');
387
388 $this->tpl->setVariable("LANGUAGE_SELECTION",$this->lng->txt('crs_archive_language_selection'));
389 $this->tpl->setVariable("LANGUAGE",$this->lng->txt('obj_lng'));
390 $this->tpl->setVariable("INFO_TXT",$this->lng->txt('crs_select_archive_language'));
391 $this->tpl->setVariable("SELECT_FORMACTION",$this->ctrl->getFormAction($this));
392 $this->tpl->setVariable("LANG_SELECTOR",ilUtil::formSelect($selected,'lang',$actions,false,true));
393 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
394 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('crs_add_html_archive'));
395
396 return true;
397 }
398
399 function addHTMLArchive()
400 {
401 global $ilAccess;
402
403 // MINIMUM ACCESS LEVEL = 'write'
404 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
405 {
406 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
407 }
408
409 $this->course_obj->initCourseArchiveObject();
410 $this->course_obj->archives_obj->setLanguage($_POST['lang']);
411 $this->course_obj->archives_obj->addHTML();
412
413 ilUtil::sendSuccess($this->lng->txt("crs_added_new_archive"));
414 $this->view();
415
416 return true;
417 }
418
420 {
421 global $ilAccess;
422
423 // MINIMUM ACCESS LEVEL = 'write'
424 if(!$ilAccess->checkAccess("read",'',$this->course_obj->getRefId()))
425 {
426 $ilErr->raiseError($this->lng->txt('msg_no_perm_write'),$ilErr->MESSAGE);
427 }
428
429 $_POST["archives"] = $_POST["archives"] ? $_POST["archives"] : array();
430
431 if(!count($_POST['archives']))
432 {
433 ilUtil::sendFailure($this->lng->txt('crs_no_archive_selected'));
434 $this->view();
435
436 return false;
437 }
438 if(count($_POST['archives']) > 1)
439 {
440 ilUtil::sendFailure($this->lng->txt('crs_select_one_archive'));
441 $this->view();
442
443 return false;
444 }
445
446 $this->course_obj->initCourseArchiveObject();
447
448 $abs_path = $this->course_obj->archives_obj->getArchiveFile((int) $_POST['archives'][0]);
449 $basename = basename($abs_path);
450
451 ilUtil::deliverFile($abs_path,$basename);
452 }
453
454
456 {
457 if(!$this->is_tutor)
458 {
459 return false;
460 }
461 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
462
463 if(!PATH_TO_ZIP)
464 {
465 ilUtil::sendFailure($this->lng->txt('zip_test_failed'));
466 return true;
467 }
468 /*
469 $this->tpl->setCurrentBlock("btn_cell");
470 $link = $this->ctrl->getLinkTargetByClass(
471 'ilobjectcopygui',
472 'initSourceSelection'
473 );
474 $this->tpl->setVariable('BTN_LINK',$link);
475 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("clone_existing_course"));
476 $this->tpl->parseCurrentBlock();
477 */
478 // create xml archive button
479 $this->tpl->setCurrentBlock("btn_cell");
480 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "selectXMLArchiveItems"));
481 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("crs_add_archive_xml"));
482 $this->tpl->parseCurrentBlock();
483
484 $this->tpl->setCurrentBlock("btn_cell");
485 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "selectArchiveLanguage"));
486 $this->tpl->setVariable("BTN_TXT", $this->lng->txt("crs_add_archive_html"));
487 $this->tpl->parseCurrentBlock();
488
489 return true;
490 }
491
493 {
494 global $tree;
495
496 if($this->content_obj->getType() == 'crs')
497 {
498 // Container is course
499 $this->course_obj =& $this->content_obj;
500 }
501 else
502 {
503 $course_ref_id = $tree->checkForParentType($this->content_obj->getRefId(),'crs');
504 $this->course_obj =& ilObjectFactory::getInstanceByRefId($course_ref_id);
505 }
506 return true;
507 }
508
509
510} // END class.ilCourseArchivesGUI
511?>
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_CAL_UNIX
Class ilCourseArchivesGUI.
ilCourseArchivesGUI(&$content_gui)
Constructor @access public.
& executeCommand()
execute command
selectXMLArchiveItems()
Select items for archive.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
GUI class for the workflow of copying objects.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilTableGUI.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$_POST['username']
Definition: cron.php:12
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35