Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube

This commit is contained in:
Thomas 2011-12-06 08:48:52 +01:00
commit 6781ada8ce
6 changed files with 257 additions and 8 deletions

View file

@ -265,7 +265,7 @@ rcube_calendar.fetch_event_rsvp_status = function(event)
window.rcmail && rcmail.addEventListener('init', function(evt) {
if (rcmail.task != 'calendar') {
var cal = new rcube_calendar(rcmail.env.calendar_settings);
rcmail.addEventListener('plugin.display_alarms', function(alarms){ cal.display_alarms(alarms); });
rcmail.addEventListener('plugin.update_event_rsvp_status', function(p){
@ -294,6 +294,8 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.enable_command('calendar-create-from-mail', true);
}
}
rcmail.register_command('plugin.calendar', function() { rcmail.switch_task('calendar'); }, true);
rcmail.addEventListener('plugin.ping_url', function(p){
var action = p.action;

View file

@ -48,10 +48,11 @@ class calendar_ui
// add taskbar button
$this->cal->add_button(array(
'name' => 'calendar',
'class' => 'button-calendar',
'label' => 'calendar.calendar',
'href' => './?_task=calendar',
'name' => 'calendar',
'class' => 'button-calendar',
'label' => 'calendar.calendar',
'href' => './?_task=calendar',
'onclick' => sprintf("%s.command('plugin.calendar');return false", JS_OBJECT_NAME),
), 'taskbar');
// load basic client script (which - unfortunately - requires fullcalendar)

View file

@ -22,13 +22,41 @@ $rcmail_config['kolab_auth_admin_password'] = '';
// Enable audit logging for abuse of administrative privileges.
$rcmail_config['kolab_auth_auditlog'] = true;
// Administrative role field (from fieldmap configuration) which must be filled with
// specified value which adds privilege to login as another user.
$rcmail_config['kolab_auth_role'] = '';
// Role field (from fieldmap configuration)
$rcmail_config['kolab_auth_role'] = 'role';
// The required value for the role attribute to contain should the user be allowed
// to login as another user.
$rcmail_config['kolab_auth_role_value'] = '';
// Administrative group name to which user must be assigned to
// which adds privilege to login as another user.
$rcmail_config['kolab_auth_group'] = '';
// Enable plugins on a role-by-role basis. In this example, the 'acl' plugin
// is enabled for people with a 'cn=professional-user,dc=mykolab,dc=ch' role.
//
// Note that this does NOT mean the 'acl' plugin is disabled for other people.
$rcmail_config['kolab_auth_role_plugins'] = Array(
'cn=professional-user,dc=mykolab,dc=ch' => Array(
'acl',
),
);
// Settings on a role-by-role basis. In this example, the 'htmleditor' setting
// is enabled(1) for people with a 'cn=professional-user,dc=mykolab,dc=ch' role,
// and it cannot be overridden. Sample use-case: disable htmleditor for normal people,
// do not allow the setting to be controlled through the preferences, enable the
// html editor for professional users and allow them to override the setting in
// the preferences.
$rcmail_config['kolab_auth_role_settings'] = Array(
'cn=professional-user,dc=mykolab,dc=ch' => Array(
'htmleditor' => Array(
'mode' => 'override',
'value' => 1,
'allow_override' => true
),
),
);
?>

View file

@ -38,6 +38,7 @@ class kolab_auth extends rcube_plugin
$rcmail = rcmail::get_instance();
$this->add_hook('authenticate', array($this, 'authenticate'));
$this->add_hook('startup', array($this, 'startup'));
$this->add_hook('user_create', array($this, 'user_create'));
// Hooks related to "Login As" feature
@ -48,6 +49,7 @@ class kolab_auth extends rcube_plugin
$this->add_hook('write_log', array($this, 'write_log'));
// TODO: This section does not actually seem to work
if ($rcmail->config->get('kolab_auth_auditlog', false)) {
$rcmail->config->set('debug_level', 1);
$rcmail->config->set('devel_mode', true);
@ -64,6 +66,89 @@ class kolab_auth extends rcube_plugin
}
public function startup($args) {
// Arguments are task / action, not interested
if (!empty($_SESSION['user_roledns'])) {
$this->load_user_role_plugins_and_settings($_SESSION['user_roledns']);
}
return $args;
}
public function load_user_role_plugins_and_settings($role_dns) {
$rcmail = rcmail::get_instance();
$this->load_config();
// Check role dependent plugins to enable and settings to modify
// Example 'kolab_auth_role_plugins' =
//
// Array(
// '<role_dn>' => Array('plugin1', 'plugin2'),
// );
$role_plugins = $rcmail->config->get('kolab_auth_role_plugins');
// Example $rcmail_config['kolab_auth_role_settings'] =
//
// Array(
// '<role_dn>' => Array(
// '$setting' => Array(
// 'mode' => '(override|merge)', (default: override)
// 'value' => <>,
// 'allow_override' => (true|false) (default: false)
// ),
// ),
// );
$role_settings = $rcmail->config->get('kolab_auth_role_settings');
foreach ($role_dns as $role_dn) {
if (isset($role_plugins[$role_dn]) && is_array($role_plugins[$role_dn])) {
foreach ($role_plugins[$role_dn] as $plugin) {
$this->require_plugin($plugin);
}
}
if (isset($role_settings[$role_dn]) && is_array($role_settings[$role_dn])) {
foreach ($role_settings[$role_dn] as $setting_name => $setting) {
if (!isset($setting['mode'])) {
$setting['mode'] = 'override';
}
if ($setting['mode'] == "override") {
$rcmail->config->set($setting_name, $setting['value']);
} elseif ($setting['mode'] == "merge") {
$orig_setting = $rcmail->config->get($setting_name);
if (!empty($orig_setting)) {
if (is_array($orig_setting)) {
$rcmail->config->set($setting_name, array_merge($orig_setting, $setting['value']));
}
} else {
$rcmail->config->set($setting_name, $setting['value']);
}
}
if (!isset($setting['allow_override']) || !$setting['allow_override']) {
$rcmail->config->set('dont_override', array_merge($rcmail->config->get('dont_override', Array()), Array($setting_name)));
} else {
$dont_override = $rcmail->config->get('dont_override');
if (in_array($setting_name, $dont_override)) {
$_dont_override = Array();
foreach ($dont_override as $_setting) {
if ($_setting != $setting_name) {
$_dont_override[] = $_setting;
}
}
$rcmail->config->set('dont_override', $_dont_override);
}
}
}
}
}
}
public function write_log($args) {
$rcmail = rcmail::get_instance();
@ -188,6 +273,12 @@ class kolab_auth extends rcube_plugin
return $args;
}
$role_attr = $rcmail->config->get('kolab_auth_role');
if (!empty($role_attr) && !empty($record[$role_attr])) {
$_SESSION['user_roledns'] = (array)($record[$role_attr]);
}
// Login As...
if (!empty($loginas) && $admin_login) {
// Authenticate to LDAP

View file

@ -0,0 +1,44 @@
<?php
/* piwik site id */
$rcmail_config['piwik_analytics_id'] = 4;
/* domain of your piwik installation */
$rcmail_config['piwik_analytics_url'] = 'noc.kolabsys.com/piwik/';
/* exclude private pages - analytics will works only for non-logged users */
$rcmail_config['piwik_analytics_privacy'] = false;
/* exclude the following templates */
$rcmail_config['piwik_analytics_exclude'] = Array(
);
// Possible templates:
// "message",
// "messagepreview",
// "compose",
// "editidentity",
// "editcontact",
// "showcontact"
// "message",
// "messagepart",
// "messagepreview",
// "messageerror",
// "showcontact",
// "addcontact",
// "editcontact",
// "importcontacts",
// "addressbook",
// "compose",
// "editidentity",
// "error",
// "identities",
// "login",
// "mail",
// "managefolders",
// "plugin",
// "settingsedit",
// "settings"
?>

View file

@ -0,0 +1,83 @@
<?php
/**
*
* piwik_analytics
*
* Bind piwik analytics script - based on: http://github.com/igloonet/roundcube_google_analytics
*
* @version 1.0 - 28. 11. 2010
* @author Florian Beer
* @modified_by Florian Beer
* @website http://blog.no-panic.at
* @licence GNU GPL
*
* Updated by Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>
*
**/
class piwik_analytics extends rcube_plugin
{
function init()
{
if (file_exists(dirname(__FILE__) . "/config.inc.php")) {
$this->load_config('config.inc.php');
} elseif (file_exists(dirname(__FILE__) . "/config.inc.php.dist")) {
$this->load_config('config.inc.php.dist');
} elseif (file_exists(dirname(__FILE__) . "/config/config.inc.php")) {
$this->load_config('config/config.inc.php');
} elseif (file_exists(dirname(__FILE__) . "/config/config.inc.php.dist")) {
$this->load_config('config/config.inc.php.dist');
/* } else {
error_log("Cannot find / load configuration for plugin piwik_analytics"); */
}
$this->add_hook('render_page', array($this, 'add_script'));
}
function add_script($args) {
$rcmail = rcmail::get_instance();
$exclude = $rcmail->config->get('piwik_analytics_exclude');
if (empty($exclude) || !is_array($exclude)) {
$exclude = Array();
}
if (isset($exclude[$args['template']])) {
return $args;
}
if ($rcmail->config->get('piwik_analytics_privacy', true)) {
if (!empty($_SESSION['user_id'])) {
return $args;
}
}
if (!$rcmail->config->get('piwik_analytics_url', false)) {
return $args;
}
$script = '
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://' . $rcmail->config->get('piwik_analytics_url') . '" : "http://' . $rcmail->config->get('piwik_analytics_url') . '");
document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\' type=\'text/javascript\'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", ' . $rcmail->config->get('piwik_analytics_id') . ');
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://' . $rcmail->config->get('piwik_analytics_url') . '/piwik.php?idsite=' . $rcmail->config->get('piwik_analytics_id') . '" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tag -->';
// add script to end of page
$rcmail->output->add_footer($script);
return $args;
}
}
?>