* 댓글알리미 module 추가


git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4326 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2008-06-25 23:12:36 +00:00
parent 56f7c52f7d
commit de2b57c2d2
37 changed files with 1036 additions and 0 deletions

View file

@ -0,0 +1,3 @@
2008.06.18 v0.1.3 queue에서 잘 안 빠지는 문제 수정
2008.06.18 v0.1.2 page module로 들어오는 noti가 반영이 안되는 문제 수정
2008.06.17 v0.1.1 tag strip안되는 문제 수정

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<module version="0.2" category="accessory">
<title xml:lang="ko">댓글알리미</title>
<author email_address="haneul0318@gmail.com" link="http://seungyeop.kr" date="2008. 06. 02">
<name xml:lang="ko">haneul</name>
<description xml:lang="ko">댓글알리미 모듈입니다.</description>
</author>
</module>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<module>
<grants />
<actions>
<action name="dispCommentNotifyAdminIndex" type="view" standalone="true" admin_index="true" />
<action name="procCommentNotifyAdminDeleteChild" type="controller" standalone="true" />
<action name="procCommentNotifyAdminDeleteParent" type="controller" standalone="true" />
<action name="procCommentNotifyAdminDeleteChecked" type="controller" standalone="true" />
<action name="procDoNotify" type="controller" standalone="true" />
</actions>
</module>

View file

@ -0,0 +1,5 @@
<?php
$lang->commentnotify = '댓글알리미';
$lang->msg_checked_comment_is_deleted = '%d개의 알림글이 삭제되었습니다';
$lang->cmd_delete_checked_comment = '선택삭제';
?>

View file

@ -0,0 +1,8 @@
<query id="deleteChild" action="delete">
<tables>
<table name="tcnotifiedchildren" />
</tables>
<conditions>
<condition operation="equal" column="notified_srl" var="notified_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteChild" action="delete">
<tables>
<table name="tcnotifiedchildren" />
</tables>
<conditions>
<condition operation="equal" column="parent_srl" var="parent_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteFromQueue" action="delete">
<tables>
<table name="tcnotifyqueue" />
</tables>
<conditions>
<condition operation="equal" column="comment_srl" var="comment_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteParent" action="delete">
<tables>
<table name="tcnotified" />
</tables>
<conditions>
<condition operation="equal" column="notified_srl" var="notified_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getChild" action="select">
<tables>
<table name="tcnotifiedchildren" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="notified_srl" var="notified_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getChildren" action="select">
<tables>
<table name="tcnotifiedchildren" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="parent_srl" var="parent_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,10 @@
<query id="getFromQueue" action="select">
<tables>
<table name="tcnotifyqueue" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
</conditions>
</query>

View file

@ -0,0 +1,26 @@
<query id="getNotifiedList" action="select">
<tables>
<table name="tcnotified" alias="tcnotified"/>
<table name="tcnotifiedsites" alias="tcnotifiedsites" />
</tables>
<columns>
<column name="tcnotified.name" />
<column name="title" />
<column name="written" />
<column name="tcnotified.url" alias="commenturl"/>
<column name="tcnotifiedsites.url" alias="siteurl"/>
<column name="entryurl" />
<column name="entrytitle" />
<column name="comment" />
<column name="notified_srl" />
</columns>
<conditions>
<condition operation="equal" column="tcnotified.siteid" var="tcnotifiedsites.id" />
</conditions>
<navigation>
<index var="sort_index" default="list_order" order="asc" />
<list_count var="list_count" default="10" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -0,0 +1,14 @@
<query id="getParentId" action="select">
<tables>
<table name="tcnotified" />
</tables>
<columns>
<column name="notified_srl" alias="notified_srl"/>
</columns>
<conditions>
<condition operation="equal" column="entry" var="entry" notnull="notnull" />
<condition operation="equal" column="siteid" var="siteid" notnull="notnull" pipe="and"/>
<condition operation="equal" column="module_srl" var="module_srl" notnull="notnull" pipe="and"/>
<condition operation="equal" column="remoteid" var="remoteid" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="getSite" action="select">
<tables>
<table name="tcnotifiedsites" />
</tables>
<columns>
<column name="id" alias="id"/>
</columns>
<conditions>
<condition operation="equal" column="url" var="url" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,25 @@
<query id="insertCommentNotified" action="insert">
<tables>
<table name="tcnotified" />
</tables>
<columns>
<column name="notified_srl" var="notified_srl" notnull="notnull" />
<column name="module_srl" var="module_srl" notnull="notnull" />
<column name="name" var="name" notnull="notnull" />
<column name="entry" var="entry" notnull="notnull" />
<column name="password" var="password" />
<column name="homepage" var="homepage" />
<column name="secret" var="secret" default="0" />
<column name="comment" var="comment" notnull="notnull" />
<column name="ip" var="ip" />
<column name="isnew" var="isnew" default="1" />
<column name="siteid" var="siteid" notnull="notnull" />
<column name="remoteid" var="remoteid" default="0" />
<column name="entrytitle" var="entrytitle" notnull="notnull" />
<column name="entryurl" var="entryurl" notnull="notnull" />
<column name="url" var="url" />
<column name="written" var="written" default="curdate()" notnull="notnull" />
<column name="modified" var="modified" default="curdate()" />
<column name="list_order" var="list_order" notnull="notnull" />
</columns>
</query>

View file

@ -0,0 +1,22 @@
<query id="insertCommentNotifiedChild" action="insert">
<tables>
<table name="tcnotifiedchildren" />
</tables>
<columns>
<column name="notified_srl" var="notified_srl" notnull="notnull" />
<column name="module_srl" var="module_srl" notnull="notnull" />
<column name="parent_srl" var="parent_srl" />
<column name="name" var="name" notnull="notnull" />
<column name="password" var="password" />
<column name="homepage" var="homepage" />
<column name="secret" var="secret" default="0" />
<column name="comment" var="comment" notnull="notnull" />
<column name="ip" var="ip" />
<column name="isnew" var="isnew" default="1" />
<column name="remoteid" var="remoteid" default="0" />
<column name="url" var="url" />
<column name="written" var="written" default="curdate()" notnull="notnull" />
<column name="modified" var="modified" default="curdate()" />
<column name="list_order" var="list_order" notnull="notnull" />
</columns>
</query>

View file

@ -0,0 +1,8 @@
<query id="insertQueue" action="insert">
<tables>
<table name="tcnotifyqueue" />
</tables>
<columns>
<column name="comment_srl" var="comment_srl" notnull="notnull" />
</columns>
</query>

View file

@ -0,0 +1,12 @@
<query id="insertSite" action="insert">
<tables>
<table name="tcnotifiedsites" />
</tables>
<columns>
<column name="id" var="id" notnull="notnull" />
<column name="title" var="title" />
<column name="name" var="name" />
<column name="url" var="url" notnull="notnull" />
<column name="modified" var="modified" default="curdate()" notnull="notnull" />
</columns>
</query>

View file

@ -0,0 +1,12 @@
<query id="updateParent" action="update">
<tables>
<table name="tcnotified" />
</tables>
<columns>
<column name="modified" var="modified" default="curdate()" notnull="notnull" />
<column name="list_order" var="list_order" notnull="notnull" />
</columns>
<conditions>
<condition operation="equal" column="notified_srl" var="notified_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,20 @@
<table name="tcnotified">
<column name="notified_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="module_srl" type="number" size="11" notnull="notnull" />
<column name="entry" type="number" size="11" />
<column name="name" type="varchar" size="80" notnull="notnull" />
<column name="password" type="varchar" size="32" />
<column name="homepage" type="varchar" size="80" />
<column name="secret" type="number" size="1" notnull="notnull" />
<column name="comment" type="bigtext" notnull="notnull" />
<column name="ip" type="varchar" size="15" />
<column name="isnew" type="number" size="1" notnull="notnull" />
<column name="siteid" type="number" size="11" notnull="notnull" />
<column name="remoteid" type="number" size="11" notnull="notnull" />
<column name="entrytitle" type="varchar" size="255" notnull="notnull" />
<column name="entryurl" type="varchar" size="255" notnull="notnull" />
<column name="url" type="varchar" size="255" notnull="notnull" />
<column name="written" type="date" notnull="notnull" />
<column name="modified" type="date" notnull="notnull" />
<column name="list_order" type="number" size="11" />
</table>

