Merge branch 'master' of ssh://git.kolab.org/git/roundcubemail-plugins-kolab

This commit is contained in:
Thomas Bruederli 2014-03-17 12:36:08 +01:00
commit 3ebc2dc548
10 changed files with 141 additions and 80 deletions

View file

@ -159,25 +159,5 @@ function kolab_activesync_config()
window.rcmail && rcmail.addEventListener('init', function(evt) { window.rcmail && rcmail.addEventListener('init', function(evt) {
// add button to tabs list
var tab = $('<span>').attr('id', 'settingstabpluginactivesync').addClass('tablink'),
button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.activesync')
.html(rcmail.gettext('tabtitle', 'kolab_activesync'))
.appendTo(tab);
rcmail.add_element(tab, 'tabs');
if (/^plugin.activesync/.test(rcmail.env.action))
activesync_object = new kolab_activesync_config(); activesync_object = new kolab_activesync_config();
}); });
// extend jQuery
(function($){
$.fn.serializeJSON = function(){
var json = {};
jQuery.map($(this).serializeArray(), function(n, i) {
json[n['name']] = n['value'];
});
return json;
};
})(jQuery);

View file

@ -52,9 +52,29 @@ class kolab_activesync extends rcube_plugin
$this->register_action('plugin.activesync-config', array($this, 'config_frame')); $this->register_action('plugin.activesync-config', array($this, 'config_frame'));
$this->register_action('plugin.activesync-json', array($this, 'json_command')); $this->register_action('plugin.activesync-json', array($this, 'json_command'));
$this->add_texts('localization/', true); $this->add_hook('settings_actions', array($this, 'settings_actions'));
$this->add_texts('localization/', array('devicedeleteconfirm', 'savingdata'));
if (strpos($this->rc->action, 'plugin.activesync') === 0) {
$this->include_script('kolab_activesync.js'); $this->include_script('kolab_activesync.js');
} }
}
/**
* Adds Activesync section in Settings
*/
function settings_actions($args)
{
$args['actions'][] = array(
'action' => 'plugin.activesync',
'class' => 'activesync',
'label' => 'tabtitle',
'domain' => 'kolab_activesync',
);
return $args;
}
/** /**
* Handle JSON requests * Handle JSON requests

View file

@ -95,7 +95,7 @@ class kolab_activesync_ui
$attrib['id'] = 'foldersubscriptions'; $attrib['id'] = 'foldersubscriptions';
// group folders by type (show only known types) // group folders by type (show only known types)
$folder_groups = array('mail' => array(), 'contact' => array(), 'event' => array(), 'task' => array()); $folder_groups = array('mail' => array(), 'contact' => array(), 'event' => array(), 'task' => array(), 'note' => array());
$folder_types = kolab_storage::folders_typedata(); $folder_types = kolab_storage::folders_typedata();
$imei = $this->device['_id']; $imei = $this->device['_id'];
$subscribed = array(); $subscribed = array();

View file

@ -329,12 +329,14 @@ class kolab_auth_ldap extends rcube_ldap_generic
// fields mapping // fields mapping
foreach ($this->fieldmap as $field => $attr) { foreach ($this->fieldmap as $field => $attr) {
// $entry is indexed by lower-case attribute names // $entry might be indexed by lower-case attribute names
$attr_lc = strtolower($attr); $attr_lc = strtolower($attr);
if (isset($entry[$attr_lc])) { if (isset($entry[$attr_lc])) {
$entry[$field] = $entry[$attr_lc]; $entry[$field] = $entry[$attr_lc];
} }
// @TODO: consider returning also $entry[$attr] when $attr != $attr_lc else if (isset($entry[$attr])) {
$entry[$field] = $entry[$attr];
}
} }
return $entry; return $entry;

View file

@ -38,13 +38,6 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
else if (rcmail.env.task != 'settings') else if (rcmail.env.task != 'settings')
return; return;
// add Delegation section to the list
var tab = $('<span>').attr('id', 'settingstabplugindelegation').addClass('tablink'),
button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.delegation')
.html(rcmail.gettext('tabtitle', 'kolab_delegation'))
.appendTo(tab);
rcmail.add_element(tab, 'tabs');
if (/^plugin.delegation/.test(rcmail.env.action)) { if (/^plugin.delegation/.test(rcmail.env.action)) {
rcmail.addEventListener('plugin.delegate_save_complete', function(e) { rcmail.delegate_save_complete(e); }); rcmail.addEventListener('plugin.delegate_save_complete', function(e) { rcmail.delegate_save_complete(e); });

View file

@ -65,9 +65,15 @@ class kolab_delegation extends rcube_plugin
$this->register_action('plugin.delegation-save', array($this, 'controller_action')); $this->register_action('plugin.delegation-save', array($this, 'controller_action'));
$this->register_action('plugin.delegation-autocomplete', array($this, 'controller_action')); $this->register_action('plugin.delegation-autocomplete', array($this, 'controller_action'));
$this->add_hook('settings_actions', array($this, 'settings_actions'));
if ($this->rc->action == 'plugin.delegation' || empty($_REQUEST['_framed'])) { if ($this->rc->action == 'plugin.delegation' || empty($_REQUEST['_framed'])) {
$this->add_texts('localization/', array('tabtitle', 'deleteconfirm', 'savingdata', 'yes', 'no')); $this->add_texts('localization/', array('deleteconfirm', 'savingdata', 'yes', 'no'));
if ($this->rc->action == 'plugin.delegation') {
$this->include_script('kolab_delegation.js'); $this->include_script('kolab_delegation.js');
}
$this->skin_path = $this->local_skin_path(); $this->skin_path = $this->local_skin_path();
$this->include_stylesheet($this->skin_path . '/style.css'); $this->include_stylesheet($this->skin_path . '/style.css');
} }
@ -78,6 +84,21 @@ class kolab_delegation extends rcube_plugin
} }
} }
/**
* Adds Delegation section in Settings
*/
function settings_actions($args)
{
$args['actions'][] = array(
'action' => 'plugin.delegation',
'class' => 'delegation',
'label' => 'tabtitle',
'domain' => 'kolab_delegation',
);
return $args;
}
/** /**
* Engine object getter * Engine object getter
*/ */

