ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
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  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
53  }
54  $this->addColumn($this->lng->txt('language'), 'lng');
55  $this->addColumn($this->lng->txt('tos_agreement_document'), 'src');
56 
57  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAcceptanceHistoryFilter'));
58 
59  $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
60 
61  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
62  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
66 
67  $this->setShowRowsSelector(true);
68 
69  $this->initFilter();
70  $this->setFilterCommand('applyAcceptanceHistoryFilter');
71  $this->setResetCommand('resetAcceptanceHistoryFilter');
72  }
73 
77  public function getSelectableColumns()
78  {
79  $cols = array(
80  'firstname' => array('txt' => $this->lng->txt('firstname'), 'default' => false),
81  'lastname' => array('txt' => $this->lng->txt('lastname'), 'default' => false)
82  );
83 
84  return $cols;
85  }
86 
91  protected function prepareData(array &$data)
92  {
93  foreach ($data['items'] as &$row) {
94  $row['lng'] = $this->lng->txt('meta_l_' . $row['lng']);
95  }
96  }
97 
102  protected function prepareRow(array &$row)
103  {
104  $unique_id = md5($row['usr_id'] . $row['ts']);
105 
106  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', $row['tosv_id']);
107  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAcceptedContentAsynch', '', true, false);
108  $this->ctrl->setParameter($this->getParentObject(), 'tosv_id', '');
109  $row['img_down'] = ilGlyphGUI::get(ilGlyphGUI::SEARCH);
110  $row['id'] = $unique_id;
111 
112  $modal = ilModalGUI::getInstance();
113  $modal->setType(ilModalGUI::TYPE_LARGE);
114  $modal->setHeading($this->lng->txt('tos_agreement_document'));
115  $modal->setId('tos_' . $unique_id);
116  $modal->setBody('');
117  $row['modal'] = $modal->getHTML();
118  }
119 
123  protected function getStaticData()
124  {
125  return array('modal', 'ts', 'login', 'lng', 'src', 'text', 'id', 'img_down', 'content_link');
126  }
127 
133  protected function formatCellValue($column, array $row)
134  {
135  if ($column == 'ts') {
137  }
138 
139  return $row[$column];
140  }
141 
146  public function numericOrdering($column)
147  {
148  if ('ts' == $column) {
149  return true;
150  }
151 
152  return false;
153  }
154 
158  public function initFilter()
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  $options[$lng['title']] = $this->lng->txt('meta_l_' . $lng['title']);
174  }
175  asort($options);
176 
177  $options = array('' => $this->lng->txt('any_language')) + $options;
178 
179  $si = new ilSelectInputGUI($this->lng->txt('language'), 'lng');
180  $si->setOptions($options);
181  $this->addFilterItem($si);
182  $si->readFromSession();
183  $this->filter['lng'] = $si->getValue();
184 
185  include_once 'Services/Form/classes/class.ilDateDurationInputGUI.php';
186  $this->tpl->addJavaScript("./Services/Form/js/Form.js");
187  $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
188  $duration->setRequired(true);
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 }
setExternalSorting($a_val)
Set external sorting.
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.
global $DIC
Definition: saml.php:7
setExternalSegmentation($a_val)
Set external segmentation.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
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.
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)
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
$column
Definition: 39dropdown.php:62
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
Class ilObjectGUI Basic methods of all Output classes.
This class represents a text property in a property form.
Date and time handling
getSelectedColumns()
Get selected columns.
setOptions($a_options)
Set Options.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static getInstance()
Get instance.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
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.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
$cols
Definition: xhr_table.php:11
setRequired($a_required)
Set Required.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
setFilterCommand($a_val, $a_caption=null)
Set filter command.