Ejemplo n.º 1
0
function notifyNewUser($address, $username)
{
    global $AppUI;
    $mail = new w2p_Utilities_Mail();
    if ($mail->ValidEmail($address)) {
        if ($mail->ValidEmail($AppUI->user_email)) {
            $email = $AppUI->user_email;
        } else {
            return false;
        }
        $mail->To($address);
        $emailManager = new w2p_Output_EmailManager();
        $body = $emailManager->getNotifyNewUser($username);
        $mail->Subject('New Account Created');
        $mail->Body($body);
        $mail->Send();
    }
}
Ejemplo n.º 2
0
 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 '';
 }
Ejemplo n.º 3
0
 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 '';
         }
     }
 }
Ejemplo n.º 4
0
 public function sendWatchMail($debug = false)
 {
     // Get the message from details.
     $q = $this->_getQuery();
     $q->clear();
     $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);
     $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();
     $subj_prefix = $this->_AppUI->_('forumEmailSubj', UI_OUTPUT_RAW);
     $mail->Subject($subj_prefix . ' ' . $this->message_title);
     $emailManager = new w2p_Output_EmailManager($this->_AppUI);
     $body = $emailManager->getForumWatchEmail($this, $forum_name, $message_from);
     $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
     while ($row = $q->fetchRow()) {
         $mail->To($row['contact_email'], true);
         $mail->Send();
     }
     $q->clear();
 }
Ejemplo n.º 5
0
 public function notifyContacts($isNotNew)
 {
     $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->getProjectNotify($this, $isNotNew);
         foreach ($users as $row) {
             $mail = new w2p_Utilities_Mail();
             $mail->To($row['contact_email'], true);
             $mail->Subject($subject);
             $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
             $mail->Send();
         }
     }
     return '';
 }
Ejemplo n.º 6
0
 public function notify($assignees, $update = false, $clash = false)
 {
     global $AppUI, $locale_char_set, $w2Pconfig;
     $mail_owner = $AppUI->getPref('MAILALL');
     $assignee_list = explode(',', $assignees);
     $owner_is_assigned = in_array($this->event_owner, $assignee_list);
     if ($mail_owner && !$owner_is_assigned && $this->event_owner) {
         array_push($assignee_list, $this->event_owner);
     }
     // Remove any empty elements otherwise implode has a problem
     foreach ($assignee_list as $key => $x) {
         if (!$x) {
             unset($assignee_list[$key]);
         }
     }
     if (!count($assignee_list)) {
         return;
     }
     $q = $this->_query;
     $q->addTable('users', 'u');
     $q->addTable('contacts', 'con');
     $q->addQuery('user_id, contact_first_name, contact_last_name, con.contact_id, contact_email');
     $q->addWhere('u.user_contact = con.contact_id');
     $q->addWhere('user_id in (' . implode(',', $assignee_list) . ')');
     $users = $q->loadHashList('user_id');
     $date_format = $AppUI->getPref('SHDATEFORMAT');
     $time_format = $AppUI->getPref('TIMEFORMAT');
     $fmt = $date_format . ' ' . $time_format;
     $start_date = new w2p_Utilities_Date($this->event_start_date);
     $end_date = new w2p_Utilities_Date($this->event_end_date);
     $mail = new w2p_Utilities_Mail();
     $type = $update ? $AppUI->_('Updated') : $AppUI->_('New');
     if ($clash) {
         $mail->Subject($AppUI->_('Requested Event') . ': ' . $this->event_title, $locale_char_set);
     } else {
         $mail->Subject($type . ' ' . $AppUI->_('Event') . ': ' . $this->event_title, $locale_char_set);
     }
     $body = '';
     if ($clash) {
         $emailManager = new w2p_Output_EmailManager();
         $body .= $emailManager->getCalendarConflictEmail($AppUI);
     }
     $body .= $AppUI->_('Event') . ":\t" . $this->event_title . "\n";
     if (!$clash) {
         $body .= $AppUI->_('URL') . ":\t" . w2PgetConfig('base_url') . "/index.php?m=calendar&a=view&event_id=" . $this->event_id . "\n";
     }
     $body .= $AppUI->_('Starts') . ":\t" . $start_date->format($fmt) . " GMT/UTC\n";
     $body .= $AppUI->_('Ends') . ":\t" . $end_date->format($fmt) . " GMT/UTC\n";
     // Find the project name.
     if ($this->event_project) {
         $project = new CProject();
         $project->load($this->event_project);
         $body .= $AppUI->_('Project') . ":\t" . $project->project_name . "\n";
     }
     $types = w2PgetSysVal('EventType');
     $body .= $AppUI->_('Type') . ":\t" . $AppUI->_($types[$this->event_type]) . "\n";
     $body .= $AppUI->_('Attendees') . ":\t";
     $body_attend = '';
     foreach ($users as $user) {
         $body_attend .= ($body_attend ? ', ' : '') . $user['contact_first_name'] . ' ' . $user['contact_last_name'];
     }
     $body .= $body_attend . "\n\n" . $this->event_description . "\n";
     $mail->Body($body, $locale_char_set);
     foreach ($users as $user) {
         if (!$mail_owner && $user['user_id'] == $this->event_owner) {
             continue;
         }
         $mail->To($user['contact_email'], true);
         $mail->Send();
     }
 }
