From de2b57c2d2f53f09a34bd485171948a25fa81b0d Mon Sep 17 00:00:00 2001 From: haneul Date: Wed, 25 Jun 2008 23:12:36 +0000 Subject: [PATCH] =?UTF-8?q?#484=20*=20=EB=8C=93=EA=B8=80=EC=95=8C=EB=A6=AC?= =?UTF-8?q?=EB=AF=B8=20module=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4326 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/tccommentnotify/ReleaseNote | 3 + modules/tccommentnotify/conf/info.xml | 8 + modules/tccommentnotify/conf/module.xml | 11 + modules/tccommentnotify/lang/ko.lang.php | 5 + .../tccommentnotify/queries/deleteChild.xml | 8 + .../queries/deleteChildren.xml | 8 + .../queries/deleteFromQueue.xml | 8 + .../tccommentnotify/queries/deleteParent.xml | 8 + modules/tccommentnotify/queries/getChild.xml | 11 + .../tccommentnotify/queries/getChildren.xml | 11 + .../tccommentnotify/queries/getFromQueue.xml | 10 + .../queries/getNotifiedList.xml | 26 ++ .../tccommentnotify/queries/getParentId.xml | 14 + modules/tccommentnotify/queries/getSite.xml | 11 + .../queries/insertCommentNotified.xml | 25 ++ .../queries/insertCommentNotifiedChild.xml | 22 ++ .../tccommentnotify/queries/insertQueue.xml | 8 + .../tccommentnotify/queries/insertSite.xml | 12 + .../tccommentnotify/queries/updateParent.xml | 12 + .../tccommentnotify/schemas/tcnotified.xml | 20 ++ .../schemas/tcnotifiedchildren.xml | 17 + .../schemas/tcnotifiedsites.xml | 7 + .../tccommentnotify/schemas/tcnotifyqueue.xml | 3 + .../tccommentnotify.admin.controller.php | 68 ++++ .../tccommentnotify.admin.view.php | 64 ++++ .../tccommentnotify/tccommentnotify.class.php | 61 ++++ .../tccommentnotify.controller.php | 319 ++++++++++++++++++ .../tccommentnotify/tccommentnotify.model.php | 102 ++++++ .../tpl/commentnotify_list.html | 82 +++++ .../tccommentnotify/tpl/css/commentnotify.css | 2 + .../tpl/filter/delete_checked.xml | 12 + .../tpl/filter/delete_child.xml | 13 + .../tpl/filter/delete_parent.xml | 13 + modules/tccommentnotify/tpl/header.html | 7 + .../tpl/images/buttonDeleteX.gif | Bin 0 -> 61 bytes .../tpl/images/iconReplyArrow.gif | Bin 0 -> 54 bytes .../tccommentnotify/tpl/js/commentnotify.js | 25 ++ 37 files changed, 1036 insertions(+) create mode 100644 modules/tccommentnotify/ReleaseNote create mode 100644 modules/tccommentnotify/conf/info.xml create mode 100644 modules/tccommentnotify/conf/module.xml create mode 100644 modules/tccommentnotify/lang/ko.lang.php create mode 100644 modules/tccommentnotify/queries/deleteChild.xml create mode 100644 modules/tccommentnotify/queries/deleteChildren.xml create mode 100644 modules/tccommentnotify/queries/deleteFromQueue.xml create mode 100644 modules/tccommentnotify/queries/deleteParent.xml create mode 100644 modules/tccommentnotify/queries/getChild.xml create mode 100644 modules/tccommentnotify/queries/getChildren.xml create mode 100644 modules/tccommentnotify/queries/getFromQueue.xml create mode 100644 modules/tccommentnotify/queries/getNotifiedList.xml create mode 100644 modules/tccommentnotify/queries/getParentId.xml create mode 100644 modules/tccommentnotify/queries/getSite.xml create mode 100644 modules/tccommentnotify/queries/insertCommentNotified.xml create mode 100644 modules/tccommentnotify/queries/insertCommentNotifiedChild.xml create mode 100644 modules/tccommentnotify/queries/insertQueue.xml create mode 100644 modules/tccommentnotify/queries/insertSite.xml create mode 100644 modules/tccommentnotify/queries/updateParent.xml create mode 100644 modules/tccommentnotify/schemas/tcnotified.xml create mode 100644 modules/tccommentnotify/schemas/tcnotifiedchildren.xml create mode 100644 modules/tccommentnotify/schemas/tcnotifiedsites.xml create mode 100644 modules/tccommentnotify/schemas/tcnotifyqueue.xml create mode 100644 modules/tccommentnotify/tccommentnotify.admin.controller.php create mode 100644 modules/tccommentnotify/tccommentnotify.admin.view.php create mode 100644 modules/tccommentnotify/tccommentnotify.class.php create mode 100644 modules/tccommentnotify/tccommentnotify.controller.php create mode 100644 modules/tccommentnotify/tccommentnotify.model.php create mode 100644 modules/tccommentnotify/tpl/commentnotify_list.html create mode 100644 modules/tccommentnotify/tpl/css/commentnotify.css create mode 100644 modules/tccommentnotify/tpl/filter/delete_checked.xml create mode 100644 modules/tccommentnotify/tpl/filter/delete_child.xml create mode 100644 modules/tccommentnotify/tpl/filter/delete_parent.xml create mode 100644 modules/tccommentnotify/tpl/header.html create mode 100644 modules/tccommentnotify/tpl/images/buttonDeleteX.gif create mode 100644 modules/tccommentnotify/tpl/images/iconReplyArrow.gif create mode 100644 modules/tccommentnotify/tpl/js/commentnotify.js diff --git a/modules/tccommentnotify/ReleaseNote b/modules/tccommentnotify/ReleaseNote new file mode 100644 index 000000000..8d9fab0a6 --- /dev/null +++ b/modules/tccommentnotify/ReleaseNote @@ -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안되는 문제 수정 diff --git a/modules/tccommentnotify/conf/info.xml b/modules/tccommentnotify/conf/info.xml new file mode 100644 index 000000000..8f2ac3d79 --- /dev/null +++ b/modules/tccommentnotify/conf/info.xml @@ -0,0 +1,8 @@ + + + 댓글알리미 + + haneul + 댓글알리미 모듈입니다. + + diff --git a/modules/tccommentnotify/conf/module.xml b/modules/tccommentnotify/conf/module.xml new file mode 100644 index 000000000..ddc60d5af --- /dev/null +++ b/modules/tccommentnotify/conf/module.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/tccommentnotify/lang/ko.lang.php b/modules/tccommentnotify/lang/ko.lang.php new file mode 100644 index 000000000..9d4913abe --- /dev/null +++ b/modules/tccommentnotify/lang/ko.lang.php @@ -0,0 +1,5 @@ +commentnotify = '댓글알리미'; + $lang->msg_checked_comment_is_deleted = '%d개의 알림글이 삭제되었습니다'; + $lang->cmd_delete_checked_comment = '선택삭제'; +?> diff --git a/modules/tccommentnotify/queries/deleteChild.xml b/modules/tccommentnotify/queries/deleteChild.xml new file mode 100644 index 000000000..18618e3be --- /dev/null +++ b/modules/tccommentnotify/queries/deleteChild.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/modules/tccommentnotify/queries/deleteChildren.xml b/modules/tccommentnotify/queries/deleteChildren.xml new file mode 100644 index 000000000..ed56920f3 --- /dev/null +++ b/modules/tccommentnotify/queries/deleteChildren.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/tccommentnotify/queries/deleteFromQueue.xml b/modules/tccommentnotify/queries/deleteFromQueue.xml new file mode 100644 index 000000000..c41446480 --- /dev/null +++ b/modules/tccommentnotify/queries/deleteFromQueue.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/tccommentnotify/queries/deleteParent.xml b/modules/tccommentnotify/queries/deleteParent.xml new file mode 100644 index 000000000..d671dcc0a --- /dev/null +++ b/modules/tccommentnotify/queries/deleteParent.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/tccommentnotify/queries/getChild.xml b/modules/tccommentnotify/queries/getChild.xml new file mode 100644 index 000000000..4686dcf79 --- /dev/null +++ b/modules/tccommentnotify/queries/getChild.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/tccommentnotify/queries/getChildren.xml b/modules/tccommentnotify/queries/getChildren.xml new file mode 100644 index 000000000..3e3171257 --- /dev/null +++ b/modules/tccommentnotify/queries/getChildren.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/tccommentnotify/queries/getFromQueue.xml b/modules/tccommentnotify/queries/getFromQueue.xml new file mode 100644 index 000000000..dd156c565 --- /dev/null +++ b/modules/tccommentnotify/queries/getFromQueue.xml @@ -0,0 +1,10 @@ + + +
+ + + + + + + diff --git a/modules/tccommentnotify/queries/getNotifiedList.xml b/modules/tccommentnotify/queries/getNotifiedList.xml new file mode 100644 index 000000000..9b3dad3b2 --- /dev/null +++ b/modules/tccommentnotify/queries/getNotifiedList.xml @@ -0,0 +1,26 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/tccommentnotify/queries/getParentId.xml b/modules/tccommentnotify/queries/getParentId.xml new file mode 100644 index 000000000..fe27ee479 --- /dev/null +++ b/modules/tccommentnotify/queries/getParentId.xml @@ -0,0 +1,14 @@ + + +
+ + + + + + + + + + + diff --git a/modules/tccommentnotify/queries/getSite.xml b/modules/tccommentnotify/queries/getSite.xml new file mode 100644 index 000000000..0821081bd --- /dev/null +++ b/modules/tccommentnotify/queries/getSite.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + + + diff --git a/modules/tccommentnotify/queries/insertCommentNotified.xml b/modules/tccommentnotify/queries/insertCommentNotified.xml new file mode 100644 index 000000000..e73c39d95 --- /dev/null +++ b/modules/tccommentnotify/queries/insertCommentNotified.xml @@ -0,0 +1,25 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/tccommentnotify/queries/insertCommentNotifiedChild.xml b/modules/tccommentnotify/queries/insertCommentNotifiedChild.xml new file mode 100644 index 000000000..df1a26ce2 --- /dev/null +++ b/modules/tccommentnotify/queries/insertCommentNotifiedChild.xml @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/modules/tccommentnotify/queries/insertQueue.xml b/modules/tccommentnotify/queries/insertQueue.xml new file mode 100644 index 000000000..e4593389b --- /dev/null +++ b/modules/tccommentnotify/queries/insertQueue.xml @@ -0,0 +1,8 @@ + + +
+ + + + + diff --git a/modules/tccommentnotify/queries/insertSite.xml b/modules/tccommentnotify/queries/insertSite.xml new file mode 100644 index 000000000..2bf165598 --- /dev/null +++ b/modules/tccommentnotify/queries/insertSite.xml @@ -0,0 +1,12 @@ + + +
+ + + + + + + + + diff --git a/modules/tccommentnotify/queries/updateParent.xml b/modules/tccommentnotify/queries/updateParent.xml new file mode 100644 index 000000000..98598ef62 --- /dev/null +++ b/modules/tccommentnotify/queries/updateParent.xml @@ -0,0 +1,12 @@ + + +
+ + + + + + + + + diff --git a/modules/tccommentnotify/schemas/tcnotified.xml b/modules/tccommentnotify/schemas/tcnotified.xml new file mode 100644 index 000000000..db5d8a4cd --- /dev/null +++ b/modules/tccommentnotify/schemas/tcnotified.xml @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + + +
diff --git a/modules/tccommentnotify/schemas/tcnotifiedchildren.xml b/modules/tccommentnotify/schemas/tcnotifiedchildren.xml new file mode 100644 index 000000000..864cba50e --- /dev/null +++ b/modules/tccommentnotify/schemas/tcnotifiedchildren.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + +
diff --git a/modules/tccommentnotify/schemas/tcnotifiedsites.xml b/modules/tccommentnotify/schemas/tcnotifiedsites.xml new file mode 100644 index 000000000..0276988bb --- /dev/null +++ b/modules/tccommentnotify/schemas/tcnotifiedsites.xml @@ -0,0 +1,7 @@ + + + + + + +
diff --git a/modules/tccommentnotify/schemas/tcnotifyqueue.xml b/modules/tccommentnotify/schemas/tcnotifyqueue.xml new file mode 100644 index 000000000..434f0598d --- /dev/null +++ b/modules/tccommentnotify/schemas/tcnotifyqueue.xml @@ -0,0 +1,3 @@ + + +
diff --git a/modules/tccommentnotify/tccommentnotify.admin.controller.php b/modules/tccommentnotify/tccommentnotify.admin.controller.php new file mode 100644 index 000000000..8081cd636 --- /dev/null +++ b/modules/tccommentnotify/tccommentnotify.admin.controller.php @@ -0,0 +1,68 @@ +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); + } + } + } +?> diff --git a/modules/tccommentnotify/tccommentnotify.admin.view.php b/modules/tccommentnotify/tccommentnotify.admin.view.php new file mode 100644 index 000000000..ecc66b2c0 --- /dev/null +++ b/modules/tccommentnotify/tccommentnotify.admin.view.php @@ -0,0 +1,64 @@ +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'); + } + } +?> diff --git a/modules/tccommentnotify/tccommentnotify.class.php b/modules/tccommentnotify/tccommentnotify.class.php new file mode 100644 index 000000000..dba1bb393 --- /dev/null +++ b/modules/tccommentnotify/tccommentnotify.class.php @@ -0,0 +1,61 @@ +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() { + } + } +?> diff --git a/modules/tccommentnotify/tccommentnotify.controller.php b/modules/tccommentnotify/tccommentnotify.controller.php new file mode 100644 index 000000000..0f17c292d --- /dev/null +++ b/modules/tccommentnotify/tccommentnotify.controller.php @@ -0,0 +1,319 @@ +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(); + } + } +?> diff --git a/modules/tccommentnotify/tccommentnotify.model.php b/modules/tccommentnotify/tccommentnotify.model.php new file mode 100644 index 000000000..44b0871eb --- /dev/null +++ b/modules/tccommentnotify/tccommentnotify.model.php @@ -0,0 +1,102 @@ +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; + } + } +?> diff --git a/modules/tccommentnotify/tpl/commentnotify_list.html b/modules/tccommentnotify/tpl/commentnotify_list.html new file mode 100644 index 000000000..2ceb10ee8 --- /dev/null +++ b/modules/tccommentnotify/tpl/commentnotify_list.html @@ -0,0 +1,82 @@ + + + + + + + +
+ Total {number_format($total_count)}, Page {number_format($page)}/{number_format($total_page)} +
+ +
+ + + + +{@ $col_width = array(40,85, 150,65,0,45)} + + +width="{$width}" /> + + + + + + + + + + + + + + {@ $parent = $val->parent; } + + + + + + + + + + + + + + + + + + + + + +
등록일자사이트명이름내용삭제
{zdate($parent->written, "Y/m/d")}{$parent->title?$parent->title:"[No title]"}{$parent->name}{$parent->entrytitle} {$parent->comment}
{zdate($child->written, "Y/m/d")}{$parent->title?$parent->title:"[No title]"}{$child->name} {$child->comment}
+ + + + +
+
+ +
+ + + + diff --git a/modules/tccommentnotify/tpl/css/commentnotify.css b/modules/tccommentnotify/tpl/css/commentnotify.css new file mode 100644 index 000000000..873f595b8 --- /dev/null +++ b/modules/tccommentnotify/tpl/css/commentnotify.css @@ -0,0 +1,2 @@ +.parent td { background-color : #fff9ff; } +.date { font-size : 0.9em; } diff --git a/modules/tccommentnotify/tpl/filter/delete_checked.xml b/modules/tccommentnotify/tpl/filter/delete_checked.xml new file mode 100644 index 000000000..db9f95dd4 --- /dev/null +++ b/modules/tccommentnotify/tpl/filter/delete_checked.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + + +
diff --git a/modules/tccommentnotify/tpl/filter/delete_child.xml b/modules/tccommentnotify/tpl/filter/delete_child.xml new file mode 100644 index 000000000..953a0693b --- /dev/null +++ b/modules/tccommentnotify/tpl/filter/delete_child.xml @@ -0,0 +1,13 @@ + +
+ + + + + + + + + + +
diff --git a/modules/tccommentnotify/tpl/filter/delete_parent.xml b/modules/tccommentnotify/tpl/filter/delete_parent.xml new file mode 100644 index 000000000..9483684ee --- /dev/null +++ b/modules/tccommentnotify/tpl/filter/delete_parent.xml @@ -0,0 +1,13 @@ + +
+ + + + + + + + + + +
diff --git a/modules/tccommentnotify/tpl/header.html b/modules/tccommentnotify/tpl/header.html new file mode 100644 index 000000000..df63b4b22 --- /dev/null +++ b/modules/tccommentnotify/tpl/header.html @@ -0,0 +1,7 @@ + +

{$lang->commentnotify} {$lang->cmd_management}

+ +
+
    +
+
diff --git a/modules/tccommentnotify/tpl/images/buttonDeleteX.gif b/modules/tccommentnotify/tpl/images/buttonDeleteX.gif new file mode 100644 index 0000000000000000000000000000000000000000..c066e49be9d50d49daaf3a1c500142e171a25687 GIT binary patch literal 61 zcmZ?wbhEHbN%7tf3>tvlao HGFSrug{Tj~ literal 0 HcmV?d00001 diff --git a/modules/tccommentnotify/tpl/js/commentnotify.js b/modules/tccommentnotify/tpl/js/commentnotify.js new file mode 100644 index 000000000..6bee927d7 --- /dev/null +++ b/modules/tccommentnotify/tpl/js/commentnotify.js @@ -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; +}