Changeset View
Changeset View
Standalone View
Standalone View
plugins/kolab_folders/kolab_folders.php
Show All 36 Lines | public $subtypes = array( | ||||
'file' => array('default'), | 'file' => array('default'), | ||||
'freebusy' => array('default'), | 'freebusy' => array('default'), | ||||
); | ); | ||||
public $act_types = array('event', 'task'); | public $act_types = array('event', 'task'); | ||||
private $rc; | private $rc; | ||||
private static $instance; | private static $instance; | ||||
private $expire_annotation = '/shared/vendor/cmu/cyrus-imapd/expire'; | private $expire_annotation = '/shared/vendor/cmu/cyrus-imapd/expire'; | ||||
private $is_processing = false; | |||||
/** | /** | ||||
* Plugin initialization. | * Plugin initialization. | ||||
*/ | */ | ||||
function init() | function init() | ||||
{ | { | ||||
self::$instance = $this; | self::$instance = $this; | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | function folders_list($args) | ||||
$folderdata = kolab_storage::folders_typedata(); | $folderdata = kolab_storage::folders_typedata(); | ||||
if (!is_array($folderdata)) { | if (!is_array($folderdata)) { | ||||
return $args; | return $args; | ||||
} | } | ||||
// Add type-based style for table rows | // Add type-based style for table rows | ||||
// See kolab_folders::folder_class_name() | // See kolab_folders::folder_class_name() | ||||
if ($table = $args['table']) { | if ($table = ($args['table'] ?? null)) { | ||||
for ($i=1, $cnt=$table->size(); $i<=$cnt; $i++) { | for ($i=1, $cnt=$table->size(); $i<=$cnt; $i++) { | ||||
$attrib = $table->get_row_attribs($i); | $attrib = $table->get_row_attribs($i); | ||||
$folder = $attrib['foldername']; // UTF7-IMAP | $folder = $attrib['foldername']; // UTF7-IMAP | ||||
$type = $folderdata[$folder]; | $type = $folderdata[$folder]; | ||||
if (!$type) { | if (!$type) { | ||||
$type = 'mail'; | $type = 'mail'; | ||||
} | } | ||||
$class_name = self::folder_class_name($type); | $class_name = self::folder_class_name($type); | ||||
$attrib['class'] = trim($attrib['class'] . ' ' . $class_name); | $attrib['class'] = trim($attrib['class'] . ' ' . $class_name); | ||||
$table->set_row_attribs($attrib, $i); | $table->set_row_attribs($attrib, $i); | ||||
} | } | ||||
} | } | ||||
// Add type-based class for list items | // Add type-based class for list items | ||||
if (is_array($args['list'])) { | if (is_array($args['list'] ?? null)) { | ||||
foreach ((array)$args['list'] as $k => $item) { | foreach ((array)$args['list'] as $k => $item) { | ||||
$folder = $item['folder_imap']; // UTF7-IMAP | $folder = $item['folder_imap']; // UTF7-IMAP | ||||
$type = $folderdata[$folder]; | $type = $folderdata[$folder] ?? null; | ||||
if (!$type) { | if (!$type) { | ||||
$type = 'mail'; | $type = 'mail'; | ||||
} | } | ||||
$class_name = self::folder_class_name($type); | $class_name = self::folder_class_name($type); | ||||
$args['list'][$k]['class'] = trim($item['class'] . ' ' . $class_name); | $args['list'][$k]['class'] = trim($item['class'] . ' ' . $class_name); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | function folder_form($args) | ||||
$type_select->add($ctype, $ctype); | $type_select->add($ctype, $ctype); | ||||
} | } | ||||
$sub_types = array(); | $sub_types = array(); | ||||
foreach ($this->subtypes as $ftype => $subtypes) { | foreach ($this->subtypes as $ftype => $subtypes) { | ||||
$sub_types[$ftype] = array_combine($subtypes, array_map(array($this, 'gettext'), $subtypes)); | $sub_types[$ftype] = array_combine($subtypes, array_map(array($this, 'gettext'), $subtypes)); | ||||
// fill options for the current folder type | // fill options for the current folder type | ||||
if ($ftype == $ctype || $ftype == $new_ctype) { | if ($ftype == $ctype || (isset($new_ctype) && $ftype == $new_ctype)) { | ||||
$sub_select->add(array_values($sub_types[$ftype]), $subtypes); | $sub_select->add(array_values($sub_types[$ftype]), $subtypes); | ||||
} | } | ||||
} | } | ||||
$args['form']['props']['fieldsets']['settings']['content']['folderctype'] = array( | $args['form']['props']['fieldsets']['settings']['content']['folderctype'] = array( | ||||
'label' => $this->gettext('folderctype'), | 'label' => $this->gettext('folderctype'), | ||||
'value' => html::div('input-group', | 'value' => html::div('input-group', | ||||
$type_select->show(isset($new_ctype) ? $new_ctype : $ctype) | $type_select->show(isset($new_ctype) ? $new_ctype : $ctype) | ||||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | class kolab_folders extends rcube_plugin | ||||
* Returns CSS class name for specified folder type | * Returns CSS class name for specified folder type | ||||
* | * | ||||
* @param string $type Folder type | * @param string $type Folder type | ||||
* | * | ||||
* @return string Class name | * @return string Class name | ||||
*/ | */ | ||||
static function folder_class_name($type) | static function folder_class_name($type) | ||||
{ | { | ||||
list($ctype, $subtype) = explode('.', $type); | list($ctype, $subtype) = array_pad(explode('.', $type), 2, null); | ||||
$class[] = 'type-' . ($ctype ? $ctype : 'mail'); | $class[] = 'type-' . ($ctype ? $ctype : 'mail'); | ||||
if ($subtype) | if ($subtype) | ||||
$class[] = 'subtype-' . $subtype; | $class[] = 'subtype-' . $subtype; | ||||
return implode(' ', $class); | return implode(' ', $class); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | private function get_expire_annotation($folder) | ||||
if (!strlen($folder)) { | if (!strlen($folder)) { | ||||
return 0; | return 0; | ||||
} | } | ||||
$value = $storage->get_metadata($folder, $this->expire_annotation); | $value = $storage->get_metadata($folder, $this->expire_annotation); | ||||
if (is_array($value)) { | if (is_array($value)) { | ||||
return $value[$folder] ? intval($value[$folder][$this->expire_annotation]) : 0; | return ($value[$folder] ?? false) ? intval($value[$folder][$this->expire_annotation]) : 0; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Add expiration time input to the form if supported | * Add expiration time input to the form if supported | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |