- fixed not being able to switch off notification for responsible

- new preference for htmlmail with larger fontsize
- new preference for notification of responsible: only when I get assigned or removed
- notifications are now suppressed, if no changes made (according to save_history)
This commit is contained in:
Ralf Becker 2007-06-21 16:25:08 +00:00
parent e004216f15
commit 5d9ff65391
5 changed files with 43 additions and 17 deletions

View File

@ -163,19 +163,21 @@ class bo_tracking
* @param array $data current entry
* @param array $old=null old/last state of the entry or null for a new entry
* @param int $user=null user who made the changes, default to current user
* @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
* @return int/boolean false on error, integer number of changes logged or true for new entries ($old == null)
*/
function track($data,$old=null,$user=null)
function track($data,$old=null,$user=null,$deleted=null)
{
$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
$changes = true;
if ($old)
if ($old && $this->field2history)
{
$changes = $this->save_history($data,$old);
$changes = $this->save_history($data,$old,$deleted);
}
if (!$this->do_notifications($data,$old))
// do not run do_notifications if we have no changes
if ($changes && !$this->do_notifications($data,$old,$deleted))
{
$changes = false;
}
@ -188,9 +190,10 @@ class bo_tracking
* @internal use only track($data,$old)
* @param array $data current entry
* @param array $old=null old/last state of the entry or null for a new entry
* @param int number of log-entries made
* @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
* @return int number of log-entries made
*/
function save_history($data,$old)
function save_history($data,$old,$deleted=null)
{
$changes = 0;
foreach($this->field2history as $name => $status)
@ -217,9 +220,10 @@ class bo_tracking
* @internal use only track($data,$old,$user)
* @param array $data current entry
* @param array $old=null old/last state of the entry or null for a new entry
* @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
* @return boolean true on success, false on error (error messages are in $this->errors)
*/
function do_notifications($data,$old)
function do_notifications($data,$old,$deleted=null)
{
$this->errors = $email_sent = array();
@ -262,7 +266,8 @@ class bo_tracking
{
if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent))
{
$this->send_notification($data,$old,$email,$data['tr_assigned'],'notify_assigned');
$this->send_notification($data,$old,$email,$assignee,'notify_assigned',
in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted); // assignment changed
$email_sent[] = $email;
}
}
@ -272,7 +277,8 @@ class bo_tracking
{
if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent))
{
$this->send_notification($data,$old,$email,$u,'notify_assigned');
$this->send_notification($data,$old,$email,$u,'notify_assigned',
in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted); // assignment changed
$email_sent[] = $email;
}
}
@ -337,9 +343,10 @@ class bo_tracking
* @param string $email address to send the notification to
* @param string $user_or_lang='en' user-id or 2 char lang-code for a non-system user
* @param string $check=null pref. to check if a notification is wanted
* @param boolean $assignment_changed=true the assignment of the user $user_or_lang changed
* @return boolean true on success or false on error (error-message is in $this->errors)
*/
function send_notification($data,$old,$email,$user_or_lang,$check=null)
function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true)
{
//error_log("bo_trackering::send_notification(,,'$email',$user_or_lang,$check)");
if (!$email) return false;
@ -353,10 +360,15 @@ class bo_tracking
$GLOBALS['egw']->preferences->preferences($user_or_lang);
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
}
if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$this->check2pref ? $this->check2pref[$check] : $check])
if ($check && $this->check2pref) $check = $this->check2pref[$check];
if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check])
{
return false; // no notification requested
}
if ($check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed)
{
return false; // only notification about changed assignment requested
}
}
else
{
@ -628,7 +640,7 @@ class bo_tracking
$line = $this->html->htmlspecialchars($line); // XSS
$color = $modified ? 'red' : false;
$size = 'small';
$size = $html_mail == 'medium' ? 'medium' : 'small';
$bold = false;
$background = '#FFFFF1';
switch($type)
@ -651,7 +663,7 @@ class bo_tracking
$background = '#F1F1F1';
break;
default:
$size = 'x-small';
$size = $size == 'small' ? 'x-small' : 'small';
}
$style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color?'color:'.$color:'');

