ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $submit_button_label = $this->lng->txt('obj_' . $this->type . '_duplicate');
86 if ($this->parent_obj->getSubMode() === ilObjectCopyGUI::SUBMODE_CONTENT_ONLY) {
87 $submit_button_label = $this->lng->txt('cntr_adopt_content');
88 }
89
90
91 $this->addCommandButton('copyContainerToTargets', $submit_button_label);
92 if ($a_back_cmd == "") { // see bug #25991
93 $this->addCommandButton("cancel", $this->lng->txt('cancel'));
94 } else {
95 $this->addCommandButton($a_back_cmd, $this->lng->txt('btn_back'));
96 }
97 }
98
103 public function getType()
104 {
105 return $this->type;
106 }
107
113 public function parseSource($a_source)
114 {
116 $objDefinition = $this->obj_definition;
117 $ilAccess = $this->access;
118
119 $first = true;
120 foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) {
121 if ($node['type'] == 'rolf') {
122 continue;
123 }
124 if (!$ilAccess->checkAccess('visible', '', $node['child'])) {
125 continue;
126 }
127
128
129 $r = array();
130 $r['last'] = false;
131 $r['source'] = $first;
132 $r['ref_id'] = $node['child'];
133 $r['depth'] = $node['depth'] - $root['depth'];
134 $r['type'] = $node['type'];
135 $r['title'] = $node['title'];
136 $r['copy'] = $objDefinition->allowCopy($node['type']);
137 $r['perm_copy'] = $ilAccess->checkAccess('copy', '', $node['child']);
138 $r['link'] = $objDefinition->allowLink($node['type']);
139 $r['perm_link'] = true;
140
141 // #11905
142 if (!trim($r['title']) && $r['type'] == 'sess') {
143 // use session date as title if no object title
144 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
145 $app_info = ilSessionAppointment::_lookupAppointment($node["obj_id"]);
146 $r['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
147 }
148
149 $rows[] = $r;
150
151 $first = false;
152 }
153 $rows[] = array('last' => true);
154 $this->setData((array) $rows);
155 }
156
160 protected function fillRow($s)
161 {
162 if ($s['last']) {
163 $this->tpl->setCurrentBlock('footer_copy');
164 $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
165 $this->tpl->parseCurrentBlock();
166 $this->tpl->setCurrentBlock('footer_link');
167 $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
168 $this->tpl->parseCurrentBlock();
169 $this->tpl->setCurrentBlock('footer_omit');
170 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
171 $this->tpl->parseCurrentBlock();
172 return true;
173 }
174
175
176 for ($i = 0; $i < $s['depth']; $i++) {
177 $this->tpl->touchBlock('padding');
178 $this->tpl->touchBlock('end_padding');
179 }
180 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
181 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $s['type']));
182 $this->tpl->setVariable('TREE_TITLE', $s['title']);
183
184 if ($s['source']) {
185 return true;
186 }
187
188 // Copy
189 if ($s['perm_copy'] and $s['copy']) {
190 $this->tpl->setCurrentBlock('radio_copy');
191 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
192 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $s['ref_id'] . '][type]');
193 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
194 $this->tpl->setVariable('ID_COPY', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_copy');
195 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
196 $this->tpl->parseCurrentBlock();
197 } elseif ($s['copy']) {
198 $this->tpl->setCurrentBlock('missing_copy_perm');
199 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
200 $this->tpl->parseCurrentBlock();
201 }
202
203
204 // Link
205 if ($s['perm_link'] and $s['link']) {
206 $this->tpl->setCurrentBlock('radio_link');
207 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
208 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $s['ref_id'] . '][type]');
209 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
210 $this->tpl->setVariable('ID_LINK', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_link');
211 if (!$s['copy'] or !$s['perm_copy']) {
212 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
213 }
214 $this->tpl->parseCurrentBlock();
215 } elseif ($s['link']) {
216 $this->tpl->setCurrentBlock('missing_link_perm');
217 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
218 $this->tpl->parseCurrentBlock();
219 }
220
221 // Omit
222 $this->tpl->setCurrentBlock('omit_radio');
223 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
224 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $s['ref_id'] . '][type]');
225 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
226 $this->tpl->setVariable('ID_OMIT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_omit');
227 if ((!$s['copy'] or !$s['perm_copy']) and (!$s['link'])) {
228 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
229 }
230 $this->tpl->parseCurrentBlock();
231 }
232}
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 _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10