Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage.php
Show First 20 Lines • Show All 819 Lines • ▼ Show 20 Lines | public static function list_folders($root = '', $mbox = '*', $filter = null, $subscribed = null, &$folderdata = array()) | ||||
// use IMAP subscriptions | // use IMAP subscriptions | ||||
if ($subscribed === null && self::$config->get('kolab_use_subscriptions')) { | if ($subscribed === null && self::$config->get('kolab_use_subscriptions')) { | ||||
$subscribed = true; | $subscribed = true; | ||||
} | } | ||||
if (!$filter) { | if (!$filter) { | ||||
// Get ALL folders list, standard way | // Get ALL folders list, standard way | ||||
if ($subscribed) { | if ($subscribed) { | ||||
$folders = self::$imap->list_folders_subscribed($root, $mbox); | $folders = self::_imap_list_subscribed($root, $mbox); | ||||
// add temporarily subscribed folders | |||||
if (self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'])) { | |||||
$folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders'])); | |||||
} | |||||
} | } | ||||
else { | else { | ||||
$folders = self::_imap_list_folders($root, $mbox); | $folders = self::_imap_list_folders($root, $mbox); | ||||
} | } | ||||
return $folders; | return $folders; | ||||
} | } | ||||
$prefix = $root . $mbox; | $prefix = $root . $mbox; | ||||
Show All 20 Lines | public static function list_folders($root = '', $mbox = '*', $filter = null, $subscribed = null, &$folderdata = array()) | ||||
} | } | ||||
} | } | ||||
return self::$imap->sort_folder_list(array_keys($folderdata), true); | return self::$imap->sort_folder_list(array_keys($folderdata), true); | ||||
} | } | ||||
// Get folders list | // Get folders list | ||||
if ($subscribed) { | if ($subscribed) { | ||||
$folders = self::$imap->list_folders_subscribed($root, $mbox); | $folders = self::_imap_list_subscribed($root, $mbox); | ||||
// add temporarily subscribed folders | |||||
if (self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'])) { | |||||
$folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders'])); | |||||
} | |||||
} | } | ||||
else { | else { | ||||
$folders = self::_imap_list_folders($root, $mbox); | $folders = self::_imap_list_folders($root, $mbox); | ||||
} | } | ||||
// In case of an error, return empty list (?) | // In case of an error, return empty list (?) | ||||
if (!is_array($folders)) { | if (!is_array($folders)) { | ||||
return array(); | return array(); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | protected static function _imap_list_folders($root, $mbox) | ||||
if (!empty($postfilter)) { | if (!empty($postfilter)) { | ||||
$folders = array_filter($folders, function($folder) use ($postfilter) { return !preg_match($postfilter, $folder); }); | $folders = array_filter($folders, function($folder) use ($postfilter) { return !preg_match($postfilter, $folder); }); | ||||
$folders = self::$imap->sort_folder_list($folders); | $folders = self::$imap->sort_folder_list($folders); | ||||
} | } | ||||
return $folders; | return $folders; | ||||
} | } | ||||
/** | |||||
* Wrapper for rcube_imap::list_folders_subscribed() | |||||
* with support for temporarily subscribed folders | |||||
*/ | |||||
protected static function _imap_list_subscribed($root, $mbox) | |||||
{ | |||||
$folders = self::$imap->list_folders_subscribed($root, $mbox); | |||||
// add temporarily subscribed folders | |||||
if (self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'])) { | |||||
$folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders'])); | |||||
} | |||||
return $folders; | |||||
} | |||||
/** | /** | ||||
* Search for shared or otherwise not listed groupware folders the user has access | * Search for shared or otherwise not listed groupware folders the user has access | ||||
* | * | ||||
* @param string Folder type of folders to search for | * @param string Folder type of folders to search for | ||||
* @param string Search string | * @param string Search string | ||||
* @param array Namespace(s) to exclude results from | * @param array Namespace(s) to exclude results from | ||||
* | * | ||||
▲ Show 20 Lines • Show All 588 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* Returns a list of IMAP folders shared by the given user | * Returns a list of IMAP folders shared by the given user | ||||
* | * | ||||
* @param array User entry from LDAP | * @param array User entry from LDAP | ||||
* @param string Data type to list folders for (contact,event,task,journal,file,note,mail,configuration) | * @param string Data type to list folders for (contact,event,task,journal,file,note,mail,configuration) | ||||
* @param boolean Return subscribed folders only (null to use configured subscription mode) | * @param int 1 - subscribed folders only, 0 - all folders, 2 - all non-active | ||||
* @param array Will be filled with folder-types data | * @param array Will be filled with folder-types data | ||||
* | * | ||||
* @return array List of folders | * @return array List of folders | ||||
*/ | */ | ||||
public static function list_user_folders($user, $type, $subscribed = null, &$folderdata = array()) | public static function list_user_folders($user, $type, $subscribed = 0, &$folderdata = array()) | ||||
{ | { | ||||
self::setup(); | self::setup(); | ||||
$folders = array(); | $folders = array(); | ||||
// use localpart of user attribute as root for folder listing | // use localpart of user attribute as root for folder listing | ||||
$user_attrib = self::$config->get('kolab_users_id_attrib', self::$config->get('kolab_auth_login', 'mail')); | $user_attrib = self::$config->get('kolab_users_id_attrib', self::$config->get('kolab_auth_login', 'mail')); | ||||
if (!empty($user[$user_attrib])) { | if (!empty($user[$user_attrib])) { | ||||
list($mbox) = explode('@', $user[$user_attrib]); | list($mbox) = explode('@', $user[$user_attrib]); | ||||
$delimiter = self::$imap->get_hierarchy_delimiter(); | $delimiter = self::$imap->get_hierarchy_delimiter(); | ||||
$other_ns = self::namespace_root('other'); | $other_ns = self::namespace_root('other'); | ||||
$folders = self::list_folders($other_ns . $mbox . $delimiter, '*', $type, $subscribed, $folderdata); | $prefix = $other_ns . $mbox . $delimiter; | ||||
$subscribed = (int) $subscribed; | |||||
$subs = $subscribed < 2 ? (bool) $subscribed : false; | |||||
$folders = self::list_folders($prefix, '*', $type, $subs, $folderdata); | |||||
if ($subscribed === 2 && !empty($folders)) { | |||||
$active = self::get_states(); | |||||
if (!empty($active)) { | |||||
$folders = array_diff($folders, $active); | |||||
} | |||||
} | |||||
} | } | ||||
return $folders; | return $folders; | ||||
} | } | ||||
/** | /** | ||||
* Get a list of (virtual) top-level folders from the other users namespace | * Get a list of (virtual) top-level folders from the other users namespace | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |