ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
22  {
23  $this->cal_id = $a_calendar_id;
24  include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
25  $this->calendar = new ilCalendarCategory($this->cal_id);
26  }
27 
32  public function getCalendarId()
33  {
34  return $this->cal_id;
35  }
36 
37  public function getCalendar()
38  {
39  return $this->calendar ? $this->calendar : new ilCalendarCategory();
40  }
41 
45  public function executeCommand()
46  {
47  global $ilCtrl;
48 
49  $next_class = $ilCtrl->getNextClass($this);
50  switch($next_class)
51  {
52  default:
53  $cmd = $ilCtrl->getCmd("show");
54 
55  $this->$cmd();
56  break;
57  }
58  return true;
59  }
60 
64  protected function show()
65  {
66  $token = $this->createToken();
67 
68  ilUtil::sendInfo($GLOBALS['lng']->txt('cal_subscription_info'));
69 
70  include_once './Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
71  $info = new ilInfoScreenGUI($this);
72  $info->setFormAction($GLOBALS['ilCtrl']->getFormAction($this));
73 
74  $hash = $this->createToken();
75  $url = ILIAS_HTTP_PATH.'/calendar.php?client_id='.CLIENT_ID.'&token='.$hash;
76  $info->addSection($this->getCalendar()->getTitle());
77  $info->addProperty('Abonnieren', $url, $url);
78 
79  $GLOBALS['tpl']->setContent($info->getHTML());
80  }
81 
85  private function createToken()
86  {
87  include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
89  $GLOBALS['ilUser']->getId(),
91  $this->getCalendarId()
92  );
93  if(strlen($hash))
94  {
95  return $hash;
96  }
97 
98  $token = new ilCalendarAuthenticationToken($GLOBALS['ilUser']->getId());
99  $token->setSelectionType(ilCalendarAuthenticationToken::SELECTION_CALENDAR);
100  $token->setCalendar($this->getCalendarId());
101  return $token->add();
102  }
103 
104 }
105 ?>