gunnar: server/patches/horde-webmail/1.2.0 horde-webmail-1.2.0_kolab_fbview_openpkg.patch, NONE, 1.1

cvs at kolab.org cvs at kolab.org
Thu Sep 18 20:56:51 CEST 2008


Author: gunnar

Update of /kolabrepository/server/patches/horde-webmail/1.2.0
In directory doto:/tmp/cvs-serv22919

Added Files:
	horde-webmail-1.2.0_kolab_fbview_openpkg.patch 
Log Message:
Add a first version of the fbview patch.

--- NEW FILE: horde-webmail-1.2.0_kolab_fbview_openpkg.patch ---
diff -r 85d33de56004 kronolith/attendees.php
--- a/kronolith/attendees.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/attendees.php	Thu Sep 18 20:56:25 2008 +0200
@@ -178,6 +178,16 @@
     $attendees = array();
     $_SESSION['kronolith']['attendees'] = $attendees;
     break;
+
+case 'save':
+    if (empty($attendees)) {
+        break;
+    }
+    $savedattlist = unserialize($prefs->getValue('saved_attendee_list'));
+    $savedattlist[] = array_keys($attendees);
+    $prefs->setValue('saved_attendee_list', serialize($savedattlist));
+    $notification->push(_('Successfully saved attendee list'), 'horde.success');
+    break;
 }
 
 // Get the current Free/Busy view; default to the 'day' view if none specified.
@@ -264,6 +274,15 @@
 
 $title = _("Edit attendees");
 require KRONOLITH_TEMPLATES . '/common-header.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
+
+if ($browser->hasFeature('javascript')) {
+    Horde::addScriptFile('open_savedattlist_win.js');
+    $savedattlist_url = 'javascript:open_savedattlist_win();';
+} else {
+    $savedattlist_url = Horde::applicationUrl('savedattlist.php');
+}
+
 $notification->notify(array('status'));
 require KRONOLITH_TEMPLATES . '/attendees/attendees.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/create.php
--- a/kronolith/calendars/create.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/create.php	Thu Sep 18 20:56:25 2008 +0200
@@ -39,6 +39,6 @@
 
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'create.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/delete.php
--- a/kronolith/calendars/delete.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/delete.php	Thu Sep 18 20:56:25 2008 +0200
@@ -56,6 +56,6 @@
 
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'delete.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/edit.php
--- a/kronolith/calendars/edit.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/edit.php	Thu Sep 18 20:56:25 2008 +0200
@@ -53,8 +53,12 @@
 
 $vars->set('name', $calendar->get('name'));
 $vars->set('description', $calendar->get('desc'));
+$params = @unserialize($calendar->get('params'));
+if (isset($params['fbrelevance'])) {
+    $vars->set('fbrelevance', $params['fbrelevance']);
+}
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'edit.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/index.php
--- a/kronolith/calendars/index.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/index.php	Thu Sep 18 20:56:25 2008 +0200
@@ -73,6 +73,6 @@
 Horde::addScriptFile('tables.js', 'kronolith', true);
 $title = _("Manage Calendars");
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 require KRONOLITH_TEMPLATES . '/calendar_list.php';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/remote_edit.php
--- a/kronolith/calendars/remote_edit.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/remote_edit.php	Thu Sep 18 20:56:25 2008 +0200
@@ -68,6 +68,6 @@
 $vars->set('password', $password);
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'remote_edit.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/remote_subscribe.php
--- a/kronolith/calendars/remote_subscribe.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/remote_subscribe.php	Thu Sep 18 20:56:25 2008 +0200
@@ -39,6 +39,6 @@
 
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'remote_subscribe.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/calendars/remote_unsubscribe.php
--- a/kronolith/calendars/remote_unsubscribe.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/calendars/remote_unsubscribe.php	Thu Sep 18 20:56:25 2008 +0200
@@ -56,6 +56,6 @@
 $vars->set('url', $calendar['url']);
 $title = $form->getTitle();
 require KRONOLITH_TEMPLATES . '/common-header.inc';
