46 "SELECT * FROM booking_preferences " .
47 " WHERE book_pool_id = %s ",
52 while ($rec =
$db->fetchAssoc($set)) {
53 if (!is_array($preferences[$rec[
"user_id"]]) || !in_array($rec[
"book_obj_id"], $preferences[$rec[
"user_id"]])) {
54 $preferences[$rec[
"user_id"]][] = $rec[
"book_obj_id"];
57 return $this->factory->preferences($preferences);
72 "SELECT * FROM booking_preferences " .
73 " WHERE book_pool_id = %s " .
75 array(
"integer",
"integer"),
76 array($a_pool_id, $a_user_id)
79 while ($rec =
$db->fetchAssoc($set)) {
80 if (!is_array($preferences[$rec[
"user_id"]]) || !in_array($rec[
"book_obj_id"], $preferences[$rec[
"user_id"]])) {
81 $preferences[$rec[
"user_id"]][] = $rec[
"book_obj_id"];
84 return $this->factory->preferences($preferences);
98 "DELETE FROM booking_preferences WHERE " .
104 foreach ($preferences as $user_id => $obj_ids) {
105 if (is_array($obj_ids) && $user_id > 0) {
106 foreach ($obj_ids as $obj_id) {
107 $db->insert(
"booking_preferences", array(
108 "book_pool_id" => array(
"integer", $a_pool_id),
109 "user_id" => array(
"integer", $user_id),
110 "book_obj_id" => array(
"integer", $obj_id),
129 "DELETE FROM booking_preferences WHERE " .
130 " book_pool_id = %s" .
132 array(
"integer",
"integer"),
133 array($a_pool_id, $a_user_id)
136 foreach ($preferences->
getPreferences() as $user_id => $obj_ids) {
137 if (is_array($obj_ids) && $user_id == $a_user_id) {
138 foreach ($obj_ids as $obj_id) {
139 $db->insert(
"booking_preferences", array(
140 "book_pool_id" => array(
"integer", $a_pool_id),
141 "user_id" => array(
"integer", $user_id),
142 "book_obj_id" => array(
"integer", $obj_id),
getPreferences(int $a_pool_id)
Get booking preferences for a pool id.
savePreferencesOfUser(int $a_pool_id, int $a_user_id, ilBookingPreferences $preferences)
Save all preferences of a user for a pool.
getPreferences()
Get user preferences.
getPreferencesOfUser(int $a_pool_id, int $a_user_id)
Get booking preferences for a pool id.
__construct(ilBookingPreferencesFactory $factory, ilDBInterface $db=null)
Constructor.
Factory for booking preference data objects.
Booking preferences repo.
savePreferences(int $a_pool_id, ilBookingPreferences $preferences)
Save all preferences of a pool.