本文整理汇总了PHP中FD::mailer方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::mailer方法的具体用法?PHP FD::mailer怎么用?PHP FD::mailer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::mailer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchEmails
/**
* Dispatches Pending Emails
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function dispatchEmails()
{
$config = FD::config();
// Dispatch mails here.
$mailer = FD::mailer();
$state = $mailer->cron($config->get('general.cron.limit'));
if ($state) {
return JText::_('COM_EASYSOCIAL_CRONJOB_PROCESSED');
}
return JText::_('COM_EASYSOCIAL_CRONJOB_NOTHING_TO_EXECUTE');
}
示例2: preview
/**
* Previews an email
*
* @since 1.0
* @access public
*/
public function preview()
{
$ajax = FD::ajax();
// Get the id.
$id = JRequest::getInt('id');
$mailer = FD::table('Mailer');
$mailer->load($id);
$mailer->loadLanguage();
$lib = FD::mailer();
$mailer->title = $lib->translate($mailer->title, $mailer->params);
$theme = FD::themes();
$theme->set('mailer', $mailer);
$contents = $theme->output('admin/mailer/preview');
return $ajax->resolve($contents);
}
示例3: display
/**
* Default user listings page.
*
* @since 1.0
* @access public
* @param null
* @return null
*/
public function display($tpl = null)
{
// Set page heading
$this->setHeading(JText::_('COM_EASYSOCIAL_HEADING_EMAIL_ACTIVITIES'));
// Set page icon
$this->setIcon('icon-jar jar-email_envelope');
// Set page description
$this->setDescription(JText::_('COM_EASYSOCIAL_DESCRIPTION_EMAIL_ACTIVITIES'));
// Add buttons
JToolbarHelper::publishList('publish', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_MARK_SENT'));
JToolbarHelper::unpublishList('unpublish', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_MARK_PENDING'));
JToolbarHelper::divider();
JToolbarHelper::trash('purgeSent', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PURGE_SENT'), false);
JToolbarHelper::trash('purgePending', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PURGE_PENDING'), false);
JToolbarHelper::trash('purgeAll', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PURGE_ALL'), false);
// Get the model
$model = FD::model('Mailer', array('initState' => true));
// Load site's language file
FD::language()->loadSite();
$emails = $model->getItemsWithState();
$pagination = $model->getPagination();
$state = $model->getState('published');
$limit = $model->getState('limit');
$search = $model->getState('search');
$ordering = $model->getState('ordering');
$direction = $model->getState('direction');
if ($state != 'all') {
$state = (int) $state;
}
$lib = FD::mailer();
// Need to do some processing on the emails
foreach ($emails as $mail) {
// Load necessary language required by the mail
$mail->loadLanguage();
// Translate the title with necessary parameters
$mail->title = $lib->translate($mail->title, $mail->params);
}
$this->set('ordering', $ordering);
$this->set('direction', $direction);
$this->set('search', $search);
$this->set('limit', $limit);
$this->set('published', $state);
$this->set('emails', $emails);
$this->set('pagination', $pagination);
echo parent::display('admin/mailer/default');
}
示例4: delete
/**
* Allows user to delete their own account
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function delete()
{
// Check for request forgeries
FD::checkToken();
// Get current view
$view = $this->getCurrentView();
// Get the current logged in user.
$my = FD::user();
// Determine if the user is really allowed
if (!$my->deleteable()) {
$view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_NOT_ALLOWED_TO_DELETE'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
$config = FD::config();
// Determine if we should immediately delete the user
if ($config->get('users.deleteLogic') == 'delete') {
$mailTemplate = 'deleted.removed';
// Delete the user.
$my->delete();
}
if ($config->get('users.deleteLogic') == 'unpublish') {
$mailTemplate = 'deleted.blocked';
// Block the user
$my->block();
}
// Send notification to admin
// Push arguments to template variables so users can use these arguments
$params = array('name' => $my->getName(), 'avatar' => $my->getAvatar(SOCIAL_AVATAR_MEDIUM), 'profileLink' => JURI::root() . 'administrator/index.php?option=com_easysocial&view=users&layout=form&id=' . $my->id, 'date' => FD::date()->format(JText::_('COM_EASYSOCIAL_DATE_DMY')), 'totalFriends' => $my->getTotalFriends(), 'totalFollowers' => $my->getTotalFollowers());
$title = JText::sprintf('COM_EASYSOCIAL_EMAILS_USER_DELETED_ACCOUNT_TITLE', $my->getName());
// Get a list of super admins on the site.
$usersModel = FD::model('Users');
$admins = $usersModel->getSiteAdmins();
if ($admins) {
foreach ($admins as $admin) {
$params['adminName'] = $admin->getName();
$mailer = FD::mailer();
$template = $mailer->getTemplate();
$template->setRecipient($admin->getName(), $admin->email);
$template->setTitle($title);
$template->setTemplate('site/profile/' . $mailTemplate, $params);
$template->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email to the admin now.
$state = $mailer->create($template);
}
}
// Log the user out from the system
$my->logout();
return $view->call(__FUNCTION__);
}
示例5: notify
/**
* Processes email notifications
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function notify()
{
// Set all properties from this table into the mail template
$params = FD::makeArray($this);
//remove this _tbl_keys
unset($params['_tbl_keys']);
// Additional parameters.
$user = FD::user($this->created_by);
$params['reporter'] = $user->getName();
$params['reporterLink'] = $user->getPermalink(true, true);
$params['item'] = $this->title;
// Get a list of super admins on the site.
$usersModel = FD::model('Users');
// We need to merge admin and custom emails
$admins = $usersModel->getSiteAdmins();
$config = FD::config();
$custom = $config->get('reports.notifications.emails', '');
$recipients = array();
foreach ($admins as $user) {
$recipients[] = $user->email;
}
if (!empty($custom)) {
foreach ($custom as $email) {
$recipients[] = $email;
}
}
// Ensure for uniqueness here.
$recipients = array_unique($recipients);
// Get mailer object
$mailer = FD::mailer();
$templates = array();
foreach ($recipients as $recipient) {
// Get boilerplate
$template = $mailer->getTemplate();
// Set recipient
$template->setRecipient('', $recipient);
// Set title of email
$template->setTitle('COM_EASYSOCIAL_EMAILS_NEW_REPORT_SUBJECT');
// Set template file.
$template->setTemplate('site/reports/moderator', $params);
$mailer->create($template);
}
}
示例6: notifyAdminsModeration
/**
* Notify site admins that a group is created and it is pending moderation.
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function notifyAdminsModeration(SocialGroup $group)
{
// Push arguments to template variables so users can use these arguments
$params = array('title' => $group->getName(), 'creatorName' => $group->getCreator()->getName(), 'categoryTitle' => $group->getCategory()->get('title'), 'avatar' => $group->getAvatar(SOCIAL_AVATAR_LARGE), 'permalink' => JURI::root() . 'administrator/index.php?option=com_easysocial&view=groups&layout=pending', 'reject' => FRoute::controller('groups', array('external' => true, 'task' => 'rejectGroup', 'id' => $group->id, 'key' => $group->key)), 'approve' => FRoute::controller('groups', array('external' => true, 'task' => 'approveGroup', 'id' => $group->id, 'key' => $group->key)), 'alerts' => false);
// Set the e-mail title
$title = JText::sprintf('COM_EASYSOCIAL_EMAILS_GROUP_CREATED_MODERATOR_EMAIL_TITLE', $group->getName());
// Get a list of super admins on the site.
$usersModel = FD::model('Users');
$admins = $usersModel->getSiteAdmins();
foreach ($admins as $admin) {
// Ensure that the user is a site admin or the Receive System email is turned off
if (!$admin->isSiteAdmin() || !$admin->sendEmail) {
continue;
}
// Immediately send out emails
$mailer = FD::mailer();
// Set the admin's name.
$params['adminName'] = $admin->getName();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($admin->getName(), $admin->email);
// Set title
$mailTemplate->setTitle($title);
// Set the template
$mailTemplate->setTemplate('site/group/moderate', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email to the admin now.
$state = $mailer->create($mailTemplate);
}
return true;
}
示例7: reject
/**
* Rejects the event.
* @author Jason Rey <jasonrey@stackideas.com>
* @since 1.3
* @access public
* @return boolean True if successfull.
*/
public function reject()
{
$this->state = SOCIAL_CLUSTER_UNPUBLISHED;
$state = $this->save();
if (!$state) {
return false;
}
// Send email.
FD::language()->loadSite();
$params = array('title' => $this->getName(), 'name' => $this->getCreator()->getName());
$title = JText::sprintf('COM_EASYSOCIAL_EMAILS_EVENT_REJECT', $this->getName());
$mailer = FD::mailer();
$tpl = $mailer->getTemplate();
$recipient = $this->getCreator();
$tpl->setRecipient($recipient->getName(), $recipient->email);
$tpl->setTitle($title);
$tpl->setTemplate('site/event/reject', $params);
$tpl->setPriority(SOCIAL_MAILER_PRIORITy_IMMEDIATE);
$mailer->create($tpl);
return true;
}
示例8: sendLink
public function sendLink($recipients, $token, $content = '')
{
$my = FD::user();
$mailer = FD::mailer();
$mail = $mailer->getTemplate();
$subject = JText::sprintf('COM_EASYSOCIAL_SHARING_EMAIL_TITLE', $my->getName());
$url = base64_decode($token);
// Set the subject
$mail->setTitle($subject);
// Set the mail template
$options = array('url' => $url, 'content' => $content, 'senderName' => $my->getName(), 'sender' => $my->email);
$mail->setTemplate('site/sharing/link', $options);
foreach ($recipients as $recipient) {
$mail->setRecipient('', $recipient);
$mailer->create($mail);
}
return true;
}
示例9: reject
/**
* Reject's a user's registration application
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function reject($reason = '', $sendEmail = true, $deleteUser = false)
{
// Announce to the world when a new user registered on the site.
$config = FD::config();
// If we need to send email to the user, we need to process this here.
if ($sendEmail) {
// Get the application data.
$jConfig = FD::jConfig();
// Get the current profile this user has registered on.
$profile = $this->getProfile();
// Push arguments to template variables so users can use these arguments
$params = array('site' => $jConfig->getValue('sitename'), 'username' => $this->username, 'name' => $this->getName(), 'email' => $this->email, 'reason' => $reason, 'profileType' => $profile->get('title'), 'manageAlerts' => false);
JFactory::getLanguage()->load('com_easysocial', JPATH_ROOT);
// Get the email title.
$title = JText::_('COM_EASYSOCIAL_EMAILS_REGISTRATION_REJECTED_EMAIL_TITLE');
// Immediately send out emails
$mailer = FD::mailer();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($this->getName(), $this->email);
// Set title
$mailTemplate->setTitle($title);
// Set the contents
$mailTemplate->setTemplate('site/registration/rejected', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email now.
$mailer->create($mailTemplate);
}
// If required, delete the user from the site.
if ($deleteUser) {
$this->delete();
}
return true;
}
示例10: store
/**
* Overrides the parent's implementation of store
*
* @since 1.3
* @access public
* @param string
* @return
*/
public function store($pk = null)
{
$isNew = !$this->id;
// Save this into the table first
parent::store($pk);
// Add this into the mail queue
if ($isNew) {
$jconfig = FD::jconfig();
$mailer = FD::mailer();
$template = $mailer->getTemplate();
$sender = FD::user($this->user_id);
$params = new stdClass();
$params->senderName = $sender->getName();
$params->message = $this->message;
$params->siteName = $jconfig->getValue('sitename');
$params->manageAlerts = false;
$params->link = FRoute::registration(array('invite' => $this->id, 'external' => true));
$template->setSender($sender->getName(), $sender->email);
$template->setReplyTo($sender->email);
$template->setRecipient('', $this->email);
$template->setTitle(JText::sprintf('COM_EASYSOCIAL_FRIENDS_INVITE_MAIL_SUBJECT', $jconfig->getValue('sitename')));
$template->setTemplate('site/friends/invite', $params);
$mailer->create($template);
// Assign points to the user that created this invite
$points = FD::points();
$points->assign('friends.invite', 'com_easysocial', $this->user_id);
}
}
示例11: resendActivation
/**
* Resends activation emails to the user.
*
* @since 1.0
* @access public
* @param SocialUser The user object.
* @param SocialTableProfile The profile type.
* @return bool True if success, false otherwise.
* @author Mark Lee <mark@stackideas.com>
*/
public function resendActivation(SocialUser $user)
{
// Get the application data.
$jConfig = FD::jConfig();
$config = FD::config();
// Push arguments to template variables so users can use these arguments
$params = array('site' => $jConfig->getValue('sitename'), 'username' => $user->username, 'password' => $user->password_clear, 'name' => $user->getName(), 'id' => $user->id, 'avatar' => $user->getAvatar(SOCIAL_AVATAR_LARGE), 'profileLink' => $user->getPermalink(true, true), 'email' => $user->email, 'activation' => FRoute::registration(array('external' => true, 'task' => 'activate', 'controller' => 'registration', 'token' => $user->activation)), 'token' => $user->activation, 'manageAlerts' => false);
// Get the email title.
$title = JText::_('COM_EASYSOCIAL_REGISTRATION_ACTIVATION_REMINDER');
// Immediately send out emails
$mailer = FD::mailer();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($user->name, $user->email);
// Set title
$mailTemplate->setTitle($title);
// Set the contents
$mailTemplate->setTemplate('site/registration/reactivate', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email now.
$state = $mailer->create($mailTemplate);
return $state;
}
示例12: sendEmail
/**
* Apps email title (assuming that app itself have already loaded the language file before calling this function)
* APP_{ELEMENT}_{RULENAME}_EMAIL_TITLE
*
* Apps email template namespace
* apps/{group}/{element}/alerts.{rulename}
*
* Apps email template path
* apps/{group}/{element}/themes/{default/themeName}/emails/{html/text}/alerts.{rulename}
*
* Core email title
* COM_EASYSOCIAL_{ELEMENT}_{RULENAME}_EMAIL_TITLE
*
* Core email template namespace
* site/{element}/alerts.{rulename}
*
* Core email template path
* site/themes/{wireframe/themeName}/emails/{html/text}/{element}/alert.{rulename}
*
* @since 1.0
* @access public
* @param array $participants The array of participants (user id) of the action
* @param array $options Custom options of the email notification
*
* @return boolean State of the email notification
*
* @author Jason Rey <jasonrey@stackideas.com>
*/
public function sendEmail($participants, $options = array())
{
$users = $this->getUsers('email', $participants);
if (empty($users)) {
return true;
}
if (is_object($options)) {
$options = FD::makeArray($options);
}
// If params is not set, just give it an empty array
if (!isset($options['params'])) {
$options['params'] = array();
} else {
// If params is already set, it is possible that it might be object or registry object
$options['params'] = FD::makeArray($options['params']);
}
// Assign any non-table key into params automatically
$columns = FD::db()->getTableColumns('#__social_mailer');
foreach ($options as $key => $val) {
if (!in_array($key, $columns)) {
$options['params'][$key] = $val;
}
}
// Set default title if no title is passed in
if (!isset($options['title'])) {
$options['title'] = $this->getNotificationTitle('email');
}
// Set default template if no template is passed in
if (!isset($options['template'])) {
$options['template'] = $this->getMailTemplateName();
}
if (!isset($options['html'])) {
$options['html'] = 1;
}
$mailer = FD::mailer();
$data = new SocialMailerData();
$data->set('title', $options['title']);
$data->set('template', $options['template']);
$data->set('html', $options['html']);
if (isset($options['params'])) {
$data->setParams($options['params']);
}
// If priority is set, set the priority
if (isset($options['priority'])) {
$data->set('priority', $options['priority']);
}
if (isset($options['sender_name'])) {
$data->set('sender_name', $options['sender_name']);
}
if (isset($options['sender_email'])) {
$data->set('sender_email', $options['sender_email']);
}
if (isset($options['replyto_email'])) {
$data->set('replyto_email', $options['replyto_email']);
}
// The caller might be passing in 'params' as a SocialRegistry object. Just need to standardize them here.
// Ensure that the params if set is a valid array
if (isset($options['params']) && is_object($options['params'])) {
$options['params'] = FD::makeArray($options['params']);
}
// Init a few default widely used parameter
$user = FD::user();
if (!isset($options['params']['actor'])) {
$options['params']['actor'] = $user->getName();
}
if (!isset($options['params']['posterName'])) {
$options['params']['posterName'] = $user->getName();
}
if (!isset($options['params']['posterAvatar'])) {
$options['params']['posterAvatar'] = $user->getAvatar();
}
if (!isset($options['params']['posterLink'])) {
//.........这里部分代码省略.........
示例13: reject
/**
* Rejects the group
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function reject($reason = '', $email = false, $delete = false)
{
// Announce to the world when a new user registered on the site.
$config = FD::config();
// If we need to send email to the user, we need to process this here.
if ($email) {
// Push arguments to template variables so users can use these arguments
$params = array('title' => $this->getName(), 'name' => $this->getCreator()->getName(), 'reason' => $reason, 'manageAlerts' => false);
// Load front end language file.
FD::language()->loadSite();
// Get the email title.
$title = JText::_('COM_EASYSOCIAL_EMAILS_GROUP_REJECTED_EMAIL_TITLE');
// Immediately send out emails
$mailer = FD::mailer();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($this->getCreator()->getName(), $this->getCreator()->email);
// Set title
$mailTemplate->setTitle($title);
// Set the contents
$mailTemplate->setTemplate('site/group/rejected', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email now.
$mailer->create($mailTemplate);
}
// If required, delete the user from the site.
if ($delete) {
$this->delete();
}
return true;
}
示例14: notifyAdmins
/**
* Notifies administrator when a new event is created.
*
* @since 1.3
* @access public
* @param string
* @return
*/
public function notifyAdmins($event)
{
$params = array('title' => $event->getName(), 'creatorName' => $event->getCreator()->getName(), 'creatorLink' => $event->getCreator()->getPermalink(false, true), 'categoryTitle' => $event->getCategory()->get('title'), 'avatar' => $event->getAvatar(SOCIAL_AVATAR_LARGE), 'permalink' => $event->getPermalink(true, true), 'alerts' => false);
$title = JText::sprintf('COM_EASYSOCIAL_EMAILS_MODERATE_EVENT_CREATED_TITLE', $event->getName());
$template = 'site/event/created';
if ($event->state === SOCIAL_CLUSTER_PENDING) {
$params['reject'] = FRoute::controller('events', array('external' => true, 'task' => 'rejectEvent', 'id' => $event->id, 'key' => $event->key));
$params['approve'] = FRoute::controller('events', array('external' => true, 'task' => 'approveEvent', 'id' => $event->id, 'key' => $event->key));
$template = 'site/event/moderate';
}
$admins = FD::model('Users')->getSiteAdmins();
foreach ($admins as $admin) {
if (!$admin->sendEmail) {
continue;
}
$mailer = FD::mailer();
$params['adminName'] = $admin->getName();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($admin->getName(), $admin->email);
// Set title
$mailTemplate->setTitle($title);
// Set the template
$mailTemplate->setTemplate($template, $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email to the admin now.
$state = $mailer->create($mailTemplate);
}
}
示例15: remindUsername
/**
* Remind username
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function remindUsername($email)
{
// Load backend language file.
FD::language()->loadAdmin();
$db = FD::db();
$sql = $db->sql();
// Check if such email exists
$sql->select('#__users');
$sql->where('email', $email);
$db->setQuery($sql);
$row = $db->loadObject();
if (!$row) {
$this->setError(JText::_('COM_EASYSOCIAL_USERS_NO_SUCH_USER_WITH_EMAIL'));
return false;
}
// Ensure that the user is not blocked
if ($row->block) {
$this->setError(JText::_('COM_EASYSOCIAL_USERS_USER_BLOCKED'));
return false;
}
$user = FD::user($row->id);
// Get the application data.
$jConfig = FD::jConfig();
// Push arguments to template variables so users can use these arguments
$params = array('site' => $jConfig->getValue('sitename'), 'username' => $row->username, 'name' => $user->getName(), 'id' => $user->id, 'avatar' => $user->getAvatar(SOCIAL_AVATAR_LARGE), 'profileLink' => $user->getPermalink(true, true), 'email' => $email);
// Get the email title.
$title = JText::sprintf('COM_EASYSOCIAL_EMAILS_REMIND_USERNAME_TITLE', $jConfig->getValue('sitename'));
// Immediately send out emails
$mailer = FD::mailer();
// Get the email template.
$mailTemplate = $mailer->getTemplate();
// Set recipient
$mailTemplate->setRecipient($user->name, $user->email);
// Set title
$mailTemplate->setTitle($title);
// Set the contents
$mailTemplate->setTemplate('site/user/remind.username', $params);
// Set the priority. We need it to be sent out immediately since this is user registrations.
$mailTemplate->setPriority(SOCIAL_MAILER_PRIORITY_IMMEDIATE);
// Try to send out email now.
$state = $mailer->create($mailTemplate);
return $state;
}