ILIAS  release_4-4 Revision
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 
11 {
16  public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
17  {
21  global $ilCtrl;
22 
23  $this->ctrl = $ilCtrl;
24 
25  // Call this immediately in constructor
26  $this->setId('tos_acceptance_history');
27 
28  $this->setDefaultOrderDirection('DESC');
29  $this->setDefaultOrderField('ts');
30  $this->setExternalSorting(true);
31  $this->setExternalSegmentation(true);
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  $this->setTitle($this->lng->txt('tos_acceptance_history'));
36 
37  $this->addColumn($this->lng->txt('tos_acceptance_datetime'), 'ts');
38  $this->addColumn($this->lng->txt('login'), 'login');
39  $this->optionalColumns = (array)$this->getSelectableColumns();
40  $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
41  foreach($this->visibleOptionalColumns as $column)
42  {
43  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
44  }
45  $this->addColumn($this->lng->txt('language'), 'lng');
46  $this->addColumn($this->lng->txt('tos_agreement_document'), 'src');
47 
48  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAcceptanceHistoryFilter'));
49 
50  $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
51 
52  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
53  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
57 
58  $this->setShowRowsSelector(true);
59 
60  $this->initFilter();
61  $this->setFilterCommand('applyAcceptanceHistoryFilter');
62  $this->setResetCommand('resetAcceptanceHistoryFilter');
63  }
64 
68  public function getSelectableColumns()
69  {
70  $cols = array(
71  'firstname' => array('txt' => $this->lng->txt('firstname'), 'default' => false),
72  'lastname' => array('txt' => $this->lng->txt('lastname'), 'default' => false)
73  );
74 
75  return $cols;
76  }
77 
82  protected function prepareData(array &$data)
83  {
84  foreach($data['items'] as &$row)
85  {
86  $row['lng'] = $this->lng->txt('meta_l_' . $row['lng']);
87  }
88  }
89 
94  protected function prepareRow(array &$row)
95  {
96  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', $row['tosv_id']);
97  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAcceptedContentAsynch', '', true, false);
98  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', '');
99  $row['img_down'] = ilUtil::getImagePath('icon_preview.png');
100 
101  $row['id'] = md5($row['usr_id'].$row['ts']);
102  }
103 
107  protected function getStaticData()
108  {
109  return array('ts', 'login', 'lng', 'src', 'text', 'id', 'img_down', 'content_link');
110  }
111 
117  protected function formatCellValue($column, array $row)
118  {
119  if($column == 'ts')
120  {
121  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
122  }
123 
124  return $row[$column];
125  }
126 
131  public function numericOrdering($column)
132  {
133  if('ts' == $column)
134  {
135  return true;
136  }
137 
138  return false;
139  }
140 
144  public function initFilter()
145  {
149  global $tpl;
150 
151  include_once 'Services/Form/classes/class.ilTextInputGUI.php';
152  $ul = new ilTextInputGUI($this->lng->txt('login').'/'.$this->lng->txt('email').'/'.$this->lng->txt('name'), 'query');
153  $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
154  $ul->setSize(20);
155  $ul->setSubmitFormOnEnter(true);
156  $this->addFilterItem($ul);
157  $ul->readFromSession();
158  $this->filter['query'] = $ul->getValue();
159 
160  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
161  $options = array();
162  $languages = ilObject::_getObjectsByType('lng');
163  foreach($languages as $lng)
164  {
165  $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
166  }
167  asort($options);
168 
169  $options = array('' => $this->lng->txt('any_language')) + $options;
170 
171  $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
172  $si->setOptions($options);
173  $this->addFilterItem($si);
174  $si->readFromSession();
175  $this->filter['lng'] = $si->getValue();
176 
177  include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
178  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
179  $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
180  $duration->setStartText($this->lng->txt('tos_period_from'));
181  $duration->setEndText($this->lng->txt('tos_period_until'));
182  $duration->setStart(new ilDateTime(strtotime('-1 year', time()), IL_CAL_UNIX));
183  $duration->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
184  $duration->setMinuteStepSize(5);
185  $duration->setShowTime(true);
186  $duration->setShowDate(true);
187  $this->addFilterItem($duration, true);
188  $duration->readFromSession();
189  $this->optional_filter['period'] = $duration->getValue();
190  }
191 }
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.
setFilterCommand($a_val)
Set filter command.
setExternalSegmentation($a_val)
Set external segmentation.
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 $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)
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.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
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
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
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 initOverlay()
Init YUI Overlay module.
global $lng
Definition: privfeed.php:40
setFormAction($a_form_action)
Set Form action parameter.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
static initjQuery($a_tpl=null)
Init jQuery.
setResetCommand($a_val)
Set reset filter command.