Skip to content

Commit

Permalink
Add Kronolith_Api::sources()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 30, 2013
1 parent cc4267d commit a409d6b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions kronolith/lib/Api.php
Expand Up @@ -440,6 +440,31 @@ public function listCalendars($owneronly = false, $permission = null)
return array_keys(Kronolith::listInternalCalendars($owneronly, $permission));
}

/**
* Returns a list of available sources.
*
* @param boolean $writeable If true, limits to writeable sources.
* @param boolean $sync_only Only include syncable sources.
*
* @return array An array of the available sources. Keys are source IDs,
* values are source titles.
*/
public function sources($writeable = false, $sync_only = false)
{
$out = array();

foreach (Kronolith::listInternalCalendars(false, $writeable ? Horde_Perms::EDIT : Horde_Perms::READ) as $id => $data) {
$out[$id] = $data->get('name');
}

if ($sync_only) {
$syncable = Kronolith::getSyncCalendars();
$out = array_intersect_key($out, array_flip($syncable));
}

return $out;
}

/**
* Returns the ids of all the events that happen within a time period.
* Only includes recurring events once per time period, and does not include
Expand Down

0 comments on commit a409d6b

Please sign in to comment.