4 require_once
'Services/Object/classes/class.ilObject2GUI.php';
5 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
6 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
7 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
8 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceAgreementByLanguageTableGUI.php';
9 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceAcceptanceHistoryTableGUI.php';
54 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
64 $this->lng->loadLanguageModule(
'tos');
67 $this->factory->setLanguageAdapter($lng);
68 $this->factory->setDatabaseAdapter($ilDB);
84 $next_class = $this->ctrl->getNextClass($this);
85 $cmd = $this->ctrl->getCmd();
90 case 'ilpermissiongui':
91 $this->tabs_gui->setTabActive(
'perm_settings');
92 require_once
'Services/AccessControl/classes/class.ilPermissionGUI.php';
94 $this->ctrl->forwardCommand($perm_gui);
117 if($rbacsystem->checkAccess(
'read', $this->object->getRefId()))
119 $tabs_gui->
addTarget(
'settings', $this->ctrl->getLinkTarget($this,
'settings'), array(
'saveSettings',
'settings',
'',
'view'),
'',
'');
122 if($rbacsystem->checkAccess(
'read', $this->object->getRefId()))
124 $tabs_gui->
addTarget(
'tos_agreement_by_lng', $this->ctrl->getLinkTarget($this,
'showAgreementByLanguage'), array(
'reset',
'confirmReset',
'showAgreementByLanguage',
'resetAgreementByLanguageFilter',
'applyAgreementByLanguageFilter'),
'',
'');
127 if($rbacsystem->checkAccess(
'read', $this->object->getRefId()) &&
131 $tabs_gui->
addTarget(
'tos_acceptance_history', $this->ctrl->getLinkTarget($this,
'showAcceptanceHistory'), array(
'showAcceptanceHistory',
'resetAcceptanceHistoryFilter',
'applyAcceptanceHistoryFilter'),
'',
'');
134 if($rbacsystem->checkAccess(
'edit_permission', $this->object->getRefId()))
136 $tabs_gui->
addTarget(
'perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
'perm'), array(
'perm',
'info',
'owner'),
'ilpermissiongui');
145 if(null == $this->form)
148 $this->form->setTitle($this->lng->txt(
'tos_tos_settings'));
149 $this->form->setFormAction($this->ctrl->getFormAction($this,
'saveSettings'));
152 $status->
setInfo($this->lng->txt(
'tos_status_desc'));
153 $this->form->addItem($status);
155 $this->form->addCommandButton(
'saveSettings', $this->lng->txt(
'save'));
162 protected function saveSettings()
168 global $rbacsystem,
$ilErr;
170 if(!$rbacsystem->checkAccess(
'write', $this->object->getRefId()))
172 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
176 $list = $provider->getList(array(), array());
178 $has_documents =
false;
179 foreach($list[
'items'] as $item)
181 if($item[
'agreement_document'])
183 $has_documents =
true;
189 if($this->form->checkInput())
191 if($has_documents || !(
int)$this->form->getInput(
'tos_status'))
193 $this->
object->saveStatus((
int)$this->form->getInput(
'tos_status'));
200 (
int)$this->form->getInput(
'tos_status') &&
201 !$this->
object->getStatus()
208 $this->settings(
false);
214 protected function settings($init_from_database =
true)
223 if(!$rbacsystem->checkAccess(
'read', $this->object->getRefId()))
225 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
231 if($init_from_database)
233 $this->form->setValuesByArray(array(
234 'tos_status' => $this->object->getStatus()
239 $this->form->setValuesByPost();
242 $tpl->setContent($this->form->getHtml());
248 protected function confirmReset()
257 if(!$rbacsystem->checkAccess(
'write', $this->object->getRefId()))
259 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
263 $confirmation->setFormAction($this->ctrl->getFormAction($this,
'confirmReset'));
264 $confirmation->setConfirm($this->lng->txt(
'confirm'),
'reset');
265 $confirmation->setCancel($this->lng->txt(
'cancel'),
'showAgreementByLanguage');
266 $confirmation->setHeaderText($this->lng->txt(
'tos_sure_reset_tos'));
268 $tpl->setContent($confirmation->getHtml());
274 protected function reset()
284 if(!$rbacsystem->checkAccess(
'write', $this->object->getRefId()))
286 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
289 $this->
object->resetAll();
290 $ilLog->write(__METHOD__ .
': Terms of service reset by ' . $ilUser->getId() .
' [' . $ilUser->getLogin() .
']');
293 $this->showAgreementByLanguage();
299 protected function showAgreementByLanguage()
309 if(!$rbacsystem->checkAccess(
'read', $this->object->getRefId()))
311 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
314 $this->lng->loadLanguageModule(
'meta');
316 if($rbacsystem->checkAccess(
'write', $this->object->getRefId()))
318 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
'settings'));
319 $ilToolbar->addFormButton($this->lng->txt(
'tos_reset_tos_for_all_users'),
'confirmReset');
322 $this->showLastResetDate();
328 $tpl->setContent($table->getHtml());
334 protected function showLastResetDate()
341 if($this->object->getLastResetDate() && $this->
object->getLastResetDate()->get(
IL_CAL_UNIX) != 0)
355 if(!$this->object->getStatus())
361 $list = $provider->getList(array(), array());
363 $has_documents =
false;
364 foreach($list[
'items'] as $item)
366 if($item[
'agreement_document'])
368 $has_documents =
true;
385 $table->resetOffset();
386 $table->writeFilterToSession();
388 $this->showAgreementByLanguage();
397 $table->resetOffset();
398 $table->resetFilter();
400 $this->showAgreementByLanguage();
406 protected function getAgreementTextByFilenameAsynch()
413 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceJsonResponse.php';
416 if(!isset(
$_GET[
'agreement_document']) || !strlen(
$_GET[
'agreement_document']) || !$rbacsystem->checkAccess(
'read', $this->object->getRefId()))
423 if(preg_match(
'/Customizing[\/\\\](global[\/\\\]agreement|clients[\/\\\]' . CLIENT_ID .
'[\/\\\]agreement)[\/\\\]agreement_([a-z]{2})\.html$/',
$file))
425 $response->setBody(nl2br(trim(file_get_contents(
$file))));
438 protected function showAcceptanceHistory()
447 if(!$rbacsystem->checkAccess(
'read',
'', $this->object->getRefId()) ||
451 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
454 $this->lng->loadLanguageModule(
'meta');
460 $tpl->setContent($table->getHtml());
468 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceJsonResponse.php';
471 if(!isset(
$_GET[
'tosv_id']))
478 $response->setBody($entity->getText());
486 protected function addUserAutoComplete()
493 if(!$rbacsystem->checkAccess(
'read',
'', $this->object->getRefId()) ||
497 echo json_encode(array());
501 include_once
'Services/User/classes/class.ilUserAutoComplete.php';
503 $auto->setSearchFields(array(
'login',
'firstname',
'lastname',
'email'));
504 $auto->enableFieldSearchableCheck(
false);
515 $table->resetOffset();
516 $table->writeFilterToSession();
518 $this->showAcceptanceHistory();
527 $table->resetOffset();
528 $table->resetFilter();
530 $this->showAcceptanceHistory();