Ejemplo n.º 7
0
 public function notify($assignees, $update = false, $clash = false)
 {
     $mail_owner = $this->_AppUI->getPref('MAILALL');
     $assignee_list = explode(',', $assignees);
     $owner_is_assigned = in_array($this->event_owner, $assignee_list);
     if ($mail_owner && !$owner_is_assigned && $this->event_owner) {
         array_push($assignee_list, $this->event_owner);
     }
     // Remove any empty elements otherwise implode has a problem
     foreach ($assignee_list as $key => $x) {
         if (!$x) {
             unset($assignee_list[$key]);
         }
     }
     if (!count($assignee_list)) {
         return;
     }
     $q = $this->_getQuery();
     $q->addTable('users', 'u');
     $q->addTable('contacts', 'con');
     $q->addQuery('user_id, con.contact_id, contact_email');
     $q->addQuery('contact_display_name, contact_display_name as contact_name');
     $q->addWhere('u.user_contact = con.contact_id');
     $q->addWhere('user_id in (' . implode(',', $assignee_list) . ')');
     $users = $q->loadHashList('user_id');
     $mail = new w2p_Utilities_Mail();
     $type = $update ? $this->_AppUI->_('Event updated') : $this->_AppUI->_('New event');
     $mail->Subject($type . ': ' . $this->event_name);
     $emailManager = new w2p_Output_EmailManager($this->_AppUI);
     $body = $emailManager->getEventNotify($this, false, $users);
     $mail->Body($body, $this->_locale_char_set);
     foreach ($users as $user) {
         if (!$mail_owner && $user['user_id'] == $this->event_owner) {
             continue;
         }
         $mail->To($user['contact_email'], true);
         $mail->Send();
     }
 }
