ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCalendarSubscriptionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
5
13{
14 private $cal_id = 0;
15 private $calendar = null;
16
21 public function __construct($a_calendar_id, $a_ref_id = 0)
22 {
23 global $DIC;
24
25 $this->cal_id = $a_calendar_id;
26 $this->ref_id = $a_ref_id;
27 $this->user = $DIC->user();
28 $this->lng = $DIC->language();
29 $this->tpl = $DIC["tpl"];
30
31 include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
32 }
33
37 public function executeCommand()
38 {
39 global $ilCtrl;
40
41 $next_class = $ilCtrl->getNextClass($this);
42 switch ($next_class) {
43 default:
44 $cmd = $ilCtrl->getCmd("show");
45
46 $this->$cmd();
47 break;
48 }
49 return true;
50 }
51
55 protected function show()
56 {
57 ilUtil::sendInfo($this->lng->txt('cal_subscription_info'));
58
59 include_once './Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
60 $info = new ilInfoScreenGUI($this);
61 $info->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
62
63 if ($this->cal_id > 0) {
66 } elseif ($this->ref_id > 0) {
69 $id = $category->getCategoryID();
70 } else {
72 $id = 0;
73 }
74
75 $hash = $this->createToken($this->user->getID(), $selection, $id);
76 $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
77 $info->addSection($this->lng->txt("cal_subscription"));
78 $info->addProperty($this->lng->txt('cal_ical_url'), $url, $url);
79
80 $this->tpl->setContent($info->getHTML());
81 }
82
86 private function createToken($user_id, $selection, $id)
87 {
88 include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
89 $hash = ilCalendarAuthenticationToken::lookupAuthToken($user_id, $selection, $id);
90 if (strlen($hash)) {
91 return $hash;
92 }
93 $token = new ilCalendarAuthenticationToken($user_id);
94 $token->setSelectionType($selection);
95 $token->setCalendar($id);
96 return $token->add();
97 }
98}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Handles calendar authentication tokens for external calendar subscriptions.
static lookupAuthToken($a_user_id, $a_selection, $a_calendar=0)
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
Show calendar subscription info.
createToken($user_id, $selection, $id)
Create calendar token.
__construct($a_calendar_id, $a_ref_id=0)
Constructor.
Class ilInfoScreenGUI.
static _lookupObjId($a_id)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
$url
global $DIC
Definition: saml.php:7