-require KRONOLITH_TEMPLATES . '/menu.inc';
+require KRONOLITH_TEMPLATES . '/fbview-menu.inc';
 echo $form->renderActive($form->getRenderer(), $vars, 'remote_unsubscribe.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/config/prefs.php.dist
--- a/kronolith/config/prefs.php.dist	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/config/prefs.php.dist	Thu Sep 18 20:56:25 2008 +0200
@@ -457,6 +457,14 @@
     'shared' => false,
     'type' => 'implicit'
 );
+
+$_prefs['saved_attendee_list'] = array(
+    'value' => 'a:0:{}',
+    'locked' => false,
+    'shared' => false,
+    'type' => 'implicit',
+    'desc' => _("A saved list of attendees")
+);
 $_prefs['event_colors'] = array(
     'value' => '',
     'locked' => false,
diff -r 85d33de56004 kronolith/lib/FBView.php
--- a/kronolith/lib/FBView.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/lib/FBView.php	Thu Sep 18 20:56:25 2008 +0200
@@ -87,7 +87,7 @@
             $rows = '';
             foreach ($this->_requiredMembers as $member) {
                 $member->simplify();
-                $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
+                $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"), $member->getExtraParams());
                 $template = new Horde_Template();
                 $template->set('blocks', $blocks);
                 $template->set('name', $member->getName());
@@ -109,7 +109,7 @@
             $rows = '';
             foreach ($this->_optionalMembers as $member) {
                 $member->simplify();
-                $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
+                $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"), $member->getExtraParams());
                 $template = new Horde_Template();
                 $template->set('blocks', $blocks);
                 $template->set('name', $member->getName());
@@ -124,6 +124,9 @@
             $template->set('legend', '');
             $html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
         }
+
+	//**********
+	//This has been disabled in kolab-fbview. Make this optional?
 
         // Possible meeting times.
         $optimal->setAttribute('ORGANIZER', _("All Attendees"));
@@ -146,6 +149,9 @@
         $template->set('name', _("Required Attendees"));
         $template->set('blocks', $blocks);
         $rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
+
+	//This has been disabled in kolab-fbview. Make this optional?
+	//**********
 
         // Reset locale.
         setlocale(LC_NUMERIC, $lc);
@@ -215,7 +221,7 @@
         return $instances[$view];
     }
 
-    function _getBlocks($member, $periods, $blockfile, $label)
+    function _getBlocks($member, $periods, $blockfile, $label, $extra = array())
     {
         $template = new Horde_Template();
         $template->set('label', $label);
@@ -248,6 +254,21 @@
 
                 $template->set('left', $left . '%');
                 $template->set('width', $width . '%');
+                $template->set('evclick', '');
+
+                if (isset($extra[$periodStart])) {
+                    if (!empty($extra[$periodStart]['X-UID'])) {
+                        $link = "javascript:performAction('viewaction', '" 
+			  . addslashes($member->getName() . "#" 
+				       . String::convertCharset(base64_decode($extra[$periodStart]['X-UID']), 
+								'UTF-8',NLS::getCharset())) . "')";
+                        $template->set('evclick', $link);
+                    }
+                    if (!empty($extra[$periodStart]['X-SUMMARY'])) {
+                        $template->set('label', String::convertCharset(base64_decode($extra[$periodStart]['X-SUMMARY']),'UTF-8',
+				       NLS::getCharset()));
+                    }
+                }
 
                 $blocks .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/' . $blockfile);
             } else {
diff -r 85d33de56004 kronolith/lib/Forms/CreateCalendar.php
--- a/kronolith/lib/Forms/CreateCalendar.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/lib/Forms/CreateCalendar.php	Thu Sep 18 20:56:25 2008 +0200
@@ -35,6 +35,9 @@
 
         $this->addVariable(_("Name"), 'name', 'text', true);
         $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Relevance"), 'fbrelevance', 'radio', false, false, null, 
+                           array(array('owners/administrators', 'readers', 'no one'), 
+                                 'This calendar is only included into the free/busy data for ...'));
 
         $this->setButtons(array(_("Create")));
     }