View File

@ -559,7 +559,7 @@ class boinfolog
{
$this->tracking =& new infolog_tracking($this);
}
$this->tracking->track($deleted,$info,$this->user);
$this->tracking->track($deleted,$info,$this->user,true);
}
return True;
}
@ -746,7 +746,7 @@ class boinfolog
{
$this->tracking =& new infolog_tracking($this);
}
$this->tracking->track($values,$old,$this->user);
$this->tracking->track($values,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted');
}
if ($info_from_set) $values['info_from'] = '';

View File

@ -141,10 +141,15 @@ $GLOBALS['settings']['notify_creator'] = array(
'admin' => False,
);
$GLOBALS['settings']['notify_assigned'] = array(
'type' => 'check',
'type' => 'select',
'label' => 'Receive notifications about items assigned to you',
'name' => 'notify_assigned',
'help' => 'Do you want a notification, if items get assigned to you or assigned items get updated?',
'values' => array(
'0' => lang('No'),
'1' => lang('Yes'),
'assignment' => lang('Only if I get assigned or removed'),
),
'xmlrpc' => True,
'admin' => False,
);
@ -196,10 +201,15 @@ $GLOBALS['settings']['notify_start_responsible'] = array(
);
$GLOBALS['settings']['notify_html'] = array(
'type' => 'check',
'type' => 'select',
'label' => 'Receive notifications as html-mails',
'name' => 'notify_html',
'help' => 'Do you want to receive notifications as html-mails or plain text?',
'values' => array(
'0' => lang('No'),
'1' => lang('Yes'),
'medium' => lang('Yes, with larger fontsize'),
),
'xmlrpc' => True,
'admin' => False,
);

View File

@ -210,6 +210,7 @@ one day after infolog de am n
one day in advance infolog de am Vortag
ongoing infolog de in Arbeit
only for details infolog de Nur bei Details
only if i get assigned or removed infolog de Nur wenn ich zugewiesen oder entfernt werde
only the attachments infolog de nur die Anhänge
only the links infolog de nur die Verknüpfungen
open infolog de offen
@ -345,6 +346,7 @@ yes - delete infolog de Ja - L
yes - delete including sub-entries infolog de Ja - Löschen einschließlich Untereinträge
yes, noone can purge deleted items infolog de Ja, niemand darf gelöschte Einträge bereinigen
yes, only admins can purge deleted items infolog de Ja, nur Admins dürfen gelöschte Einträge bereinigen
yes, with larger fontsize infolog de Ja, mit einer größeren Schrift
yes, with purging of deleted items possible infolog de Ja, jeder darf gelöschte Einträge bereinigen
you can't delete one of the stock types !!! infolog de Sie können keinen der Standardtypen löschen!!!
you have entered an invalid ending date infolog de Sie haben ein ungültiges Fälligkeitsdatum eingegeben

View File

@ -210,6 +210,7 @@ one day after infolog en one day after
one day in advance infolog en one day in advance
ongoing infolog en ongoing
only for details infolog en Only for details
only if i get assigned or removed infolog en Only if I get assigned or removed
only the attachments infolog en only the attachments
only the links infolog en only the links
open infolog en open
@ -343,6 +344,7 @@ yes - delete infolog en Yes - Delete
yes - delete including sub-entries infolog en Yes - Delete including sub-entries
yes, noone can purge deleted items infolog en Yes, noone can purge deleted items
yes, only admins can purge deleted items infolog en Yes, only admins can purge deleted items
yes, with larger fontsize infolog en Yes, with larger fontsize
yes, with purging of deleted items possible infolog en Yes, with purging of deleted items possible
you can't delete one of the stock types !!! infolog en You can't delete one of the stock types !!!
you have entered an invalid ending date infolog en You have entered an invalid due date