ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableGUI.php';
5require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
6require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
7
13{
17 protected $ctrl;
18
22 protected $tpl;
23
28 public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
29 {
30 global $DIC;
31
32 $this->ctrl = $DIC['ilCtrl'];
33 $this->tpl = $DIC['tpl'];
34
35 // Call this immediately in constructor
36 $this->setId('tos_acceptance_history');
37
38 $this->setDefaultOrderDirection('DESC');
39 $this->setDefaultOrderField('ts');
40 $this->setExternalSorting(true);
41 $this->setExternalSegmentation(true);
42
43 parent::__construct($a_parent_obj, $a_parent_cmd);
44
45 $this->setTitle($this->lng->txt('tos_acceptance_history'));
46
47 $this->addColumn($this->lng->txt('tos_acceptance_datetime'), 'ts');
48 $this->addColumn($this->lng->txt('login'), 'login');
49 $this->optionalColumns = (array)$this->getSelectableColumns();
50 $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
51 foreach($this->visibleOptionalColumns as $column)
52 {
53 $this->addColumn($this->optionalColumns[$column]['txt'], $column);
54 }
55 $this->addColumn($this->lng->txt('language'), 'lng');
56 $this->addColumn($this->lng->txt('tos_agreement_document'), 'src');
57
58 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAcceptanceHistoryFilter'));
59
60 $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
61
62 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
63 require_once 'Services/YUI/classes/class.ilYuiUtil.php';
67
68 $this->setShowRowsSelector(true);
69
70 $this->initFilter();
71 $this->setFilterCommand('applyAcceptanceHistoryFilter');
72 $this->setResetCommand('resetAcceptanceHistoryFilter');
73 }
74
78 public function getSelectableColumns()
79 {
80 $cols = array(
81 'firstname' => array('txt' => $this->lng->txt('firstname'), 'default' => false),
82 'lastname' => array('txt' => $this->lng->txt('lastname'), 'default' => false)
83 );
84
85 return $cols;
86 }
87
92 protected function prepareData(array &$data)
93 {
94 foreach($data['items'] as &$row)
95 {
96 $row['lng'] = $this->lng->txt('meta_l_' . $row['lng']);
97 }
98 }
99
104 protected function prepareRow(array &$row)
105 {
106 $unique_id = md5($row['usr_id'].$row['ts']);
107
108 $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', $row['tosv_id']);
109 $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAcceptedContentAsynch', '', true, false);
110 $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', '');
111 $row['img_down'] = ilGlyphGUI::get(ilGlyphGUI::SEARCH);
112 $row['id'] = $unique_id;
113
114 $modal = ilModalGUI::getInstance();
115 $modal->setType(ilModalGUI::TYPE_LARGE);
116 $modal->setHeading($this->lng->txt('tos_agreement_document'));
117 $modal->setId('tos_' . $unique_id);
118 $modal->setBody('');
119 $row['modal'] = $modal->getHTML();
120 }
121
125 protected function getStaticData()
126 {
127 return array('modal', 'ts', 'login', 'lng', 'src', 'text', 'id', 'img_down', 'content_link');
128 }
129
135 protected function formatCellValue($column, array $row)
136 {
137 if($column == 'ts')
138 {
140 }
141
142 return $row[$column];
143 }
144
149 public function numericOrdering($column)
150 {
151 if('ts' == $column)
152 {
153 return true;
154 }
155
156 return false;
157 }
158
162 public function initFilter()
163 {
164 include_once 'Services/Form/classes/class.ilTextInputGUI.php';
165 $ul = new ilTextInputGUI($this->lng->txt('login').'/'.$this->lng->txt('email').'/'.$this->lng->txt('name'), 'query');
166 $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
167 $ul->setSize(20);
168 $ul->setSubmitFormOnEnter(true);
169 $this->addFilterItem($ul);
170 $ul->readFromSession();
171 $this->filter['query'] = $ul->getValue();
172
173 include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
174 $options = array();
176 foreach($languages as $lng)
177 {
178 $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
179 }
180 asort($options);
181
182 $options = array('' => $this->lng->txt('any_language')) + $options;
183
184 $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
185 $si->setOptions($options);
186 $this->addFilterItem($si);
187 $si->readFromSession();
188 $this->filter['lng'] = $si->getValue();
189
190 include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
191 $this->tpl->addJavaScript("./Services/Form/js/Form.js");
192 $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
193 $duration->setRequired(true);
194 $duration->setStartText($this->lng->txt('tos_period_from'));
195 $duration->setEndText($this->lng->txt('tos_period_until'));
196 $duration->setStart(new ilDateTime(strtotime('-1 year', time()), IL_CAL_UNIX));
197 $duration->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
198 $duration->setShowTime(true);
199 $this->addFilterItem($duration, true);
200 $duration->readFromSession();
201 $this->optional_filter['period'] = $duration->getValue();
202 }
203}
$column
Definition: 39dropdown.php:62
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
input GUI for a time span (start and end date)
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static get($a_glyph, $a_text="")
Get glyph html.
static getInstance()
Get instance.
Class ilObjectGUI Basic methods of all Output classes.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
This class represents a selection list property in a property form.
getSelectedColumns()
Get selected columns.
setExternalSorting($a_val)
Set external sorting.
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
This class represents a text property in a property form.
static initPanel($a_resize=false)
Init yui panel.
static initOverlay()
Init YUI Overlay module.
static initjQuery($a_tpl=null)
Init jQuery.
$languages
Definition: cssgen2.php:34
global $lng
Definition: privfeed.php:17
if(!is_array($argv)) $options
global $DIC