Added rcube_kolab::folder_id() with improved ID generation method
This commit is contained in:
parent
feae471289
commit
1c51c1a9d9
3 changed files with 15 additions and 5 deletions
|
@ -39,7 +39,6 @@ class kolab_calendar
|
|||
'sensitivity'=>'sensitivity',
|
||||
'show-time-as' => 'free_busy',
|
||||
'alarm','alarms'
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -47,11 +46,11 @@ class kolab_calendar
|
|||
*/
|
||||
public function __construct($imap_folder = null)
|
||||
{
|
||||
if ($imap_folder)
|
||||
if (strlen($imap_folder))
|
||||
$this->imap_folder = $imap_folder;
|
||||
write_log('err_log',$imap_folder);
|
||||
|
||||
// ID is derrived from folder name
|
||||
$this->id = strtolower(asciiwords(strtr($this->imap_folder, '/.', '--')));
|
||||
$this->id = rcube_kolab::folder_id($this->imap_folder);
|
||||
|
||||
// fetch objects from the given IMAP folder
|
||||
$this->storage = rcube_kolab::get_storage($this->imap_folder);
|
||||
|
@ -68,6 +67,7 @@ class kolab_calendar
|
|||
*/
|
||||
public function get_name()
|
||||
{
|
||||
// @TODO: get namespace prefixes from IMAP
|
||||
$dispname = preg_replace(array('!INBOX/Calendar/!', '!^INBOX/!', '!^shared/!', '!^user/([^/]+)/!'), array('','','','(\\1) '), $this->imap_folder);
|
||||
return strlen($dispname) ? $dispname : $this->imap_folder;
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ class kolab_addressbook extends rcube_plugin
|
|||
else {
|
||||
foreach ($this->folders as $c_folder) {
|
||||
// create instance of rcube_contacts
|
||||
$abook_id = strtolower(asciiwords(strtr($c_folder->name, '/.', '--')));
|
||||
$abook_id = rcube_kolab::folder_id($c_folder->name);
|
||||
$abook = new rcube_kolab_contacts($c_folder->name);
|
||||
$this->sources[$abook_id] = $abook;
|
||||
}
|
||||
|
|
|
@ -119,4 +119,14 @@ class rcube_kolab
|
|||
if (isset($_SESSION['__auth']))
|
||||
unset($_SESSION['__auth']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates folder ID from folder name
|
||||
*/
|
||||
public static function folder_id($folder)
|
||||
{
|
||||
$folder = rcube_charset_convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP');
|
||||
return asciiwords(strtr($folder, '/.', '--'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue