#105 Projects: Don't send notification on every change

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

This one fixes bug#1293907: each time a project task is
updates (e.g. update the hours worked) a notification
is sent, a new task was assigned to you.

With this fix, the notification is sent only when the
assignee was actually changed:

In the function "editTask($data), add the following
lines before the task is updated and after the
parent_task check:

// Check the current assignee
$sql = "SELECT assignee FROM mgw_projects_tasks
WHERE task_id=$tid";
if(!($row = $conn->GetRow($sql))===false){
$assignee_changed = ($row["assignee"] !=
$assignedto);
} else {
$assignee_changed = 1; //Default
}

Then, after the update, look for the Notification and
put an if() around is as in this example:

// Notification
if ($assignee_changed) {
$msg = Lang::getLanguageString('delegatedtask')
. " " . $qtitle . " \n\n" .
Lang::getLanguageString('description') . ": " . $qdesc;
$sql = "SELECT title FROM mgw_projects WHERE
project_id=$pid";
if(!$res = $conn->Execute($sql))
exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__,
__FILE__));
$row = $res->FetchRow();
$subj = "more.groupware: " .
Lang::getLanguageString('changedproject') . ": " .
$row["title"];

// to fix bug #899784
if(get_magic_quotes_gpc()){
$subj = addslashes($subj);
$msg = addslashes($msg);
}

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);
}

Discussion