@@ -48,6 +51,7 @@
         }
         $calendar->set('name', $this->_vars->get('name'));
         $calendar->set('desc', $this->_vars->get('description'));
+        $calendar->set('params', serialize(array('fbrelevance' => (int) $this->_vars->get('fbrelevance', 0))));
         return $GLOBALS['kronolith_shares']->addShare($calendar);
     }
 
diff -r 85d33de56004 kronolith/lib/Forms/EditCalendar.php
--- a/kronolith/lib/Forms/EditCalendar.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/lib/Forms/EditCalendar.php	Thu Sep 18 20:56:25 2008 +0200
@@ -42,6 +42,9 @@
         $this->addHidden('', 'c', 'text', true);
         $this->addVariable(_("Name"), 'name', 'text', true);
         $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Relevance"), 'fbrelevance', 'radio', false, false, null, 
+                           array(array('owners/administrators', 'readers', 'no one'), 
+                                 'This calendar is only included into the free/busy data for ...'));
 
         $this->setButtons(array(_("Save")));
     }
@@ -51,6 +54,7 @@
         $original_name = $this->_calendar->get('name');
         $this->_calendar->set('name', $this->_vars->get('name'));
         $this->_calendar->set('desc', $this->_vars->get('description'));
+        $this->_calendar->set('params', serialize(array('fbrelevance' => (int) $this->_vars->get('fbrelevance', 0))));
 
         if ($original_name != $this->_vars->get('name')) {
             $result = $GLOBALS['kronolith_driver']->rename($original_name, $this->_vars->get('name'));
diff -r 85d33de56004 kronolith/lib/Kronolith.php
--- a/kronolith/lib/Kronolith.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/lib/Kronolith.php	Thu Sep 18 20:56:25 2008 +0200
@@ -2098,6 +2098,33 @@
     }
 
     /**
+     * Builds Kronolith's list of menu items.
+     */
+    function getFbviewMenu($returnType = 'object')
+    {
+        global $conf, $registry, $browser, $prefs;
+
+        /* Check here for guest calendars so that we don't get multiple
+         * messages after redirects, etc. */
+        if (!Auth::getAuth() && !count($GLOBALS['all_calendars'])) {
+            $GLOBALS['notification']->push(_("No calendars are available to guests."));
+        }
+
+        require_once 'Horde/Menu.php';
+        $menu = new Menu(HORDE_MENU_MASK_HELP | HORDE_MENU_MASK_LOGIN);
+
+        $menu->add(Horde::applicationUrl('attendees.php'), _("Attendees"), 'attendees.png', null, null, null, '__noselection');
+
+        $menu->add(Horde::applicationUrl('calendars/'), _("Calendars"), 'calendars.png', null, null, null, '__noselection');
+
+        if ($returnType == 'object') {
+            return $menu;
+        } else {
+            return $menu->render();
+        }
+    }
+
+    /**
      * Used with usort() to sort events based on their start times.
      */
     function _sortEventStartTime($a, $b)
diff -r 85d33de56004 kronolith/perms.php
--- a/kronolith/perms.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/perms.php	Thu Sep 18 20:56:25 2008 +0200
@@ -14,6 +14,34 @@
 @define('KRONOLITH_BASE', dirname(__FILE__));
 require_once KRONOLITH_BASE . '/lib/base.php';
 require_once 'Horde/Group.php';
+
+function &getFbperms($share) 
+{
+    $fbperms = array();
+    $params = $share->get('params');
+    if (!is_a($params, 'PEAR_Error')) {
+        $params = @unserialize($params);
+        if (isset($params['xfbaccess'])) {
+            $xfbusers = $params['xfbaccess'];
+            foreach ($xfbusers as $user) {
+                $fbperms[$user] = PERMS_READ;
+            }
+        }
+    }
+    return $fbperms;
+}
+
+function setFbperms($share, $xfbusers)
+{
+    $fbperms = array();
+    $params = $share->get('params');
+    if (!is_a($params, 'PEAR_Error')) {
+        $params = @unserialize($params);
+        $params['xfbaccess'] = $xfbusers;
+        $params = serialize($params);
+        $share->set('params', $params);
+    }
+}
 
 $shares = &Horde_Share::singleton('kronolith');
 $groups = &Group::singleton();
