ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarCategoryGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
36 {
37  const SEARCH_USER = 1;
38  const SEARCH_ROLE = 2;
39 
40  const VIEW_MANAGE = 1;
41 
42  protected $user_id;
43 
47  protected $ctrl;
48 
52  protected $lng;
53 
57  protected $tabs;
58 
59  protected $editable = false;
60  protected $visible = false;
61 
65  protected $category_id = 0;
66 
70  protected $tpl;
71 
80  public function __construct($a_user_id, $seed, $a_ref_id = 0)
81  {
82  global $DIC;
83 
84  $this->user_id = $a_user_id;
85  $this->seed = $seed;
86  $this->lng = $DIC->language();
87  $this->lng->loadLanguageModule('dateplaner');
88  $this->ctrl = $DIC->ctrl();
89  $this->ref_id = $a_ref_id;
90  $this->obj_id = ilObject::_lookupObjId($a_ref_id);
91  $this->tabs = $DIC->tabs();
92  $this->tpl = $DIC->ui()->mainTemplate();
93 
94  $this->lng->loadLanguageModule("dateplaner");
95 
96  if (in_array($this->ctrl->getNextClass(), array("", "ilcalendarcategorygui")) && $this->ctrl->getCmd() == "manage") {
97  if ($a_ref_id > 0) { // no manage screen in repository
98  $this->ctrl->returnToParent($this);
99  }
100  if ((int) $_GET['category_id'] > 0) {
101  // reset category id on manage screen (redirect needed to initialize categories correctly)
102  $this->ctrl->setParameter($this, "category_id", "");
103  $this->ctrl->setParameterByClass("ilcalendarpresentationgui", "category_id", "");
104  $this->ctrl->redirect($this, "manage");
105  }
106  }
107 
108  $this->category_id = (int) $_GET['category_id'];
109 
110  include_once("./Services/Calendar/classes/class.ilCalendarActions.php");
111  $this->actions = ilCalendarActions::getInstance();
112  }
113 
121  public function executeCommand()
122  {
123  global $DIC;
124 
125  $ilUser = $DIC['ilUser'];
126  $ilSetting = $DIC['ilSetting'];
127  $tpl = $DIC['tpl'];
128 
129  $next_class = $this->ctrl->getNextClass($this);
130  $this->ctrl->saveParameter($this, 'category_id');
131  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
132 
133  if (array_key_exists('backvm', $_REQUEST)) {
134  $this->ctrl->setParameter($this, 'backvm', 1);
135  }
136  switch ($next_class) {
137  case 'ilcalendarappointmentgui':
138  $this->ctrl->setReturn($this, 'details');
139 
140  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
141  $app = new ilCalendarAppointmentGUI($this->seed, $this->seed, (int) $_GET['app_id']);
142  $this->ctrl->forwardCommand($app);
143  break;
144 
145  default:
146  $cmd = $this->ctrl->getCmd("show");
147  $this->$cmd();
148  if (!in_array($cmd, array("details", "askDeleteAppointments", "deleteAppointments"))) {
149  return true;
150  }
151  }
152  return false;
153  }
154 
161  protected function cancel()
162  {
163  if (array_key_exists('backvm', $_REQUEST)) {
164  $this->ctrl->redirect($this, 'manage');
165  return true;
166  }
167 
168  $this->ctrl->returnToParent($this);
169  return true;
170  }
171 
172 
179  protected function add(ilPropertyFormGUI $form = null)
180  {
181  global $DIC;
182 
183  $tpl = $DIC['tpl'];
184  $ilTabs = $DIC['ilTabs'];
185 
186  $ilTabs->clearTargets();
187  $ilTabs->setBackTarget($this->lng->txt("cal_back_to_list"), $this->ctrl->getLinkTarget($this, 'cancel'));
188 
189  $ed_tpl = new ilTemplate('tpl.edit_category.html', true, true, 'Services/Calendar');
190 
191  if (!$form instanceof ilPropertyFormGUI) {
192  $form = $this->initFormCategory('create');
193  }
194  $ed_tpl->setVariable('EDIT_CAT', $form->getHTML());
195  $tpl->setContent($ed_tpl->get());
196  }
197 
203  protected function save()
204  {
205  $form = $this->initFormCategory('create');
206  if ($form->checkInput()) {
207  $category = new ilCalendarCategory(0);
208  $category->setTitle($form->getInput('title'));
209  $category->setColor('#' . $form->getInput('color'));
210  $category->setLocationType($form->getInput('type_rl'));
211  $category->setRemoteUrl($form->getInput('remote_url'));
212  $category->setRemoteUser($form->getInput('remote_user'));
213  $category->setRemotePass($form->getInput('remote_pass'));
214  if ($form->getInput('type') == ilCalendarCategory::TYPE_GLOBAL) {
215  $category->setType((int) $form->getInput('type'));
216  $category->setObjId(0);
217  } else {
218  $category->setType(ilCalendarCategory::TYPE_USR);
219  $category->setObjId($GLOBALS['DIC']->user()->getId());
220  }
221  $category->add();
222  } else {
223  ilUtil::sendFailure($this->lng->txt('err_check_input'));
224  $form->setValuesByPost();
225  $this->add($form);
226  return false;
227  }
228 
229  // try sync
230  try {
231  if ($category->getLocationType() == ilCalendarCategory::LTYPE_REMOTE) {
232  $this->doSynchronisation($category);
233  }
234  } catch (Exception $e) {
235  // Delete calendar if creation failed
236  $category->delete();
237  ilUtil::sendFailure($e->getMessage());
238  $form->setValuesByPost();
239  $this->add($form);
240  return false;
241  }
242 
243  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
244  $GLOBALS['DIC']->ctrl()->redirect($this, 'manage');
245  }
246 
252  protected function edit(ilPropertyFormGUI $form = null)
253  {
254  global $DIC;
255 
256  $tpl = $DIC["tpl"];
257  $tabs = $DIC->tabs();
258  $tabs->activateTab("edit");
259 
260  $this->readPermissions();
261 
262  if (!$this->category_id) {
263  ilUtil::sendFailure($this->lng->txt('select_one'), true);
264  $this->ctrl->returnToParent($this);
265  }
266 
267  if (!$this->actions->checkSettingsCal($this->category_id)) {
268  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
269  $this->ctrl->returnToParent($this);
270  }
271 
272  if (!$form instanceof ilPropertyFormGUI) {
273  $form = $this->initFormCategory('edit');
274  }
275  $tpl->setContent($form->getHTML());
276  }
277 
283  protected function details()
284  {
285  global $DIC;
286 
287  $tpl = $DIC['tpl'];
288 
289  if (!$this->category_id) {
290  ilUtil::sendFailure($this->lng->txt('select_one'), true);
291  $this->ctrl->returnToParent($this);
292  }
293 
294  $this->readPermissions();
295  $this->checkVisible();
296 
297  // Non editable category
298  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
299  $info = new ilInfoScreenGUI($this);
300  $info->setFormAction($this->ctrl->getFormAction($this));
301 
302  $info->addSection($this->lng->txt('cal_cal_details'));
303 
304  $tpl->setContent($info->getHTML() . $this->showAssignedAppointments());
305  }
306 
307  protected function synchroniseCalendar()
308  {
309  if (!$this->category_id) {
310  ilUtil::sendFailure($this->lng->txt('select_one'), true);
311  $this->ctrl->returnToParent($this);
312  }
313 
314  $category = new ilCalendarCategory($this->category_id);
315 
316  try {
317  $this->doSynchronisation($category);
318  } catch (Exception $e) {
319  ilUtil::sendFailure($e->getMessage(), true);
320  $this->ctrl->redirect($this, 'manage');
321  }
322  ilUtil::sendSuccess($this->lng->txt('cal_cal_sync_success'), true);
323  $this->ctrl->redirect($this, 'manage');
324  }
325 
330  protected function doSynchronisation(ilCalendarCategory $category)
331  {
332  include_once './Services/Calendar/classes/class.ilCalendarRemoteReader.php';
333  $remote = new ilCalendarRemoteReader($category->getRemoteUrl());
334  $remote->setUser($category->getRemoteUser());
335  $remote->setPass($category->getRemotePass());
336  $remote->read();
337  $remote->import($category);
338  }
339 
346  protected function update()
347  {
348  if (!$this->category_id) {
349  ilUtil::sendFailure($this->lng->txt('select_one'), true);
350  $this->ctrl->returnToParent($this);
351  }
352  $this->readPermissions();
353  if (!$this->isEditable()) {
354  ilUtil::sendFailure($this->lng->txt('permission_denied'));
355  $this->edit();
356  return false;
357  }
358 
359  $form = $this->initFormCategory('edit');
360  if ($form->checkInput()) {
361  $category = new ilCalendarCategory($this->category_id);
362  if ($category->getType() != ilCalendarCategory::TYPE_OBJ) {
363  $category->setTitle($form->getInput('title'));
364  }
365  $category->setColor('#' . $form->getInput('color'));
366  $category->update();
367  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
368  if ($this->ref_id > 0) {
369  $this->ctrl->returnToParent($this);
370  } else {
371  $this->ctrl->redirect($this, "manage");
372  }
373  } else {
374  $form->setValuesByPost();
375  ilUtil::sendFailure($this->lng->txt('err_check_input'));
376  $this->edit($form);
377  }
378  }
379 
386  protected function confirmDelete()
387  {
388  global $DIC;
389 
390  $tpl = $DIC['tpl'];
391 
392  $cat_ids = (is_array($_POST['selected_cat_ids']) && count($_POST['selected_cat_ids']) > 0)
393  ? $_POST['selected_cat_ids']
394  : ($_GET["category_id"] > 0 ? array($_GET["category_id"]) : null);
395 
396  if (!is_array($cat_ids)) {
397  ilUtil::sendFailure($this->lng->txt('select_one'), true);
398  $this->manage();
399  }
400 
401  /*
402  $this->readPermissions();
403  if(!$this->isEditable())
404  {
405  ilUtil::sendFailure($this->lng->txt('permission_denied'));
406  $this->manage();
407  return false;
408  }
409  */
410 
411  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
412  $confirmation_gui = new ilConfirmationGUI();
413 
414  $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
415  $confirmation_gui->setHeaderText($this->lng->txt('cal_del_cal_sure'));
416  $confirmation_gui->setConfirm($this->lng->txt('delete'), 'delete');
417  $confirmation_gui->setCancel($this->lng->txt('cancel'), 'manage');
418 
419  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
420  foreach ($cat_ids as $cat_id) {
421  $category = new ilCalendarCategory((int) $cat_id);
422  $confirmation_gui->addItem('category_id[]', $cat_id, $category->getTitle());
423  }
424 
425  $tpl->setContent($confirmation_gui->getHTML());
426  }
427 
435  protected function delete()
436  {
437  global $DIC;
438 
439  $ilCtrl = $DIC['ilCtrl'];
440 
441  if (!$_POST['category_id']) {
442  ilUtil::sendFailure($this->lng->txt('select_one'), true);
443  $this->manage();
444  }
445 
446  /*
447  $this->readPermissions();
448  if(!$this->isEditable())
449  {
450  ilUtil::sendFailure($this->lng->txt('permission_denied'));
451  $this->edit();
452  return false;
453  }
454  */
455 
456  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
457  foreach ($_POST['category_id'] as $cat_id) {
458  $category = new ilCalendarCategory((int) $cat_id);
459  $category->delete();
460  }
461 
462  ilUtil::sendSuccess($this->lng->txt('cal_cal_deleted'), true);
463  $ilCtrl->redirect($this, 'manage');
464  }
465 
466 
467 
475  public function saveSelection()
476  {
477  global $DIC;
478 
479  $ilUser = $DIC['ilUser'];
480 
481  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
482  include_once('./Services/Calendar/classes/class.ilCalendarVisibility.php');
483 
484  $selected_cat_ids = $_POST['selected_cat_ids'] ? $_POST['selected_cat_ids'] : array();
485  $shown_cat_ids = $_POST['shown_cat_ids'] ? $_POST['shown_cat_ids'] : array();
486 
488  $cat_ids = $cats->getCategories();
489 
490  $cat_visibility = ilCalendarVisibility::_getInstanceByUserId($ilUser->getId(), $this->ref_id);
491 
492 
493 
494  if ($this->obj_id > 0) {
495  $old_selection = $cat_visibility->getVisible();
496  } else {
497  $old_selection = $cat_visibility->getHidden();
498  }
499 
500 
501  $new_selection = array();
502 
503  // put all entries from the old selection into the new one
504  // that are not presented on the screen
505  foreach ($old_selection as $cat_id) {
506  if (!in_array($cat_id, $shown_cat_ids)) {
507  $new_selection[] = $cat_id;
508  }
509  }
510 
511  foreach ($shown_cat_ids as $shown_cat_id) {
512  $shown_cat_id = (int) $shown_cat_id;
513  if ($this->obj_id > 0) {
514  if (in_array($shown_cat_id, $selected_cat_ids)) {
515  $new_selection[] = $shown_cat_id;
516  }
517  } else {
518  if (!in_array($shown_cat_id, $selected_cat_ids)) {
519  $new_selection[] = $shown_cat_id;
520  }
521  }
522  }
523 
524  if ($this->obj_id > 0) {
525  $cat_visibility->showSelected($new_selection);
526  } else {
527  $cat_visibility->hideSelected($new_selection);
528  }
529 
530  $cat_visibility->save();
531 
532  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
533  $this->ctrl->returnToParent($this);
534  }
535 
543  public function shareSearch()
544  {
545  global $DIC;
546 
547  $tpl = $DIC['tpl'];
548 
549  $tabs = $DIC->tabs();
550  $tabs->activateTab("share");
551 
552  if (!$this->category_id) {
553  ilUtil::sendFailure($this->lng->txt('select_one'), true);
554  $this->ctrl->returnToParent($this);
555  }
556 
557  $this->readPermissions();
558  if (!$this->isEditable()) {
559  ilUtil::sendFailure($this->lng->txt('permission_denied'));
560  $this->manage();
561  return false;
562  }
563 
564 
565  $_SESSION['cal_query'] = '';
566 
567  $this->ctrl->saveParameter($this, 'category_id');
568 
569  include_once('./Services/Calendar/classes/class.ilCalendarSharedListTableGUI.php');
570  $table = new ilCalendarSharedListTableGUI($this, 'shareSearch');
571  $table->setTitle($this->lng->txt('cal_cal_shared_with'));
572  $table->setCalendarId($this->category_id);
573  $table->parse();
574 
575  $this->getSearchToolbar();
576  $tpl->setContent($table->getHTML());
577  }
578 
585  public function sharePerformSearch()
586  {
587  global $DIC;
588 
589  $tabs = $DIC->tabs();
590  $tabs->activateTab("share");
591 
592  $this->lng->loadLanguageModule('search');
593 
594  if (!$this->category_id) {
595  ilUtil::sendFailure($this->lng->txt('select_one'), true);
596  $this->ctrl->returnToParent($this);
597  }
598  $this->ctrl->saveParameter($this, 'category_id');
599 
600 
601  if (!isset($_POST['query'])) {
602  $query = $_SESSION['cal_query'];
603  $type = $_SESSION['cal_type'];
604  } elseif ($_POST['query']) {
605  $query = $_SESSION['cal_query'] = $_POST['query'];
606  $type = $_SESSION['cal_type'] = $_POST['query_type'];
607  }
608 
609  if (!$query) {
610  ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
611  $this->shareSearch();
612  return false;
613  }
614 
615  $this->getSearchToolbar();
616 
617  include_once 'Services/Search/classes/class.ilQueryParser.php';
618  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
619  include_once 'Services/Search/classes/class.ilSearchResult.php';
620 
621  $res_sum = new ilSearchResult();
622 
623  $query_parser = new ilQueryParser(ilUtil::stripSlashes($query));
624  $query_parser->setCombination(QP_COMBINATION_OR);
625  $query_parser->setMinWordLength(3);
626  $query_parser->parse();
627 
628 
629  switch ($type) {
630  case self::SEARCH_USER:
631  $search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
632  $search->enableActiveCheck(true);
633 
634  $search->setFields(array('login'));
635  $res = $search->performSearch();
636  $res_sum->mergeEntries($res);
637 
638  $search->setFields(array('firstname'));
639  $res = $search->performSearch();
640  $res_sum->mergeEntries($res);
641 
642  $search->setFields(array('lastname'));
643  $res = $search->performSearch();
644  $res_sum->mergeEntries($res);
645 
646  $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
647  break;
648 
649  case self::SEARCH_ROLE:
650 
651  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
652  $search = new ilLikeObjectSearch($query_parser);
653  $search->setFilter(array('role'));
654 
655  $res = $search->performSearch();
656  $res_sum->mergeEntries($res);
657 
658  $res_sum->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
659  break;
660  }
661 
662  if (!count($res_sum->getResults())) {
663  ilUtil::sendFailure($this->lng->txt('search_no_match'));
664  $this->shareSearch();
665  return true;
666  }
667 
668 
669  switch ($type) {
670  case self::SEARCH_USER:
671  $this->showUserList($res_sum->getResultIds());
672  break;
673 
674  case self::SEARCH_ROLE:
675  $this->showRoleList($res_sum->getResultIds());
676  break;
677  }
678  }
679 
683  public function shareAssignEditable()
684  {
685  return $this->shareAssign(true);
686  }
687 
694  public function shareAssign($a_editable = false)
695  {
696  global $DIC;
697 
698  $ilUser = $DIC['ilUser'];
699 
700  if (!$this->category_id) {
701  ilUtil::sendFailure($this->lng->txt('select_one'), true);
702  $this->ctrl->returnToParent($this);
703  }
704  if (!count($_POST['user_ids'])) {
705  ilUtil::sendFailure($this->lng->txt('select_one'));
706  $this->sharePerformSearch();
707  return false;
708  }
709 
710  $this->readPermissions();
711  if (!$this->isEditable()) {
712  ilUtil::sendFailure($this->lng->txt('permission_denied'));
713  $this->shareSearch();
714  return false;
715  }
716 
717 
718  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
719  $shared = new ilCalendarShared($this->category_id);
720 
721  foreach ($_POST['user_ids'] as $user_id) {
722  if ($ilUser->getId() != $user_id) {
723  $shared->share($user_id, ilCalendarShared::TYPE_USR, $a_editable);
724  }
725  }
726  ilUtil::sendSuccess($this->lng->txt('cal_shared_selected_usr'));
727  $this->shareSearch();
728  }
729 
733  protected function shareAssignRolesEditable()
734  {
735  return $this->shareAssignRoles(true);
736  }
737 
745  public function shareAssignRoles($a_editable = false)
746  {
747  global $DIC;
748 
749  $ilUser = $DIC['ilUser'];
750 
751  if (!$this->category_id) {
752  ilUtil::sendFailure($this->lng->txt('select_one'), true);
753  $this->ctrl->returnToParent($this);
754  }
755  if (!count($_POST['role_ids'])) {
756  ilUtil::sendFailure($this->lng->txt('select_one'));
757  $this->sharePerformSearch();
758  return false;
759  }
760 
761  $this->readPermissions();
762  if (!$this->isEditable()) {
763  ilUtil::sendFailure($this->lng->txt('permission_denied'));
764  $this->shareSearch();
765  return false;
766  }
767 
768  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
769  $shared = new ilCalendarShared($this->category_id);
770 
771  foreach ($_POST['role_ids'] as $role_id) {
772  $shared->share($role_id, ilCalendarShared::TYPE_ROLE, $a_editable);
773  }
774  ilUtil::sendSuccess($this->lng->txt('cal_shared_selected_usr'));
775  $this->shareSearch();
776  }
777 
785  public function shareDeassign()
786  {
787  if (!$this->category_id) {
788  ilUtil::sendFailure($this->lng->txt('select_one'), true);
789  $this->ctrl->returnToParent($this);
790  }
791  if (!count($_POST['obj_ids'])) {
792  ilUtil::sendFailure($this->lng->txt('select_one'));
793  $this->shareSearch();
794  return false;
795  }
796 
797  $this->readPermissions();
798  if (!$this->isEditable()) {
799  ilUtil::sendFailure($this->lng->txt('permission_denied'));
800  $this->shareSearch();
801  return false;
802  }
803 
804 
805  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
806  $shared = new ilCalendarShared($this->category_id);
807 
808  foreach ($_POST['obj_ids'] as $obj_id) {
809  $shared->stopSharing($obj_id);
810  }
811  ilUtil::sendSuccess($this->lng->txt('cal_unshared_selected_usr'));
812  $this->shareSearch();
813  return true;
814  }
815 
816 
824  protected function showUserList($a_ids = array())
825  {
826  global $DIC;
827 
828  $tpl = $DIC['tpl'];
829 
830  include_once('./Services/Calendar/classes/class.ilCalendarSharedUserListTableGUI.php');
831 
832  $table = new ilCalendarSharedUserListTableGUI($this, 'sharePerformSearch');
833  $table->setTitle($this->lng->txt('cal_share_search_usr_header'));
834  $table->setFormAction($this->ctrl->getFormAction($this));
835  $table->setUsers($a_ids);
836  $table->parse();
837 
838  // $table->addCommandButton('shareSearch',$this->lng->txt('search_new'));
839  // $table->addCommandButton('manage',$this->lng->txt('cancel'));
840 
841  $tpl->setContent($table->getHTML());
842  }
843 
851  protected function showRoleList($a_ids = array())
852  {
853  global $DIC;
854 
855  $tpl = $DIC['tpl'];
856 
857  include_once('./Services/Calendar/classes/class.ilCalendarSharedRoleListTableGUI.php');
858 
859  $table = new ilCalendarSharedRoleListTableGUI($this, 'sharePerformSearch');
860  $table->setTitle($this->lng->txt('cal_share_search_role_header'));
861  $table->setFormAction($this->ctrl->getFormAction($this));
862  $table->setRoles($a_ids);
863  $table->parse();
864 
865  // $table->addCommandButton('shareSearch',$this->lng->txt('search_new'));
866  // $table->addCommandButton('manage',$this->lng->txt('cancel'));
867 
868  $tpl->setContent($table->getHTML());
869  }
870 
876  public function getSearchToolbar()
877  {
878  global $DIC;
879 
880  $tb = $DIC->toolbar();
881  $lng = $DIC->language();
882 
883  $lng->loadLanguageModule('search');
884 
885  $tb->setFormAction($this->ctrl->getFormAction($this));
886 
887  // search term
888  $search = new ilTextInputGUI($this->lng->txt('cal_search'), 'query');
889  $search->setValue($_POST['query']);
890  $search->setSize(16);
891  $search->setMaxLength(128);
892 
893  $tb->addInputItem($search, true);
894 
895  // search type
896  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
897  $options = array(
898  self::SEARCH_USER => $this->lng->txt('obj_user'),
899  self::SEARCH_ROLE => $this->lng->txt('obj_role'),
900  );
901  $si = new ilSelectInputGUI($this->lng->txt('search_type'), "query_type");
902  $si->setValue($_POST['query_type']);
903  $si->setOptions($options);
904  $si->setInfo($this->lng->txt(""));
905  $tb->addInputItem($si);
906 
907 
908  $tb->addFormButton($this->lng->txt('search'), "sharePerformSearch");
909  }
910 
911 
918  protected function initFormCategory($a_mode)
919  {
920  global $DIC;
921 
922  $rbacsystem = $DIC['rbacsystem'];
923  $ilUser = $DIC['ilUser'];
924  $ilHelp = $DIC['ilHelp'];
925 
926  $ilHelp->setScreenIdComponent("cal");
927  $ilHelp->setScreenId("cal");
928  if ($a_mode == "edit") {
929  $ilHelp->setSubScreenId("edit");
930  } else {
931  $ilHelp->setSubScreenId("create");
932  }
933 
934  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
935  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($this->category_id);
936 
937  $this->form = new ilPropertyFormGUI();
938  #$this->form->setTableWidth('40%');
939  switch ($a_mode) {
940  case 'edit':
941  $category = new ilCalendarCategory($this->category_id);
942  $this->form->setTitle($this->lng->txt('cal_edit_category'));
943  $this->ctrl->saveParameter($this, array('seed','category_id'));
944  $this->form->setFormAction($this->ctrl->getFormAction($this));
945  if ($this->isEditable()) {
946  $this->form->addCommandButton('update', $this->lng->txt('save'));
947 
948  /*
949  if($cat_info['type'] == ilCalendarCategory::TYPE_USR)
950  {
951  $this->form->addCommandButton('shareSearch',$this->lng->txt('cal_share'));
952  }
953  $this->form->addCommandButton('confirmDelete',$this->lng->txt('delete'));
954  */
955  }
956  break;
957  case 'create':
958  $this->editable = true;
959  $category = new ilCalendarCategory(0);
960  $this->ctrl->saveParameter($this, array('category_id'));
961  $this->form->setFormAction($this->ctrl->getFormAction($this));
962  $this->form->setTitle($this->lng->txt('cal_add_category'));
963  $this->form->addCommandButton('save', $this->lng->txt('save'));
964  break;
965  }
966 
967  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
968 
969  // Calendar name
970  $title = new ilTextInputGUI($this->lng->txt('cal_calendar_name'), 'title');
971  if ($a_mode == 'edit') {
972  if (!$this->isEditable() || $category->getType() == ilCalendarCategory::TYPE_OBJ) {
973  $title->setDisabled(true);
974  }
975  }
976  $title->setRequired(true);
977  $title->setMaxLength(64);
978  $title->setSize(32);
979  $title->setValue($category->getTitle());
980  $this->form->addItem($title);
981 
982 
983  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
984  if ($a_mode == 'create' and $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId())) {
985  $type = new ilRadioGroupInputGUI($this->lng->txt('cal_cal_type'), 'type');
986  $type->setValue($category->getType());
987  $type->setRequired(true);
988 
989  $opt = new ilRadioOption($this->lng->txt('cal_type_personal'), ilCalendarCategory::TYPE_USR);
990  $type->addOption($opt);
991 
992  $opt = new ilRadioOption($this->lng->txt('cal_type_system'), ilCalendarCategory::TYPE_GLOBAL);
993  $type->addOption($opt);
994  $type->setInfo($this->lng->txt('cal_type_info'));
995  $this->form->addItem($type);
996  }
997 
998  // color
999  $color = new ilColorPickerInputGUI($this->lng->txt('cal_calendar_color'), 'color');
1000  $color->setValue($category->getColor());
1001  if (!$this->isEditable()) {
1002  $color->setDisabled(true);
1003  }
1004  $color->setRequired(true);
1005  $this->form->addItem($color);
1006 
1007  $location = new ilRadioGroupInputGUI($this->lng->txt('cal_type_rl'), 'type_rl');
1008  $location->setDisabled($a_mode == 'edit');
1009  $location_local = new ilRadioOption($this->lng->txt('cal_type_local'), ilCalendarCategory::LTYPE_LOCAL);
1010  $location->addOption($location_local);
1011  $location_remote = new ilRadioOption($this->lng->txt('cal_type_remote'), ilCalendarCategory::LTYPE_REMOTE);
1012  $location->addOption($location_remote);
1013  $location->setValue($category->getLocationType());
1014 
1015 
1016  $url = new ilTextInputGUI($this->lng->txt('cal_remote_url'), 'remote_url');
1017  $url->setDisabled($a_mode == 'edit');
1018  $url->setValue($category->getRemoteUrl());
1019  $url->setMaxLength(500);
1020  $url->setSize(60);
1021  $url->setRequired(true);
1022  $location_remote->addSubItem($url);
1023 
1024  $user = new ilTextInputGUI($this->lng->txt('username'), 'remote_user');
1025  $user->setDisabled($a_mode == 'edit');
1026  $user->setValue($category->getRemoteUser());
1027  $user->setMaxLength(50);
1028  $user->setSize(20);
1029  $user->setRequired(false);
1030  $location_remote->addSubItem($user);
1031 
1032  $pass = new ilPasswordInputGUI($this->lng->txt('password'), 'remote_pass');
1033  $pass->setDisabled($a_mode == 'edit');
1034  $pass->setValue($category->getRemotePass());
1035  $pass->setMaxLength(50);
1036  $pass->setSize(20);
1037  $pass->setRetype(false);
1038  $pass->setInfo($this->lng->txt('remote_pass_info'));
1039  $location_remote->addSubItem($pass);
1040 
1041  // permalink
1042  if ($a_mode == "edit" && $category->getType() == ilCalendarCategory::TYPE_OBJ) {
1043  $ne = new ilNonEditableValueGUI($this->lng->txt("perma_link"), "", true);
1044  $ne->setValue($this->addReferenceLinks($category->getObjId()));
1045  $this->form->addItem($ne);
1046  }
1047 
1048  // owner
1049  if ($a_mode == "edit" && $category->getType() == ilCalendarCategory::TYPE_USR) {
1050  $ne = new ilNonEditableValueGUI($this->lng->txt("cal_owner"), "", true);
1051  $ne->setValue(ilUserUtil::getNamePresentation($category->getObjId()));
1052  $this->form->addItem($ne);
1053  }
1054 
1055  $this->form->addItem($location);
1056  return $this->form;
1057  }
1058 
1062  protected function unshare()
1063  {
1064  global $DIC;
1065 
1066  $ilUser = $DIC['ilUser'];
1067 
1068  if (!$this->category_id) {
1069  ilUtil::sendFailure($this->lng->txt('select_one'), true);
1070  $this->ctrl->returnToParent($this);
1071  }
1072 
1073  $this->readPermissions();
1074  $this->checkVisible();
1075 
1076  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
1077  $status = new ilCalendarSharedStatus($ilUser->getId());
1078 
1079  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
1081  ilUtil::sendFailure($this->lng->txt('permission_denied'));
1082  $this->inbox();
1083  return false;
1084  }
1085  $status->decline($this->category_id);
1086 
1087  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1088  $this->ctrl->redirect($this, 'manage');
1089  }
1090 
1097  protected function showAssignedAppointments()
1098  {
1099  include_once('./Services/Calendar/classes/class.ilCalendarCategoryTableGUI.php');
1100  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
1101  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentsTableGUI.php');
1102 
1103  $table_gui = new ilCalendarAppointmentsTableGUI($this, 'details', $this->category_id);
1104  $table_gui->setTitle($this->lng->txt('cal_assigned_appointments'));
1105  $table_gui->setAppointments(
1107  ilCalendarCategories::_getInstance()->getSubitemCategories($this->category_id)
1108  )
1109  );
1110  return $table_gui->getHTML();
1111  }
1112 
1119  protected function askDeleteAppointments()
1120  {
1121  global $DIC;
1122 
1123  $tpl = $DIC['tpl'];
1124 
1125  if (!count($_POST['appointments'])) {
1126  ilUtil::sendFailure($this->lng->txt('select_one'));
1127  $this->details();
1128  return true;
1129  }
1130 
1131  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
1132  $confirmation_gui = new ilConfirmationGUI();
1133 
1134  $this->ctrl->setParameter($this, 'category_id', $this->category_id);
1135  $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
1136  $confirmation_gui->setHeaderText($this->lng->txt('cal_del_app_sure'));
1137  $confirmation_gui->setConfirm($this->lng->txt('delete'), 'deleteAppointments');
1138  $confirmation_gui->setCancel($this->lng->txt('cancel'), 'details');
1139 
1140  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
1141  foreach ($_POST['appointments'] as $app_id) {
1142  $app = new ilCalendarEntry($app_id);
1143  $confirmation_gui->addItem('appointments[]', (int) $app_id, $app->getTitle());
1144  }
1145 
1146  $tpl->setContent($confirmation_gui->getHTML());
1147  }
1148 
1155  protected function deleteAppointments()
1156  {
1157  if (!count($_POST['appointments'])) {
1158  ilUtil::sendFailure($this->lng->txt('select_one'));
1159  $this->details();
1160  return true;
1161  }
1162  include_once('./Services/Calendar/classes/class.ilCalendarEntry.php');
1163  foreach ($_POST['appointments'] as $app_id) {
1164  $app = new ilCalendarEntry($app_id);
1165  $app->delete();
1166 
1167  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
1169  }
1170 
1171  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1172  $this->details();
1173  return true;
1174  }
1175 
1176  public function getHTML()
1177  {
1178  global $DIC;
1179 
1180  $ilUser = $DIC['ilUser'];
1181  $ilCtrl = $DIC['ilCtrl'];
1182 
1183  include_once("./Services/Calendar/classes/class.ilCalendarSelectionBlockGUI.php");
1184  $block_gui = new ilCalendarSelectionBlockGUI($this->seed, $this->ref_id);
1185  $html = $ilCtrl->getHTML($block_gui);
1186  return $html;
1187  }
1188 
1189 
1195  protected function appendCalendarSelection()
1196  {
1197  global $DIC;
1198 
1199  $ilUser = $DIC['ilUser'];
1200 
1201  $this->lng->loadLanguageModule('pd');
1202 
1203  $tpl = new ilTemplate('tpl.calendar_selection.html', true, true, 'Services/Calendar');
1204  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
1205  switch (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType()) {
1207  $tpl->setVariable('HTEXT', $this->lng->txt('pd_my_memberships'));
1208  $tpl->touchBlock('head_item');
1209  $tpl->touchBlock('head_delim');
1210  $tpl->touchBlock('head_item');
1211 
1212  $this->ctrl->setParameter($this, 'calendar_mode', ilCalendarUserSettings::CAL_SELECTION_ITEMS);
1213  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
1214  $tpl->setVariable('HHREF', $this->ctrl->getLinkTarget($this, 'switchCalendarMode'));
1215  $tpl->setVariable('HLINK', $this->lng->txt('pd_my_offers'));
1216  $tpl->touchBlock('head_item');
1217  break;
1218 
1220  $this->ctrl->setParameter($this, 'calendar_mode', ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP);
1221  $this->ctrl->setParameter($this, 'seed', $this->seed->get(IL_CAL_DATE));
1222  $tpl->setVariable('HHREF', $this->ctrl->getLinkTarget($this, 'switchCalendarMode'));
1223  $tpl->setVariable('HLINK', $this->lng->txt('pd_my_memberships'));
1224  $tpl->touchBlock('head_item');
1225  $tpl->touchBlock('head_delim');
1226  $tpl->touchBlock('head_item');
1227 
1228  $tpl->setVariable('HTEXT', $this->lng->txt('pd_my_offers'));
1229  $tpl->touchBlock('head_item');
1230  break;
1231 
1232 
1233  }
1234  return $tpl->get();
1235  }
1236 
1241  protected function switchCalendarMode()
1242  {
1243  include_once('./Services/Calendar/classes/class.ilCalendarUserSettings.php');
1244  ilCalendarUserSettings::_getInstance()->setCalendarSelectionType((int) $_GET['calendar_mode']);
1246 
1247  $this->ctrl->returnToParent($this);
1248  }
1249 
1250 
1258  private function readPermissions()
1259  {
1260  global $DIC;
1261 
1262  $ilUser = $DIC['ilUser'];
1263  $rbacsystem = $DIC['rbacsystem'];
1264  $ilAccess = $DIC['ilAccess'];
1265 
1266  $this->editable = false;
1267 
1268  $this->visible = false;
1269  $this->importable = false;
1270 
1271  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
1272 
1274  $cat = new ilCalendarCategory($this->category_id);
1275 
1276  switch ($cat->getType()) {
1278 
1279  if ($cat->getObjId() == $ilUser->getId()) {
1280  $this->visible = true;
1281  $this->editable = true;
1282  $this->importable = true;
1283  } elseif (isset($shared[$cat->getCategoryID()])) {
1284  $this->visible = true;
1285  }
1286  break;
1287 
1289  $this->importable = $this->editable = $rbacsystem->checkAccess('edit_event', ilCalendarSettings::_getInstance()->getCalendarSettingsId());
1290  $this->visible = true;
1291  break;
1292 
1294  $this->editable = false;
1295 
1296  $refs = ilObject::_getAllReferences($cat->getObjId());
1297  foreach ($refs as $ref) {
1298  if ($ilAccess->checkAccess('read', '', $ref)) {
1299  $this->visible = true;
1300  }
1301  if ($ilAccess->checkAccess('edit_event', '', $ref)) {
1302  $this->importable = true;
1303  }
1304  if ($ilAccess->checkAccess('write', '', $ref)) {
1305  $this->editable = true;
1306  }
1307  }
1308  break;
1309 
1312  $this->editable = $ilUser->getId() == $cat->getCategoryID();
1313  $this->visible = true;
1314  $this->importable = false;
1315  break;
1316  }
1317  }
1318 
1324  protected function checkVisible()
1325  {
1326  global $DIC;
1327 
1328  $ilErr = $DIC['ilErr'];
1329 
1330  if (!$this->visible) {
1331  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->FATAL);
1332  }
1333  }
1334 
1340  private function isEditable()
1341  {
1342  return $this->editable;
1343  }
1344 
1345  protected function isImportable()
1346  {
1347  return $this->importable;
1348  }
1349 
1350 
1356  protected function addReferenceLinks($a_obj_id)
1357  {
1358  global $DIC;
1359 
1360  $tree = $DIC['tree'];
1361 
1362  $tpl = new ilTemplate('tpl.cal_reference_links.html', true, true, 'Services/Calendar');
1363 
1364  foreach (ilObject::_getAllReferences($a_obj_id) as $ref_id => $ref_id) {
1365  include_once('./Services/Link/classes/class.ilLink.php');
1366 
1367  $parent_ref_id = $tree->getParentId($ref_id);
1368  $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
1369  $parent_type = ilObject::_lookupType($parent_obj_id);
1370  $parent_title = ilObject::_lookupTitle($parent_obj_id);
1371 
1372  $type = ilObject::_lookupType($a_obj_id);
1373  $title = ilObject::_lookupTitle($a_obj_id);
1374 
1375  $tpl->setCurrentBlock('reference');
1376  //$tpl->setVariable('PIMG_SRC',ilUtil::getTypeIconPath($parent_type,$parent_obj_id,'tiny'));
1377  //$tpl->setVariable('PIMG_ALT',$this->lng->txt('obj_'.$parent_type));
1378  $tpl->setVariable('PARENT_TITLE', $parent_title);
1379  $tpl->setVariable('PARENT_HREF', ilLink::_getLink($parent_ref_id));
1380 
1381  //$tpl->setVariable('SRC',ilUtil::getTypeIconPath($type,$a_obj_id,'tiny'));
1382  //$tpl->setVariable('ALT',$this->lng->txt('obj_'.$type));
1383  $tpl->setVariable('TITLE', $title);
1384  $tpl->setVariable('HREF', ilLink::_getLink($ref_id));
1385  $tpl->parseCurrentBlock();
1386  }
1387  return $tpl->get();
1388  }
1389 
1396  protected function manage($a_reset_offsets = false)
1397  {
1398  global $DIC;
1399 
1400  $lng = $DIC['lng'];
1401  $ilCtrl = $DIC['ilCtrl'];
1402  $tpl = $DIC['tpl'];
1403 
1404  $this->addSubTabs("manage");
1405 
1406  include_once('./Services/Calendar/classes/class.ilCalendarManageTableGUI.php');
1407  $table_gui = new ilCalendarManageTableGUI($this);
1408 
1409  if ($a_reset_offsets) {
1410  $table_gui->resetToDefaults();
1411  }
1412 
1413  $table_gui->parse();
1414 
1415  include_once "./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php";
1416  $toolbar = new ilToolbarGui();
1417  $ilCtrl->setParameter($this, 'backvm', 1);
1418  $toolbar->addButton($lng->txt("cal_add_calendar"), $ilCtrl->getLinkTarget($this, "add"));
1419 
1420  $tpl->setContent($toolbar->getHTML() . $table_gui->getHTML());
1421  }
1422 
1426  protected function importAppointments(ilPropertyFormGUI $form = null)
1427  {
1428  global $DIC;
1429 
1430  $ilTabs = $DIC['ilTabs'];
1431  $tpl = $DIC['tpl'];
1432 
1433  if (!$this->category_id) {
1434  ilUtil::sendFailure($this->lng->txt('select_one'), true);
1435  $this->ctrl->returnToParent($this);
1436  }
1437  $this->ctrl->setParameter($this, 'category_id', $this->category_id);
1438 
1439  // Check permissions
1440  $this->readPermissions();
1441  $this->checkVisible();
1442 
1443  if (!$this->isImportable()) {
1444  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
1445  $this->ctrl->returnToParent($this);
1446  }
1447 
1448  $ilTabs->clearTargets();
1449  $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "cancel"));
1450 
1451 
1452  if (!$form instanceof ilPropertyFormGUI) {
1453  $form = $this->initImportForm();
1454  }
1455  $tpl->setContent($form->getHTML());
1456  }
1457 
1461  protected function initImportForm()
1462  {
1463  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1464  $form = new ilPropertyFormGUI();
1465  $form->setTitle($this->lng->txt('cal_import_tbl'));
1466  $form->setFormAction($this->ctrl->getFormAction($this));
1467 
1468  $form->addCommandButton('uploadAppointments', $this->lng->txt('import'));
1469 
1470  $ics = new ilFileInputGUI($this->lng->txt('cal_import_file'), 'file');
1471  $ics->setALlowDeletion(false);
1472  $ics->setSuffixes(array('ics'));
1473  $ics->setInfo($this->lng->txt('cal_import_file_info'));
1474  $form->addItem($ics);
1475 
1476  return $form;
1477  }
1478 
1482  protected function uploadAppointments()
1483  {
1484  $form = $this->initImportForm();
1485  if ($form->checkInput()) {
1486  $file = $form->getInput('file');
1487  $tmp = ilUtil::ilTempnam();
1488 
1489  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $tmp);
1490 
1491  $num = $this->doImportFile($tmp, (int) $_REQUEST['category_id']);
1492 
1493  ilUtil::sendSuccess(sprintf($this->lng->txt('cal_imported_success'), (int) $num), true);
1494  $this->ctrl->redirect($this, 'cancel');
1495  }
1496 
1497  ilUtil::sendFailure($this->lng->txt('cal_err_file_upload'), true);
1498  $this->initImportForm($form);
1499  }
1500 
1506  protected function doImportFile($file, $category_id)
1507  {
1508  include_once './Services/Calendar/classes/../classes/iCal/class.ilICalParser.php';
1509  include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
1510 
1512 
1514  $parser->setCategoryId($category_id);
1515  $parser->parse();
1516 
1518 
1519  return $assigned_after - $assigned_before;
1520  }
1521 
1528  public function addSubTabs($a_active)
1529  {
1530  $ilTabs = $this->tabs;
1531  $ilCtrl = $this->ctrl;
1532  $lng = $this->lng;
1533 
1534  $ilTabs->addSubTab(
1535  "manage",
1536  $lng->txt("calendar"),
1537  $ilCtrl->getLinkTarget($this, "manage")
1538  );
1539 
1540  $status = new ilCalendarSharedStatus($this->user_id);
1541  $calendars = $status->getOpenInvitations();
1542 
1543  //if (count($calendars) > 0)
1544  //{
1545  $ilTabs->addSubTab(
1546  "invitations",
1547  $lng->txt("cal_shared_calendars"),
1548  $ilCtrl->getLinkTarget($this, "invitations")
1549  );
1550  //}
1551 
1552  $ilTabs->activateSubTab($a_active);
1553  }
1554 
1561  public function invitations()
1562  {
1563  $this->addSubTabs("invitations");
1564 
1565  // shared calendar invitations: @todo needs to be moved
1566  include_once('./Services/Calendar/classes/class.ilCalendarInboxSharedTableGUI.php');
1567  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
1568 
1569  $table = new ilCalendarInboxSharedTableGUI($this, 'inbox');
1571 
1572  //if($table->parse())
1573  //{
1574  $this->tpl->setContent($table->getHTML());
1575  //}
1576  }
1577 
1584  protected function acceptShared()
1585  {
1586  global $DIC;
1587 
1588  $ilUser = $DIC['ilUser'];
1589 
1590  if (!$_POST['cal_ids'] or !is_array($_POST['cal_ids'])) {
1591  ilUtil::sendFailure($this->lng->txt('select_one'));
1592  $this->inbox();
1593  return false;
1594  }
1595 
1596  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
1597  $status = new ilCalendarSharedStatus($ilUser->getId());
1598 
1599  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
1600  foreach ($_POST['cal_ids'] as $calendar_id) {
1601  if (!ilCalendarShared::isSharedWithUser($ilUser->getId(), $calendar_id)) {
1602  ilUtil::sendFailure($this->lng->txt('permission_denied'));
1603  $this->inbox();
1604  return false;
1605  }
1606  $status->accept($calendar_id);
1607  }
1608 
1609  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1610 
1611  $this->ctrl->redirect($this, 'invitations');
1612  }
1613 
1620  protected function declineShared()
1621  {
1622  global $DIC;
1623 
1624  $ilUser = $DIC['ilUser'];
1625 
1626  if (!$_POST['cal_ids'] or !is_array($_POST['cal_ids'])) {
1627  ilUtil::sendFailure($this->lng->txt('select_one'));
1628  $this->inbox();
1629  return false;
1630  }
1631 
1632  include_once('./Services/Calendar/classes/class.ilCalendarSharedStatus.php');
1633  $status = new ilCalendarSharedStatus($ilUser->getId());
1634 
1635  include_once('./Services/Calendar/classes/class.ilCalendarShared.php');
1636  foreach ($_POST['cal_ids'] as $calendar_id) {
1637  if (!ilCalendarShared::isSharedWithUser($ilUser->getId(), $calendar_id)) {
1638  ilUtil::sendFailure($this->lng->txt('permission_denied'));
1639  $this->inbox();
1640  return false;
1641  }
1642  $status->decline($calendar_id);
1643  }
1644 
1645  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1646 
1647  $this->ctrl->redirect($this, 'invitations');
1648  }
1649 }
This class represents an option in a radio group.
initImportForm()
Create import form.
Model for a calendar entry.
static _getInstance()
get singleton instance
Class ilInfoScreenGUI.
initFormCategory($a_mode)
init edit/create category form
sharePerformSearch()
share perform search
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
This class represents a property form user interface.
$type
global $DIC
Definition: saml.php:7
static getSharedCalendarsForUser($a_usr_id=0)
get shared calendars of user
$_GET["client_id"]
$location
Definition: buildRTE.php:44
addReferenceLinks($a_obj_id)
Show links to references.
setALlowDeletion($a_val)
Set allow deletion.
unshare()
Stop calendar sharing.
This class represents a file property in a property form.
Stores status (accepted/declined) of shared calendars.
acceptShared()
accept shared calendar
shareAssignRoles($a_editable=false)
share assign roles
Color picker form for selecting color hexcodes using yui library.
saveSelection()
save selection of categories
static getInstance()
Get instance.
static lookupNumberOfAssignedAppointments($a_cat_ids)
Get number of assigned appoitments.
show list of alle calendars to manage
static _lookupTitle($a_id)
lookup object title
isEditable()
check if calendar is editable private
declineShared()
accept shared calendar
Stores calendar categories.
Reader for remote ical calendars.
showUserList($a_ids=array())
show user list
BlockGUI class calendar selection.
Handles shared calendars.
switchCalendarMode()
Switch calendar selection nmode.
__construct($a_user_id, $seed, $a_ref_id=0)
Constructor.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
$ilErr
Definition: raiseError.php:18
const QP_COMBINATION_OR
doSynchronisation(ilCalendarCategory $category)
Sync calendar.
global $ilCtrl
Definition: ilias.php:18
static _getInstanceByUserId($a_user_id, $a_ref_id=0)
get instance by user id
importAppointments(ilPropertyFormGUI $form=null)
import appointments
deleteAppointments()
delete appointments
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
showAssignedAppointments()
show assigned aapointments
This class represents a property in a property form.
Show shared calendars for a specific user.
foreach($_POST as $key=> $value) $res
if(isset($_POST['submit'])) $form
setValue($a_value)
Set Value.
static _getInstance()
get instance for logged in user
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
shareAssign($a_editable=false)
share assign
This class represents a password property in a property form.
$ilUser
Definition: imgupload.php:18
shareAssignRolesEditable()
Share editable.
$query
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
getSearchToolbar()
Get search toolbar.
static _deleteByAppointmentId($a_app_id)
Delete appointment assignment.
$user
Definition: migrateto20.php:57
static _getInstance($a_usr_id=0)
get singleton instance
askDeleteAppointments()
ask delete appointments
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
add(ilPropertyFormGUI $form=null)
add new calendar
static _getAssignedAppointments($a_cat_id)
Get assigned apointments.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
doImportFile($file, $category_id)
Import ics.
const IL_CAL_DATE
shareAssignEditable()
Share with write access.
$parser
Definition: BPMN2Parser.php:23
This class represents a non editable value in a property form.
Administrate calendar appointments.
global $ilSetting
Definition: privfeed.php:17
$url
if(empty($password)) $table
Definition: pwgen.php:24
addSubTabs($a_active)
Add subtabs.
showRoleList($a_ids=array())
show role list
$info
Definition: index.php:5
setValue($a_value)
Set Value.
edit(ilPropertyFormGUI $form=null)
edit category
details()
show calendar details
$_POST["username"]
$html
Definition: example_001.php:87
static isSharedWithUser($a_usr_id, $a_calendar_id)
is shared with user
manage($a_reset_offsets=false)
Manage calendars type $lng type $ilCtrl type $tpl.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
shareDeassign()
desassign users/roles from calendar
Administration, Side-Block presentation of calendar categories.
Confirmation screen class.
uploadAppointments()
Upload appointments.