コード例 #1
0
 /**
  * Stop calendar sharing
  */
 protected function unshare()
 {
     global $ilUser;
     if (!$_GET['category_id']) {
         ilUtil::sendFailure($this->lng->txt('select_one'), true);
         $this->ctrl->returnToParent($this);
     }
     $this->readPermissions();
     $this->checkVisible();
     include_once './Services/Calendar/classes/class.ilCalendarSharedStatus.php';
     $status = new ilCalendarSharedStatus($ilUser->getId());
     include_once './Services/Calendar/classes/class.ilCalendarShared.php';
     if (!ilCalendarShared::isSharedWithUser($ilUser->getId(), $_GET['category_id'])) {
         ilUtil::sendFailure($this->lng->txt('permission_denied'));
         $this->inbox();
         return false;
     }
     $status->decline($_GET['category_id']);
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     $this->ctrl->redirect($this, 'manage');
 }
コード例 #2
0
 /**
  * Read private calendars
  *
  * @access protected
  * @return
  */
 protected function readPrivateCalendars()
 {
     global $ilUser;
     global $ilDB;
     // First read private calendars of user
     $query = "SELECT cat_id FROM cal_categories " . "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " . "AND obj_id = " . $this->db->quote($ilUser->getId(), 'integer') . " ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $cat_ids[] = $row->cat_id;
     }
     // Read shared calendars
     include_once './Services/Calendar/classes/class.ilCalendarSharedStatus.php';
     $accepted_ids = ilCalendarSharedStatus::getAcceptedCalendars($ilUser->getId());
     if (!($cat_ids = array_merge((array) $cat_ids, $accepted_ids))) {
         return true;
     }
     // user categories
     $query = "SELECT * FROM cal_categories " . "WHERE type = " . $this->db->quote(ilCalendarCategory::TYPE_USR, 'integer') . " " . "AND " . $ilDB->in('cat_id', $cat_ids, false, 'integer') . " " . "ORDER BY title ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->categories[] = $row->cat_id;
         $this->categories_info[$row->cat_id]['obj_id'] = $row->obj_id;
         $this->categories_info[$row->cat_id]['cat_id'] = $row->cat_id;
         $this->categories_info[$row->cat_id]['title'] = $row->title;
         $this->categories_info[$row->cat_id]['color'] = $row->color;
         $this->categories_info[$row->cat_id]['type'] = $row->type;
         include_once './Services/Calendar/classes/class.ilCalendarShared.php';
         if (in_array($row->cat_id, $accepted_ids)) {
             $shared = new ilCalendarShared($row->cat_id);
             if ($shared->isEditableForUser($ilUser->getId())) {
                 $this->categories_info[$row->cat_id]['editable'] = true;
             } else {
                 $this->categories_info[$row->cat_id]['editable'] = false;
             }
         } else {
             $this->categories_info[$row->cat_id]['editable'] = true;
         }
         $this->categories_info[$row->cat_id]['accepted'] = in_array($row->cat_id, $accepted_ids);
         $this->categories_info[$row->cat_id]['remote'] = $row->loc_type == ilCalendarCategory::LTYPE_REMOTE;
     }
 }
コード例 #3
0
 /**
  * parse calendar data
  *
  * @access public
  * @param
  * @return
  */
 public function parse()
 {
     global $ilUser;
     $counter = 0;
     $calendars = array();
     $status = new ilCalendarSharedStatus($ilUser->getId());
     foreach ($this->cal_data as $data) {
         if ($status->isDeclined($data['cal_id']) || $status->isAccepted($data['cal_id'])) {
             continue;
         }
         $tmp_calendar = new ilCalendarCategory($data['cal_id']);
         $calendars[$counter]['cal_id'] = $data['cal_id'];
         $calendars[$counter]['create_date'] = $data['create_date'];
         $calendars[$counter]['obj_type'] = $data['obj_type'];
         $calendars[$counter]['name'] = $tmp_calendar->getTitle();
         $calendars[$counter]['owner'] = $tmp_calendar->getObjId();
         $calendars[$counter]['apps'] = count(ilCalendarCategoryAssignments::_getAssignedAppointments(array($data['cal_id'])));
         $calendars[$counter]['accepted'] = $status->isAccepted($data['cal_id']);
         $calendars[$counter]['declined'] = $status->isDeclined($data['cal_id']);
         $counter++;
     }
     $this->setData($calendars ? $calendars : array());
     return count($calendars) ? true : false;
 }
コード例 #4
0
 /**
  * stop sharing
  *
  * @access public
  * @param int obj_id
  * @return bool
  */
 public function stopSharing($a_obj_id)
 {
     global $ilDB;
     if (!$this->isShared($a_obj_id)) {
         return false;
     }
     $query = "DELETE FROM cal_shared WHERE cal_id = " . $this->db->quote($this->getCalendarId(), 'integer') . " " . "AND obj_id = " . $this->db->quote($a_obj_id, 'integer') . " ";
     $res = $ilDB->manipulate($query);
     include_once './Services/Calendar/classes/class.ilCalendarSharedStatus.php';
     ilCalendarSharedStatus::deleteStatus($a_obj_id, $this->getCalendarId());
     $this->read();
     return true;
 }
コード例 #5
0
 /**
  * accept shared calendar
  *
  * @access protected
  * @return
  */
 protected function declineShared()
 {
     global $ilUser;
     if (!$_POST['cal_ids'] or !is_array($_POST['cal_ids'])) {
         ilUtil::sendFailure($this->lng->txt('select_one'));
         $this->inbox();
         return false;
     }
     include_once './Services/Calendar/classes/class.ilCalendarSharedStatus.php';
     $status = new ilCalendarSharedStatus($ilUser->getId());
     include_once './Services/Calendar/classes/class.ilCalendarShared.php';
     foreach ($_POST['cal_ids'] as $calendar_id) {
         if (!ilCalendarShared::isSharedWithUser($ilUser->getId(), $calendar_id)) {
             ilUtil::sendFailure($this->lng->txt('permission_denied'));
             $this->inbox();
             return false;
         }
         $status->decline($calendar_id);
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     $this->inbox();
     return true;
 }