ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $this->addCommandButton('copyContainerToTargets', $this->lng->txt('obj_' . $this->type . '_duplicate'));
86 $this->addCommandButton($a_back_cmd, $this->lng->txt('btn_back'));
87 }
88
93 public function getType()
94 {
95 return $this->type;
96 }
97
103 public function parseSource($a_source)
104 {
106 $objDefinition = $this->obj_definition;
107 $ilAccess = $this->access;
108
109 $first = true;
110 foreach ($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node) {
111 if ($node['type'] == 'rolf') {
112 continue;
113 }
114 if (!$ilAccess->checkAccess('visible', '', $node['child'])) {
115 continue;
116 }
117
118
119 $r = array();
120 $r['last'] = false;
121 $r['source']= $first;
122 $r['ref_id']= $node['child'];
123 $r['depth'] = $node['depth'] - $root['depth'];
124 $r['type'] = $node['type'];
125 $r['title'] = $node['title'];
126 $r['copy'] = $objDefinition->allowCopy($node['type']);
127 $r['perm_copy'] = $ilAccess->checkAccess('copy', '', $node['child']);
128 $r['link'] = $objDefinition->allowLink($node['type']);
129 $r['perm_link'] = true;
130
131 // #11905
132 if (!trim($r['title']) && $r['type'] == 'sess') {
133 // use session date as title if no object title
134 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
135 $app_info = ilSessionAppointment::_lookupAppointment($node["obj_id"]);
136 $r['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
137 }
138
139 $rows[] = $r;
140
141 $first = false;
142 }
143 $rows[] = array('last' => true);
144 $this->setData((array) $rows);
145 }
146
150 protected function fillRow($s)
151 {
152 if ($s['last']) {
153 $this->tpl->setCurrentBlock('footer_copy');
154 $this->tpl->setVariable('TXT_COPY_ALL', $this->lng->txt('copy_all'));
155 $this->tpl->parseCurrentBlock();
156 $this->tpl->setCurrentBlock('footer_link');
157 $this->tpl->setVariable('TXT_LINK_ALL', $this->lng->txt('link_all'));
158 $this->tpl->parseCurrentBlock();
159 $this->tpl->setCurrentBlock('footer_omit');
160 $this->tpl->setVariable('TXT_OMIT_ALL', $this->lng->txt('omit_all'));
161 $this->tpl->parseCurrentBlock();
162 return true;
163 }
164
165
166 for ($i = 0; $i < $s['depth']; $i++) {
167 $this->tpl->touchBlock('padding');
168 $this->tpl->touchBlock('end_padding');
169 }
170 $this->tpl->setVariable('TREE_IMG', ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
171 $this->tpl->setVariable('TREE_ALT_IMG', $this->lng->txt('obj_' . $s['type']));
172 $this->tpl->setVariable('TREE_TITLE', $s['title']);
173
174 if ($s['source']) {
175 return true;
176 }
177
178 // Copy
179 if ($s['perm_copy'] and $s['copy']) {
180 $this->tpl->setCurrentBlock('radio_copy');
181 $this->tpl->setVariable('TXT_COPY', $this->lng->txt('copy'));
182 $this->tpl->setVariable('NAME_COPY', 'cp_options[' . $s['ref_id'] . '][type]');
183 $this->tpl->setVariable('VALUE_COPY', ilCopyWizardOptions::COPY_WIZARD_COPY);
184 $this->tpl->setVariable('ID_COPY', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_copy');
185 $this->tpl->setVariable('COPY_CHECKED', 'checked="checked"');
186 $this->tpl->parseCurrentBlock();
187 } elseif ($s['copy']) {
188 $this->tpl->setCurrentBlock('missing_copy_perm');
189 $this->tpl->setVariable('TXT_MISSING_COPY_PERM', $this->lng->txt('missing_perm'));
190 $this->tpl->parseCurrentBlock();
191 }
192
193
194 // Link
195 if ($s['perm_link'] and $s['link']) {
196 $this->tpl->setCurrentBlock('radio_link');
197 $this->tpl->setVariable('TXT_LINK', $this->lng->txt('link'));
198 $this->tpl->setVariable('NAME_LINK', 'cp_options[' . $s['ref_id'] . '][type]');
199 $this->tpl->setVariable('VALUE_LINK', ilCopyWizardOptions::COPY_WIZARD_LINK);
200 $this->tpl->setVariable('ID_LINK', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_link');
201 if (!$s['copy'] or !$s['perm_copy']) {
202 $this->tpl->setVariable('LINK_CHECKED', 'checked="checked"');
203 }
204 $this->tpl->parseCurrentBlock();
205 } elseif ($s['link']) {
206 $this->tpl->setCurrentBlock('missing_link_perm');
207 $this->tpl->setVariable('TXT_MISSING_LINK_PERM', $this->lng->txt('missing_perm'));
208 $this->tpl->parseCurrentBlock();
209 }
210
211 // Omit
212 $this->tpl->setCurrentBlock('omit_radio');
213 $this->tpl->setVariable('TXT_OMIT', $this->lng->txt('omit'));
214 $this->tpl->setVariable('NAME_OMIT', 'cp_options[' . $s['ref_id'] . '][type]');
215 $this->tpl->setVariable('VALUE_OMIT', ilCopyWizardOptions::COPY_WIZARD_OMIT);
216 $this->tpl->setVariable('ID_OMIT', $s['depth'] . '_' . $s['type'] . '_' . $s['ref_id'] . '_omit');
217 if ((!$s['copy'] or !$s['perm_copy']) and (!$s['link'])) {
218 $this->tpl->setVariable('OMIT_CHECKED', 'checked="checked"');
219 }
220 $this->tpl->parseCurrentBlock();
221 }
222}
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.
$i
Definition: disco.tpl.php:19
$r
Definition: example_031.php:79
global $ilCtrl
Definition: ilias.php:18
$s
Definition: pwgen.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