ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\BookingManager\Schedule\SchedulesDBRepository Class Reference

Repo class for schedules. More...

+ Collaboration diagram for ILIAS\BookingManager\Schedule\SchedulesDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db)
 
 loadDataOfPool (int $pool_id)
 
 hasSchedules (int $pool_id)
 
 getScheduleList (int $pool_id)
 
 getScheduleData (int $pool_id)
 
 getPoolIdForSchedule (int $schedule_id)
 

Protected Member Functions

 getScheduleDataForPool (int $pool_id)
 

Protected Attributes

ilDBInterface $db
 

Static Protected Attributes

static array $pool_loaded = []
 
static array $pool_schedules = []
 
static array $raw_data = []
 

Detailed Description

Repo class for schedules.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.SchedulesDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::__construct ( \ilDBInterface  $db)

Member Function Documentation

◆ getPoolIdForSchedule()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::getPoolIdForSchedule ( int  $schedule_id)

Definition at line 103 of file class.SchedulesDBRepository.php.

103 : int
104 {
105 $set = $this->db->query("SELECT pool_id " .
106 " FROM booking_schedule" .
107 " WHERE booking_schedule_id = " . $this->db->quote($schedule_id, 'integer'));
108 if ($rec = $this->db->fetchAssoc($set)) {
109 return (int) $rec['pool_id'];
110 }
111 return 0;
112 }

◆ getScheduleData()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::getScheduleData ( int  $pool_id)

Definition at line 94 of file class.SchedulesDBRepository.php.

94 : array
95 {
96 $schedules = [];
97 foreach ($this->getScheduleDataForPool($pool_id) as $data) {
98 $schedules[$data["booking_schedule_id"]] = $data;
99 }
100 return $schedules;
101 }

References $data.

◆ getScheduleDataForPool()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::getScheduleDataForPool ( int  $pool_id)
protected

Definition at line 71 of file class.SchedulesDBRepository.php.

73 : array {
74 $this->loadDataOfPool($pool_id);
75 return self::$pool_schedules[$pool_id] ?? [];
76 }

◆ getScheduleList()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::getScheduleList ( int  $pool_id)

Definition at line 85 of file class.SchedulesDBRepository.php.

85 : array
86 {
87 $list = [];
88 foreach ($this->getScheduleDataForPool($pool_id) as $data) {
89 $list[$data["booking_schedule_id"]] = $data["title"];
90 }
91 return $list;
92 }

References $data.

◆ hasSchedules()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::hasSchedules ( int  $pool_id)

Definition at line 78 of file class.SchedulesDBRepository.php.

80 : bool {
81 $this->loadDataOfPool($pool_id);
82 return count(self::$pool_schedules[$pool_id] ?? []) > 0;
83 }

◆ loadDataOfPool()

ILIAS\BookingManager\Schedule\SchedulesDBRepository::loadDataOfPool ( int  $pool_id)

Definition at line 38 of file class.SchedulesDBRepository.php.

38 : void
39 {
40 $db = $this->db;
41
42 if (isset(self::$pool_loaded[$pool_id]) && self::$pool_loaded[$pool_id]) {
43 return;
44 }
45
46 $set = $db->query(
47 'SELECT s.booking_schedule_id,s.title,' .
48 'MAX(o.schedule_id) AS object_has_schedule' .
49 ' FROM booking_schedule s' .
50 ' LEFT JOIN booking_object o ON (s.booking_schedule_id = o.schedule_id)' .
51 ' WHERE s.pool_id = ' . $db->quote($pool_id, 'integer') .
52 ' GROUP BY s.booking_schedule_id,s.title' .
53 ' ORDER BY s.title'
54 );
55
56 self::$pool_schedules[$pool_id] = [];
57
58 while ($row = $db->fetchAssoc($set)) {
59 if (!$row['object_has_schedule']) {
60 $row['is_used'] = false;
61 } else {
62 $row['is_used'] = true;
63 }
64 self::$raw_data[$row["booking_schedule_id"]] = $row;
65 self::$pool_schedules[$pool_id][] = $row;
66 }
67
68 self::$pool_loaded[$pool_id] = true;
69 }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)

References ILIAS\BookingManager\Schedule\SchedulesDBRepository\$db, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ILIAS\BookingManager\Schedule\SchedulesDBRepository::$db
protected

◆ $pool_loaded

array ILIAS\BookingManager\Schedule\SchedulesDBRepository::$pool_loaded = []
staticprotected

Definition at line 28 of file class.SchedulesDBRepository.php.

◆ $pool_schedules

array ILIAS\BookingManager\Schedule\SchedulesDBRepository::$pool_schedules = []
staticprotected

Definition at line 29 of file class.SchedulesDBRepository.php.

◆ $raw_data

array ILIAS\BookingManager\Schedule\SchedulesDBRepository::$raw_data = []
staticprotected

Definition at line 30 of file class.SchedulesDBRepository.php.


The documentation for this class was generated from the following file: