* InfoLog/CalDAV: preference allowing to modify responsible user from devices not supporting them by setting EMail address as category

This commit is contained in:
Ralf Becker 2012-07-20 13:07:20 +00:00
parent ade542201c
commit 7e83e4359b
4 changed files with 109 additions and 2 deletions

View File

@ -462,7 +462,12 @@ class infolog_groupdav extends groupdav_handler
$taskId = 0;
$retval = '201 Created';
}
if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id)))
if ($GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'] &&
$GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'] !== 'none')
{
$callback_data = array(array($this, 'cat_action'), $oldTask);
}
if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data)))
{
if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false");
return '403 Forbidden';
@ -484,6 +489,71 @@ class infolog_groupdav extends groupdav_handler
return $retval;
}
/**
* Callback for infolog_ical::importVTODO to implement infolog-cat-action
*
* @param array $task
* @param array $oldTask=null
* @return array modified task data
*/
public function cat_action(array $task, $oldTask=null)
{
$action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'];
//error_log(__METHOD__.'('.array2string($task).', '.array2string($oldTask).") action=$action");
if ($task['info_cat'] && ($new_cat = categories::id2name($task['info_cat'])) &&
strpos($new_cat, '@') !== false)
{
$new_user = $GLOBALS['egw']->accounts->name2id($new_cat, 'account_email');
}
$old_responsible = $task['info_responsible'];
// no action taken, if cat is not email of user
if ($new_user)
{
// make sure category is global, as otherwise it will not be transmitted to other users
if (!categories::is_global($task['info_cat']))
{
$cat_obj = new categories(categories::GLOBAL_ACCOUNT, 'infolog');
$cat = categories::read($task['info_cat']);
$cat['owner'] = categories::GLOBAL_ACCOUNT;
$cat['access'] = 'public';
$cat_obj->edit($cat);
}
// if replace, remove user of old category from responsible
if ($action == 'replace' && $oldTask && $oldTask['info_cat'] &&
($old_cat = categories::id2name($oldTask['info_cat'])) && strpos($old_cat, '@') !== false &&
($old_user = $GLOBALS['egw']->accounts->name2id($old_cat, 'account_email')) &&
($key = array_search($old_user, (array)$task['info_responsible'])) !== false)
{
unset($task['info_responsible'][$key]);
}
switch($action)
{
case 'set':
$task['info_responsible'] = array();
// fall through
case 'set-user':
foreach($task['info_responsible'] as $key => $account_id)
{
if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u')
{
unset($task['info_responsible'][$key]);
}
}
// fall-through
case 'add':
case 'replace':
if (!in_array($new_user, (array)$task['info_responsible']))
{
$task['info_responsible'][] = $new_user;
}
break;
}
}
error_log(__METHOD__."() action=$action, new_cat=$new_cat --> new_user=$new_user, old_cat=$old_cat --> old_user=$old_user: responsible: ".array2string($old_responsible).' --> '.array2string($task['info_responsible']));
return $task;
}
/**
* Handle delete request for a task / infolog entry
*
@ -647,6 +717,22 @@ class infolog_groupdav extends groupdav_handler
'xmlrpc' => True,
'admin' => False,
);
$settings['infolog-cat-action'] = array(
'type' => 'select',
'label' => 'Action when category is an EMail address',
'name' => 'infolog-cat-action',
'help' => 'Allows to modify responsible users from devices not supporting them, by setting EMail address of a user as category.',
'values' => array(
'none' => lang('none'),
'add' => lang('add user to responsibles'),
'replace' => lang('add user to responsibles, removing evtl. previous category user'),
'set' => lang('set user as only responsible, removing all existing responsibles'),
'set-user' => lang('set user as only responsible user, but keeping groups'),
),
'default' => 'none',
'xmlrpc' => True,
'admin' => False,
);
return $settings;
}
}

View File

@ -513,9 +513,12 @@ class infolog_ical extends infolog_bo
* @param string $charset=null The encoding charset for $text. Defaults to
* utf-8 for new format, iso-8859-1 for old format.
* @param string $caldav_name=null CalDAV URL name-part for new entries
* @param array $callback_data=null array with callback and further parameters, first param is task to save
* signature array callback($task, $param1, ...)
* @return int|boolean integer info_id or false on error
*/
function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null)
function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null,
array $callback_data=null)
{
if ($this->tzid)
@ -579,6 +582,12 @@ class infolog_ical extends infolog_bo
// merge in again all infolog fields not supported by iCal or not allowed to change
$taskData = array_merge($taskData, $old);
}
if ($callback_data)
{
$callback = array_shift($callback_data);
array_unshift($callback_data, $taskData);
$taskData = call_user_func_array($callback, $callback_data);
}
return $this->write($taskData, true, true, false, false, false, 'ical');
}