@@ -36,6 +64,8 @@
         $notification->push($share, 'horde.error');
     } elseif (isset($share) && Auth::getAuth() != $share->get('owner')) {
         exit('permission denied');
+    } else {
+        $fbperms = getFbperms($share);
     }
     break;
 
@@ -226,6 +256,24 @@
             }
         }
 
+        // Process free/busy permissions.
+        $fb_names = Util::getFormData('fb_names');
+        $fb_read = Util::getFormData('fb_read');
+
+        $fbperms = getFbperms($share);
+        foreach ($fb_names as $key => $user) {
+            if (empty($user)) {
+                continue;
+            }
+
+            if (!empty($fb_read[$key])) {
+                $fbperms[$user] = PERMS_READ;
+            } else {
+                unset($fbperms[$user]);
+            }
+        }
+        setFbperms($share, array_keys($fbperms));
+
         $share->setPermission($perm, false);
         $share->save();
         $notification->push(sprintf(_("Updated \"%s\"."), $share->get('name')), 'horde.success');
diff -r 85d33de56004 kronolith/savedattlist.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kronolith/savedattlist.php	Thu Sep 18 20:56:25 2008 +0200
@@ -0,0 +1,77 @@
+<?php
+/**
+ * $Horde: kronolith/attendeeshandler.php,v 1.1 2004/05/25 08:34:21 stuart Exp $
+ *
+ * Copyright 2004 Code Fusion  <http://www.codefusion.co.za/>
+ *                Stuart Binge <s.binge at codefusion.co.za>
+ *
+ * See the enclosed file COPYING for license information (GPL).  If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ */
+
+ at define('KRONOLITH_BASE', dirname(__FILE__));
+require_once KRONOLITH_BASE . '/lib/base.php';
+require_once KRONOLITH_BASE . '/lib/FBView.php';
+
+$title = _('Load Attendee List');
+
+Horde::addScriptFile('tooltip.js', 'horde');
+require KRONOLITH_TEMPLATES . '/common-header.inc';
+
+// Get our list of saved attendees
+$savedattlist = unserialize($prefs->getValue('saved_attendee_list'));
+
+// Preformat our image urls
+$delimg = Horde::img('delete.png', _("Remove List"), null, $GLOBALS['registry']->getImageDir('horde'));
+$loadimg = Horde::img('tree/folder.png', _("Load List"), null, $GLOBALS['registry']->getImageDir('horde'));
+
+// Get our Action ID & Value. This specifies what action the user initiated.
+$actionID = Util::getFormData('actionID', false);
+$actionValue = Util::getFormData('actionValue', false);
+if (!$actionID) {
+    $actionID = (Util::getFormData('addNew', false) ? 'add' : false);
+    $actionValue = Util::getFormData('newAttendees', '');
+}
+
+// Perform the specified action, if there is one.
+switch ($actionID) {
+case 'remove':
+    // Remove the specified attendee
+    if (array_key_exists($actionValue, $savedattlist)) {
+        unset($savedattlist[$actionValue]);
+	$prefs->setValue('saved_attendee_list', serialize($savedattlist));
+    }
+    
+    break;
+
+case 'dismiss':
+    // Make sure we're actually allowed to dismiss
+    if (!$allow_dismiss) break;
+
+    // Close the attendee window
+    global $browser;
+
+    if ($browser->hasFeature('javascript')) {
+        Util::closeWindowJS();
+    } else {
+        $url = Util::getFormData('url');
+
+        if (!empty($url)) {
+            $location = Horde::applicationUrl($url, true);
+        } else {
+            $url = Util::addParameter($prefs->getValue('defaultview') . '.php', 'month', Util::getFormData('month'));
+            $url = Util::addParameter($url, 'year', Util::getFormData('year'));
+            $location = Horde::applicationUrl($url, true);
+        }
+
+        // Make sure URL is unique.
+        $location = Util::addParameter($location, 'unique', md5(microtime()));
+
+        header('Location: ' . $location);
+    }
+    break;
+}
+
+$form_handler = Horde::applicationUrl('savedattlist.php');
+require KRONOLITH_TEMPLATES . '/savedattlist/savedattlist.inc';
+require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
diff -r 85d33de56004 kronolith/templates/attendees/attendees.inc
--- a/kronolith/templates/attendees/attendees.inc	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/templates/attendees/attendees.inc	Thu Sep 18 20:56:25 2008 +0200
@@ -92,6 +92,8 @@
 <div>
  <input type="submit" class="button" name="addNew" value="<?php echo htmlspecialchars(_("Save Attendees")) ?>" />
  <input type="submit" class="button" name="addNewClose" value="<?php echo htmlspecialchars(_("Save and Finish")) ?>" />
