Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#106 When sending notifications, use the receiver's preferences

0.7.x
open
nobody
5
2005-09-20
2005-09-20
Oscar
No

Earlier today I created bug# 1296329, but I couldn't
wait, so here's the patch :-)
It solves the issue that users won't be notified as
they want to according their seetings; the settings of
the sender are used instead, e.g. when someone creates
a project task (sender) for somebody else (receiver).

The fix below describes how to fix this in the projects
module, but it can be used for more modules.

Create a file called notifyprefs.inc.php in the
moregroupware/include directory with the following
contents:

<?
function getRecvNotificationPrefs($user, $tag, $method){
global $conn;

$sql = 'SELECT COUNT(*) AS count FROM mgw_config '
. "WHERE configtagname='$tag'"
. ' AND userid='.(int)$user
. ' AND value_int='.(int)$method;

if(!$res = $conn->Execute($sql))
exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,
__FILE__));
$row = $res->FetchRow();
return ($row["count"]==1);

}
?>

In moregroupware/modules/projects/index.php, add the
following line somewhere in the top:

include(INCLUDEPATH . "notifyprefs.inc.php");

and change the following lines:

if(in_array(NOTIFY_MIM,$_SESSION['MGW']->settings['projects_notification']))
$GLOBALS['notify']->message($msg, NOTIFY_MIM,
'u:'.$assignedto, $subj);

if(in_array(NOTIFY_SCREEN,$_SESSION['MGW']->settings['projects_notification']))
$GLOBALS['notify']->message($msg, NOTIFY_SCREEN,
'u:'.$assignedto, $subj);

if(in_array(NOTIFY_MAIL,$_SESSION['MGW']->settings['projects_notification']))
$GLOBALS['notify']->message($msg, NOTIFY_MAIL,
'u:'.$assignedto, $subj);

To:

if(getRecvNotificationPrefs($assignedto,
'projects_notification', NOTIFY_MIM))
$GLOBALS['notify']->message($msg, NOTIFY_MIM,
'u:'.$assignedto, $subj);
if(getRecvNotificationPrefs($assignedto,
'projects_notification', NOTIFY_SCREEN))
$GLOBALS['notify']->message($msg, NOTIFY_SCREEN,
'u:'.$assignedto, $subj);
if(getRecvNotificationPrefs($assignedto,
'projects_notification', NOTIFY_MAIL))
$GLOBALS['notify']->message($msg, NOTIFY_MAIL,
'u:'.$assignedto, $subj);

You should change these (or similar) lines at 2
location: in createTask() and editTask().

Similar changes can also be made to the TODO module,
maybe more?

Discussion