本文整理汇总了PHP中JMailHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JMailHelper类的具体用法?PHP JMailHelper怎么用?PHP JMailHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JMailHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Process
public function Process()
{
// Newsletter component disabled or not found. Aborting.
if (!$this->enabled) {
return true;
}
$config = acymailing_config();
// Build subscriber object
$subscriber = new stdClass();
// Name field may be absent. AcyMailing will guess the user's name from his email address
$subscriber->name = isset($this->FieldsBuilder->Fields['sender0']) ? $this->FieldsBuilder->Fields['sender0']['Value'] : "";
// AcyMailing refuses to save the user (return false) if the email address is empty, so we don't care to check it
$subscriber->email = empty($this->FieldsBuilder->Fields['sender1']['Value']) ? NULL : JMailHelper::cleanAddress($this->FieldsBuilder->Fields['sender1']['Value']);
// It seems that $subscriber->confirmed defaults to unconfirmed if unset, so we need to read and pass the actual value from the configuration
//ADRIEN : not necessary, you should keep the user as unconfirmed, Acy will take care of that
//$subscriber->confirmed = !(bool)$config->get('require_confirmation');
$userClass = acymailing_get('class.subscriber');
$userClass->checkVisitor = false;
// Add or update the user
$sub_id = $userClass->save($subscriber);
if (empty($sub_id)) {
// User save failed. Probably email address is empty or invalid
$this->logger->Write(get_class($this) . " Process(): User save failed");
return true;
}
// Lists
$cumulative = JRequest::getVar("acymailing_subscribe_cumulative", NULL, "POST");
$checkboxes = array(FAcyMailing::subscribe => JRequest::getVar("acymailing_subscribe", array(), "POST"));
$lists = $cumulative ? $checkboxes : array();
// Subscription
//$listsubClass = acymailing_get('class.listsub');
//$listsubClass->addSubscription($sub_id, $lists);
// ADRIEN : we use an other function so Acy will check the subscription and only subscribe the user if he was not already subscribed to that list.
/*
$newSubscription = array();
if(!empty($lists)){
foreach($lists[FAcyMailing::subscribe] as $listId){
$newList = array();
$newList['status'] = FAcyMailing::subscribe;
$newSubscription[$listId] = $newList;
}
$userClass->saveSubscription($sub_id, $newSubscription);
}
*/
// When in mode "one checkbox for each list" and no lists selected the code above produce an SQL error because passes an empty array to saveSubscription()
$newSubscription = array();
foreach ($lists[FAcyMailing::subscribe] as $listId) {
$newList = array();
$newList['status'] = FAcyMailing::subscribe;
$newSubscription[$listId] = $newList;
}
if (!empty($newSubscription)) {
$userClass->saveSubscription($sub_id, $newSubscription);
}
// implode() doesn't accept NULL values :(
@$lists[FAcyMailing::subscribe] or $lists[FAcyMailing::subscribe] = array();
// Log
$this->logger->Write(get_class($this) . " Process(): subscribed " . $this->FieldsBuilder->Fields['sender0']['Value'] . " (" . $this->FieldsBuilder->Fields['sender1']['Value'] . ") to lists " . implode(",", $lists[FAcyMailing::subscribe]));
return true;
}
示例2: prepareDisplayedData
/**
*
* Get data
* @param Array $pk
*/
public function prepareDisplayedData($pk)
{
$data = null;
$params = $this->getState('params');
// Get some data from the models
$state = $this->getState();
$items = $this->getItems();
$pagination = $this->getPagination();
for ($i = 0, $n = count($items); $i < $n; $i++) {
$item =& $items[$i];
$item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
$temp = new JRegistry();
$temp->loadString($item->params);
$item->params = clone $params;
$item->params->merge($temp);
if ($item->params->get('show_email', 0) == 1) {
$item->email_to = trim($item->email_to);
if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) {
$item->email_to = $item->email_to;
} else {
$item->email_to = '';
}
}
}
$JSNConfig = JSNFactory::getConfig();
$JSNConfig->megreMenuParams($pk['Itemid'], $params, 'com_contact');
$JSNConfig->megreGlobalParams('com_contact', $params, true);
$maxLevel = $params->get('maxLevel', -1);
$data->maxLevel = $maxLevel;
$data->state = $state;
$data->items = $items;
$data->params = $params;
$data->pagination = $pagination;
return $data;
}
示例3: Process
public function Process()
{
$uid = $this->Params->get("jmessenger_user", NULL);
// No user selected for Joomla messenger
if (!$uid) {
//JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this));
// It's not a problem. Maybe it's even wanted. Return succesful.
return true;
}
$body = $this->body();
$body .= $this->attachments();
$body .= PHP_EOL;
// Info about url
$body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL;
// Info about client
$body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->insert($db->quoteName("#__messages"));
$query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid));
$query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid));
$query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql()));
$query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")"));
$query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body)));
$db->setQuery((string) $query);
if (!$db->query()) {
//JLog::add($msg, JLog::ERROR, get_class($this));
$this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), FoxMessageBoard::error);
// Database problems. Return error.
return false;
}
//JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this));
return true;
}
示例4: validate_email_list
static function validate_email_list(&$email_list, $allow_blank = true)
{
$email_list = str_replace(' ', '', $email_list);
// remove spaces
$email_list = trim($email_list, ',');
// trim off any spare commas
if ($email_list == '') {
if ($allow_blank) {
$ret = '';
return $ret;
} else {
$ret = JText::_('COM_FLEXICONTACT_REQUIRED');
return $ret;
}
}
$email_list = strtolower($email_list);
// make all lower case for array_unique() call
$email_addresses = explode(',', $email_list);
// make it an array
$email_addresses = array_unique($email_addresses);
// remove any duplicates
$email_list = implode(',', $email_addresses);
// recreate the original email list to return
jimport('joomla.mail.helper');
foreach ($email_addresses as $address) {
if (!JMailHelper::isEmailAddress($address)) {
return '(' . $address . ')';
}
}
return '';
}
示例5: requestReset
/**
* Verifies the validity of a username/e-mail address
* combination and creates a token to verify the request
* was initiated by the account owner. The token is
* sent to the account owner by e-mail
*
* @since 1.5
* @param string Username string
* @param string E-mail address
* @return bool True on success/false on failure
*/
function requestReset($email)
{
jimport('joomla.mail.helper');
jimport('joomla.user.helper');
$db =& JFactory::getDBO();
// Make sure the e-mail address is valid
if (!JMailHelper::isEmailAddress($email)) {
$this->setError(JText::_('INVALID_EMAIL_ADDRESS'));
return false;
}
// Build a query to find the user
$query = 'SELECT id FROM #__users' . ' WHERE email = ' . $db->Quote($email) . ' AND block = 0';
$db->setQuery($query);
// Check the results
if (!($id = $db->loadResult())) {
$this->setError(JText::_('COULD_NOT_FIND_USER'));
return false;
}
// Generate a new token
$token = JUtility::getHash(JUserHelper::genRandomPassword());
$salt = JUserHelper::getSalt('crypt-md5');
$hashedToken = md5($token . $salt) . ':' . $salt;
$query = 'UPDATE #__users' . ' SET activation = ' . $db->Quote($hashedToken) . ' WHERE id = ' . (int) $id . ' AND block = 0';
$db->setQuery($query);
// Save the token
if (!$db->query()) {
$this->setError(JText::_('DATABASE_ERROR'));
return false;
}
// Send the token to the user via e-mail
if (!$this->_sendConfirmationMail($email, $token)) {
return false;
}
return true;
}
示例6: validateUser
public function validateUser()
{
try {
$email = JRequest::getVar('email', '', 'post', 'string');
if (!JMailHelper::isEmailAddress($email)) {
throw new Exception(JText::_('COM_AAWS_EMAIL_BAD_FORMAT'));
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Se valida unicamente mediante el correo, y se retorna el nombre de usuario para hacer el login
$query->select('id, name, username')->from('#__users')->where('email = ' . $db->Quote($email));
$db->setQuery($query);
$result = $db->loadObject();
if ($result != null && $result->id != 0) {
$answer = array('message' => JText::sprintf('COM_AAWS_USER_IDENTIFIED', $result->name), 'username' => $result->username, 'type' => 'info');
} else {
$answer = array('message' => '', 'type' => 'info');
}
echo json_encode($answer);
} catch (Exception $e) {
echo json_encode(array('message' => $e->getMessage(), 'type' => 'error'));
}
$app = JFactory::getApplication();
$app->close();
}
示例7: remindUsername
/**
* Takes a user supplied e-mail address, looks
* it up in the database to find the username
* and then e-mails the username to the e-mail
* address given.
*
* @since 1.5
* @param string E-mail address
* @return bool True on success/false on failure
*/
function remindUsername($email)
{
jimport('joomla.mail.helper');
global $mainframe;
// Validate the e-mail address
if (!JMailHelper::isEmailAddress($email)) {
$message = JText::_('INVALID_EMAIL_ADDRESS');
$this->setError($message);
UserHelper::showMessage(ERROR, $message);
return false;
}
$db =& JFactory::getDBO();
$db->setQuery('SELECT username FROM #__users WHERE email = ' . $db->Quote($email), 0, 1);
// Get the username
if (!($username = $db->loadResult())) {
$message = JText::_('COULD_NOT_FIND_EMAIL');
$this->setError($message);
UserHelper::showMessage(ERROR, $message);
return false;
}
// Push the email address into the session
$mainframe->setUserState($this->_namespace . 'email', $email);
// Send the reminder email
if (!$this->_sendReminderMail($email, $username)) {
return false;
}
return true;
}
示例8: Process
public function Process()
{
$mail = JFactory::getMailer();
$this->set_from($mail);
$this->set_to($mail, "to_address", "addRecipient");
$this->set_to($mail, "cc_address", "addCC");
$this->set_to($mail, "bcc_address", "addBCC");
$mail->setSubject($this->subject());
$body = $this->body();
$body .= $this->attachments($mail);
$body .= PHP_EOL;
// Info about url
$body .= JFactory::getConfig()->get("sitename") . " - " . $this->CurrentURL() . PHP_EOL;
// Info about client
$body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL;
$body = JMailHelper::cleanBody($body);
$mail->setBody($body);
$sent = $this->send($mail);
if ($sent) {
// Notify email send success
$this->MessageBoard->Add($this->Params->get("email_sent_text"), FoxMessageBoard::success);
$this->Logger->Write("Notification email sent.");
}
return $sent;
}
示例9: Process
public function Process()
{
$uid = $this->Params->get("jmessenger_user", NULL);
// No user selected for Joomla messenger
if (!$uid) {
//JLog::add("No recipient selected in Joomla Messenger dispatcher. Private message was not send.", JLog::INFO, get_class($this));
// It's not a problem. Maybe it's even wanted. Return succesful.
return true;
}
$body = $this->body();
$body .= $this->attachments();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->insert("#__messages");
$query->columns(array($db->quoteName('user_id_from'), $db->quoteName('user_id_to'), $db->quoteName('date_time'), $db->quoteName('subject'), $db->quoteName('message')));
$query->values($uid . ", " . $uid . ", " . $db->Quote(JFactory::getDate()->toSql()) . ", " . $db->Quote($this->submittername() . " (" . $this->submitteraddress() . ")") . ', ' . $db->Quote(JMailHelper::cleanBody($body)));
$db->setQuery((string) $query);
if (!$db->query()) {
$msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE");
//JLog::add($msg, JLog::ERROR, get_class($this));
$this->Messages[] = $msg;
// Database problems. Return error.
return false;
}
//JLog::add("Private message sent to Joomla messenger.", JLog::INFO, get_class($this));
return true;
}
示例10: changeEmail
function changeEmail()
{
// Initialise the App variables
$app = JFactory::getApplication();
if ($app->isAdmin()) {
$json = array();
$model = $this->getThisModel();
// Assign the get Id to the Variable
$email_id = $app->input->getString('email');
$new_email = $app->input->getString('new_email');
if (empty($new_email) && !JMailHelper::isEmailAddress($new_email)) {
$json = array('msg' => JText::_('Invalid Email Address'), 'msgType' => 'warning');
} else {
//incase an account already exists ?
if ($app->input->getString('task') == 'changeEmail') {
$json = array('msg' => JText::_('J2STORE_EMAIL_UPDATE_NO_WARNING'), 'msgType' => 'message');
$json = $this->validateEmailexists($new_email);
} elseif ($app->input->getString('task') == 'confirmchangeEmail') {
$json = array('redirect' => JUri::base() . 'index.php?option=com_j2store&view=customer&task=viewOrder&email_id=' . $new_email, 'msg' => JText::_('J2STORE_SUCCESS_SAVING_EMAIL'), 'msgType' => 'message');
if (!$model->savenewEmail()) {
$json = array('msg' => JText::_('J2STORE_ERROR_SAVING_EMAIL'), 'msgType' => 'warning');
}
}
}
echo json_encode($json);
$app->close();
}
}
示例11: Process
public function Process()
{
$uid = $this->Params->get("jmessenger_user", NULL);
if (!$uid) {
return true;
}
$body = $this->body();
$body .= $this->attachments();
$body .= PHP_EOL;
$body .= $this->Application->getCfg("sitename") . " - " . $this->CurrentURL() . PHP_EOL;
$body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL;
$body = nl2br($body);
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->insert($db->quoteName("#__messages"));
$query->set($db->quoteName("user_id_from") . "=" . $db->quote($uid));
$query->set($db->quoteName("user_id_to") . "=" . $db->quote($uid));
$query->set($db->quoteName("date_time") . "=" . $db->quote(JFactory::getDate()->toSql()));
$query->set($db->quoteName("subject") . "=" . $db->quote($this->submittername() . " (" . $this->submitteraddress() . ")"));
$query->set($db->quoteName("message") . "=" . $db->quote(JMailHelper::cleanBody($body)));
$db->setQuery((string) $query);
if (!$db->query()) {
$this->MessageBoard->Add(JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MESSAGE"), B2JMessageBoard::error);
return false;
}
return true;
}
示例12: sendNotificationOnUpdateRank
private function sendNotificationOnUpdateRank($userinfo, $result)
{
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
$lang->load('com_alphauserpoints', JPATH_SITE);
jimport('joomla.mail.helper');
require_once JPATH_ROOT . '/components/com_alphauserpoints/helper.php';
// get params definitions
$params = JComponentHelper::getParams('com_alphauserpoints');
$jsNotification = $params->get('jsNotification', 0);
$jsNotificationAdmin = $params->get('fromIdUddeim', 0);
$SiteName = $app->getCfg('sitename');
$MailFrom = $app->getCfg('mailfrom');
$FromName = $app->getCfg('fromname');
$sef = $app->getCfg('sef');
$email = $userinfo->email;
$subject = $result->emailsubject;
$body = $result->emailbody;
$formatMail = $result->emailformat;
$bcc2admin = $result->bcc2admin;
$subject = str_replace('{username}', $userinfo->username, $subject);
$subject = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $subject);
$body = str_replace('{username}', $userinfo->username, $body);
$body = str_replace('{points}', AlphaUserPointsHelper::getFPoints($userinfo->points), $body);
$subject = JMailHelper::cleanSubject($subject);
if (!$jsNotification) {
$mailer = JFactory::getMailer();
$mailer->setSender(array($MailFrom, $FromName));
$mailer->setSubject($subject);
$mailer->isHTML((bool) $formatMail);
$mailer->CharSet = "utf-8";
$mailer->setBody($body);
$mailer->addRecipient($email);
if ($bcc2admin) {
// get all users allowed to receive e-mail system
$query = "SELECT email" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
$db->setQuery($query);
$rowsAdmins = $db->loadObjectList();
foreach ($rowsAdmins as $rowsAdmin) {
$mailer->addBCC($rowsAdmin->email);
}
}
$send = $mailer->Send();
} else {
require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
$params = new CParameter('');
CNotificationLibrary::add('system_messaging', $jsNotificationAdmin, $userinfo->id, $subject, $body, '', $params);
if ($bcc2admin) {
// get all users allowed to receive e-mail system
$query = "SELECT id" . " FROM #__users" . " WHERE sendEmail='1' AND block='0'";
$db->setQuery($query);
$rowsAdmins = $db->loadObjectList();
foreach ($rowsAdmins as $rowsAdmin) {
$mailer->addBCC($rowsAdmin->id);
CNotificationLibrary::add('system_messaging', $userinfo->id, $rowsAdmin->id, $subject, $body, '', $params);
}
}
}
}
示例13: validemail
function validemail($emailid)
{
if (!JMailHelper::isEmailAddress($emailid)) {
return false;
} else {
return true;
}
}
示例14: display
/**
* Display the view
*
* @return mixed False on error, null otherwise.
*/
function display($tpl = null)
{
$comName = JRequest::getCmd('option');
$document =& JFactory::getDocument();
$app = JFactory::getApplication();
$params = $app->getParams();
//Check whether category access level allows access.
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
//Load resources
$document->addStyleSheet($this->baseurl . "/media/{$comName}/css/styles.css");
//Get some data from the models
$state = $this->get('State');
$items = $this->get('Items');
$category = $this->get('Category');
$children = $this->get('Children');
$parent = $this->get('Parent');
$pagination = $this->get('Pagination');
//Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
//Prepare the data
//Compute the contact slug
for ($i = 0, $n = count($items); $i < $n; $i++) {
$item =& $items[$i];
$item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
$temp = new JRegistry();
$temp->loadJSON($item->params);
$item->params = clone $params;
$item->params->merge($temp);
if ($item->params->get('show_email', 0) == 1) {
$item->email_to = trim($item->email_to);
if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) {
$item->email_to = JHtml::_('email.cloak', $item->email_to);
} else {
$item->email_to = '';
}
}
}
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$maxLevel = $params->get('maxLevel', -1);
$this->assignRef('maxLevel', $maxLevel);
$this->assignRef('state', $state);
$this->assignRef('items', $items);
$this->assignRef('category', $category);
$this->assignRef('children', $children);
$this->assignRef('params', $params);
$this->assignRef('parent', $parent);
$this->assignRef('pagination', $pagination);
//define some few document params
$this->_prepareDocument();
//Display the view
parent::display($tpl);
}
示例15: submitteraddress
protected function submitteraddress()
{
// Bug: http://www.fox.ra.it/forum/3-bugs/2399-error-when-email-is-optional-and-field-is-left-empty.html
// $from = isset($this->FieldsBuilder->Fields['sender1']['Value']) ? $this->FieldsBuilder->Fields['sender1']['Value'] : $this->Application->getCfg("mailfrom");
// If submitter address is present and not empty, we can use it
// otherwise system global address will be used
$addr = isset($this->FieldsBuilder->Fields['sender1']['Value']) && !empty($this->FieldsBuilder->Fields['sender1']['Value']) ? $this->FieldsBuilder->Fields['sender1']['Value'] : $this->Application->getCfg("mailfrom");
return JMailHelper::cleanAddress($addr);
}