View file

@ -0,0 +1,17 @@
<table name="tcnotifiedchildren">
<column name="notified_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="module_srl" type="number" size="11" notnull="notnull" />
<column name="parent_srl" type="number" size="11" />
<column name="name" type="varchar" size="80" notnull="notnull" />
<column name="password" type="varchar" size="32" />
<column name="homepage" type="varchar" size="80" />
<column name="secret" type="number" size="1" notnull="notnull" />
<column name="comment" type="bigtext" notnull="notnull" />
<column name="ip" type="varchar" size="15" />
<column name="isnew" type="number" size="1" notnull="notnull" />
<column name="remoteid" type="number" size="11" notnull="notnull" />
<column name="url" type="varchar" size="255" notnull="notnull" />
<column name="written" type="date" notnull="notnull" />
<column name="modified" type="date" notnull="notnull" />
<column name="list_order" type="number" size="11" />
</table>

View file

@ -0,0 +1,7 @@
<table name="tcnotifiedsites">
<column name="id" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="title" type="varchar" size="255" notnull="notnull" />
<column name="name" type="varchar" size="255" notnull="notnull" />
<column name="url" type="varchar" size="250" notnull="notnull" index="idx_url"/>
<column name="modified" type="date" notnull="notnull" />
</table>

View file

@ -0,0 +1,3 @@
<table name="tcnotifyqueue">
<column name="comment_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
</table>

View file

@ -0,0 +1,68 @@
<?php
/**
* @class commentnotifyAdminView
* @author haneul (haneul0318@gmail.com)
* @brief commentnotify 모듈의 Admin view class
**/
class tccommentnotifyAdminController extends tccommentnotify {
/**
* @brief 초기화
**/
function init() {
}
function procCommentNotifyAdminDeleteChecked()
{
$cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
$comment_srl_list= explode('|@|', $cart);
$comment_count = count($comment_srl_list);
if(!$comment_count) return $this->stop('msg_cart_is_null');
for($i=0;$i<$comment_count;$i++) {
$notified_srl = trim($comment_srl_list[$i]);
if(!$notified_srl) continue;
$output = $this->deleteParent($notified_srl);
if(!$output->toBool()) continue;
$deleted_count ++;
}
$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
}
function deleteParent($parent_srl)
{
$args->notified_srl = $parent_srl;
executeQuery('tccommentnotify.deleteParent', $args);
$newargs->parent_srl = $args->notified_srl;
return executeQuery('tccommentnotify.deleteChildren', $newargs);
}
function procCommentNotifyAdminDeleteParent()
{
$notified_srl = Context::get('notified_srl');
$this->deleteParent($notified_srl);
}
function procCommentNotifyAdminDeleteChild()
{
$args->notified_srl = Context::get('notified_srl');
$oModel = &getModel('tccommentnotify');
$output = $oModel->GetChild($args->notified_srl);
if(!$output->toBool())
{
return;
}
$parent_srl = $output->data->parent_srl;
executeQuery('tccommentnotify.deleteChild', $args);
if(!$oModel->GetChildren($parent_srl))
{
$newarg->notified_srl = $parent_srl;
executeQuery('tccommentnotify.deleteParent', $newarg);
}
}
}
?>

View file

