public function notify() { global $AppUI, $w2Pconfig, $locale_char_set; $df = $AppUI->getPref('SHDATEFORMAT'); $df .= ' ' . $AppUI->getPref('TIMEFORMAT'); $mail = new w2p_Utilities_Mail(); $mail->Subject('Hello', $locale_char_set); if ($this->contact_email) { $emailManager = new w2p_Output_EmailManager(); $body = $emailManager->getContactUpdateNotify($AppUI, $this); $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); } if ($mail->ValidEmail($this->contact_email)) { $mail->To($this->contact_email, true); $mail->Send(); } return ''; }
public function notifyContacts($notifyContacts) { global $w2Pconfig, $locale_char_set; if ($notifyContacts) { //if no project specified than we will not do anything if ($this->file_project != 0) { $this->_project = new CProject(); $this->_project->overrideDatabase($this->_query); $this->_project->load($this->file_project); $mail = new w2p_Utilities_Mail(); if ($this->file_task == 0) { //notify all developers $mail->Subject($this->_AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->file_name, $locale_char_set); } else { //notify all assigned users $this->_task = new CTask(); $this->_task->overrideDatabase($this->_query); $this->_task->load($this->file_task); $mail->Subject($this->_AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->_task->task_name . '::' . $this->file_name, $locale_char_set); } $emailManager = new w2p_Output_EmailManager($this->_AppUI); $body = $emailManager->getFileNotifyContacts($this); $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); $q = $this->_getQuery(); $q->addTable('project_contacts', 'pc'); if (intval($this->_task->task_id) != 0) { $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $q->addWhere('pc.project_id = ' . (int) $this->_project->project_id); $sql = '(' . $q->prepare() . ')'; $q->clear(); $sql .= ' UNION '; $q->addTable('task_contacts', 'tc'); $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id'); $q->addWhere('tc.task_id = ' . (int) $this->_task->task_id); } else { $q->addQuery('pc.project_id, pc.contact_id'); $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $q->addWhere('pc.project_id = ' . (int) $this->file_project); } $this->_users = $q->loadList(); foreach ($this->_users as $row) { if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } return ''; } } }
/** * Called by the Event Queue processor to process a reminder * on a task. * @access public * @param string $module Module name (not used) * @param string $type Type of event (not used) * @param integer $id ID of task being reminded * @param integer $owner Originator of event * @param mixed $args event-specific arguments. * @return mixed true, dequeue event, false, event stays in queue. * -1, event is destroyed. */ public function remind($module, $type, $id, $owner, &$args) { global $locale_char_set, $AppUI; $q = new w2p_Database_Query(); // At this stage we won't have an object yet if (!$this->load($id)) { return -1; // No point it trying again later. } $this->htmlDecode(); // Only remind on working days. $today = new w2p_Utilities_Date(); if (!$today->isWorkingDay()) { return true; } // Check if the task is completed if ($this->task_percent_complete == 100) { return -1; } $contacts = $this->getAssigned(); // Now we also check the owner of the task, as we will need // to notify them as well. $owner_is_not_assignee = false; $q->addTable('users', 'u'); $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact', 'inner'); $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email'); $q->addWhere('u.user_id = ' . (int) $this->task_owner); if ($q->exec(ADODB_FETCH_NUM)) { list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow(); if (!isset($contacts[$owner_contact])) { $owner_is_not_assignee = true; $contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email); } } $q->clear(); // build the subject line, based on how soon the // task will be overdue. $starts = new w2p_Utilities_Date($this->task_start_date); $expires = new w2p_Utilities_Date($this->task_end_date); $now = new w2p_Utilities_Date(); $diff = $expires->dateDiff($now); $diff *= w2p_Utilities_Date::compare($expires, $now); $prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW); if ($diff == 0) { $msg = $AppUI->_('TODAY', UI_OUTPUT_RAW); } elseif ($diff == 1) { $msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW); } elseif ($diff < 0) { $msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS')); $prefix = $AppUI->_('Task', UI_OUTPUT_RAW); } else { $msg = $AppUI->_(array($diff, 'DAYS')); } $project = new CProject(); $project_name = $project->load($this->task_project)->project_name; // Check to see that the project is both active and not a template if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) { return -1; } $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name; $body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': START-TIME' . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': END-TIME' . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n"; foreach ($contacts as $contact) { if (!$owner_is_not_assignee || $owner_is_not_assignee && $contact['contact_id'] != $owner_contact) { $body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n"; } } $body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n"; $mail = new w2p_Utilities_Mail(); $mail->Subject($subject, $locale_char_set); foreach ($contacts as $contact) { $user_id = CUser::getUserIdByContactID($contact['contact_id']); $AppUI->loadPrefs($user_id); $df = $AppUI->getPref('DISPLAYFORMAT'); $tz = $AppUI->getPref('TIMEZONE'); $body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body); $body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body); $mail->Body($body, $locale_char_set); if ($mail->ValidEmail($contact['contact_email'])) { $mail->To($contact['contact_email'], true); $mail->Send(); } } return true; }
public function notifyContacts($isNotNew) { global $AppUI, $w2Pconfig, $locale_char_set; $subject = intval($isNotNew) ? "Project Updated: {$this->project_name} " : "Project Submitted: {$this->project_name} "; $users = CProject::getContacts($AppUI, $this->project_id); if (count($users)) { if (intval($isNotNew)) { $body = $AppUI->_('Project') . ": {$this->project_name} Has Been Updated Via Project Manager. You can view the Project by clicking: "; } else { $body = $AppUI->_('Project') . ": {$this->project_name} Has Been Submitted Via Project Manager. You can view the Project by clicking: "; } $body .= "\n" . $AppUI->_('URL') . ': ' . w2PgetConfig('base_url') . '/index.php?m=projects&a=view&project_id=' . $this->project_id; $body .= "\n\n(You are receiving this message because you are a contact or assignee for this Project)"; $body .= "\n\n" . $AppUI->_('Description') . ':' . "\n{$this->project_description}"; if (intval($isNotNew)) { $body .= "\n\n" . $AppUI->_('Updater') . ': ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name; } else { $body .= "\n\n" . $AppUI->_('Creator') . ': ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name; } if ($this->_message == 'deleted') { $body .= "\n\nProject " . $this->project_name . ' was ' . $this->_message . ' by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name; } foreach ($users as $row) { $mail = new w2p_Utilities_Mail(); $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); $mail->Subject($subject, $locale_char_set); if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } } return ''; }
function notifyNewUserCredentials($address, $username, $logname, $logpwd) { global $AppUI, $w2Pconfig; $mail = new w2p_Utilities_Mail(); if ($mail->ValidEmail($address)) { if ($mail->ValidEmail($AppUI->user_email)) { $email = $AppUI->user_email; } else { $email = "web2project@" . $AppUI->cfg['site_domain']; } $mail->To($address); $mail->Subject('New Account Created - web2Project Project Management System'); $mail->Body($username . ",\n\n" . "An access account has been created for you in our web2Project project management system.\n\n" . "You can access it here at " . w2PgetConfig('base_url') . "\n\n" . "Your username is: " . $logname . "\n" . "Your password is: " . $logpwd . "\n\n" . "This account will allow you to see and interact with projects. If you have any questions please contact us."); $mail->Send(); } }
public function notifyContacts($notifyContacts) { global $AppUI, $w2Pconfig, $locale_char_set; if ($notifyContacts) { //if no project specified than we will not do anything if ($this->file_project != 0) { $this->_project = new CProject(); $this->_project->load($this->file_project); $mail = new w2p_Utilities_Mail(); if ($this->file_task == 0) { //notify all developers $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->file_name, $locale_char_set); } else { //notify all assigned users $this->_task = new CTask(); $this->_task->load($this->file_task); $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->_task->task_name . '::' . $this->file_name, $locale_char_set); } $body = $AppUI->_('Project') . ': ' . $this->_project->project_name; $body .= "\n" . $AppUI->_('URL') . ': ' . W2P_BASE_URL . '/index.php?m=projects&a=view&project_id=' . $this->_project->project_id; if (intval($this->_task->task_id) != 0) { $body .= "\n\n" . $AppUI->_('Task') . ': ' . $this->_task->task_name; $body .= "\n" . $AppUI->_('URL') . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->_task->task_id; $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->_task->task_description; $q = new w2p_Database_Query(); $q->addTable('project_contacts', 'pc'); $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $q->addWhere('pc.project_id = ' . (int) $this->_project->project_id); $sql = '(' . $q->prepare() . ')'; $q->clear(); $sql .= ' UNION '; $q->addTable('task_contacts', 'tc'); $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id'); $q->addWhere('tc.task_id = ' . (int) $this->_task->task_id); } else { $q = new w2p_Database_Query(); $q->addTable('project_contacts', 'pc'); $q->addQuery('pc.project_id, pc.contact_id'); $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name'); $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $q->addWhere('pc.project_id = ' . (int) $this->file_project); } $this->_users = $q->loadList(); $body .= "\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name; if ($this->_message != 'deleted') { $body .= "\n" . $AppUI->_('URL') . ': ' . W2P_BASE_URL . '/fileviewer.php?file_id=' . $this->file_id; $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->file_description; } //send mail $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); foreach ($this->_users as $row) { if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } return ''; } } }
public function sendWatchMail($debug = false) { global $AppUI, $debug, $w2Pconfig; $subj_prefix = $AppUI->_('forumEmailSubj', UI_OUTPUT_RAW); $body_msg = $AppUI->_('forumEmailBody', UI_OUTPUT_RAW); // Get the message from details. $q = $this->_query; $q->addTable('users', 'u'); $q->addQuery('contact_first_name, contact_last_name, contact_email'); $q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner'); $q->addWhere('user_id = ' . (int) $this->message_author); $res = $q->exec(); if ($row = $q->fetchRow()) { $message_from = $row['contact_first_name'] . ' ' . $row['contact_last_name'] . '<' . $row['contact_email'] . '>'; } else { $message_from = 'Unknown user'; } // Get the forum name; $q->clear(); $q->addTable('forums'); $q->addQuery('forum_name'); $q->addWhere('forum_id = \'' . $this->message_forum . '\''); $res = $q->exec(); if ($row = $q->fetchRow()) { $forum_name = $row['forum_name']; } else { $forum_name = 'Unknown'; } // SQL-Query to check if the message should be delivered to all users (forced) // In positive case there will be a (0,0,0) row in the forum_watch table $q->clear(); $q->addTable('forum_watch'); $q->addQuery('*'); $q->addWhere('watch_user = 0 AND watch_forum = 0 AND watch_topic = 0'); $resAll = $q->exec(); $AllCount = db_num_rows($resAll); $q->clear(); $q->addTable('users'); $q->addQuery('DISTINCT user_id, contact_first_name, contact_last_name, contact_email'); $q->leftJoin('contacts', 'con', 'con.contact_id = user_contact'); if ($AllCount < 1) { //message is only delivered to users that checked the forum watch $q->addTable('forum_watch'); $q->addWhere('user_id = watch_user AND (watch_forum = ' . (int) $this->message_forum . ' OR watch_topic = ' . (int) $this->message_parent . ')'); } if (!($res = $q->exec(ADODB_FETCH_ASSOC))) { $q->clear(); return; } if (db_num_rows($res) < 1) { return; } $mail = new w2p_Utilities_Mail(); $mail->Subject($subj_prefix . ' ' . $this->message_title, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); $body = $body_msg; $body .= "\n\n" . $AppUI->_('Forum', UI_OUTPUT_RAW) . ': ' . $forum_name; $body .= "\n" . $AppUI->_('Subject', UI_OUTPUT_RAW) . ': ' . $this->message_title; $body .= "\n" . $AppUI->_('Message From', UI_OUTPUT_RAW) . ': ' . $message_from; $body .= "\n\n" . W2P_BASE_URL . '/index.php?m=forums&a=viewer&forum_id=' . $this->message_forum; $body .= "\n\n" . $this->message_body; $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); while ($row = $q->fetchRow()) { if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } $q->clear(); return; }
public function notifyContacts($isNotNew) { global $w2Pconfig, $locale_char_set; $subject = intval($isNotNew) ? "Project Updated: {$this->project_name} " : "Project Submitted: {$this->project_name} "; $users = CProject::getContacts($this->_AppUI, $this->project_id); if (count($users)) { $emailManager = new w2p_Output_EmailManager($this->_AppUI); $body = $emailManager->getProjectNotifyContacts($this, $isNotNew); foreach ($users as $row) { $mail = new w2p_Utilities_Mail(); $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : ''); $mail->Subject($subject, $locale_char_set); if ($mail->ValidEmail($row['contact_email'])) { $mail->To($row['contact_email'], true); $mail->Send(); } } } return ''; }