示例#1
0
 function sendNotificationEmail($type)
 {
     jTipsLogger::_log('preparing to send ' . $type . ' notification email', 'INFO');
     global $jTips, $database;
     $subject = stripslashes($jTips["UserNotify" . $type . "Subject"]);
     $message = stripslashes($jTips["UserNotify" . $type . "Message"]);
     $from_name = $jTips['UserNotifyFromName'];
     $from_email = $jTips['UserNotifyFromEmail'];
     $variables = array();
     $values = array();
     foreach (get_object_vars($this) as $key => $val) {
         if (is_string($key)) {
             array_push($variables, $key);
             $values[$key] = $val;
         }
     }
     if (isJoomla15()) {
         $user = new JUser();
     } else {
         $user = new mosUser($database);
     }
     $user->load($this->user_id);
     foreach (get_object_vars($user) as $key => $val) {
         if (is_string($key)) {
             array_push($variables, $key);
             $values[$key] = $val;
         }
     }
     // find out which season this is for an add it to the avaialble variables
     $query = "SELECT name FROM #__jtips_seasons WHERE id = '" . $this->season_id . "'";
     $database->setQuery($query);
     $season = $database->loadResult();
     $values['competition'] = $season;
     $values['season'] = $season;
     $body = parseTemplate($message, $variables, $values);
     jTipsLogger::_log('sending email: ' . $body, 'INFO');
     if (jTipsMail($from_email, $from_name, $this->getUserField('email'), $subject, $body)) {
         jTipsLogger::_log('notification email sent successfully', 'INFO');
         return TRUE;
     } else {
         jTipsLogger::_log('sending notification email failed', 'ERROR');
         return FALSE;
     }
 }
示例#2
0
/**
 * Sends an email to the user confirming their selections
 * TODO: Make the email customisable
 *
 * @param object The jTipsUser to send to
 * @param array The set of tips for the user
 */
function sendTipsConfirmation($jTipsUser, $tips)
{
    global $database, $jTips;
    if (!$jTips['TipsNotifyEnable']) {
        jTipsLogger::_log('tips confirmation email disabled', 'INFO');
        return true;
    }
    jTipsLogger::_log('building tips confirmation email');
    $jSeason = new jSeason($database);
    $jSeason->load($jTipsUser->season_id);
    $from_name = $jTips['UserNotifyFromName'];
    $from_email = $jTips['UserNotifyFromEmail'];
    if ($jTips['DisplayName'] == 'user') {
        $name = 'username';
    } else {
        $name = 'name';
    }
    $subject = "Selection Confirmation";
    $content = "Hi " . $jTipsUser->getUserField($name) . ",<br /><br />" . "Thanks for submitting your tips!<br /><br />" . "You picked:<br /><br />";
    foreach ($tips as $jTip) {
        $jGame = new jGame($database);
        $jGame->load($jTip->game_id);
        $home = new jTeam($database);
        $away = new jTeam($database);
        $home->load($jGame->home_id);
        $away->load($jGame->away_id);
        $phrase = 'to defeat';
        if ($jTip->tip_id == $home->id or $jTip->tip_id == '-1') {
            $tipped =& $home;
            $notTipped =& $away;
        } else {
            $tipped =& $away;
            $notTipped =& $home;
        }
        if ($jTip->tip_id == '-1') {
            $phrase = 'to draw with';
        }
        $content .= $tipped->getName() . " {$phrase} " . $notTipped->getName();
        if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) {
            $content .= " by " . ($jTip->margin ? $jTip->margin : '0');
        }
        if ($jSeason->pick_score == 1 and $jGame->has_score == 1) {
            $content .= " with a final score of ";
            if ($jTip->tip_id == $home->id or $jTip->tip_id == '-1') {
                $content .= $jTip->home_score . " to " . $jTip->away_score;
            } else {
                $content .= $jTip->away_score . " to " . $jTip->home_score;
            }
        }
        $content .= "<br />";
    }
    $content .= "<br />";
    $content .= "Good Luck!<br />";
    $content .= $from_name;
    //BUG 223 - Send the email in plaintext for best compatibility, so convert the line breaks
    $content = str_replace('<br />', "\n", $content);
    jTipsLogger::_log($content, 'ERROR');
    jTipsLogger::_log('sending tips confirmation email to ' . $jTipsUser->getUserField('email') . ' from <' . $from_email . '>');
    if (jTipsMail($from_email, $from_name, $jTipsUser->getUserField('email'), $subject, $content)) {
        jTipsLogger::_log('tips email confirmation sent', 'INFO');
        return true;
    } else {
        jTipsLogger::_log('failed to sent tips confirmation email', 'ERROR');
        return false;
    }
}
示例#3
0
文件: MailMan.php 项目: joomux/jTips
    $rows = (array) $database->loadAssocList();
    jTipsLogger::_log('found ' . count($rows) . ' users to try to send to ', 'info');
    foreach ($rows as $user) {
        ksort($user);
        $jTipsUser = new jTipsUser($database);
        $jTipsUser->load($user['id']);
        //jTipsLogger::_log($jTipsUser);
        if ($jTipsUser->getPreference('email_reminder')) {
            $recipient = $user['email'];
            $user['round'] = $round[0]['round'];
            $user['competition'] = $round[0]['season'];
            $user['season'] = $round[0]['season'];
            $body = parseTemplate($body, $variables, $user);
            $record = array('round_id' => $round[0]['id'], 'user_id' => $user['id'], 'notified' => 0);
            $attempted++;
            if (jTipsMail($from, $fromname, $recipient, $subject, $body)) {
                $record['notified'] = 1;
                jTipsLogger::_log('sent reminder email to ' . $recipient . ' subject: ' . $subject . ' from: ' . $fromname . ' <' . $from . '>', 'info');
                $sent++;
            } else {
                jTipsLogger::_log('failed to send reminder email to ' . $recipient, 'error');
            }
            $jRemind = new jRemind($database);
            $jRemindParams = array('round_id' => $record['round_id'], 'user_id' => $record['user_id']);
            $jRemind->loadByParams($jRemindParams);
            $jRemind->attempts++;
            $jRemind->bind($record);
            $jRemind->save();
        }
    }
}
示例#4
0
文件: add.php 项目: joomux/jTips
    }
    foreach (get_object_vars($my) as $key => $val) {
        if (is_string($key)) {
            array_push($variables, $key);
            $values[$key] = $val;
        }
    }
    // add the season name to the email variables
    $query = "SELECT name FROM #__jtips_seasons WHERE id = '" . $this->season_id . "'";
    $database->setQuery($query);
    $season = $database->loadResult();
    $values['competition'] = $season;
    $values['season'] = $season;
    /**
     * BUG 76: the parseTemplate function was taking
     * the AdminNotifySubject as the first parameter.
     * Changed to be the actual message body
     */
    $body = parseTemplate($jTips['AdminNotifyMessage'], $variables, $values);
    if (jTipsMail($jTips['AdminNotifyFromEmail'], $jTips['AdminNotifyFromName'], $jTips['AdminNotifyToEmail'], $jTips['AdminNotifySubject'], $body)) {
        jTipsLogger::_log('email sent to administration', 'INFO');
    } else {
        jTipsLogger::_log('failed to send email to administration', 'ERROR');
    }
}
if ($jTips['AutoReg']) {
    $message = $jLang['_COM_JOIN_COMPLETE'];
} else {
    $message = $jLang['_COM_JOIN_PENDING'];
}
jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid', '') . '&season=' . $season_id, $message);