+ <input type="button" class="button" name="loadAttList" value="<?php echo htmlspecialchars(_("Load Attendee List")) ?>" onclick="<?php echo $savedattlist_url ?>" />
+ <?php if (!empty($attendees)): ?><input type="button" class="button" name="saveAttList" value="<?php echo htmlspecialchars(_("Save Attendee List")) ?>" onclick="performAction('save', '');" /><?php endif; ?>
  <?php if (!empty($attendees)): ?><input type="submit" class="button" name="clearAll" value="<?php echo htmlspecialchars(_("Clear all attendees")) ?>" /><?php endif; ?>
 </div>
 
diff -r 85d33de56004 kronolith/templates/fbview-menu.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kronolith/templates/fbview-menu.inc	Thu Sep 18 20:56:25 2008 +0200
@@ -0,0 +1,4 @@
+<div id="menu">
+ <?php echo Kronolith::getFbviewMenu('string') ?>
+</div>
+<?php $GLOBALS['notification']->notify(array('listeners' => 'status')) ?>
diff -r 85d33de56004 kronolith/templates/javascript/open_savedattlist_win.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kronolith/templates/javascript/open_savedattlist_win.js	Thu Sep 18 20:56:25 2008 +0200
@@ -0,0 +1,36 @@
+<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?><script language="JavaScript" type="text/javascript">
+<!--
+<?php endif; ?>
+function open_savedattlist_win(args)
+{
+    var url = "<?php echo Horde::url($GLOBALS['registry']->applicationWebPath('%application%/savedattlist.php', 'kronolith')) ?>";
+    if (url.indexOf('?') == -1) glue = '?';
+    else glue = '<?php echo ini_get('arg_separator.output') ?>';
+    var now = new Date();
+    var name = "savedattlist_window_" + now.getTime();
+    if (args != "") {
+        url = url + glue + args + '<?php echo ini_get('arg_separator.output') ?>' + "uniq=" + now.getTime();
+    } else {
+        url = url + glue + "uniq=" + now.getTime();
+    }
+    var Width = screen.width;
+    if (Width > 775) {
+        Width = 700;
+    } else {
+        Width -= 75;
+    }
+    var Height = screen.height;
+    if (Height > 725) {
+        Height = 650;
+    } else {
+        Height -= 75;
+    }
+    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + Width + ",height=" + Height + ",left=0,top=0";
+    name = window.open(url, name, param);
+    if (!eval("name.opener")) {
+        name.opener = self;
+    }
+}
+<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?>// -->
+</script>
+<?php endif; ?>
diff -r 85d33de56004 kronolith/templates/perms/perms.inc
--- a/kronolith/templates/perms/perms.inc	Thu Sep 18 20:48:11 2008 +0200
+++ b/kronolith/templates/perms/perms.inc	Thu Sep 18 20:56:25 2008 +0200
@@ -322,6 +322,61 @@
   <td> </td>
 </tr>
 
