コード例 #1
0
 /**
  * Fill table row
  * @param	array	$a_set
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilUser;
     $has_booking = false;
     $booking_possible = true;
     $has_reservations = false;
     $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
     $this->tpl->setVariable("TXT_DESC", nl2br($a_set["description"]));
     if (!$this->has_schedule) {
         include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
         $reservation = ilBookingReservation::getList(array($a_set['booking_object_id']), 1000, 0, array());
         $cnt = 0;
         $user_ids = array();
         foreach ($reservation["data"] as $item) {
             if ($item["status"] != ilBookingReservation::STATUS_CANCELLED) {
                 $cnt++;
                 $user_ids[$item["user_id"]] = ilObjUser::_lookupFullName($item['user_id']);
                 if ($item["user_id"] == $ilUser->getId()) {
                     $has_booking = true;
                 }
                 $has_reservations = true;
             }
         }
         $this->tpl->setVariable("VALUE_AVAIL", $a_set["nr_items"] - $cnt);
         $this->tpl->setVariable("VALUE_AVAIL_ALL", $a_set["nr_items"]);
         if ($a_set["nr_items"] <= $cnt) {
             $booking_possible = false;
         }
         if ($this->may_edit) {
             if ($user_ids) {
                 $this->tpl->setVariable("TXT_CURRENT_USER", implode("<br />", array_unique($user_ids)));
             } else {
                 $this->tpl->setVariable("TXT_CURRENT_USER", "");
             }
         }
     } else {
         if ($this->may_edit) {
             include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
             $reservation = ilBookingReservation::getCurrentOrUpcomingReservation($a_set['booking_object_id']);
             if ($reservation) {
                 $date_from = new ilDateTime($reservation['date_from'], IL_CAL_UNIX);
                 $date_to = new ilDateTime($reservation['date_to'], IL_CAL_UNIX);
                 $this->tpl->setVariable("TXT_CURRENT_USER", ilObjUser::_lookupFullName($reservation['user_id']));
                 $this->tpl->setVariable("VALUE_DATE", ilDatePresentation::formatPeriod($date_from, $date_to));
                 $has_reservations = true;
             } else {
                 $this->tpl->setVariable("TXT_CURRENT_USER", "");
                 $this->tpl->setVariable("VALUE_DATE", "");
             }
         }
     }
     $items = array();
     $ilCtrl->setParameter($this->parent_obj, 'object_id', $a_set['booking_object_id']);
     if ($a_set['info_file']) {
         $items['info'] = array($lng->txt('book_download_info'), $ilCtrl->getLinkTarget($this->parent_obj, 'deliverInfo'));
     }
     if (!$has_booking) {
         if ($booking_possible) {
             $items['book'] = array($lng->txt('book_book'), $ilCtrl->getLinkTarget($this->parent_obj, 'book'));
         }
     } else {
         if (trim($a_set['post_text']) || $a_set['post_file']) {
             $items['post'] = array($lng->txt('book_post_booking_information'), $ilCtrl->getLinkTarget($this->parent_obj, 'displayPostInfo'));
         }
         $items['cancel'] = array($lng->txt('book_set_cancel'), $ilCtrl->getLinkTarget($this->parent_obj, 'rsvCancelUser'));
     }
     if ($this->may_edit) {
         // #10890
         if (!$has_reservations) {
             $items['delete'] = array($lng->txt('delete'), $ilCtrl->getLinkTarget($this->parent_obj, 'confirmDelete'));
         }
         $items['edit'] = array($lng->txt('edit'), $ilCtrl->getLinkTarget($this->parent_obj, 'edit'));
     }
     if (sizeof($items)) {
         $this->tpl->setCurrentBlock("actions");
         foreach ($items as $item) {
             $this->tpl->setVariable("ACTION_CAPTION", $item[0]);
             $this->tpl->setVariable("ACTION_LINK", $item[1]);
             $this->tpl->parseCurrentBlock();
         }
     }
 }