Ejemplo n.º 8
0
function sendNewPass()
{
    global $AppUI;
    // ensure no malicous sql gets past
    $checkusername = preg_replace("/[^A-Za-z0-9]/", "", w2PgetParam($_POST, 'checkusername', ''));
    $confirmEmail = trim(w2PgetParam($_POST, 'checkemail', ''));
    $confirmEmail = strtolower(db_escape($confirmEmail));
    $q = new w2p_Database_Query();
    $q->addTable('users');
    $q->addJoin('contacts', 'con', 'user_contact = contact_id', 'inner');
    $q->addQuery('user_id');
    $q->addWhere("user_username = '******'");
    /* Begin Hack */
    /*
     * This is a particularly annoying hack but I don't know of a better
     *   way to resolve #457. In v2.0, there was a refactoring to allow for
     *   muliple contact methods which resulted in the contact_email being
     *   removed from the contacts table. If the user is upgrading from
     *   v1.x and they try to log in before applying the database, crash.
     *   Info: http://bugs.web2project.net/view.php?id=457
     */
    $qTest = new w2p_Database_Query();
    $qTest->addTable('w2pversion');
    $qTest->addQuery('max(db_version)');
    $dbVersion = $qTest->loadResult();
    if ($dbVersion >= 21 && $dbVersion < 26) {
        $q->leftJoin('contacts_methods', 'cm', 'cm.contact_id = con.contact_id');
        $q->addWhere("cm.method_value = '{$confirmEmail}'");
    } else {
        $q->addWhere("LOWER(user_email) = '{$confirmEmail}'");
    }
    /* End Hack */
    $user_id = $q->loadResult();
    if (!$user_id) {
        $AppUI->setMsg('Invalid username or email.', UI_MSG_ERROR);
        $AppUI->redirect();
    }
    $auth = new w2p_Authenticators_SQL();
    $newpass = $auth->createNewPassword();
    $hashed = $auth->hashPassword($newpass);
    $q->addTable('users');
    $q->addUpdate('user_password', $hashed);
    $q->addWhere('user_id=' . $user_id);
    $cur = $q->exec();
    if ($cur) {
        $emailManager = new w2p_Output_EmailManager($AppUI);
        $body = $emailManager->notifyPasswordReset($checkusername, $newpass);
        $m = new w2p_Utilities_Mail();
        // create the mail
        $m->To($confirmEmail);
        $subject = $_sitename . ' :: ' . $AppUI->_('sendpass4', UI_OUTPUT_RAW) . ' - ' . $checkusername;
        $m->Subject($subject);
        $m->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
        // set the body
        $m->Send();
        // send the mail
        $AppUI->setMsg('New User Password created and emailed to you');
        $AppUI->redirect();
    }
}
Ejemplo n.º 9
0
 /**
  * Called by the Event Queue processor to process a reminder
  * on a task.
  * @access  public
  * @param   string  $notUsed    Module name (not used)
  * @param   string  $notUsed2   Type of event (not used)
  * @param   integer $id         ID of task being reminded
  * @param   integer $owner      Originator of event
  * @param   mixed   $notUsed    event-specific arguments.
  *
  * @return  mixed   true, dequeue event, false, event stays in queue.
  * -1, event is destroyed.
  */
 public function remind($notUsed = null, $notUsed2 = null, $id, $owner, $notUsed3 = null)
 {
     // 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->assignees($this->task_id);
     $contact = new CContact();
     $owner = $contact->findContactByUserId($this->task_owner);
     $contacts[$owner->contact_id] = array('user_id' => $this->task_owner, 'contact_id' => $owner->contact_id, 'contact_name' => $owner->contact_display_name, 'contact_email' => $owner->contact_email);
     // 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 *= $expires->compare($expires, $now);
     $prefix = $this->_AppUI->_('Task Due', UI_OUTPUT_RAW);
     if ($diff == 0) {
         $msg = $this->_AppUI->_('TODAY', UI_OUTPUT_RAW);
     } elseif ($diff == 1) {
         $msg = $this->_AppUI->_('TOMORROW', UI_OUTPUT_RAW);
     } elseif ($diff < 0) {
         $msg = $this->_AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
         $prefix = $this->_AppUI->_('Task', UI_OUTPUT_RAW);
     } else {
         $msg = $this->_AppUI->_(array($diff, 'DAYS'));
     }
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $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;
     $emailManager = new w2p_Output_EmailManager($this->_AppUI);
     $body = $emailManager->getTaskRemind($this, $msg, $project_name, $contacts);
     $mail = new w2p_Utilities_Mail();
     $mail->Subject($subject);
     foreach ($contacts as $contact) {
         $user_id = $contact['user_id'];
         $this->_AppUI->loadPrefs($user_id);
         $df = $this->_AppUI->getPref('SHDATEFORMAT');
         $tz = $this->_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, $this->_locale_char_set);
         $mail->To($contact['contact_email'], true);
         $mail->Send();
     }
     return true;
 }
Ejemplo n.º 10
0
function notifyNewUser($emailAddress, $username, $emailUtility = null)
{
    global $AppUI;
    $emailManager = new w2p_Output_EmailManager($AppUI);
    $body = $emailManager->getNotifyNewUser($username);
    $mail = !is_null($emailUtility) ? $emailUtility : new w2p_Utilities_Mail();
    $mail->To($emailAddress);
    $mail->Subject('New Account Created');
    $mail->Body($body);
    return $mail->Send();
}
Ejemplo n.º 11
0
 public function notify()
 {
     $emailManager = new w2p_Output_EmailManager($this->_AppUI);
     $body = $emailManager->getContactUpdateNotify(null, $this);
     $mail = new w2p_Utilities_Mail();
     $mail->To($this->contact_email, true);
     $mail->Subject('Hello');
     $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
     return $mail->Send();
 }