+<!-- Extended free/busy Permissions -->
+<tr valign="middle">
+  <td class="header leftAlign">
+    <?php echo Horde::img('user.png', '', '', $registry->getImageDir('horde')) . ' ' . _("Extended free/busy access") ?>
+  </td>
+  <td class="header" align="center"> </td>
+  <td class="header" align="center"><?php echo _("Read") ?></td>
+  <td class="header" align="center"> </td>
+  <td class="header" align="center"> </td>
+  <td class="header" align="center"> </td>
+  <td class="header"> </td>
+</tr>
+<?php foreach ($fbperms as $user => $fbperm) { if ($user != $owner) { ?>
+<tr>
+  <td class="light"><?php echo htmlspecialchars(Auth::removeHook($user)) ?><input type="hidden" name="fb_names[<?php echo htmlspecialchars($user) ?>]" value="<?php echo htmlspecialchars($user) ?>" /></td>
+  <td align="center"> </td>
+  <td align="center">
+    <input type="checkbox" id="fb_read_<?php echo str_replace('@', '_', htmlspecialchars($user)) ?>" name="fb_read[<?php echo htmlspecialchars($user) ?>]"<?php echo ($fbperm & PERMS_READ) ? ' checked="checked"' : '' ?> />
+    <label for="fb_read_<?php echo str_replace('@', '_', htmlspecialchars($user)) ?>" class="hidden"><?php echo _("Read") ?></label>
+  </td>
+  <td align="center"> </td>
+  <td align="center"> </td>
+  <td align="center"> </td>
+  <td> </td>
+</tr>
+<?php } } ?>
+<!-- New extended free/busy row -->
+<tr>
+<?php if ($auth->hasCapability('list')): ?>
+  <td class="light">
+    <label for="fb_names_new" class="hidden"><?php echo _("Select a user to add:") ?></label>
+    <select id="fb_names_new" name="fb_names[||new]">
+      <option value=""><?php echo _("Select a user to add:") ?></option>
+    <?php foreach ($userList as $user) { if (!isset($userperms[$user])) { ?>
+      <option value="<?php echo htmlspecialchars($user) ?>"><?php echo htmlspecialchars(Auth::removeHook($user)) ?></option>
+    <?php } } ?>
+    </select>
+  </td>
+<?php else: ?>
+  <td class="light">
+    <label for="fb_names_new" class="hidden"><?php echo _("User to add:") ?></label>
+    <input type="text" id="fb_names_new" name="fb_names[||new]" />
+  </td>
+<?php endif; ?>
+  <td align="center"> </td>
+  <td align="center">
+    <input type="checkbox" id="fb_read_new" name="fb_read[||new]" />
+    <label for="fb_read_new" class="hidden"><?php echo _("Read") ?></label>
+  </td>
+  <td align="center"> </td>
+  <td align="center"> </td>
+  <td align="center"> </td>
+  <td> </td>
+</tr>
+
 <tr>
  <td colspan="7"> </td>
 </tr>