View file

@ -1,10 +1,10 @@
/* Stylesheets for the Kolab Delegation configuration UI */ /* Stylesheets for the Kolab Delegation configuration UI */
#settings-sections #settingstabplugindelegation a { #settings-sections span.listitem.delegation a {
background: url(delegation.png) 6px 1px no-repeat; background: url(delegation.png) 6px 1px no-repeat;
} }
#settings-sections #settingstabplugindelegation.selected a { #settings-sections span.listitem.delegation.selected a {
background-position: 6px -23px; background-position: 6px -23px;
} }

View file

@ -497,4 +497,50 @@ abstract class kolab_format
{ {
return array(); return array();
} }
protected function get_attachments(&$object)
{
// handle attachments
$vattach = $this->obj->attachments();
for ($i=0; $i < $vattach->size(); $i++) {
$attach = $vattach->get($i);
// skip cid: attachments which are mime message parts handled by kolab_storage_folder
if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) {
$name = $attach->label();
$content = $attach->data();
$object['_attachments'][$name] = array(
'name' => $name,
'mimetype' => $attach->mimetype(),
'size' => strlen($content),
'content' => $content,
);
}
else if (substr($attach->uri(), 0, 4) == 'http') {
$object['links'][] = $attach->uri();
}
}
}
protected function set_attachments($object)
{
// save attachments
$vattach = new vectorattachment;
foreach ((array) $object['_attachments'] as $cid => $attr) {
if (empty($attr))
continue;
$attach = new Attachment;
$attach->setLabel((string)$attr['name']);
$attach->setUri('cid:' . $cid, $attr['mimetype']);
$vattach->push($attach);
}
foreach ((array) $object['links'] as $link) {
$attach = new Attachment;
$attach->setUri($link, 'unknown');
$vattach->push($attach);
}
$this->obj->setAttachments($vattach);
}
} }

View file

@ -31,6 +31,11 @@ class kolab_format_note extends kolab_format
protected $read_func = 'readNote'; protected $read_func = 'readNote';
protected $write_func = 'writeNote'; protected $write_func = 'writeNote';
protected $sensitivity_map = array(
'public' => kolabformat::ClassPublic,
'private' => kolabformat::ClassPrivate,
'confidential' => kolabformat::ClassConfidential,
);
/** /**
* Set properties to the kolabformat object * Set properties to the kolabformat object
@ -42,7 +47,12 @@ class kolab_format_note extends kolab_format
// set common object properties // set common object properties
parent::set($object); parent::set($object);
// TODO: set object propeties $this->obj->setSummary($object['title']);
$this->obj->setDescription($object['description']);
$this->obj->setClassification($this->sensitivity_map[$object['sensitivity']]);
$this->obj->setCategories(self::array2vector($object['categories']));
$this->set_attachments($object);
// cache this data // cache this data
$this->data = $object; $this->data = $object;
@ -73,10 +83,35 @@ class kolab_format_note extends kolab_format
// read common object props into local data object // read common object props into local data object
$object = parent::to_array($data); $object = parent::to_array($data);
// TODO: read object properties $sensitivity_map = array_flip($this->sensitivity_map);
$this->data = $object; // read object properties
return $this->data; $object += array(
'sensitivity' => $sensitivity_map[$this->obj->classification()],
'categories' => self::vector2array($this->obj->categories()),
'title' => $this->obj->summary(),
'description' => $this->obj->description(),
);
$this->get_attachments($object);
return $this->data = $object;
}
/**
* Callback for kolab_storage_cache to get object specific tags to cache
*
* @return array List of tags to save in cache
*/
public function get_tags()
{
$tags = array();
foreach ((array) $this->data['categories'] as $cat) {
$tags[] = rcube_utils::normalize_string($cat);
}
return $tags;
} }
} }

View file

@ -237,26 +237,7 @@ abstract class kolab_format_xcal extends kolab_format
} }
} }
// handle attachments $this->get_attachments($object);
$vattach = $this->obj->attachments();
for ($i=0; $i < $vattach->size(); $i++) {
$attach = $vattach->get($i);
// skip cid: attachments which are mime message parts handled by kolab_storage_folder
if (substr($attach->uri(), 0, 4) != 'cid:' && $attach->label()) {
$name = $attach->label();
$content = $attach->data();
$object['_attachments'][$name] = array(
'name' => $name,
'mimetype' => $attach->mimetype(),
'size' => strlen($content),
'content' => $content,
);
}
else if (substr($attach->uri(), 0, 4) == 'http') {
$object['links'][] = $attach->uri();
}
}
return $object; return $object;
} }
@ -443,24 +424,7 @@ abstract class kolab_format_xcal extends kolab_format
} }
$this->obj->setAlarms($valarms); $this->obj->setAlarms($valarms);
// save attachments $this->set_attachments($object);
$vattach = new vectorattachment;
foreach ((array)$object['_attachments'] as $cid => $attr) {
if (empty($attr))
continue;
$attach = new Attachment;
$attach->setLabel((string)$attr['name']);
$attach->setUri('cid:' . $cid, $attr['mimetype']);
$vattach->push($attach);
}
foreach ((array)$object['links'] as $link) {
$attach = new Attachment;
$attach->setUri($link, 'unknown');
$vattach->push($attach);
}
$this->obj->setAttachments($vattach);
} }
/** /**