| Welcome to the Zimbra :: Forums! | |
Welcome, if you would like to post a comment please register.
We also encourage you to explore all things Zimbra with our team and members of the community.
|  | | 
07-04-2009, 01:26 AM
| | | Improved version This version deals gracefully with situations where Calendar or Meeting Notifications folder have already been mounted by assistant. Code: # ! /bin/sh
#
# Script to perform Calendar delegation between accounts
# Author: Elliot Wilen
#
# Usage ./zmdelegate source_account delegate_account
#
#
# Name of notifications folder
notifications="Meeting Notifications"
# Name of filter used on boss's account
filtername="Meeting Notifications"
# variable to look at response to interactive prompt
response=
# Note: could do all checking and then output list of all problems
# instead of exiting after first detected problem
#
# Verify exactly two arguments
# (Could use shell Shift command to allow multiple delegation)
if test $# -ne 2
then
echo "Must supply exactly two arguments."
exit 1
fi
# Assign variables
boss_account=$1
assistant_account=$2
# Verify <boss_account> and <assistant_account> exist on the server
if ! zmmailbox -z -m $boss_account gms 1>/dev/null 2>/dev/null
then
echo "Boss account doesn't exist. Exiting."
exit 1
fi
if ! zmmailbox -z -m $assistant_account gms 1>/dev/null 2>/dev/null
then
echo "Assistant account doesn't exist. Exiting."
exit 1
fi
# Check if Meeting Notifications folder already exists; if it does, then post warning and ask if want to continue.
# Otherwise Create Meeting Notifications folder
if zmmailbox -z -m $boss_account gf "$notifications" 1>/dev/null 2>/dev/null
then
while [ "$response" != "y" -a "$response" != "n" ]
do
echo -e 'Folder "\c'
echo -e "$notifications\c"
echo -e '" already exists, use it to store/share notification messages? (y/n) \c'
read response
done
if [ "$response" = n ]
then
echo "Command cancelled."
exit 1
fi
else
echo -e 'Creating folder "\c'
echo -e "$notifications\c"
echo -e '".'
zmmailbox -z -m $boss_account cf -V message "/$notifications" 1>/dev/null 2>/dev/null
fi
# Share Meeting Notifications folder and Calendar to assistant with Manager rights.
echo "Sharing Meeting Notifications folder."
zmmailbox -z -m $boss_account mfg "/$notifications" account $assistant_account rwidx
echo "Sharing Calendar."
zmmailbox -z -m $boss_account mfg "/Calendar" account $assistant_account rwidx
# I have to use account names in names of mountpoints because I don't see
# a way to discover display names via CLI. Could prompt for user-defined sharepoint
# names.
# Check if Meeting Notifications is already mounted. (Edge case: it could be mounted but in the Trash.)
if zmmailbox -z -m $assistant_account gaf | grep \($boss_account\:`zmmailbox -z -m $boss_account gaf | awk '/\/Meeting\ Notifications$/ {print $1}'`\) 1>/dev/null
then
echo "Meeting Notifications is already mounted in assistant account...proceeding..."
else
# Check for name conflict.
if zmmailbox -z -m $assistant_account gf "/$boss_account $notifications" 1>/dev/null 2>/dev/null
then
echo -e 'Naming conflict--delete or rename folder "\c'
echo -e "$boss_account $notifications\c"
echo -e '" on assistant account.'
exit 1
else
# Accept mail folder share by assistant (only for web interface; Outlook must be done at the workstation)
echo "Mounting Meeting Notifications folder on assistant account. Right-click in Zimbra Web Client to change name."
zmmailbox -z -m $assistant_account cm -F# "/$boss_account $notifications" $boss_account "/$notifications" 1>/dev/null
fi
fi
# Check if Calendar is already mounted.
if zmmailbox -z -m $assistant_account gaf | grep \($boss_account\:`zmmailbox -z -m $boss_account gaf | awk '/\/Calendar$/ {print $1}'`\) 1>/dev/null
then
echo "Calendar is already mounted in boss account...proceeding..."
else
# Check for name conflict.
if zmmailbox -z -m $assistant_account gf "/$boss_account Calendar" 1>/dev/null 2>/dev/null
then
echo -e 'Naming conflict--delete or rename calendar "\c'
echo -e "$boss_account Calendar\c"
echo -e '" on assistant account.'
exit 1
else
# Accept Calendar share by assistant (only for web interface; Outlook must be done at the workstation)
echo "Mounting Calendar folder on assistant account. Right-click in Zimbra Web Client to change name."
zmmailbox -z -m $assistant_account cm -F# "/$boss_account Calendar" $boss_account "/Calendar" 1>/dev/null
fi
fi
echo "(In Outlook, use File>Open>Other User's Mailbox to access.)"
# Verify that filter rule with same name doesn't already exist
if zmmailbox -z -m $boss_account gfrl | grep ^\"Meeting\ Notifications\" 1>/dev/null
then
echo -e 'Naming conflict--delete or rename filter "\c'
echo -e "$filtername\c"
echo -e '" on boss account.'
exit 1
fi
# Create filter to file meeting messages into folder
echo "Creating filter in boss account."
zmmailbox -z -m $boss_account afrl -f "$filtername" body contains "Content-Type: text/calendar" body contains "method=" body contains "METHOD:" body contains "BEGIN:VEVENT" body contains "BEGIN:VCALENDAR" fileinto "/$notifications" stop
echo "Delegation complete!"
Last edited by ewilen; 07-04-2009 at 01:40 AM..
| 
07-12-2009, 10:24 AM
| | | Test of behavior after upgrading to ZCS 5.0.18 NE suggests that things are still working. See comments I added to bug #30217. | 
07-13-2009, 06:39 PM
| | | Okay, I better understand how bug #30217 works now. The upshot is that ZWC users aren't affected by the fix, but Outlook users are.
I don't have time at the moment to revise the script. So after running it, you must go into the admin GUI and add the boss's email address under Accounts>assistant_account>Edit>Preferences>Sendin g mail>Allow sending mail only from these.
Last edited by ewilen; 07-13-2009 at 06:50 PM..
| 
11-02-2009, 05:29 PM
| | Zimbra Employee | |
Posts: 16
| | Quote:
Originally Posted by ewilen Okay, based on some reading of the RFCs, I think this will capture any meeting-related message from any source (even Google Calendar), with a fairly low chance of capturing anything else. Code: If ALL of the following conditions are met:
Body contains Content-Type: text/calendar
Body contains method=
Body contains METHOD:
Body contains VEVENT
Body contains VCALENDAR
Perform the following actions:
File into Folder <folder_name> I'll test in the morning with the "assistant" using various clients. |
In 6.0.x, bug 18104 has been implemented, so these filter rules will not work (see bug 42304). Additionally, bug 19898 has been implemented in 6.0.2+.
To continue filtering invitations, users need to convert existing filter rules to the new bug 19898 format. | | Thread Tools | Search this Thread | | | | | Display Modes | Linear Mode | | Why Join? Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.  |