diff -r 85d33de56004 kronolith/templates/savedattlist/savedattlist.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kronolith/templates/savedattlist/savedattlist.inc	Thu Sep 18 20:56:25 2008 +0200
@@ -0,0 +1,68 @@
+<!-- javascript action handling -->
+<script language="JavaScript" type="text/javascript">
+<!--
+function performAction(id, value)
+{
+    document.savedattlistForm.actionID.value = id;
+    document.savedattlistForm.actionValue.value = value;
+    document.savedattlistForm.submit();
+    return false;
+}
+
+function updateMessage(list)
+{
+    if (parent.opener.closed) {
+        alert('<?php echo addslashes(_("The Edit Attendees screen is no longer present. Exiting.")) ?>');
+        this.close();
+        return;
+    }
+
+    if (!parent.opener.document.attendeesForm) {
+        alert('<?php echo addslashes(_("You can only use this form from the Edit Attendees screen.")) ?>');
+        this.close();
+        return;
+    }
+
+    parent.opener.document.attendeesForm.newAttendees.value = list;
+    this.close();
+}
+// -->
+</script>
+
+<form method="post" action="<?php echo $form_handler; ?>" name="savedattlistForm">
+<?php Util::pformInput(); ?>
+<input type="hidden" name="actionID" value="" />
+<input type="hidden" name="actionValue" value="" />
+
+<div align="center">
+
+<table border="0" width="500" cellspacing="0" cellpadding="2">
+
+<!-- header -->
+<tr><td colspan="4" class="header"><b><?php echo $title ?></b></td></tr>
+
+<!-- attendee list header -->
+<tr class="item">
+ <td nowrap="nowrap" width="2%" align="center"><?php echo $loadimg ?></td>
+ <td nowrap="nowrap" width="2%" align="center"><?php echo $delimg ?></td>
+ <td nowrap="nowrap" width="96%"><b><?php echo htmlspecialchars(_("Attendees")) ?></b></td>
+</tr>
+
+<!-- attendees -->
+<?php $i = 0 ?>
+<?php if (empty($savedattlist)): ?>
+ <tr class="item<?php echo ($i++ % 2) ?>"><td align="center" colspan="3"><i><?php echo htmlspecialchars('-- ' . _("No saved attendee lists are available") . ' --') ?></i></td></tr>
+<?php else: foreach ($savedattlist as $index => $list): ?>
+ <tr class="item<?php echo ($i++ % 2) ?>">
+ <?php
+  echo '<td align="center">', Horde::link("javascript:updateMessage('" . addslashes(implode(', ', $list)) . "')", _("Load this list")), $loadimg, "</a></td>";
+ ?>
+ <?php
+  echo '<td align="center">', Horde::link("javascript:performAction('remove', '" . $index . "')", _("Remove this list")), $delimg, "</a></td>";
+ ?>
+  <td><?php echo implode(', ', $list); ?></td>
+ </tr>
+<?php endforeach; endif; ?>
+</table>
+</div>
+</form>
diff -r 85d33de56004 lib/Horde/Kolab/Storage/Folder.php
--- a/lib/Horde/Kolab/Storage/Folder.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/lib/Horde/Kolab/Storage/Folder.php	Thu Sep 18 20:56:25 2008 +0200
@@ -40,6 +40,13 @@
  */
 define('KOLAB_ANNOT_FOLDER_TYPE', KOLAB_ANNOT_ROOT . 'folder-type');
 
+/**
+ * Kolab specific free/busy relevance
+ */
+define('KOLAB_FBRELEVANCE_ADMINS',  0);
+define('KOLAB_FBRELEVANCE_READERS', 1);
+define('KOLAB_FBRELEVANCE_NOBODY',  2);
+ 
 /**
  * Horde-specific annotations on the imap folder have this prefix.
  */
@@ -396,6 +403,40 @@
             $this->_attributes = $attributes;
         }
         return true;
