Skip current folder (and its children) in folder selector to prevent moving to itself
This commit is contained in:
parent
0f266481dd
commit
f56e78fbf8
3 changed files with 23 additions and 9 deletions
|
@ -920,7 +920,7 @@ class kolab_driver extends calendar_driver
|
||||||
$hidden_fields[] = array('name' => 'parent', 'value' => $path_imap);
|
$hidden_fields[] = array('name' => 'parent', 'value' => $path_imap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$select = rcube_kolab::folder_selector('event', array('name' => 'parent'));
|
$select = rcube_kolab::folder_selector('event', array('name' => 'parent'), $folder);
|
||||||
$form['props']['fieldsets']['location']['content']['path'] = array(
|
$form['props']['fieldsets']['location']['content']['path'] = array(
|
||||||
'label' => $this->cal->gettext('parentcalendar'),
|
'label' => $this->cal->gettext('parentcalendar'),
|
||||||
'value' => $select->show($path_imap),
|
'value' => $select->show($path_imap),
|
||||||
|
|
|
@ -162,7 +162,7 @@ class kolab_addressbook_ui
|
||||||
$hidden_fields[] = array('name' => '_parent', 'value' => $path_imap);
|
$hidden_fields[] = array('name' => '_parent', 'value' => $path_imap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$select = rcube_kolab::folder_selector('contact', array('name' => '_parent'));
|
$select = rcube_kolab::folder_selector('contact', array('name' => '_parent'), $folder);
|
||||||
|
|
||||||
$form['props']['fieldsets']['location']['content']['path'] = array(
|
$form['props']['fieldsets']['location']['content']['path'] = array(
|
||||||
'label' => $this->plugin->gettext('parentbook'),
|
'label' => $this->plugin->gettext('parentbook'),
|
||||||
|
|
|
@ -418,17 +418,31 @@ class rcube_kolab
|
||||||
*
|
*
|
||||||
* @param string $type Folder type
|
* @param string $type Folder type
|
||||||
* @param array $attrs SELECT field attributes (e.g. name)
|
* @param array $attrs SELECT field attributes (e.g. name)
|
||||||
|
* @param string $current The name of current folder (to skip it)
|
||||||
*
|
*
|
||||||
* @return html_select SELECT object
|
* @return html_select SELECT object
|
||||||
*/
|
*/
|
||||||
public static function folder_selector($type, $attrs)
|
public static function folder_selector($type, $attrs, $current = '')
|
||||||
{
|
{
|
||||||
// get all folders of specified type
|
// get all folders of specified type
|
||||||
$folders = self::get_folders($type);
|
$folders = self::get_folders($type);
|
||||||
|
|
||||||
|
$delim = $_SESSION['delimiter'];
|
||||||
$names = array();
|
$names = array();
|
||||||
foreach ($folders as $c_folder)
|
$len = strlen($current);
|
||||||
$names[$c_folder->name] = rcube_charset_convert($c_folder->name, 'UTF7-IMAP');
|
|
||||||
|
// Filter folders list
|
||||||
|
foreach ($folders as $c_folder) {
|
||||||
|
$name = $c_folder->name;
|
||||||
|
// skip current folder and it's subfolders
|
||||||
|
if ($len && ($name == $current || strpos($name, $current.$delim) === 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$names[$name] = rcube_charset_convert($name, 'UTF7-IMAP');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort folders list
|
||||||
asort($names, SORT_LOCALE_STRING);
|
asort($names, SORT_LOCALE_STRING);
|
||||||
|
|
||||||
$folders = array_keys($names);
|
$folders = array_keys($names);
|
||||||
|
|
Loading…
Add table
Reference in a new issue