@ -0,0 +1,64 @@
<?php
/**
* @class commentnotifyAdminView
* @author haneul (haneul0318@gmail.com)
* @brief commentnotify 모듈의 Admin view class
**/
class tccommentnotifyAdminView extends tccommentnotify {
/**
* @brief 초기화
**/
function init() {
// 템플릿 경로 지정
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief 관리자 페이지 초기화면
**/
function dispCommentNotifyAdminIndex() {
$this->dispCommentNotifyAdminList();
}
function dispCommentNotifyAdminList() {
// 목록을 구하기 위한 옵션
$args->page = Context::get('page'); ///< 페이지
$args->sort_index = 'list_order'; ///< 소팅 값
$oCommentNotifyModel = &getModel('tccommentnotify');
$output = $oCommentNotifyModel->GetNotifiedList($args);
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
$notify_list = array();
if(!$output->data)
{
$output->data = array();
}
foreach($output->data as $notifyparent)
{
$item = null;
$item->parent = $notifyparent;
$item->children = $oCommentNotifyModel->GetChildren($notifyparent->notified_srl);
$notify_list[] = $item;
}
Context::set('notify_list', $notify_list);
Context::set('page_navigation', $output->page_navigation);
// 템플릿 지정
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('commentnotify_list');
}
function dispCommentNotifyAdminDeleteChild()
{
$notified_srl = Context::get('notified_srl');
$this->setTemplateFile('delete_child');
}
}
?>

View file

@ -0,0 +1,61 @@
<?php
/**
* @class tccommentnotify
* @author haneul (haneul0318@gmail.com)
* @brief tccommentnotify module's class
**/
class tccommentnotify extends ModuleObject {
var $cachedir = "./files/cache/tccommentnotify/";
var $cachefile = "shouldnotify";
var $lockfile = "notify.lock";
/**
* @brief Install tccommentnotify module
**/
function moduleInstall() {
// action forward에 등록 (관리자 모드에서 사용하기 위함)
$oModuleController = &getController('module');
$oModuleController->insertActionForward('tccommentnotify', 'view', 'dispCommentNotifyAdminIndex');
// notify를 위한 트리거 추가
$oModuleController->insertTrigger('comment.insertComment', 'tccommentnotify', 'controller', 'triggerInsertComment', 'after');
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
**/
function checkUpdate() {
$oModuleModel = &getModel('module');
if(!$oModuleModel->getTrigger('comment.insertComment', 'tccommentnotify', 'controller', 'triggerInsertComment', 'after'))
{
return true;
}
return false;
}
/**
* @brief 업데이트 실행
**/
function moduleUpdate() {
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
if(!$oModuleModel->getTrigger('comment.insertComment', 'tccommentnotify', 'controller', 'triggerInsertComment', 'after'))
{
$oModuleController->insertTrigger('comment.insertComment', 'tccommentnotify', 'controller', 'triggerInsertComment', 'after');
}
return new Object(0, 'success_updated');
}
/**
* @brief 캐시 파일 재생성
**/
function recompileCache() {
}
}
?>

View file

@ -0,0 +1,319 @@
<?php
/**
* @class tccommentnotifier controller
* @author haneul (haneul0318@gmail.com)
* @brief tccommentnotifier 모듈의 controller class
**/
class tccommentnotifyController extends tccommentnotify {
/**
* @brief initialization
**/
function init() {
}
function insertSite($title, $name, $url)
{
$id = getNextSequence();
$args->id = $id;
$args->title = $title;
$args->name = $name;
$args->url = $url;
$output = executeQuery("tccommentnotify.insertSite", $args);
if(!$output->toBool())
{
return -1;
}
else
{
return $id;
}
}
function insertParent($obj, $siteid, $module_srl)
{
$parentid = getNextSequence();
$args->notified_srl = $parentid;
$args->module_srl = $module_srl;
$args->name = $obj->r1_name;
$args->homepage = $obj->r1_homepage;
$args->written = date('YmdHis', $obj->r1_regdate);
$args->comment = $obj->r1_body;
$args->entry = $obj->s_no;
$args->siteid = $siteid;
$args->url = $obj->r1_url;
$args->remoteid = $obj->r1_no;
$args->entrytitle = $obj->s_post_title;
$args->entryurl = $obj->s_url;
$args->list_order = $parentid * -1;
$output = executeQuery("tccommentnotify.insertCommentNotified", $args);
if(!$output->toBool())
{
return -1;
}
return $parentid;
}
function procDoNotify()
{
$lockFilePath = $this->cachedir.$this->lockfile;
if(file_exists($lockFilePath))
{
return;
}
$fp = null;
if(version_compare(PHP_VERSION, "4.3.2", '<'))
{
$fp = fopen($lockFilePath, "a");
}
else
{
$fp = fopen($lockFilePath, "x");
if(!$fp)
{
return;
}
}
fwrite($fp, "lock");
fclose($fp);
if( file_exists($this->cachedir.$this->cachefile) )
{
unlink($this->cachedir.$this->cachefile);
}
$oModel = &getModel('tccommentnotify');
$output = $oModel->GetCommentsFromNotifyQueue();
if(!$output->toBool())
{
debugPrint("Error");
debugPrint($output);
}
if($output->data)
{
foreach($output->data as $data)
{
$this->deleteFromQueue($data->comment_srl);
$this->sendCommentNotify($data->comment_srl);
}
}
unlink($lockFilePath);
}
function deleteFromQueue($comment_srl)
{
$args->comment_srl = $comment_srl;
executeQuery("tccommentnotify.deleteFromQueue", $args);
}
function triggerInsertComment($obj)
{
$oCommentModel = &getModel('comment');
$oComment = $oCommentModel->getComment($obj->comment_srl);
if($oComment->get('parent_srl'))
{
$output = $this->insertCommentNotifyQueue($obj->comment_srl);
if($output->toBool())
{
if(!file_exists($this->cachedir.$this->cachefile))
{
if(!file_exists($this->cachedir))
{
mkdir($this->cachedir);
}
$fp = fopen($this->cachedir.$this->cachefile, "w");
fwrite($fp, "aa");
fclose($fp);
}
}
}
return new Object();
}
function insertCommentNotifyQueue($comment_srl)
{
$args->comment_srl = $comment_srl;
return executeQuery("tccommentnotify.insertQueue", $args);
}
function sendCommentNotify($comment_srl)
{
set_include_path("./libs/PEAR");
require_once('PEAR.php');
require_once('HTTP/Request.php');
$oCommentModel = &getModel('comment');
$oChild = $oCommentModel->getComment($comment_srl);
if(!$oChild->isExists())
{
return;
}
$parent_srl = $oChild->get('parent_srl');
if(!$parent_srl)
{
return;
}
$oParent = $oCommentModel->getComment($parent_srl);
if(!$oParent->isExists())
{
return;
}
$parentHomepage = $oParent->getHomepageUrl();
$oMemberModel = &getModel('member');
if(!$parentHomepage)
{
$parent_member = $oParent->getMemberSrl();
if(!$parent_member)
return;
$member_info = $oMemberModel->getMemberInfoByMemberSrl($parent_member);
$parentHomepage = $member_info->homepage;
if(!$parentHomepage)
return;
}
$childHomepage = $oChild->getHomepageUrl();
if(!$childHomepage)
{
$child_member = $oChild->getMemberSrl();
if($child_member)
{
$child_info = $oMemberModel->getMemberInfoByMemberSrl($child_member);
$childHomepage = $member_info->homepage;
}
}
$document_srl = $oChild->get('document_srl');
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
if($this->SendNotifyRequest($parentHomepage, &$module_info, &$oDocument, &$oParent, $parentHomepage, &$oChild, $childHomepage) != 200)
{
$indexedPage = rtrim($parentHomepage, '/').'/index.php';
$this->SendNotifyRequest($indexedPage, &$module_info, &$oDocument, &$oParent, $parentHomepage, &$oChild, $childHomepage);
}
}
function SendNotifyRequest($target, $module_info, $oDocument, $oParent, $parentHomepage, $oChild, $childHomepage)
{
$oReq = new HTTP_Request();
$oReq->setURL($target);
$oReq->setMethod("POST");
$oReq->addHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
$oReq->addPostData('mode', 'fb');
$oReq->addPostData('url', getUrl('mid', $module_info->mid,'act','','module',''));
$oReq->addPostData('s_home_title', $module_info->browser_title);
$oReq->addPostData('s_post_title', $oDocument->getTitleText());
$oReq->addPostData('s_name', $oDocument->getNickName());
$oReq->addPostData('s_url', $oDocument->getPermanentUrl());
$oReq->addPostData('s_no', $oDocument->document_srl);
$oReq->addPostData('r1_name', $oParent->getNickName());
$oReq->addPostData('r1_no', $oParent->comment_srl);
$oReq->addPostData('r1_pno', $oDocument->document_srl);
$oReq->addPostData('r1_rno', '0');
$oReq->addPostData('r1_homepage', $parentHomepage);
$oReq->addPostData('r1_regdate', ztime($oParent->get('regdate')));
$oReq->addPostData('r1_url', sprintf("%s#comment_%s", $oDocument->getPermanentUrl(), $oParent->comment_srl));
$oReq->addPostData('r2_name', $oChild->getNickName());
$oReq->addPostData('r2_no', $oChild->comment_srl);
$oReq->addPostData('r2_pno', $oDocument->document_srl);
$oReq->addPostData('r2_rno', $oParent->comment_srl);
$oReq->addPostData('r2_homepage', $childHomepage);
$oReq->addPostData('r2_regdate', ztime($oChild->get('regdate')));
$oReq->addPostData('r2_url', sprintf("%s#comment_%s", $oDocument->getPermanentUrl(), $oChild->comment_srl));
$oReq->addPostData('r1_body', strip_tags($oParent->get('content')));
$oReq->addPostData('r2_body', strip_tags($oChild->get('content')));
$oReq->sendRequest(false);
$code = $oReq->getResponseCode();
return $code;
}
function insertCommentNotify($obj, $siteid, $parentid, $module_srl)
{
$myid = getNextSequence();
$args->notified_srl = $myid;
$args->module_srl = $module_srl;
$args->parent_srl = $parentid;
$args->name = $obj->r2_name;
$args->homepage = $obj->r2_homepage;
$args->written = date('YmdHis', $obj->r2_regdate);
$args->comment = $obj->r2_body;
$args->url = $obj->r2_url;
$args->remoteid = $obj->r2_no;
$args->list_order = $myid * -1;
$output = executeQuery("tccommentnotify.insertCommentNotifiedChild", $args);
$bRet = $output->toBool();
return $bRet;
}
function updateParent($parentid)
{
$args->notified_srl = $parentid;
$args->list_order = -1 * getNextSequence();
$output = executeQuery("tccommentnotify.updateParent", $args);
}
function procNotifyReceived() {
$obj = Context::getRequestVars();
$oModel = &getModel('tccommentnotify');
$oDB = &DB::getInstance();
$oDB -> begin();
$siteid = $oModel->GetSite( $obj->url );
$module_info = Context::get('current_module_info');
$module_srl = $module_info->module_srl;
if( $siteid == -2 )
{
$oDB->rollback();
return;
}
else if( $siteid == -1 )
{
$siteid = $this->insertSite($obj->s_home_title, $obj->s_name, $obj->url);
if($siteid == -1)
{
$oDB->rollback();
return;
}
}
$parentid = $oModel->GetParentID( $obj->s_no, $siteid, $module_srl, $obj->r1_no );
if( $parentid == -2 )
{
$oDB->rollback();
return;
}
else if ( $parentid == -1 )
{
$parentid = $this->insertParent( &$obj, $siteid, $module_srl );
if($parentid == -1)
{
$oDB->rollback();
return;
}
}
else
{
$this->updateParent($parentid);
}
if(!$this->insertCommentNotify(&$obj, $siteid, $parentid, $module_srl))
{
$oDB->rollback();
return;
}
$oDB->commit();
}
}
?>

View file

@ -0,0 +1,102 @@
<?php
/**
* @class tccommentnotifier controller
* @author haneul (haneul0318@gmail.com)
* @brief tccommentnotifier 모듈의 controller class
**/
class tccommentnotifyModel extends tccommentnotify {
function init() {
}
function checkShouldNotify()
{
if( file_exists($this->cachedir.$this->cachefile) )
{
return true;
}
else
{
return false;
}
}
function GetSite($url)
{
if(!$url) return new Object(-1, "parameter error");
$args->url = $url;
$output = executeQuery('tccommentnotify.getSite', $args);
if(!$output->toBool())
{
return -2;
}
if(!$output->data)
{
return -1;
}
$siteid = $output->data->id;
if( is_array($siteid) )
{
$siteid = array_shift($siteid);
}
return $siteid;
}
function GetParentID( $entry, $siteid, $module_srl, $remoteid )
{
$args->entry = $entry;
$args->siteid = $siteid;
$args->module_srl = $module_srl;
$args->remoteid = $remoteid;
$output = executeQuery('tccommentnotify.getParentId', $args);
if(!$output->toBool())
{
return -2;
}
if(!$output->data)
{
return -1;
}
$parentid = $output->data->notified_srl;
if( is_array($parentid) )
{
$parentid = array_shift($parentid);
}
return $parentid;
}
function GetNotifiedList($args)
{
$args->parent_srl = 0;
return executeQuery("tccommentnotify.getNotifiedList", $args);
}
function GetChildren($parentid)
{
$args->parent_srl = $parentid;
$output = executeQueryArray("tccommentnotify.getChildren", $args);
return $output->data;
}
function GetChild($notified_srl)
{
$args->notified_srl = $notified_srl;
$output = executeQuery("tccommentnotify.getChild", $args);
return $output;
}
function GetCommentsFromNotifyQueue()
{
$output = executeQueryArray("tccommentnotify.getFromQueue");
return $output;
}
}
?>

View file

@ -0,0 +1,82 @@
<!--#include("./header.html")-->
<!--%import("js/commentnotify.js")-->
<!--%import("filter/delete_child.xml")-->
<!--%import("filter/delete_parent.xml")-->
<!--%import("filter/delete_checked.xml")-->
<!-- 정보 -->
<div class="tableSummaryType1">
Total <strong>{number_format($total_count)}</strong>, Page <strong>{number_format($page)}</strong>/{number_format($total_page)}
</div>
<form id="fo_list" action="./" method="get" onsubmit="return procFilter(this, delete_checked)">
<input type="hidden" name="page" value="{$page}" />
<!-- 목록 -->
<table cellspacing="0" class="adminTable">
{@ $col_width = array(40,85, 150,65,0,45)}
<!--@foreach($col_width as $width)-->
<col <!--@if($width)-->width="{$width}" <!--@end-->/>
<!--@end-->
<thead>
<tr>
<th scope="col"><input type="checkbox" onclick="checkboxSelectAll(this.form, 'cart'); return false;" /></th>
<th scope="col">등록일자</th>
<th scope="col">사이트명</th>
<th scope="col">이름</th>
<th scope="col">내용</th>
<th scope="col">삭제</th>
</tr>
</thead>
<tbody>
<!--@foreach($notify_list as $no => $val)-->
{@ $parent = $val->parent; }
<tr class="parent">
<td><input type="checkbox" name="cart" value="{$parent->notified_srl}" /></td>
<td class="date">{zdate($parent->written, "Y/m/d")}</td>
<td><a href="{$parent->siteurl}">{$parent->title?$parent->title:"[No title]"}</a></td>
<td>{$parent->name}</td>
<td><a href="{$parent->entryurl}" class="blue">{$parent->entrytitle}</a> <a href="{$parent->commenturl}">{$parent->comment}</a></td>
<td><a href="#" onclick="deleteParent('{$parent->notified_srl}');"><img src="images/buttonDeleteX.gif" /></a></td>
</tr>
<!--@foreach($val->children as $child)-->
<tr>
<td></td>
<td class="date">{zdate($child->written, "Y/m/d")}</td>
<td><a href="{$parent->siteurl}">{$parent->title?$parent->title:"[No title]"}</a></td>
<td>{$child->name}</td>
<td><img src="images/iconReplyArrow.gif" /> <a href="{$child->url}">{$child->comment}</a></td>
<td><a href="#" onclick="deleteChild('{$child->notified_srl}');"><img src="images/buttonDeleteX.gif" /></a></td>
</tr>
<!--@end-->
<!--@end-->
</tbody>
</table>
<!-- 버튼 -->
<div class="fr gap1">
<a href="javascript:checkboxSelectAll('fo_list', 'cart', false)" class="button"><span>{$lang->cmd_unselect_all}</span></a>
<a href="javascript:checkboxSelectAll('fo_list', 'cart')" class="button"><span>{$lang->cmd_reverse_all}</span></a>
<span class="button"><input type="submit" value="{$lang->cmd_delete_checked_comment}" /></span>
</div>
</form>
<form id="deleteChildForm" action="./" method="POST">
<input type="hidden" id="notified" name="notified_srl" value="" />
</form>
<!-- 페이지 네비게이션 -->
<div class="pageNavigation">
<a href="{getUrl('page','','module_srl','')}" class="goToFirst"><img src="../../admin/tpl/images/bottomGotoFirst.gif" alt="{$lang->first_page}" width="7" height="5" /></a>
<!--@while($page_no = $page_navigation->getNextPage())-->
<!--@if($page == $page_no)-->
<span class="current">{$page_no}</span>
<!--@else-->
<a href="{getUrl('page',$page_no,'module_srl','')}">{$page_no}</a>
<!--@end-->
<!--@end-->
<a href="{getUrl('page',$page_navigation->last_page,'module_srl','')}" class="goToLast"><img src="../../admin/tpl/images/bottomGotoLast.gif" alt="{$lang->last_page}" width="7" height="5" /></a>
</div>

View file

@ -0,0 +1,2 @@
.parent td { background-color : #fff9ff; }
.date { font-size : 0.9em; }

View file

@ -0,0 +1,12 @@
<filter name="delete_checked" module="tccommentnotify" act="procCommentNotifyAdminDeleteChecked" confirm_msg_code="confirm_delete">
<form>
<node target="cart" required="true" />
</form>
<parameter>
<param name="cart" target="cart" />
</parameter>
<response>
<tag name="error" />
<tag name="message" />
</response>
</filter>

View file

@ -0,0 +1,13 @@
<filter name="delete_child" module="tccommentnotify" act="procCommentNotifyAdminDeleteChild" confirm_msg_code="confirm_delete">
<form>
<node target="notified_srl" required="true" />
</form>
<parameter>
<param name="notified_srl" target="notified_srl" />
</parameter>
<response callback_func="completeDelete">
<tag name="error" />
<tag name="message" />
<tag name="page" />
</response>
</filter>

View file

@ -0,0 +1,13 @@
<filter name="delete_parent" module="tccommentnotify" act="procCommentNotifyAdminDeleteParent" confirm_msg_code="confirm_delete">
<form>
<node target="notified_srl" required="true" />
</form>
<parameter>
<param name="notified_srl" target="notified_srl" />
</parameter>
<response callback_func="completeDelete">
<tag name="error" />
<tag name="message" />
<tag name="page" />
</response>
</filter>

View file

@ -0,0 +1,7 @@
<!--%import("css/commentnotify.css")-->
<h3>{$lang->commentnotify} <span class="gray">{$lang->cmd_management}</span></h3>
<div class="header4 gap1">
<ul class="localNavigation">
</ul>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

View file

@ -0,0 +1,25 @@
function deleteChild(notified_srl)
{
var e = xGetElementById('notified');
e.value=notified_srl;
var hF = xGetElementById("deleteChildForm");
procFilter(hF, delete_child);
}
function deleteParent(notified_srl)
{
var e = xGetElementById('notified');
e.value=notified_srl;
var hF = xGetElementById("deleteChildForm");
procFilter(hF, delete_parent);
}
function completeDelete(ret_obj)
{
var error = ret_obj['error'];
var message = ret_obj['message'];
alert(message);
var url = current_url.setQuery('act','dispCommentNotifyAdminIndex');
location.href = url;
}