View File

@ -33,6 +33,7 @@ account is expired common de Benutzerkennung ist abgelaufen
accounts common de Benutzerkonten
acl common de ACL
action common de Aktion
action when category is an email address groupdav de Aktion wenn Kategorie eine EMail Adresse ist
actions common de Befehle
active common de Aktiv
add common de Hinzufügen
@ -40,6 +41,8 @@ add %1 category for common de %1 Kategorie hinzufügen für
add category common de Kategorie hinzufügen
add shortcut common de Abkürzung hinzufügen
add sub common de Untergeordnete hinzufügen
add user to responsibles groupdav de füge Benutzer zu Verantwortlichen hinzu
add user to responsibles, removing evtl. previous category user groupdav de füge Benutzer zu Verantwortlichen hinzu, entferne Benutzer der vorherigen Kategorie
addressbook common de Adressbuch
addressbooks to sync in addition to personal addressbook groupdav de Adressbücher die zusätzlich zum persönlichen synchronisiert werden sollen
admin common de Admin
@ -52,6 +55,7 @@ all addressbooks groupdav de Alle Adressbücher
all fields common de alle Felder
all in one groupdav de Gemeinsam in einem
all languages common de Alle Sprachen
allows to modify responsible users from devices not supporting them, by setting email address of a user as category. groupdav de Erlaubt verantwortliche Benutzer durch setzen einer EMail Adresse als Kategorie zu ändern, von Geräten die keine verantwortlichen Benutzer unterstützen.
alphabet common de a,ä,b,c,d,e,f,g,h,i,j,k,l,m,n,o,ö,p,q,r,s,t,u,ü,v,w,x,y,z
alternate style-sheet: common de Alternatives Style-sheet
american samoa common de AMERICANISCH SAMOA
@ -645,6 +649,8 @@ server answered. processing response... common de Server antwortet. Bearbeite An
server contacted. waiting for response... common de Server kontaktiert. Warte auf Antwort...
server name common de Server Name
session has been killed common de Session wurde beendet
set user as only responsible user, but keeping groups groupdav de setze Benutzer als einzigen verantwortlichen Benutzer, Gruppen werden nicht geändert
set user as only responsible, removing all existing responsibles groupdav de setze Benutzer als alleinigen Verantwortlichen, entferne alle bestehenden Verantwortlichen
setup common de Setup
setup main menu common de Setup Hauptmenü
seychelles common de SEYCHELLEN

View File

@ -33,6 +33,7 @@ account is expired common en Account is expired.
accounts common en Accounts
acl common en ACL
action common en Action
action when category is an email address groupdav en Action when category is an EMail address
actions common en Actions
active common en Active
add common en Add
@ -40,6 +41,8 @@ add %1 category for common en Add %1 category for
add category common en Add category
add shortcut common en Add shortcut
add sub common en Add sub
add user to responsibles groupdav en add user to responsibles
add user to responsibles, removing evtl. previous category user groupdav en add user to responsibles, removing evtl. previous category user
addressbook common en Address Book
addressbooks to sync in addition to personal addressbook groupdav en Addressbooks to sync in addition to personal addressbook
admin common en Admin
@ -52,6 +55,7 @@ all addressbooks groupdav en All addressbooks
all fields common en All fields
all in one groupdav en All in one
all languages common en All languages
allows to modify responsible users from devices not supporting them, by setting email address of a user as category. groupdav en Allows to modify responsible users from devices not supporting them, by setting EMail address of a user as category.
alphabet common en a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
alternate style-sheet: common en Alternate style sheet:
american samoa common en AMERICAN SAMOA
@ -646,6 +650,8 @@ server answered. processing response... common en Server answered. Processing re
server contacted. waiting for response... common en Server contacted. Waiting for response...
server name common en Server name
session has been killed common en Session has been killed.
set user as only responsible user, but keeping groups groupdav en set user as only responsible user, but keeping groups
set user as only responsible, removing all existing responsibles groupdav en set user as only responsible, removing all existing responsibles
setup common en Setup
setup main menu common en Setup main menu
seychelles common en SEYCHELLES