Skip to content
This repository has been archived by the owner on Oct 31, 2018. It is now read-only.

Sort list of calendars by calendarorder #884

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@
* This class manages our calendars
*/
class OC_Calendar_Calendar{

private static function calendar_sort($a,$b) {
return $a['calendarorder']>$b['calendarorder'];
}

/**
* @brief Returns the list of calendars for a specific user.
* @param string $uid User ID
* @param boolean $active Only return calendars with this $active state, default(=false) is don't care
* @param boolean $createIfNecessary create calendars if no exist yet
* @return array
*/
public static function allCalendars($uid, $active=false, $createIfNecessary=true) {
public static function allCalendars($uid, $active=false, $createIfNecessary=true) {
$values = array($uid);
$active_where = '';
if (!is_null($active) && $active) {
Expand Down Expand Up @@ -71,6 +76,8 @@ public static function allCalendars($uid, $active=false, $createIfNecessary=true
}

$calendars = array_merge($calendars, $shared_calendars);

usort($calendars, array('OC_Calendar_Calendar','calendar_sort'));

return $calendars;
}
Expand Down