+//             } elseif ($attribute == 'params') {
+//                 $type = $this->getType();
+//                 if (!is_a($type, 'PEAR_Error') && $type[0] == 'event') {
+//                     $params = @unserialize($value);
+//                     if (isset($params['fbrelevance'])) {
+//                         $result = $this->setFbrelevance($params['fbrelevance']);
+//                         if (is_a($result, 'PEAR_Error')) {
+//                             return $result;
+//                         }
+//                         unset($params['fbrelevance']);
+//                     }
+//                     if (isset($params['xfbaccess'])) {
+//                         $result = $this->setXfbaccess($params['xfbaccess']);
+//                         if (is_a($result, 'PEAR_Error')) {
+//                             return $result;
+//                         }
+//                         unset($params['xfbaccess']);
+//                     }
+
+//                     if (empty($params)) {
+//                         continue;
+//                     }
+                    
+//                     $value = @serialize($params);
+//                 }
+
+//                 $imap = &$this->_shareOb->getImap();
+//                 // setAnnotation apparently does not suppoort UTF-8 nor any special characters
+//                 $store = base64_encode($value);
+//                 $entry = HORDE_ANNOT_SHARE_ATTR . $attribute;
+//                 $result = $imap->setAnnotation($entry, array('value.shared' => $store), $this->_folder);
+//                 if (is_a($result, 'PEAR_Error')) {
+//                     return $result;
+//                 }
     }
 
     /**
@@ -1193,4 +1234,93 @@
         $data['uid'] = 'KOLAB_FOLDER_CONFIGURATION';
         return $this->_annotation_data->save($data, $uid);
     }
+
+
+
+    /**
+     * Get the free/busy relevance for this folder
+     *
+     * @return int  Value containing the FB_RELEVANCE.
+     */
+    function getFbrelevance()
+    {
+        $imap = &$this->_shareOb->getImap();
+        $entry = KOLAB_ANNOT_ROOT . 'incidences-for';
+
+        $annotation = $imap->getAnnotation($entry, 'value.shared', $this->_folder);
+        if (is_a($annotation, 'PEAR_Error') || empty($annotation)) {
+            return KOLAB_FBRELEVANCE_ADMINS;
+        }
+        switch ($annotation) {
+        case 'admins':
+            return KOLAB_FBRELEVANCE_ADMINS;
+        case 'readers':
+            return KOLAB_FBRELEVANCE_READERS;
+        case 'nobody':
+            return KOLAB_FBRELEVANCE_NOBODY;
+        default:
+            return KOLAB_FBRELEVANCE_ADMINS;
+        }
+    }
+
+    /**
+     * Set the free/busy relevance for this folder
+     *
+     * @param int $relevance Value containing the FB_RELEVANCE
+     *
+     * @return mixed  True on success or a PEAR_Error.
+     */
+    function setFbrelevance($relevance)
+    {
+        switch ($relevance) {
+        case KOLAB_FBRELEVANCE_ADMINS:
+            $value = 'admins';
+            break;
+        case KOLAB_FBRELEVANCE_READERS:
+            $value = 'readers';
+            break;
+        case KOLAB_FBRELEVANCE_NOBODY:
+            $value = 'nobody';
+            break;
+        default:
+            $value = 'admins';
+        }
+
+        $imap = &$this->_shareOb->getImap();
+        $entry = KOLAB_ANNOT_ROOT . 'incidences-for';
+        return $imap->setAnnotation($entry, array('value.shared' => $value), $this->_folder);
+    }
+
+    /**
+     * Get the extended free/busy access settings for this folder
+     *
+     * @return array  Array containing the users with access to the
+     *                extended information.
+     */
+    function getXfbaccess()
+    {
+        $imap = &$this->_shareOb->getImap();
+        $entry = KOLAB_ANNOT_ROOT . 'xfb-readable';
+
+        $annotation = $imap->getAnnotation($entry, 'value.shared', $this->_folder);
+        if (is_a($annotation, 'PEAR_Error') || empty($annotation)) {
+            return array();
+        }
+        return explode(' ', $annotation);
+    }
+
+    /**
+     * Set the extended free/busy access settings for this folder
+     *
+     * @param array $access  Array containing the users with access to the
+     *                      extended information.
+     *
+     * @return mixed  True on success or a PEAR_Error.
+     */
+    function setXfbaccess($access)
+    {
+        $imap = &$this->_shareOb->getImap();
+        $entry = KOLAB_ANNOT_ROOT . 'xfb-readable';
+        return $imap->setAnnotation($entry, array('value.shared' => join(' ', $access)), $this->_folder);
+    }
 }
diff -r 85d33de56004 lib/Horde/Share/kolab.php
--- a/lib/Horde/Share/kolab.php	Thu Sep 18 20:48:11 2008 +0200
+++ b/lib/Horde/Share/kolab.php	Thu Sep 18 20:56:25 2008 +0200
@@ -525,6 +525,13 @@
             $default = array('source' => 'kolab',
                              'default' => $this->get('default'),
                              'name' => $this->get('name'));
+            $type = $this->get('type');
+            if (!is_a($type, 'PEAR_Error') && $type[0] == 'event') {
+                $default = array_merge($default, array(
+                                           'fbrelevance' => $this->getFbrelevance(),
+                                           'xfbaccess'   => $this->getXfbaccess()
+                                       ));
+            }
             if (is_a($params, 'PEAR_Error') || $params == '') {
                 $params = $default;
             }





More information about the commits mailing list