ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
6 
14 {
15  private $type = '';
16  private $selected_reference = null;
17 
24  public function __construct($a_parent_class,$a_parent_cmd,$a_type,$a_back_cmd)
25  {
26  global $lng,$ilCtrl,$ilUser,$objDefinition;
27 
28  parent::__construct($a_parent_class,$a_parent_cmd);
29  $this->type = $a_type;
30 
31  $this->lng = $lng;
32  $this->ctrl = $ilCtrl;
33 
34  $this->setTitle($this->lng->txt($this->type.'_wizard_page'));
35 
36 
37  $this->addColumn($this->lng->txt('title'),'','55%');
38  $this->addColumn($this->lng->txt('copy'),'','15%');
39  $this->addColumn($this->lng->txt('link'),'','15%');
40  $this->addColumn($this->lng->txt('omit'),'','15%');
41 
42  $this->setEnableHeader(true);
43  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
44  $this->setRowTemplate("tpl.obj_copy_selection_row.html", "Services/Object");
45  $this->setEnableTitle(true);
46  $this->setEnableNumInfo(true);
47  $this->setLimit(999999);
48 
49  $this->setFormName('cmd');
50 
51  $this->addCommandButton('copyContainer', $this->lng->txt('obj_'.$this->type.'_duplicate'));
52  $this->addCommandButton($a_back_cmd, $this->lng->txt('btn_back'));
53  }
54 
59  public function getType()
60  {
61  return $this->type;
62  }
63 
69  public function parseSource($a_source)
70  {
71  global $tree,$objDefinition, $ilAccess;
72 
73  $first = true;
74  foreach($tree->getSubTree($root = $tree->getNodeData($a_source)) as $node)
75  {
76  if($node['type'] == 'rolf')
77  {
78  continue;
79  }
80  if(!$ilAccess->checkAccess('visible,read','',$node['child']))
81  {
82  continue;
83  }
84 
85 
86  $r = array();
87  $r['last'] = false;
88  $r['source']= $first;
89  $r['ref_id']= $node['child'];
90  $r['depth'] = $node['depth'] - $root['depth'];
91  $r['type'] = $node['type'];
92  $r['title'] = $node['title'];
93  $r['copy'] = $objDefinition->allowCopy($node['type']);
94  $r['perm_copy'] = $ilAccess->checkAccess('copy','',$node['child']);
95  $r['link'] = $objDefinition->allowLink($node['type']);
96  $r['perm_link'] = true;
97 
98  // #11905
99  if(!trim($r['title']) && $r['type'] == 'sess')
100  {
101  // use session date as title if no object title
102  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
103  $app_info = ilSessionAppointment::_lookupAppointment($node["obj_id"]);
104  $r['title'] = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']);
105  }
106 
107  $rows[] = $r;
108 
109  $first = false;
110  }
111  $rows[] = array('last' => true);
112  $this->setData((array) $rows);
113  }
114 
118  protected function fillRow($s)
119  {
120  if($s['last'])
121  {
122  $this->tpl->setCurrentBlock('footer_copy');
123  $this->tpl->setVariable('TXT_COPY_ALL',$this->lng->txt('copy_all'));
124  $this->tpl->parseCurrentBlock();
125  $this->tpl->setCurrentBlock('footer_link');
126  $this->tpl->setVariable('TXT_LINK_ALL',$this->lng->txt('link_all'));
127  $this->tpl->parseCurrentBlock();
128  $this->tpl->setCurrentBlock('footer_omit');
129  $this->tpl->setVariable('TXT_OMIT_ALL',$this->lng->txt('omit_all'));
130  $this->tpl->parseCurrentBlock();
131  return true;
132  }
133 
134 
135  for($i = 0; $i < $s['depth']; $i++)
136  {
137  $this->tpl->touchBlock('padding');
138  $this->tpl->touchBlock('end_padding');
139  }
140  $this->tpl->setVariable('TREE_IMG',ilObject::_getIcon(ilObject::_lookupObjId($s['ref_id']), "tiny", $s['type']));
141  $this->tpl->setVariable('TREE_ALT_IMG',$this->lng->txt('obj_'.$s['type']));
142  $this->tpl->setVariable('TREE_TITLE',$s['title']);
143 
144  if($s['source'])
145  {
146  return true;
147  }
148 
149  // Copy
150  if($s['perm_copy'] and $s['copy'])
151  {
152  $this->tpl->setCurrentBlock('radio_copy');
153  $this->tpl->setVariable('TXT_COPY',$this->lng->txt('copy'));
154  $this->tpl->setVariable('NAME_COPY','cp_options['.$s['ref_id'].'][type]');
155  $this->tpl->setVariable('VALUE_COPY',ilCopyWizardOptions::COPY_WIZARD_COPY);
156  $this->tpl->setVariable('ID_COPY',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_copy');
157  $this->tpl->setVariable('COPY_CHECKED','checked="checked"');
158  $this->tpl->parseCurrentBlock();
159  }
160  elseif($s['copy'])
161  {
162  $this->tpl->setCurrentBlock('missing_copy_perm');
163  $this->tpl->setVariable('TXT_MISSING_COPY_PERM',$this->lng->txt('missing_perm'));
164  $this->tpl->parseCurrentBlock();
165  }
166 
167 
168  // Link
169  if($s['perm_link'] and $s['link'])
170  {
171  $this->tpl->setCurrentBlock('radio_link');
172  $this->tpl->setVariable('TXT_LINK',$this->lng->txt('link'));
173  $this->tpl->setVariable('NAME_LINK','cp_options['.$s['ref_id'].'][type]');
174  $this->tpl->setVariable('VALUE_LINK',ilCopyWizardOptions::COPY_WIZARD_LINK);
175  $this->tpl->setVariable('ID_LINK',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_link');
176  if(!$s['copy'] or !$s['perm_copy'])
177  {
178  $this->tpl->setVariable('LINK_CHECKED','checked="checked"');
179  }
180  $this->tpl->parseCurrentBlock();
181  }
182  elseif($s['link'])
183  {
184  $this->tpl->setCurrentBlock('missing_link_perm');
185  $this->tpl->setVariable('TXT_MISSING_LINK_PERM',$this->lng->txt('missing_perm'));
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  // Omit
190  $this->tpl->setCurrentBlock('omit_radio');
191  $this->tpl->setVariable('TXT_OMIT',$this->lng->txt('omit'));
192  $this->tpl->setVariable('NAME_OMIT','cp_options['.$s['ref_id'].'][type]');
193  $this->tpl->setVariable('VALUE_OMIT',ilCopyWizardOptions::COPY_WIZARD_OMIT);
194  $this->tpl->setVariable('ID_OMIT',$s['depth'].'_'.$s['type'].'_'.$s['ref_id'].'_omit');
195  if((!$s['copy'] or !$s['perm_copy']) and (!$s['link']))
196  {
197  $this->tpl->setVariable('OMIT_CHECKED','checked="checked"');
198  }
199  $this->tpl->parseCurrentBlock();
200 
201  }
202 
203 
204 
205 }
206 ?>