ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_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 $DIC;
40 
41  $ilCtrl = $DIC['ilCtrl'];
42 
43  $next_class = $ilCtrl->getNextClass($this);
44  switch ($next_class) {
45  default:
46  $cmd = $ilCtrl->getCmd("show");
47 
48  $this->$cmd();
49  break;
50  }
51  return true;
52  }
53 
57  protected function show()
58  {
59  ilUtil::sendInfo($this->lng->txt('cal_subscription_info'));
60 
61  include_once './Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
62  $info = new ilInfoScreenGUI($this);
63  $info->setFormAction($GLOBALS['DIC']['ilCtrl']->getFormAction($this));
64 
65  if ($this->cal_id > 0) {
68  } elseif ($this->ref_id > 0) {
71  $id = $category->getCategoryID();
72  } else {
74  $id = 0;
75  }
76 
77  $hash = $this->createToken($this->user->getID(), $selection, $id);
78  $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
79  $info->addSection($this->lng->txt("cal_subscription"));
80  $info->addProperty($this->lng->txt('cal_ical_url'), $url, $url);
81 
82  $this->tpl->setContent($info->getHTML());
83  }
84 
88  private function createToken($user_id, $selection, $id)
89  {
90  include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
91  $hash = ilCalendarAuthenticationToken::lookupAuthToken($user_id, $selection, $id);
92  if (strlen($hash)) {
93  return $hash;
94  }
95  $token = new ilCalendarAuthenticationToken($user_id);
96  $token->setSelectionType($selection);
97  $token->setCalendar($id);
98  return $token->add();
99  }
100 
104  protected function getModalForSubscription()
105  {
106  global $DIC;
107 
108  $lng = $DIC->language();
109 
110  $ui_factory = $DIC->ui()->factory();
111  $ui_renderer = $DIC->ui()->renderer();
112 
113  $tpl = new ilTemplate(
114  'tpl.subscription_dialog.html',
115  true,
116  true,
117  'Services/Calendar'
118  );
119 
120  $tpl->setVariable('TXT_SUBSCRIPTION_INFO', $lng->txt('cal_subscription_info'));
121 
122 
123  if ($this->cal_id > 0) {
125  $id = $this->cal_id;
126  } elseif ($this->ref_id > 0) {
129  $id = $category->getCategoryID();
130  } else {
132  $id = 0;
133  }
134  $hash = $this->createToken($this->user->getID(), $selection, $id);
135  $url = ILIAS_HTTP_PATH . '/calendar.php?client_id=' . CLIENT_ID . '&token=' . $hash;
136 
137  $tpl->setVariable('LINK', $url);
138  $tpl->setVariable('TXT_PERMA', $lng->txt('cal_ical_url'));
139 
140  $roundtrip = $ui_factory->modal()->roundtrip(
141  $lng->txt('cal_calendar_subscription_modal_title'),
142  $ui_factory->legacy($tpl->get())
143  );
144  echo $ui_renderer->render($roundtrip);
145  exit;
146  }
147 }
Class ilInfoScreenGUI.
getModalForSubscription()
gGet modal for subscription
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
__construct($a_calendar_id, $a_ref_id=0)
Constructor.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
Show calendar subscription info.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$lng
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
static _getInstanceByObjId($a_obj_id)
get instance by obj_id
createToken($user_id, $selection, $id)
Create calendar token.
exit
Definition: backend.php:16
static lookupAuthToken($a_user_id, $a_selection, $a_calendar=0)
Handles calendar authentication tokens for external calendar subscriptions.
$url
$info
Definition: index.php:5
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.