当前位置: 首页>>代码示例>>PHP>>正文


PHP messenger::from方法代码示例

本文整理汇总了PHP中messenger::from方法的典型用法代码示例。如果您正苦于以下问题:PHP messenger::from方法的具体用法?PHP messenger::from怎么用?PHP messenger::from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在messenger的用法示例。


在下文中一共展示了messenger::from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function notify_subscribers($digest_notify_list, $email_template = '')
 {
     // This function parses $digest_notify_list, an array of user_ids that represent users that had their digest subscriptions changed, and sends them an email
     // letting them know an action has occurred.
     global $phpbb_root_path, $phpEx, $config, $user, $db, $phpbb_log;
     $emails_sent = 0;
     if (isset($digest_notify_list) && sizeof($digest_notify_list) > 0) {
         if (!class_exists('messenger')) {
             include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
             // Used to send emails
         }
         $sql_array = array('SELECT' => 'username, user_email, user_lang, user_digest_type, user_digest_format', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $db->sql_in_set('user_id', $digest_notify_list));
         $sql = $db->sql_build_query('SELECT', $sql_array);
         $result = $db->sql_query($sql);
         $rowset = $db->sql_fetchrowset($result);
         foreach ($rowset as $row) {
             // E-mail setup
             $messenger = new \messenger();
             switch ($email_template) {
                 case 'digests_subscription_edited':
                     $digest_notify_template = $email_template;
                     $digest_email_subject = $user->lang('DIGESTS_SUBSCRIBE_EDITED');
                     break;
                 default:
                     // Mass subscribe/unsubscribe
                     $digest_notify_template = $config['phpbbservices_digests_subscribe_all'] ? 'digests_subscribe' : 'digests_unsubscribe';
                     $digest_email_subject = $config['phpbbservices_digests_subscribe_all'] ? $user->lang('DIGESTS_SUBSCRIBE_SUBJECT') : $user->lang('DIGESTS_UNSUBSCRIBE_SUBJECT');
                     break;
             }
             // Set up associations between digest types as constants and their language equivalents
             switch ($row['user_digest_type']) {
                 case constants::DIGESTS_DAILY_VALUE:
                     $digest_type_text = strtolower($user->lang('DIGESTS_DAILY'));
                     break;
                 case constants::DIGESTS_WEEKLY_VALUE:
                     $digest_type_text = strtolower($user->lang('DIGESTS_WEEKLY'));
                     break;
                 case constants::DIGESTS_MONTHLY_VALUE:
                     $digest_type_text = strtolower($user->lang('DIGESTS_MONTHLY'));
                     break;
                 case constants::DIGESTS_NONE_VALUE:
                     $digest_type_text = strtolower($user->lang('DIGESTS_NONE'));
                     break;
                 default:
                     $digest_type_text = strtolower($user->lang('DIGESTS_DAILY'));
                     break;
             }
             // Set up associations between digest formats as constants and their language equivalents
             switch ($row['user_digest_format']) {
                 case constants::DIGESTS_HTML_VALUE:
                     $digest_format_text = $user->lang('DIGESTS_FORMAT_HTML');
                     break;
                 case constants::DIGESTS_HTML_CLASSIC_VALUE:
                     $digest_format_text = $user->lang('DIGESTS_FORMAT_HTML_CLASSIC');
                     break;
                 case constants::DIGESTS_PLAIN_VALUE:
                     $digest_format_text = $user->lang('DIGESTS_FORMAT_PLAIN');
                     break;
                 case constants::DIGESTS_PLAIN_CLASSIC_VALUE:
                     $digest_format_text = $user->lang('DIGESTS_FORMAT_PLAIN_CLASSIC');
                     break;
                 case constants::DIGESTS_TEXT_VALUE:
                     $digest_format_text = strtolower($user->lang('DIGESTS_FORMAT_TEXT'));
                     break;
                 default:
                     $digest_format_text = $user->lang('DIGESTS_FORMAT_HTML');
                     break;
             }
             $messenger->template('@phpbbservices_digests/' . $digest_notify_template, $row['user_lang']);
             $messenger->to($row['user_email']);
             $from_addr = $config['phpbbservices_digests_from_email_address'] == '' ? $config['board_email'] : $config['phpbbservices_digests_from_email_address'];
             $from_name = $config['phpbbservices_digests_from_email_name'] == '' ? $config['board_contact'] : $config['phpbbservices_digests_from_email_name'];
             // SMTP delivery must strip text names due to likely bug in messenger class
             if ($config['smtp_delivery']) {
                 $messenger->from($from_addr);
             } else {
                 $messenger->from($from_addr . ' <' . $from_name . '>');
             }
             $messenger->replyto($from_addr);
             $messenger->subject($digest_email_subject);
             $messenger->assign_vars(array('DIGESTS_FORMAT' => $digest_format_text, 'DIGESTS_TYPE' => $digest_type_text, 'DIGESTS_UCP_LINK' => generate_board_url() . '/' . 'ucp.' . $phpEx, 'FORUM_NAME' => $config['sitename'], 'USERNAME' => $row['username']));
             $mail_sent = $messenger->send(NOTIFY_EMAIL, false);
             if (!$mail_sent) {
                 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_DIGESTS_NOTIFICATION_ERROR', false, array($row['user_email']));
             } else {
                 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_DIGESTS_NOTIFICATION_SENT', false, array($row['user_email'], $row['username']));
                 $emails_sent++;
             }
             $messenger->reset();
         }
         $db->sql_freeresult($result);
         // Query be gone!
     }
     return $emails_sent;
 }
开发者ID:MarkDHamill,项目名称:digests,代码行数:95,代码来源:main_module.php


注:本文中的messenger::from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。