ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjectCopySelectionTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
6
14{
18 protected $ctrl;
19
23 protected $user;
24
28 protected $obj_definition;
29
33 protected $tree;
34
38 protected $access;
39
40 private $type = '';
41 private $selected_reference = null;
42
49 public function __construct($a_parent_class, $a_parent_cmd, $a_type, $a_back_cmd)
50 {
51 global $DIC;
52
53 $this->user = $DIC->user();
54 $this->obj_definition = $DIC["objDefinition"];
55 $this->tree = $DIC->repositoryTree();
56 $this->access = $DIC->access();
57 $lng = $DIC->language();
58 $ilCtrl = $DIC->ctrl();
59 $ilUser = $DIC->user();
60 $objDefinition = $DIC["objDefinition"];
61
62 parent::__construct($a_parent_class, $a_parent_cmd);
63 $this->type = $a_type;
64
65 $this->lng = $lng;
66 $this->ctrl = $ilCtrl;
67
68 $this->setTitle($this->lng->txt($this->type . '_wizard_page'));
69
70
71 $this->addColumn($this->lng->txt('title'), '', '55%');
72 $this->addColumn($this->lng->txt('copy'), '', '15%');
73 $this->addColumn($this->lng->txt('link'), '', '15%');
74 $this->addColumn($this->lng->txt('omit'), '', '15%');
75
76 $this->setEnableHeader(true);
77 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
78 $this->setRowTemplate("tpl.obj_copy_selection_row.html", "Services/Object");
79 $this->setEnableTitle(true);
80 $this->setEnableNumInfo(true);
81 $this->setLimit(999999);
82
83 $this->setFormName('cmd');
84
85
86 $this->addCommandButton('copyContainerToTargets', $this->lng->txt('obj_' . $this->type . '_duplicate'));
87 if ($a_back_cmd == "") { // see bug #25991
88 $this->addCommandButton("cancel", $this->lng->txt('cancel'));
89 } else {
90 $this->addCommandButton($a_back_cmd, $this->lng->txt('btn_back'));
91 }
92 }
93
98 public function getType()
99 {
100 return $this->type;
101 }
102
108 public function parseSource($a_source)
109 {
111 $objDefinition = $this->obj_definition;
112 $ilAccess = $this->access;
113
114 $first = true;
115 foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) {
116 if ($node['type'] == 'rolf') {
117 continue;
118 }
119 if (!$ilAccess->checkAccess('visible', '', $node['child'])) {
120 continue;
121 }
122
123
124 $r = array();
125 $r['last'] = false;
126 $r['source'] = $first;
127 $r['ref_id'] = $node['child'];
128 $r['depth'] = $node['depth'] - $root['depth'];
129 $r['type'] = $node['type'];
130 $r['title'] = $node['title'];
131 $r['copy'] = $objDefinition->allowCopy($node['type']);
132 $r['perm_copy'] = $ilAccess->checkAccess('copy', '', $node['child']);
133 $r['link'] = $objDefinition->allowLink($node['type']);
134 $r['perm_link'] = true;
135
136 // #11905
137 if (!trim($r['title']) && $r['type'] == 'sess') {
138 // use session date as title if no object title
139 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
140 $app_info = ilSessionAppointment::_lookupAppointment($node["obj_id"]);
141 $r['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
142 }
143
144 $rows[] = $r;
145
146 $first = false;
147 }
148 $rows[] = array('last' => true);
149 $this->setData((array) $rows);
150 }
151
155 protected function fillRow($s)
156 {
157 if ($s['last']) {
158 $this->tpl->setCurrentBlock('footer_copy');
159 $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
160 $this->tpl->parseCurrentBlock();
161 $this->tpl->setCurrentBlock('footer_link');
162 $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
163 $this->tpl->parseCurrentBlock();
164 $this->tpl->setCurrentBlock('footer_omit');
165 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
166 $this->tpl->parseCurrentBlock();
167 return true;
168 }
169
170
171 for ($i = 0; $i < $s['depth']; $i++) {
172 $this->tpl->touchBlock('padding');
173 $this->tpl->touchBlock('end_padding');
174 }
175 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
176 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $s['type']));
177 $this->tpl->setVariable('TREE_TITLE', $s['title']);
178
179 if ($s['source']) {
180 return true;
181 }
182
183 // Copy
184 if ($s['perm_copy'] and $s['copy']) {
185 $this->tpl->setCurrentBlock('radio_copy');
186 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
187 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $s['ref_id'] . '][type]');
188 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
189 $this->tpl->setVariable('ID_COPY', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_copy');
190 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
191 $this->tpl->parseCurrentBlock();
192 } elseif ($s['copy']) {
193 $this->tpl->setCurrentBlock('missing_copy_perm');
194 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
195 $this->tpl->parseCurrentBlock();
196 }
197
198
199 // Link
200 if ($s['perm_link'] and $s['link']) {
201 $this->tpl->setCurrentBlock('radio_link');
202 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
203 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $s['ref_id'] . '][type]');
204 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
205 $this->tpl->setVariable('ID_LINK', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_link');
206 if (!$s['copy'] or !$s['perm_copy']) {
207 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
208 }
209 $this->tpl->parseCurrentBlock();
210 } elseif ($s['link']) {
211 $this->tpl->setCurrentBlock('missing_link_perm');
212 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
213 $this->tpl->parseCurrentBlock();
214 }
215
216 // Omit
217 $this->tpl->setCurrentBlock('omit_radio');
218 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
219 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $s['ref_id'] . '][type]');
220 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
221 $this->tpl->setVariable('ID_OMIT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_omit');
222 if ((!$s['copy'] or !$s['perm_copy']) and (!$s['link'])) {
223 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
224 }
225 $this->tpl->parseCurrentBlock();
226 }
227}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
__construct($a_parent_class, $a_parent_cmd, $a_type, $a_back_cmd)
static _lookupObjId($a_id)
static _lookupAppointment($a_obj_id)
lookup appointment
static _appointmentToString($start, $end, $fulltime)
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
global $ilCtrl
Definition: ilias.php:18
$s
Definition: pwgen.php:45
$root
Definition: sabredav.php:45
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$rows
Definition: xhr_table.php:10