ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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->setHeading($this->lng->txt('tos_agreement_document'));
108  $modal->setId('tos_' . $unique_id);
109  $modal->setBody('');
110  $row['modal'] = $modal->getHTML();
111  }
112 
116  protected function getStaticData()
117  {
118  return array('modal', 'ts', 'login', 'lng', 'src', 'text', 'id', 'img_down', 'content_link');
119  }
120 
126  protected function formatCellValue($column, array $row)
127  {
128  if($column == 'ts')
129  {
130  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
131  }
132 
133  return $row[$column];
134  }
135 
140  public function numericOrdering($column)
141  {
142  if('ts' == $column)
143  {
144  return true;
145  }
146 
147  return false;
148  }
149 
153  public function initFilter()
154  {
158  global $tpl;
159 
160  include_once 'Services/Form/classes/class.ilTextInputGUI.php';
161  $ul = new ilTextInputGUI($this->lng->txt('login').'/'.$this->lng->txt('email').'/'.$this->lng->txt('name'), 'query');
162  $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
163  $ul->setSize(20);
164  $ul->setSubmitFormOnEnter(true);
165  $this->addFilterItem($ul);
166  $ul->readFromSession();
167  $this->filter['query'] = $ul->getValue();
168 
169  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
170  $options = array();
171  $languages = ilObject::_getObjectsByType('lng');
172  foreach($languages as $lng)
173  {
174  $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
175  }
176  asort($options);
177 
178  $options = array('' => $this->lng->txt('any_language')) + $options;
179 
180  $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
181  $si->setOptions($options);
182  $this->addFilterItem($si);
183  $si->readFromSession();
184  $this->filter['lng'] = $si->getValue();
185 
186  include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
187  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
188  $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
189  $duration->setStartText($this->lng->txt('tos_period_from'));
190  $duration->setEndText($this->lng->txt('tos_period_until'));
191  $duration->setStart(new ilDateTime(strtotime('-1 year', time()), IL_CAL_UNIX));
192  $duration->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
193  $duration->setShowTime(true);
194  $this->addFilterItem($duration, true);
195  $duration->readFromSession();
196  $this->optional_filter['period'] = $duration->getValue();
197  }
198 }
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
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
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.
setFilterCommand($a_val, $a_caption=null)
Set filter command.