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