Anonymous Login
2019-08-20 04:45 PDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000638Pending RequestsTaskspublic2014-08-16 10:19
Reporteropto 
Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusnewResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0000638: enhance task notification email
Descriptionenhance, take out a bug, and a question:
(did I file this already ?

Patch: see add. info


Question:

Quote:
if ($users[0]['creator_email']) {
$body .= ("\n\n" . $AppUI->_('Creator', UI_OUTPUT_RAW) . ':' . "\n" . $users[0]['creator_first_name'] . ' ' . $users[0]['creator_last_name'] . ', ' . $users[0]['creator_email']);
 


does this mean the creator is only displayed if he has an email address? Does that make sense?
Additional Information//additional comment will be included in email body
public function notify($comment = '') {
$q = new DBQuery;
global $AppUI, $locale_char_set;
$df = $AppUI->getPref('SHDATEFORMAT');
$df .= ' ' . $AppUI->getPref('TIMEFORMAT');

$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id=' . (int)$this->task_project);
$projname = htmlspecialchars_decode($q->loadResult());
$q->clear();

$mail = new Mail;

$mail->Subject($projname . '::' . $this->task_name . ' ' . $AppUI->_($this->_action, UI_OUTPUT_RAW), $locale_char_set);

// c = creator
// a = assignee
// o = owner
$q->addTable('tasks', 't');
$q->leftJoin('user_tasks', 'u', 'u.task_id = t.task_id');

$q->leftJoin('users', 'o', 'o.user_id = t.task_owner');
$q->leftJoin('contacts', 'oc', 'oc.contact_id = o.user_contact');
$q->addQuery('oc.contact_id as owner_contact_id');

$q->leftJoin('users', 'c', 'c.user_id = t.task_creator');
$q->leftJoin('contacts', 'cc', 'cc.contact_id = c.user_contact');
$q->addQuery('cc.contact_id as creator_contact_id');

$q->leftJoin('users', 'a', 'a.user_id = u.user_id');
$q->leftJoin('contacts', 'ac', 'ac.contact_id = a.user_contact');
$q->addQuery('ac.contact_id as assignee_contact_id');

$q->addQuery('t.task_id, cc.contact_first_name as creator_first_name, cc.contact_last_name as creator_last_name, oc.contact_first_name as owner_first_name, oc.contact_last_name as owner_last_name, a.user_id as assignee_id, ac.contact_first_name as assignee_first_name, ac.contact_last_name as assignee_last_name');
$q->addWhere(' t.task_id = ' . (int)$this->task_id);
$users = $q->loadList();
$q->clear();

$contact = new CContact();
foreach ($users as $index => $info) {
$contact->contact_id = $info['owner_contact_id'];
$email = $contact->getContactMethods(array('email_primary'));
$users[$index]['owner_email'] = $email['email_primary'];

$contact->contact_id = $info['creator_contact_id'];
$email = $contact->getContactMethods(array('email_primary'));
$users[$index]['creator_email'] = $email['email_primary'];

$contact->contact_id = $info['assignee_contact_id'];
$email = $contact->getContactMethods(array('email_primary'));
$users[$index]['assignee_email'] = $email['email_primary'];
}

if (count($users)) {
$task_start_date = intval($this->task_start_date) ? new CDate($AppUI->formatTZAwareTime($this->task_start_date, '%Y-%m-%d %T')) : null;
$task_finish_date = intval($this->task_end_date) ? new CDate($AppUI->formatTZAwareTime($this->task_end_date, '%Y-%m-%d %T')) : null;
//get priority names
$task_priotities = w2PgetSysVal('TaskPriority');
$body = ($AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $projname . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name);
//Priority not working for some reason, will wait till later: SEEMS to be ok now
$body .= "\n\n" . $AppUI->_('Task Priority', UI_OUTPUT_RAW) . ': ' . (intval($this->task_priority) ? $task_priotities[$this->task_priority] . ' ' : '') . "\n";
$body .= "\n" . $AppUI->_('Percent Complete', UI_OUTPUT_RAW) . ': ' . (intval($this->task_percent_complete) ? $this->task_percent_complete. " %" : '') . "\n\n";
$body .= "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . ((intval($this->task_start_date)) ? $task_start_date->format($df) : '') . "\n";
$body .= $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . ((intval($this->task_end_date)) ? $task_finish_date->format($df) : '') . "\n";
$body .= $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . "\n\n";
$body .= $AppUI->_('Description', UI_OUTPUT_RAW) . ': ' . "\n" . $this->task_description . "\n\n";

$body .= $AppUI->_('Task Assignees', UI_OUTPUT_RAW) . ': ' . "\n";
foreach ($users as $row) {
$body .=$row['assignee_first_name'] . ' '. $row['assignee_last_name'] . ', ' . $row['assignee_email'] . "\n";
}


if ($users[0]['creator_email']) {
$body .= ("\n\n" . $AppUI->_('Creator', UI_OUTPUT_RAW) . ':' . "\n" . $users[0]['creator_first_name'] . ' ' . $users[0]['creator_last_name'] . ', ' . $users[0]['creator_email']);
}
$body .= ("\n\n" . $AppUI->_('Owner', UI_OUTPUT_RAW) . ':' . "\n" . $users[0]['owner_first_name'] . ' ' . $users[0]['owner_last_name'] . ', ' . $users[0]['owner_email']);
if ($comment != '') {
$body .= "\n\n" . $comment;
}
$mail->Body($body, (isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''));
}

$mail_owner = $AppUI->getPref('MAILALL');

foreach ($users as $row) {
if ($mail_owner || $row['assignee_id'] != $AppUI->user_id) {
if ($mail->ValidEmail($row['assignee_email'])) {
$mail->To($row['assignee_email'], true);
$mail->Send();
}
}
}

return '';
}
TagsNo tags attached.
Attached Files

-Relationships
related to 0000612new add new action: send notification email for all selected tasks 
child of 0000154new Hard-coded System Parameters 
+Relationships

-Notes
There are no notes attached to this issue.
+Notes

-Issue History
Date Modified Username Field Change
2010-11-23 23:13 opto New Issue
2011-01-06 23:20 caseydk Relationship added related to 0000612
2011-01-06 23:21 caseydk Relationship added child of 0000154
2011-02-24 00:55 caseydk Project Pending Requests => v2.4 Release (Closed)
2011-06-25 23:49 caseydk Project v2.4 Release (Closed) => Pending Requests
2014-08-16 10:19 caseydk Category General => Tasks
+Issue History