[外掛] 寄發 新文章通知 給 已加入的群組成員 v1.2

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
GaryFu
星球公民
星球公民
文章: 41
註冊時間: 2002-06-19 09:54
聯繫:

[外掛] 寄發 新文章通知 給 已加入的群組成員 v1.2

文章 GaryFu »

>>下載此說明檔

修改email寄發方式 (改成使用phpBB內發送email方式)

[php]<?
#################################################################
## Mod Title: GroupNewTopicEmail
## Mod Author: GaryFu <gary@garyfu.idv.tw> http://garyfu.idv.tw
## Mod Version: 1.2
## Mod Description:
## 在發表新文章時,標題下方新增參與群組的下拉式選單\r
## 選擇任一群組,則會寄發新文章通知給該群組成員
##
## v1.1 修改email部份
## v1.2 修改執行後無反應bug(reGroup變數接收問題)
##
## Installation Level: Easy
## Installation Time: 5 Minutes
##
## Files To Edit: 4
## posting.php
## includes/functions_post.php
## templates/subSilver/posting_body.tpl
## language/lang_chinese_traditional_taiwan/lang_main.php
## Files To Add: 1
## language/lang_chinese_traditional_taiwan/email/group_newtopic.tpl
##
#################################################################

#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);

#
#-----[ AFTER, ADD ]------------------------------------
#
include($phpbb_root_path . 'includes/emailer.'.$phpEx); //GroupNewTopicEmail by GaryFu

#
#-----[ FIND ]------------------------------------------
#
$bbcode_uid = '';

#
#-----[ AFTER, ADD ]------------------------------------
#
$reGroup = ( !empty($HTTP_POST_VARS['reGroup']) ) ? trim($HTTP_POST_VARS['reGroup']) : ''; //GroupNewTopicEmail by GaryFu

#
#-----[ FIND ]------------------------------------------
#
submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);

#
#-----[ REPLACE WITH ]------------------------------------
#
submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length,$reGroup); //GroupNewTopicEmail by GaryFu

#
#-----[ FIND ]------------------------------------------
#
$template->assign_block_vars('switch_not_privmsg', array());

#
#-----[ AFTER, ADD ]------------------------------------
#
//GroupNewTopicEmail by GaryFu start
$select_GPlist = '';
$select_JavaChk = "";
$tmpGroupID = "";

if ($userdata['user_id']!=""){
$sql = "SELECT group_id FROM " . USER_GROUP_TABLE . " WHERE user_id=".$userdata['user_id'];

if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain group list', '', __LINE__, __FILE__, $sql);
}

if ( $row = $db->sql_fetchrow($result) )
{
do
{
$tmpGroupID.=",".$row['group_id'];
}
while ( $row = $db->sql_fetchrow($result) );
}

if ($tmpGroupID!=""){
$tmpGroupID=substr($tmpGroupID,1,strlen($tmpGroupID));

$sql = "SELECT group_id, group_name
FROM " . GROUPS_TABLE . "
WHERE group_single_user <> " . TRUE . "
AND group_id in ( $tmpGroupID )
ORDER BY group_name";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain group list', '', __LINE__, __FILE__, $sql);
}

if ( $row = $db->sql_fetchrow($result) )
{
$select_GPlist .= "<select name=\"reGroup\">";
$select_GPlist .= "<option value=\"\">".$lang['Topic_Group_Send_SelectChoose']."</option>";
$select_GPlist .= "<option value=\"0\" selected>".$lang['Topic_Group_Send_SelectNo']."</option>";
do
{
$select_GPlist .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
}
while ( $row = $db->sql_fetchrow($result) );
$select_GPlist .= '</select>';
}
}
}

if ($select_GPlist!=""){
$select_GPlist = "<br><B>".$lang['Topic_Group_Send_FieldNote']." ".$select_GPlist." ".$lang['Topic_Group_Send_GroupNM']."</B>";
$select_JavaChk = " if (document.post.reGroup.value == \"\") { formErrors = \"".$lang['Topic_Group_Send_ChkNote']."\";}";
}
//GroupNewTopicEmail by GaryFu end

