묻고답하기
게시글의 댓글이 달리경우 원글 작성자에게 메일로 전달 기능.
2013.03.16 08:13
제가 위의 제목 과 같은 기능을 찾다가... 어떤분의 글을 보고 그대로 해 봤습니다.
글 내용은 여기를 참조 하세요.
http://www.xpressengine.com/qna/21425129
---------------------
xe - modules - comment - comment.controller.php 열고
line 413 쯤에
$admins_emails = $module_info->admin_mail;
이것을
$admins_emails = $module_info->admin_mail.','.$obj->email_address;
이것으로 수정
그리고
게시판 설정에 가서
관리자 메일에 이메일을 하나 등록......
-------------------------
내용은 위 와 같은데요...
제 xe 버전은 : 1.5.4.2 인데. 위글에서 알려 주신 소스를 수정 하니 댓글 자체가 달리지 않습니다.
--> 이후 조치는 [게시판정보] 에만 관리자 이메일이 있었는데, [권한관리]에도 관리자 이메일을 넣습니다.
---->그러니 결과가 댓글은 달리는데, 관리자 와 원글에게도 댓글 이메일이 오질 않습니다.
이 수정전에는 [게시판정보] 에 관리자 이메일이 있어서, 관리자에게는 메일이 왔었거든요..
이제는 양쪽 모두에게 댓글 메일이 오질 않습니다.
뭐가 이상이 있는지?
/**
* Send email to module's admins after a new comment was interted successfully
* if Comments Approval System is used
* @param object $obj
* @return void
*/
function sendEmailToAdminAfterInsertComment($obj)
{
$using_validation = $this->isModuleUsingPublishValidation($obj->module_srl);
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($obj->document_srl);
$oMemberModel = &getModel("member");
if (isset($obj->member_srl) && !is_null($obj->member_srl))
{
$member_info = $oMemberModel->getMemberInfoByMemberSrl($obj->member_srl);
}
else
{
$member_info->is_admin = "N";
$member_info->nick_name = $obj->nick_name;
$member_info->user_name = $obj->user_name;
$member_info->email_address = $obj->email_address;
}
$oCommentModel = &getModel("comment");
$nr_comments_not_approved = $oCommentModel->getCommentAllCount(null,false);
$oModuleModel = &getModel("module");
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($obj->document_srl);
// If there is no problem to register comment then send an email to all admin were set in module admin panel
if($module_info->admin_mail && $member_info->is_admin != 'Y')
{
$oMail = new Mail();
$oMail->setSender($obj->email_address, $obj->email_address);
$mail_title = "[XE - ".Context::get('mid')."] A new comment was posted on document: \"".$oDocument->getTitleText()."\"";
$oMail->setTitle($mail_title);
if ($using_validation)
{
$url_approve = getFullUrl('','module','comment','act','procCommentAdminChangePublishedStatusChecked','cart[]',$obj->comment_srl,'will_publish','1','search_target','is_published','search_keyword','N');
$url_trash = getFullUrl('','module','comment','act','procCommentAdminDeleteChecked','cart[]',$obj->comment_srl,'search_target','is_trash','search_keyword','true');
$mail_content = "
A new comment on the document \"".$oDocument->getTitleText()."\" is waiting for your approval.
<br />
<br />
Author: ".$member_info->nick_name."
<br />Author e-mail: ".$member_info->email_address."
<br />Comment:
<br />\"".$obj->content."\"
<br />
<br />
Approve it: <a href=\"".$url_approve."\">".$url_approve."</a>
<br />Trash it: <a href=\"".$url_trash."\">".$url_trash."</a>
<br />Currently ".$nr_comments_not_approved." comments on \"".Context::get('mid')."\" module are waiting for approval. Please visit the moderation panel:
<br /><a href=\"".getFullUrl('','module','admin','act','dispCommentAdminList','search_target','module','search_keyword',$obj->module_srl)."\">".getFullUrl('','module','admin','act','dispCommentAdminList','search_target','module','search_keyword',$obj->module_srl)."</a>
";
$oMail->setContent($mail_content);
}
else
{
$mail_content = "
Author: ".$member_info->nick_name."
<br />Author e-mail: ".$member_info->email_address."
<br />Comment:
<br />\"".$obj->content."\"
";
$oMail->setContent($mail_content);
// get email of thread's author
$document_author_email = $oDocument->variables['email_address'];
//get admin info
$logged_info = Context::get('logged_info');
//mail to author of thread - START
if($document_author_email != $obj->email_address && $logged_info->email_address != $document_author_email) {
$oMail->setReceiptor($document_author_email, $document_author_email);
$oMail->send();
}
// mail to author of thread - STOP
}
// get all admins emails
$admins_emails = $module_info->admin_mail.','.$obj->email_address; // 수정한 내용
$target_mail = explode(',',$admins_emails);
// send email to all admins - START
for($i=0;$i<count($target_mail);$i++)
{
$email_address = trim($target_mail[$i]);
if(!$email_address) continue;
$oMail->setReceiptor($email_address, $email_address);
$oMail->send();
}
// send email to all admins - STOP
}
$comment_srl_list = array(0 => $obj->comment_srl);
// call a trigger for calling "send mail to subscribers" (for moment just for forum)
ModuleHandler::triggerCall("comment.sendEmailToAdminAfterInsertComment","after",$comment_srl_list);
/*
// send email to author - START
$oMail = new Mail();
$mail_title = "[XE - ".Context::get('mid')."] your comment on document: \"".$oDocument->getTitleText()."\" have to be approved";
$oMail->setTitle($mail_title);
//$mail_content = sprintf("From : <a href=\"%s?document_srl=%s&comment_srl=%s#comment_%d\">%s?document_srl=%s&comment_srl=%s#comment_%d</a><br/>\r\n%s ", getFullUrl(''),$comment->document_srl,$comment->comment_srl,$comment->comment_srl, getFullUrl(''),$comment->document_srl,$comment->comment_srl,$comment->comment_srl,$comment>content);
$mail_content = "
Your comment #".$obj->comment_srl." on document \"".$oDocument->getTitleText()."\" have to be approved by admin of <strong><i>". strtoupper($module_info->mid)."</i></strong> module before to be publish.
<br />
<br />Comment content:
".$obj->content."
<br />
";
$oMail->setContent($mail_content);
$oMail->setSender($obj->email_address, $obj->email_address);
$oMail->setReceiptor($obj->email_address, $obj->email_address);
$oMail->send();
// send email to author - START
*/
return;
}
그리고, 다른 xe 사이트는 버전이 1.4.5.7 입니다.
여기에서는
xe - modules - comment - comment.controller.php 열고 확인 하니, 코드가 완전히 다른것같아요.
이런경우는 xe - modules - comment 의 comment 폴더만 최신것으로 바꾸어도 되는지여?
아니면, xe를 업그레이드 해야 할지? 알려 주시면 고맙겠습니다.
글쎄요..
테스트를 혹시 어드민으로 하신것 아닌가요?