ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTermsOfServiceAcceptanceHistoryTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableGUI.php';
5 require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
6 require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
7 
13 {
18  public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
19  {
23  global $ilCtrl;
24 
25  $this->ctrl = $ilCtrl;
26 
27  // Call this immediately in constructor
28  $this->setId('tos_acceptance_history');
29 
30  $this->setDefaultOrderDirection('DESC');
31  $this->setDefaultOrderField('ts');
32  $this->setExternalSorting(true);
33  $this->setExternalSegmentation(true);
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36 
37  $this->setTitle($this->lng->txt('tos_acceptance_history'));
38 
39  $this->addColumn($this->lng->txt('tos_acceptance_datetime'), 'ts');
40  $this->addColumn($this->lng->txt('login'), 'login');
41  $this->optionalColumns = (array)$this->getSelectableColumns();
42  $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
43  foreach($this->visibleOptionalColumns as $column)
44  {
45  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
46  }
47  $this->addColumn($this->lng->txt('language'), 'lng');
48  $this->addColumn($this->lng->txt('tos_agreement_document'), 'src');
49 
50  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAcceptanceHistoryFilter'));
51 
52  $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
53 
54  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
55  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
59 
60  $this->setShowRowsSelector(true);
61 
62  $this->initFilter();
63  $this->setFilterCommand('applyAcceptanceHistoryFilter');
64  $this->setResetCommand('resetAcceptanceHistoryFilter');
65  }
66 
70  public function getSelectableColumns()
71  {
72  $cols = array(
73  'firstname' => array('txt' => $this->lng->txt('firstname'), 'default' => false),
74  'lastname' => array('txt' => $this->lng->txt('lastname'), 'default' => false)
75  );
76 
77  return $cols;
78  }
79 
84  protected function prepareData(array &$data)
85  {
86  foreach($data['items'] as &$row)
87  {
88  $row['lng'] = $this->lng->txt('meta_l_' . $row['lng']);
89  }
90  }
91 
96  protected function prepareRow(array &$row)
97  {
98  $unique_id = md5($row['usr_id'].$row['ts']);
99 
100  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', $row['tosv_id']);
101  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAcceptedContentAsynch', '', true, false);
102  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', '');
103  $row['img_down'] = ilGlyphGUI::get(ilGlyphGUI::SEARCH);
104  $row['id'] = $unique_id;
105 
106  $modal = ilModalGUI::getInstance();
107  $modal->setType(ilModalGUI::TYPE_LARGE);
108  $modal->setHeading($this->lng->txt('tos_agreement_document'));
109  $modal->setId('tos_' . $unique_id);
110  $modal->setBody('');
111  $row['modal'] = $modal->getHTML();
112  }
113 
117  protected function getStaticData()
118  {
119  return array('modal', 'ts', 'login', 'lng', 'src', 'text', 'id', 'img_down', 'content_link');
120  }
121 
127  protected function formatCellValue($column, array $row)
128  {
129  if($column == 'ts')
130  {
131  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
132  }
133 
134  return $row[$column];
135  }
136 
141  public function numericOrdering($column)
142  {
143  if('ts' == $column)
144  {
145  return true;
146  }
147 
148  return false;
149  }
150 
154  public function initFilter()
155  {
159  global $tpl;
160 
161  include_once 'Services/Form/classes/class.ilTextInputGUI.php';
162  $ul = new ilTextInputGUI($this->lng->txt('login').'/'.$this->lng->txt('email').'/'.$this->lng->txt('name'), 'query');
163  $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
164  $ul->setSize(20);
165  $ul->setSubmitFormOnEnter(true);
166  $this->addFilterItem($ul);
167  $ul->readFromSession();
168  $this->filter['query'] = $ul->getValue();
169 
170  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
171  $options = array();
172  $languages = ilObject::_getObjectsByType('lng');
173  foreach($languages as $lng)
174  {
175  $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
176  }
177  asort($options);
178 
179  $options = array('' => $this->lng->txt('any_language')) + $options;
180 
181  $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
182  $si->setOptions($options);
183  $this->addFilterItem($si);
184  $si->readFromSession();
185  $this->filter['lng'] = $si->getValue();
186 
187  include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
188  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
189  $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
190  $duration->setStartText($this->lng->txt('tos_period_from'));
191  $duration->setEndText($this->lng->txt('tos_period_until'));
192  $duration->setStart(new ilDateTime(strtotime('-1 year', time()), IL_CAL_UNIX));
193  $duration->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
194  $duration->setShowTime(true);
195  $this->addFilterItem($duration, true);
196  $duration->readFromSession();
197  $this->optional_filter['period'] = $duration->getValue();
198  }
199 }
initFilter()
Init filter.
setExternalSorting($a_val)
Set external sorting.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
Constructor.
setDataSource($href, $a_delimiter=null)
set datasource link for js autocomplete
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
This class represents a selection list property in a property form.
setExternalSegmentation($a_val)
Set external segmentation.
static get($a_glyph, $a_text="")
Get glyph html.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
const IL_CAL_UNIX
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
input GUI for a time span (start and end date)
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
if(!is_array($argv)) $options
Class ilObjectGUI Basic methods of all Output classes.
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
getSelectedColumns()
Get selected columns.
setOptions($a_options)
Set Options.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static initPanel($a_resize=false)
Init yui panel.
setStartText($a_txt)
Set text, which will be shown before the start date.
static getInstance()
Get instance.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static initOverlay()
Init YUI Overlay module.
global $lng
Definition: privfeed.php:40
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
static initjQuery($a_tpl=null)
Init jQuery.
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.
setFilterCommand($a_val, $a_caption=null)
Set filter command.