#
#-----[ FIND ]------------------------------------------
#
'SMILIES_STATUS' => $smilies_status,

#
#-----[ AFTER, ADD ]------------------------------------
#
'S_GROUP_SELECT' => $select_GPlist, //GroupNewTopicEmail by GaryFu
'S_GROUP_CHECK' => $select_JavaChk, //GroupNewTopicEmail by GaryFu

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_post.php

#
#-----[ FIND ]------------------------------------------
#
include($phpbb_root_path . 'includes/emailer.'.$phpEx);

#
#-----[ REPLACE WITH ]------------------------------------
#
//include($phpbb_root_path . 'includes/emailer.'.$phpEx); //GroupNewTopicEmail by GaryFu

#
#-----[ FIND ]------------------------------------------
#
$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';

#
#-----[ BEFORE, ADD ]------------------------------------
#
//GroupNewTopicEmail by GaryFu start
if ($reGroup!="0" && $reGroup!=""){
$emailer = new emailer($board_config['smtp_delivery']);

$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

$email_headers = "From: " . $board_config['board_email'] . "
Return-Path: " . $board_config['board_email'] . "
";

$topic_title=$post_subject;

$sql = "SELECT u.user_email as uemail ,g.group_name as gname FROM phpbb_users u,phpbb_groups g ,phpbb_user_group ug WHERE ug.group_id = $reGroup AND ug.user_pending =0 AND u.user_id = ug.user_id and g.group_id=ug.group_id";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) )
{
$emailer->use_template('group_newtopic', $row['user_lang']);
$emailer->email_address($row['uemail']);
$emailer->set_subject();
$emailer->extra_headers($email_headers);

$emailer->assign_vars(array(
'EMAIL_SIG' => str_replace('<br />', "
", "--
" . $board_config['board_email_sig']),
'USERNAME' => $row['gname'],
'TOPIC_TITLE' => $topic_title,

'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id"
)
);

$emailer->send();
$emailer->reset();
}
}
//GroupNewTopicEmail by GaryFu end

#
#-----[ FIND ]------------------------------------------
#
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)

#
#-----[ REPLACE WITH ]------------------------------------
#
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length ,&$reGroup) //GroupNewTopicEmail by GaryFu

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------
#
if (document.post.message.value.length < 2) {

#
#-----[ BEFORE, ADD ]------------------------------------
#
{S_GROUP_CHECK} //GroupNewTopicEmail by GaryFu

#
#-----[ FIND ]------------------------------------------
#
<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />

#
#-----[ AFTER, ADD ]------------------------------------
#
{S_GROUP_SELECT} <!--//GroupNewTopicEmail by GaryFu end -->

#
#-----[ OPEN ]------------------------------------------
#
language/lang_chinese_traditional_taiwan/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!

#
#-----[ BEFORE, ADD ]------------------------------------
#
//GroupNewTopicEmail by GaryFu star
$lang['Topic_Group_Send_FieldNote'] = "寄發文章通知給";
$lang['Topic_Group_Send_GroupNM'] = "群組";
$lang['Topic_Group_Send_SelectChoose'] = "請選擇";
$lang['Topic_Group_Send_SelectNo'] = "無";
$lang['Topic_Group_Send_ChkNote'] = "請選擇是否寄發文章通知給某群組";
//GroupNewTopicEmail by GaryFu end

#
#-----[ CREATE NEW FILE ]------------------------------------------
#
language/lang_chinese_traditional_taiwan/email/group_newtopic.tpl

#
#-----[ EDIT ]------------------------------------
#
Subject: 新文章通知 - {TOPIC_TITLE}
Charset: big5

親愛的 {USERNAME} 成員 您好,

討論區有新文章:{TOPIC_TITLE}

你可以點選以下連結瀏覽此文章:

{U_TOPIC}

{EMAIL_SIG}

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
#EoM
?>[/php]
圖檔
歡迎參觀我的網站
http://garyfu.idv.tw
主題已鎖定

回到「非官方認證外掛」