issue 2119. supporting php 5.4. comment module.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12720 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-07 07:32:21 +00:00
parent c15c87c0bf
commit e2affff988
7 changed files with 1403 additions and 568 deletions

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* commentAdminController class * commentAdminController class
* admin controller class of the comment module * admin controller class of the comment module
@ -9,12 +10,14 @@
*/ */
class commentAdminController extends comment class commentAdminController extends comment
{ {
/** /**
* Initialization * Initialization
* @return void * @return void
*/ */
function init() function init()
{ {
} }
/** /**
@ -22,11 +25,12 @@ class commentAdminController extends comment
* @return void * @return void
*/ */
function procCommentAdminChangePublishedStatusChecked() function procCommentAdminChangePublishedStatusChecked()
{ // Error display if none is selected {
// Error display if none is selected
$cart = Context::get('cart'); $cart = Context::get('cart');
if(!is_array($cart)) if(!is_array($cart))
{ {
$comment_srl_list= explode('|@|', $cart); $comment_srl_list = explode('|@|', $cart);
} }
else else
{ {
@ -55,13 +59,14 @@ class commentAdminController extends comment
} }
if(!is_array($cart)) if(!is_array($cart))
{ {
$comment_srl_list= explode('|@|', $cart); $comment_srl_list = explode('|@|', $cart);
} }
else else
{ {
$comment_srl_list = $cart; $comment_srl_list = $cart;
} }
$args = new stdClass();
$args->status = $will_publish; $args->status = $will_publish;
$args->comment_srls_list = $comment_srl_list; $args->comment_srls_list = $comment_srl_list;
$output = executeQuery('comment.updatePublishedStatus', $args); $output = executeQuery('comment.updatePublishedStatus', $args);
@ -74,47 +79,50 @@ class commentAdminController extends comment
//update comment count for document //update comment count for document
$updated_documents_arr = array(); $updated_documents_arr = array();
// create the controller object of the document // create the controller object of the document
$oDocumentController = &getController('document'); $oDocumentController = getController('document');
// create the model object of the document // create the model object of the document
$oDocumentModel = &getModel('document'); $oDocumentModel = getModel('document');
// create the comment model object // create the comment model object
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
//get admin info //get admin info
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
//$oMemberModule = &getModel("member"); //$oMemberModule = getModel("member");
//$logged_info = $oMemberModule->getMemberInfoByMemberSrl($logged_member_srl); //$logged_info = $oMemberModule->getMemberInfoByMemberSrl($logged_member_srl);
$new_status = ($will_publish) ? "published" : "unpublished"; $new_status = ($will_publish) ? "published" : "unpublished";
foreach($comment_srl_list as $comment_srl) foreach($comment_srl_list as $comment_srl)
{ {
// check if comment already exists // check if comment already exists
$comment = $oCommentModel->getComment($comment_srl); $comment = $oCommentModel->getComment($comment_srl);
if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); if($comment->comment_srl != $comment_srl)
{
return new Object(-1, 'msg_invalid_request');
}
$document_srl = $comment->document_srl; $document_srl = $comment->document_srl;
if(!in_array($document_srl,$updated_documents_arr)) if(!in_array($document_srl, $updated_documents_arr))
{ {
$updated_documents_arr[] = $document_srl; $updated_documents_arr[] = $document_srl;
// update the number of comments // update the number of comments
$comment_count = $oCommentModel->getCommentCount($document_srl); $comment_count = $oCommentModel->getCommentCount($document_srl);
// update comment count of the article posting // update comment count of the article posting
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false); $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, NULL, FALSE);
$oDocument = $oDocumentModel->getDocument($document_srl); $oDocument = $oDocumentModel->getDocument($document_srl);
$author_email=$oDocument->variables['email_address']; $author_email = $oDocument->variables['email_address'];
$oModuleModel = &getModel("module"); $oModuleModel = getModel("module");
$module_info = $oModuleModel->getModuleInfoByModuleSrl($comment->module_srl); $module_info = $oModuleModel->getModuleInfoByModuleSrl($comment->module_srl);
$already_sent = array(); $already_sent = array();
// send email to comment's author, all admins and thread(document) subscribers - START // send email to comment's author, all admins and thread(document) subscribers - START
// ------------------------------------------------------- // -------------------------------------------------------
$oMail = new Mail(); $oMail = new Mail();
$mail_title = "[XE - ".$module_info->mid."] comment(s) status changed to ".$new_status." on document: \"".$oDocument->getTitleText()."\""; $mail_title = "[XE - " . $module_info->mid . "] comment(s) status changed to " . $new_status . " on document: \"" . $oDocument->getTitleText() . "\"";
$oMail->setTitle($mail_title); $oMail->setTitle($mail_title);
$mail_content = " $mail_content = "
The comment #".$comment_srl." on document \"".$oDocument->getTitleText()."\" has been ".$new_status." by admin of <strong><i>". strtoupper($module_info->mid)."</i></strong> module. The comment #" . $comment_srl . " on document \"" . $oDocument->getTitleText() . "\" has been " . $new_status . " by admin of <strong><i>" . strtoupper($module_info->mid) . "</i></strong> module.
<br /> <br />
<br />Comment content: <br />Comment content:
".$comment->content." " . $comment->content . "
<br /> <br />
"; ";
$oMail->setContent($mail_content); $oMail->setContent($mail_content);
@ -130,15 +138,17 @@ class commentAdminController extends comment
$already_sent[] = $document_author_email; $already_sent[] = $document_author_email;
} }
//mail to author of thread - STOP //mail to author of thread - STOP
//mail to all emails set for administrators - START //mail to all emails set for administrators - START
if($module_info->admin_mail) if($module_info->admin_mail)
{ {
$target_mail = explode(',',$module_info->admin_mail); $target_mail = explode(',', $module_info->admin_mail);
for($i=0;$i<count($target_mail);$i++) for($i = 0; $i < count($target_mail); $i++)
{ {
$email_address = trim($target_mail[$i]); $email_address = trim($target_mail[$i]);
if(!$email_address) continue; if(!$email_address)
{
continue;
}
if($author_email != $email_address) if($author_email != $email_address)
{ {
$oMail->setReceiptor($email_address, $email_address); $oMail->setReceiptor($email_address, $email_address);
@ -152,7 +162,7 @@ class commentAdminController extends comment
// send email to comment's author, all admins and thread(document) subscribers - STOP // send email to comment's author, all admins and thread(document) subscribers - STOP
} }
// call a trigger for calling "send mail to subscribers" (for moment just for forum) // call a trigger for calling "send mail to subscribers" (for moment just for forum)
ModuleHandler::triggerCall("comment.procCommentAdminChangeStatus","after",$comment_srl_list); ModuleHandler::triggerCall("comment.procCommentAdminChangeStatus", "after", $comment_srl_list);
} }
} }
@ -166,70 +176,99 @@ class commentAdminController extends comment
// Error display if none is selected // Error display if none is selected
$cart = Context::get('cart'); $cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null'); if(!$cart)
if(!is_array($cart)) $comment_srl_list= explode('|@|', $cart); {
else $comment_srl_list = $cart; return $this->stop('msg_cart_is_null');
}
if(!is_array($cart))
{
$comment_srl_list = explode('|@|', $cart);
}
else
{
$comment_srl_list = $cart;
}
$comment_count = count($comment_srl_list); $comment_count = count($comment_srl_list);
if(!$comment_count) return $this->stop('msg_cart_is_null'); if(!$comment_count)
{
return $this->stop('msg_cart_is_null');
}
$oCommentController = &getController('comment'); $oCommentController = getController('comment');
// begin transaction // begin transaction
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
$oDB->begin(); $oDB->begin();
// for message send - start // for message send - start
$message_content = Context::get('message_content'); $message_content = Context::get('message_content');
if($message_content) $message_content = nl2br($message_content); if($message_content)
{
$message_content = nl2br($message_content);
}
if($message_content) if($message_content)
{ {
$oCommunicationController = &getController('communication'); $oCommunicationController = getController('communication');
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
$title = cut_str($message_content,10,'...'); $title = cut_str($message_content, 10, '...');
$sender_member_srl = $logged_info->member_srl; $sender_member_srl = $logged_info->member_srl;
for($i=0;$i<$comment_count;$i++) for($i = 0; $i < $comment_count; $i++)
{ {
$comment_srl = $comment_srl_list[$i]; $comment_srl = $comment_srl_list[$i];
$oComment = $oCommentModel->getComment($comment_srl, true); $oComment = $oCommentModel->getComment($comment_srl, TRUE);
if(!$oComment->get('member_srl') || $oComment->get('member_srl')==$sender_member_srl) continue; if(!$oComment->get('member_srl') || $oComment->get('member_srl') == $sender_member_srl)
{
continue;
}
$content = sprintf("<div>%s</div><hr /><div style=\"font-weight:bold\">%s</div>",$message_content, $oComment->getContentText(20)); $content = sprintf("<div>%s</div><hr /><div style=\"font-weight:bold\">%s</div>", $message_content, $oComment->getContentText(20));
$oCommunicationController->sendMessage($sender_member_srl, $oComment->get('member_srl'), $title, $content, false); $oCommunicationController->sendMessage($sender_member_srl, $oComment->get('member_srl'), $title, $content, FALSE);
} }
} }
// for message send - end // for message send - end
// comment into trash // comment into trash
if($isTrash == 'true') $this->_moveCommentToTrash($comment_srl_list, $oCommentController, $oDB); if($isTrash == 'true')
{
$this->_moveCommentToTrash($comment_srl_list, $oCommentController, $oDB);
}
$deleted_count = 0; $deleted_count = 0;
// Delete the comment posting // Delete the comment posting
for($i=0;$i<$comment_count;$i++) for($i = 0; $i < $comment_count; $i++)
{ {
$comment_srl = trim($comment_srl_list[$i]); $comment_srl = trim($comment_srl_list[$i]);
if(!$comment_srl) continue; if(!$comment_srl)
{
continue;
}
$output = $oCommentController->deleteComment($comment_srl, true, $isTrash); $output = $oCommentController->deleteComment($comment_srl, TRUE, $isTrash);
if(!$output->toBool()) if(!$output->toBool())
{ {
$oDB->rollback(); $oDB->rollback();
return $output; return $output;
} }
$deleted_count ++; $deleted_count++;
} }
$oDB->commit(); $oDB->commit();
$msgCode = ''; $msgCode = '';
if($isTrash == 'true') $msgCode = 'success_trashed'; if($isTrash == 'true')
else $msgCode = 'success_deleted'; {
$msgCode = 'success_trashed';
}
else
{
$msgCode = 'success_deleted';
}
//$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) ); //$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
$this->setMessage($msgCode, 'info'); $this->setMessage($msgCode, 'info');
@ -238,7 +277,7 @@ class commentAdminController extends comment
$search_target = Context::get('search_target'); $search_target = Context::get('search_target');
$page = Context::get('page'); $page = Context::get('page');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', $search_keyword, 'search_target', $search_target,'page',$page); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_keyword', $search_keyword, 'search_target', $search_target, 'page', $page);
$this->setRedirectUrl($returnUrl); $this->setRedirectUrl($returnUrl);
} }
@ -248,16 +287,16 @@ class commentAdminController extends comment
*/ */
function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB) function _moveCommentToTrash($commentSrlList, &$oCommentController, &$oDB)
{ {
require_once(_XE_PATH_.'modules/trash/model/TrashVO.php'); require_once(_XE_PATH_ . 'modules/trash/model/TrashVO.php');
if(is_array($commentSrlList)) if(is_array($commentSrlList))
{ {
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
$commentItemList = $oCommentModel->getComments($commentSrlList); $commentItemList = $oCommentModel->getComments($commentSrlList);
$oTrashAdminController = &getAdminController('trash'); $oTrashAdminController = getAdminController('trash');
foreach($commentItemList AS $key=>$oComment) foreach($commentItemList AS $key => $oComment)
{ {
$oTrashVO = new TrashVO(); $oTrashVO = new TrashVO();
$oTrashVO->setTrashSrl(getNextSequence()); $oTrashVO->setTrashSrl(getNextSequence());
@ -285,9 +324,13 @@ class commentAdminController extends comment
if($comment_srl) if($comment_srl)
{ {
$args = new stdClass();
$args->comment_srl = $comment_srl; $args->comment_srl = $comment_srl;
$output = executeQuery('comment.deleteDeclaredComments', $args); $output = executeQuery('comment.deleteDeclaredComments', $args);
if(!$output->toBool()) return $output; if(!$output->toBool())
{
return $output;
}
} }
} }
@ -297,9 +340,9 @@ class commentAdminController extends comment
*/ */
function procCommentAdminAddCart() function procCommentAdminAddCart()
{ {
$comment_srl = (int)Context::get('comment_srl'); $comment_srl = (int) Context::get('comment_srl');
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
$columnList = array('comment_srl'); $columnList = array('comment_srl');
$commentSrlList = array($comment_srl); $commentSrlList = array($comment_srl);
@ -307,10 +350,16 @@ class commentAdminController extends comment
if(is_array($output)) if(is_array($output))
{ {
foreach($output AS $key=>$value) foreach($output AS $key => $value)
{ {
if($_SESSION['comment_management'][$key]) unset($_SESSION['comment_management'][$key]); if($_SESSION['comment_management'][$key])
else $_SESSION['comment_management'][$key] = true; {
unset($_SESSION['comment_management'][$key]);
}
else
{
$_SESSION['comment_management'][$key] = TRUE;
}
} }
} }
} }
@ -324,12 +373,15 @@ class commentAdminController extends comment
$args = new stdClass(); $args = new stdClass();
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
$output = executeQuery('comment.deleteModuleComments', $args); $output = executeQuery('comment.deleteModuleComments', $args);
if(!$output->toBool()) return $output; if(!$output->toBool())
{
return $output;
}
$output = executeQuery('comment.deleteModuleCommentsList', $args); $output = executeQuery('comment.deleteModuleCommentsList', $args);
//remove from cache //remove from cache
$oCacheHandler = &CacheHandler::getInstance('object'); $oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()) if($oCacheHandler->isSupport())
{ {
// Invalidate newest comments. Per document cache is invalidated inside document admin controller. // Invalidate newest comments. Per document cache is invalidated inside document admin controller.
@ -345,7 +397,10 @@ class commentAdminController extends comment
*/ */
function restoreTrash($originObject) function restoreTrash($originObject)
{ {
if(is_array($originObject)) $originObject = (object)$originObject; if(is_array($originObject))
{
$originObject = (object) $originObject;
}
$obj = new stdClass(); $obj = new stdClass();
$obj->document_srl = $originObject->document_srl; $obj->document_srl = $originObject->document_srl;
@ -361,7 +416,7 @@ class commentAdminController extends comment
$obj->notify_message = $originObject->notify_message; $obj->notify_message = $originObject->notify_message;
$obj->module_srl = $originObject->module_srl; $obj->module_srl = $originObject->module_srl;
$oCommentController = &getController('comment'); $oCommentController = getController('comment');
$output = $oCommentController->insertComment($obj); $output = $oCommentController->insertComment($obj);
return $output; return $output;
@ -375,16 +430,20 @@ class commentAdminController extends comment
function emptyTrash($originObject) function emptyTrash($originObject)
{ {
$originObject = unserialize($originObject); $originObject = unserialize($originObject);
if(is_array($originObject)) $originObject = (object) $originObject; if(is_array($originObject))
{
$originObject = (object) $originObject;
}
$oComment = new commentItem(); $oComment = new commentItem();
$oComment->setAttribute($originObject); $oComment->setAttribute($originObject);
//already comment deleted, therefore only comment log delete //already comment deleted, therefore only comment log delete
$oCommentController = &getController('comment'); $oCommentController = getController('comment');
$output = $oCommentController->deleteCommentLog($oComment->get('comment_srl')); $output = $oCommentController->deleteCommentLog($oComment->get('comment_srl'));
return $output; return $output;
} }
} }
/* End of file comment.admin.controller.php */ /* End of file comment.admin.controller.php */
/* Location: ./modules/comment/comment.admin.controller.php */ /* Location: ./modules/comment/comment.admin.controller.php */

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* commentAdminView class * commentAdminView class
* admin view class of the comment module * admin view class of the comment module
@ -9,12 +10,14 @@
*/ */
class commentAdminView extends comment class commentAdminView extends comment
{ {
/** /**
* Initialization * Initialization
* @return void * @return void
*/ */
function init() function init()
{ {
} }
/** /**
@ -33,25 +36,25 @@ class commentAdminView extends comment
$args->module_srl = Context::get('module_srl'); $args->module_srl = Context::get('module_srl');
/* /*
$search_target = Context::get('search_target'); $search_target = Context::get('search_target');
$search_keyword = Context::get('search_keyword'); $search_keyword = Context::get('search_keyword');
if ($search_target == 'is_published' && $search_keyword == 'Y') if ($search_target == 'is_published' && $search_keyword == 'Y')
{ {
$args->status = 1; $args->status = 1;
} }
if ($search_target == 'is_published' && $search_keyword == 'N') if ($search_target == 'is_published' && $search_keyword == 'N')
{ {
$args->status = 0; $args->status = 0;
} }
*/ */
// get a list by using comment->getCommentList. // get a list by using comment->getCommentList.
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
$secretNameList = $oCommentModel->getSecretNameList(); $secretNameList = $oCommentModel->getSecretNameList();
$columnList = array('comment_srl', 'document_srl', 'is_secret', 'status', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress', 'voted_count', 'blamed_count'); $columnList = array('comment_srl', 'document_srl', 'is_secret', 'status', 'content', 'comments.member_srl', 'comments.nick_name', 'comments.regdate', 'ipaddress', 'voted_count', 'blamed_count');
$output = $oCommentModel->getTotalCommentList($args, $columnList); $output = $oCommentModel->getTotalCommentList($args, $columnList);
$oCommentModel = &getModel("comment"); $oCommentModel = getModel("comment");
$modules = $oCommentModel->getDistinctModules(); $modules = $oCommentModel->getDistinctModules();
$modules_list = $modules; $modules_list = $modules;
@ -64,7 +67,7 @@ class commentAdminView extends comment
Context::set('page_navigation', $output->page_navigation); Context::set('page_navigation', $output->page_navigation);
Context::set('secret_name_list', $secretNameList); Context::set('secret_name_list', $secretNameList);
// set the template // set the template
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path . 'tpl');
$this->setTemplateFile('comment_list'); $this->setTemplateFile('comment_list');
} }
@ -75,17 +78,16 @@ class commentAdminView extends comment
function dispCommentAdminDeclared() function dispCommentAdminDeclared()
{ {
// option to get a blacklist // option to get a blacklist
$args = new stdClass(); $args = new stdClass();
$args->page = Context::get('page'); // /< Page $args->page = Context::get('page'); // /< Page
$args->list_count = 30; // /< the number of comment postings to appear on a single page $args->list_count = 30; // /< the number of comment postings to appear on a single page
$args->page_count = 10; // /< the number of pages to appear on the page navigation $args->page_count = 10; // /< the number of pages to appear on the page navigation
$args->sort_index = 'comment_declared.declared_count'; // /< sorting values $args->sort_index = 'comment_declared.declared_count'; // /< sorting values
$args->order_type = 'desc'; // /< sorted value $args->order_type = 'desc'; // /< sorted value
// get a list // get a list
$declared_output = executeQuery('comment.getDeclaredList', $args); $declared_output = executeQuery('comment.getDeclaredList', $args);
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
if($declared_output->data && count($declared_output->data)) if($declared_output->data && count($declared_output->data))
{ {
@ -109,9 +111,10 @@ class commentAdminView extends comment
Context::set('page_navigation', $declared_output->page_navigation); Context::set('page_navigation', $declared_output->page_navigation);
Context::set('secret_name_list', $secretNameList); Context::set('secret_name_list', $secretNameList);
// set the template // set the template
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path . 'tpl');
$this->setTemplateFile('declared_list'); $this->setTemplateFile('declared_list');
} }
} }
/* End of file comment.admin.view.php */ /* End of file comment.admin.view.php */
/* Location: ./modules/comment/comment.admin.view.php */ /* Location: ./modules/comment/comment.admin.view.php */

View file

@ -1,5 +1,7 @@
<?php <?php
require_once(_XE_PATH_.'modules/comment/comment.item.php');
require_once(_XE_PATH_ . 'modules/comment/comment.item.php');
/** /**
* comment * comment
* comment module's high class * comment module's high class
@ -10,24 +12,21 @@ require_once(_XE_PATH_.'modules/comment/comment.item.php');
*/ */
class comment extends ModuleObject class comment extends ModuleObject
{ {
/** /**
* Implemented if additional tasks are required when installing * Implemented if additional tasks are required when installing
* @return Object * @return Object
*/ */
function moduleInstall() function moduleInstall()
{ {
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
// register the action forward (for using on the admin mode) // register the action forward (for using on the admin mode)
$oModuleController = &getController('module'); $oModuleController = getController('module');
$oDB->addIndex $oDB->addIndex(
( "comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE
"comments", );
"idx_module_list_order",
array("module_srl", "list_order"),
true
);
// 2007. 10. 17 add a trigger to delete comments together with posting deleted // 2007. 10. 17 add a trigger to delete comments together with posting deleted
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); $oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
@ -45,37 +44,63 @@ class comment extends ModuleObject
*/ */
function checkUpdate() function checkUpdate()
{ {
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
$oModuleModel = &getModel('module'); $oModuleModel = getModel('module');
// 2007. 10. 17 add a trigger to delete comments together with posting deleted // 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) return true; if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
{
return TRUE;
}
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) return true; if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
{
return TRUE;
}
// 2007. 10. 23 add a column for recommendation votes or notification of the comments // 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments","voted_count")) return true; if(!$oDB->isColumnExists("comments", "voted_count"))
if(!$oDB->isColumnExists("comments","notify_message")) return true; {
return TRUE;
}
if(!$oDB->isColumnExists("comments", "notify_message"))
{
return TRUE;
}
// 2008. 02. 22 add comment setting when a new module added // 2008. 02. 22 add comment setting when a new module added
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) return true; if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
{
return TRUE;
}
// 2008. 05. 14 add a column for blamed count // 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) return true; if(!$oDB->isColumnExists("comments", "blamed_count"))
if(!$oDB->isColumnExists("comment_voted_log", "point")) return true; {
return TRUE;
}
if(!$oDB->isColumnExists("comment_voted_log", "point"))
{
return TRUE;
}
if (!$oDB->isIndexExists("comments", "idx_module_list_order")) if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
return true; {
return TRUE;
}
//2012. 02. 24 add comment published status column and index //2012. 02. 24 add comment published status column and index
if(!$oDB->isColumnExists("comments", "status")) if(!$oDB->isColumnExists("comments", "status"))
{ {
return true; return TRUE;
} }
if (!$oDB->isIndexExists("comments", "idx_status")) if(!$oDB->isIndexExists("comments", "idx_status"))
{ {
return true; return TRUE;
} }
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) return true; if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'))
{
return TRUE;
}
return false; return FALSE;
} }
/** /**
@ -84,63 +109,63 @@ class comment extends ModuleObject
*/ */
function moduleUpdate() function moduleUpdate()
{ {
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
$oModuleModel = &getModel('module'); $oModuleModel = getModel('module');
$oModuleController = &getController('module'); $oModuleController = getController('module');
// 2007. 10. 17 add a trigger to delete comments together with posting deleted // 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
{
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); $oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
}
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted // 2007. 10. 17 add a trigger to delete all of comments together with module deleted
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments","voted_count"))
{ {
$oDB->addColumn("comments","voted_count", "number","11"); $oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
$oDB->addIndex("comments","idx_voted_count", array("voted_count")); }
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments", "voted_count"))
{
$oDB->addColumn("comments", "voted_count", "number", "11");
$oDB->addIndex("comments", "idx_voted_count", array("voted_count"));
} }
if(!$oDB->isColumnExists("comments","notify_message")) if(!$oDB->isColumnExists("comments", "notify_message"))
{ {
$oDB->addColumn("comments","notify_message", "char","1"); $oDB->addColumn("comments", "notify_message", "char", "1");
} }
// 2008. 02. 22 add comment setting when a new module added // 2008. 02. 22 add comment setting when a new module added
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
{
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'); $oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
}
// 2008. 05. 14 add a column for blamed count // 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) if(!$oDB->isColumnExists("comments", "blamed_count"))
{ {
$oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, true); $oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, TRUE);
$oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count')); $oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count'));
} }
if(!$oDB->isColumnExists("comment_voted_log", "point")) if(!$oDB->isColumnExists("comment_voted_log", "point"))
$oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, true); {
$oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, TRUE);
}
if(!$oDB->isIndexExists("comments", "idx_module_list_order")) if(!$oDB->isIndexExists("comments", "idx_module_list_order"))
{ {
$oDB->addIndex $oDB->addIndex(
( "comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE
"comments", );
"idx_module_list_order",
array("module_srl", "list_order"),
true
);
} }
//2012. 02. 24 add comment published status column and index //2012. 02. 24 add comment published status column and index
if(!$oDB->isColumnExists("comments", "status")) if(!$oDB->isColumnExists("comments", "status"))
{ {
$oDB->addColumn("comments", "status", "number", 1, 1, true); $oDB->addColumn("comments", "status", "number", 1, 1, TRUE);
} }
if(!$oDB->isIndexExists("comments", "idx_status")) if(!$oDB->isIndexExists("comments", "idx_status"))
{ {
$oDB->addIndex $oDB->addIndex(
( "comments", "idx_status", array("status", "comment_srl", "module_srl", "document_srl"), TRUE
"comments", );
"idx_status",
array("status", "comment_srl", "module_srl", "document_srl"),
true
);
} }
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
@ -158,7 +183,9 @@ class comment extends ModuleObject
*/ */
function recompileCache() function recompileCache()
{ {
} }
} }
/* End of file comment.class.php */ /* End of file comment.class.php */
/* Location: ./modules/comment/comment.class.php */ /* Location: ./modules/comment/comment.class.php */

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* commentItem class * commentItem class
* comment Object * comment Object
@ -9,11 +10,13 @@
*/ */
class commentItem extends Object class commentItem extends Object
{ {
/** /**
* comment number * comment number
* @var int * @var int
*/ */
var $comment_srl = 0; var $comment_srl = 0;
/** /**
* Get the column list int the table * Get the column list int the table
* @var array * @var array
@ -45,9 +48,12 @@ class commentItem extends Object
*/ */
function _loadFromDB() function _loadFromDB()
{ {
if(!$this->comment_srl) return; if(!$this->comment_srl)
{
return;
}
$args =new stdClass(); $args = new stdClass();
$args->comment_srl = $this->comment_srl; $args->comment_srl = $this->comment_srl;
$output = executeQuery('comment.getComment', $args, $this->columnList); $output = executeQuery('comment.getComment', $args, $this->columnList);
@ -62,83 +68,112 @@ class commentItem extends Object
{ {
if(!$attribute->comment_srl) if(!$attribute->comment_srl)
{ {
$this->comment_srl = null; $this->comment_srl = NULL;
return; return;
} }
$this->comment_srl = $attribute->comment_srl; $this->comment_srl = $attribute->comment_srl;
$this->adds($attribute); $this->adds($attribute);
// define vars on the object for backward compatibility of skins // define vars on the object for backward compatibility of skins
if(count($attribute)) foreach($attribute as $key => $val) $this->{$key} = $val; if(count($attribute))
{
foreach($attribute as $key => $val)
{
$this->{$key} = $val;
}
}
} }
function isExists() function isExists()
{ {
return $this->comment_srl ? true : false; return $this->comment_srl ? TRUE : FALSE;
} }
function isGranted() function isGranted()
{ {
if($_SESSION['own_comment'][$this->comment_srl]) return true; if($_SESSION['own_comment'][$this->comment_srl])
{
return TRUE;
}
if(!Context::get('is_logged')) return false; if(!Context::get('is_logged'))
{
return FALSE;
}
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y') return true; if($logged_info->is_admin == 'Y')
{
return TRUE;
}
$grant = Context::get('grant'); $grant = Context::get('grant');
if($grant->manager) return true; if($grant->manager)
{
return TRUE;
}
if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true; if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl))
{
return TRUE;
}
return false; return FALSE;
} }
function setGrant() function setGrant()
{ {
$_SESSION['own_comment'][$this->comment_srl] = true; $_SESSION['own_comment'][$this->comment_srl] = TRUE;
$this->is_granted = true; $this->is_granted = TRUE;
} }
function setAccessible() function setAccessible()
{ {
$_SESSION['accessibled_comment'][$this->comment_srl] = true; $_SESSION['accessibled_comment'][$this->comment_srl] = TRUE;
} }
function isEditable() function isEditable()
{ {
if($this->isGranted() || !$this->get('member_srl')) return true; if($this->isGranted() || !$this->get('member_srl'))
return false; {
return TRUE;
}
return FALSE;
} }
function isSecret() function isSecret()
{ {
return $this->get('is_secret') == 'Y' ? true : false; return $this->get('is_secret') == 'Y' ? TRUE : FALSE;
} }
function isAccessible() function isAccessible()
{ {
if($_SESSION['accessibled_comment'][$this->comment_srl]) return true; if($_SESSION['accessibled_comment'][$this->comment_srl])
{
return TRUE;
}
if($this->isGranted() || !$this->isSecret()) if($this->isGranted() || !$this->isSecret())
{ {
$this->setAccessible(); $this->setAccessible();
return true; return TRUE;
} }
$oDocumentModel = &getModel('document'); $oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl')); $oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
if($oDocument->isGranted()) if($oDocument->isGranted())
{ {
$this->setAccessible(); $this->setAccessible();
return true; return TRUE;
} }
return false; return FALSE;
} }
function useNotify() function useNotify()
{ {
return $this->get('notify_message')=='Y' ? true : false; return $this->get('notify_message') == 'Y' ? TRUE : FALSE;
} }
/** /**
@ -148,44 +183,76 @@ class commentItem extends Object
function notify($type, $content) function notify($type, $content)
{ {
// return if not useNotify // return if not useNotify
if(!$this->useNotify()) return; if(!$this->useNotify())
{
return;
}
// pass if the author is not logged-in user // pass if the author is not logged-in user
if(!$this->get('member_srl')) return; if(!$this->get('member_srl'))
{
return;
}
// return if the currently logged-in user is an author of the comment. // return if the currently logged-in user is an author of the comment.
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
if($logged_info->member_srl == $this->get('member_srl')) return; if($logged_info->member_srl == $this->get('member_srl'))
{
return;
}
// get where the comment belongs to // get where the comment belongs to
$oDocumentModel = &getModel('document'); $oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl')); $oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
// Variables // Variables
if($type) $title = "[".$type."] "; if($type)
{
$title = "[" . $type . "] ";
}
$title .= cut_str(strip_tags($content), 30, '...'); $title .= cut_str(strip_tags($content), 30, '...');
$content = sprintf('%s<br /><br />from : <a href="%s#comment_%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->get('document_srl')), $this->get('comment_srl'), getFullUrl('','document_srl',$this->get('document_srl'))); $content = sprintf('%s<br /><br />from : <a href="%s#comment_%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->get('document_srl')), $this->get('comment_srl'), getFullUrl('', 'document_srl', $this->get('document_srl')));
$receiver_srl = $this->get('member_srl'); $receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl; $sender_member_srl = $logged_info->member_srl;
// send a message // send a message
$oCommunicationController = &getController('communication'); $oCommunicationController = getController('communication');
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false); $oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, FALSE);
} }
function getIpAddress() function getIpAddress()
{ {
if($this->isGranted()) return $this->get('ipaddress'); if($this->isGranted())
return preg_replace('/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/','*.$2.$3.$4', $this->get('ipaddress')); {
return $this->get('ipaddress');
}
return preg_replace('/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/', '*.$2.$3.$4', $this->get('ipaddress'));
} }
function isExistsHomepage() function isExistsHomepage()
{ {
if(trim($this->get('homepage'))) return true; if(trim($this->get('homepage')))
return false; {
return TRUE;
}
return FALSE;
} }
function getHomepageUrl() function getHomepageUrl()
{ {
$url = trim($this->get('homepage')); $url = trim($this->get('homepage'));
if(!$url) return; if(!$url)
{
return;
}
if(!preg_match("/^http:\/\//i",$url)) $url = "http://".$url; if(!preg_match("/^http:\/\//i", $url))
{
$url = "http://" . $url;
}
return $url; return $url;
} }
@ -216,11 +283,17 @@ class commentItem extends Object
*/ */
function getContentText($strlen = 0) function getContentText($strlen = 0)
{ {
if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); if($this->isSecret() && !$this->isAccessible())
{
return Context::getLang('msg_is_secret');
}
$content = $this->get('content'); $content = $this->get('content');
if($strlen) return cut_str(strip_tags($content),$strlen,'...'); if($strlen)
{
return cut_str(strip_tags($content), $strlen, '...');
}
return htmlspecialchars($content); return htmlspecialchars($content);
} }
@ -229,21 +302,24 @@ class commentItem extends Object
* Return content after filter * Return content after filter
* @return string * @return string
*/ */
function getContent($add_popup_menu = true, $add_content_info = true, $add_xe_content_class = true) function getContent($add_popup_menu = TRUE, $add_content_info = TRUE, $add_xe_content_class = TRUE)
{ {
if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); if($this->isSecret() && !$this->isAccessible())
{
return Context::getLang('msg_is_secret');
}
$content = $this->get('content'); $content = $this->get('content');
stripEmbedTagForAdmin($content, $this->get('member_srl')); stripEmbedTagForAdmin($content, $this->get('member_srl'));
// when displaying the comment on the pop-up menu // when displaying the comment on the pop-up menu
if($add_popup_menu && Context::get('is_logged') ) if($add_popup_menu && Context::get('is_logged'))
{ {
$content = sprintf( $content = sprintf(
'%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>', '%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>', $content, $this->comment_srl, Context::getLang('cmd_comment_do')
$content, );
$this->comment_srl, Context::getLang('cmd_comment_do')
);
} }
// if additional information which can access contents is set // if additional information which can access contents is set
if($add_content_info) if($add_content_info)
{ {
@ -253,17 +329,16 @@ class commentItem extends Object
$memberSrl = 0; $memberSrl = 0;
} }
$content = sprintf( $content = sprintf(
'<!--BeforeComment(%d,%d)--><div class="comment_%d_%d xe_content">%s</div><!--AfterComment(%d,%d)-->', '<!--BeforeComment(%d,%d)--><div class="comment_%d_%d xe_content">%s</div><!--AfterComment(%d,%d)-->', $this->comment_srl, $memberSrl, $this->comment_srl, $memberSrl, $content, $this->comment_srl, $memberSrl
$this->comment_srl, $memberSrl, );
$this->comment_srl, $memberSrl,
$content,
$this->comment_srl, $memberSrl
);
// xe_content class name should be specified although content access is not necessary. // xe_content class name should be specified although content access is not necessary.
} }
else else
{ {
if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content); if($add_xe_content_class)
{
$content = sprintf('<div class="xe_content">%s</div>', $content);
}
} }
return $content; return $content;
@ -275,21 +350,28 @@ class commentItem extends Object
*/ */
function getSummary($str_size = 50, $tail = '...') function getSummary($str_size = 50, $tail = '...')
{ {
$content = $this->getContent(false, false); $content = $this->getContent(FALSE, FALSE);
// for newline, insert a blank. // for newline, insert a blank.
$content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content); $content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content);
// replace tags such as </p> , </div> , </li> by blanks. // replace tags such as </p> , </div> , </li> by blanks.
$content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content); $content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content);
// Remove tags // Remove tags
$content = preg_replace('!<([^>]*?)>!is','', $content); $content = preg_replace('!<([^>]*?)>!is', '', $content);
// replace < , >, " // replace < , >, "
$content = str_replace(array('&lt;','&gt;','&quot;','&nbsp;'), array('<','>','"',' '), $content); $content = str_replace(array('&lt;', '&gt;', '&quot;', '&nbsp;'), array('<', '>', '"', ' '), $content);
// delete a series of blanks // delete a series of blanks
$content = preg_replace('/ ( +)/is', ' ', $content); $content = preg_replace('/ ( +)/is', ' ', $content);
// truncate strings // truncate strings
$content = trim(cut_str($content, $str_size, $tail)); $content = trim(cut_str($content, $str_size, $tail));
// restore >, <, , "\ // restore >, <, , "\
$content = str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'), $content); $content = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $content);
return $content; return $content;
} }
@ -302,18 +384,18 @@ class commentItem extends Object
function getRegdateTime() function getRegdateTime()
{ {
$regdate = $this->get('regdate'); $regdate = $this->get('regdate');
$year = substr($regdate,0,4); $year = substr($regdate, 0, 4);
$month = substr($regdate,4,2); $month = substr($regdate, 4, 2);
$day = substr($regdate,6,2); $day = substr($regdate, 6, 2);
$hour = substr($regdate,8,2); $hour = substr($regdate, 8, 2);
$min = substr($regdate,10,2); $min = substr($regdate, 10, 2);
$sec = substr($regdate,12,2); $sec = substr($regdate, 12, 2);
return mktime($hour,$min,$sec,$month,$day,$year); return mktime($hour, $min, $sec, $month, $day, $year);
} }
function getRegdateGM() function getRegdateGM()
{ {
return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone']; return $this->getRegdate('D, d M Y H:i:s') . ' ' . $GLOBALS['_time_zone'];
} }
function getUpdate($format = 'Y.m.d H:i:s') function getUpdate($format = 'Y.m.d H:i:s')
@ -323,18 +405,18 @@ class commentItem extends Object
function getPermanentUrl() function getPermanentUrl()
{ {
return getFullUrl('','document_srl',$this->get('document_srl')).'#comment_'.$this->get('comment_srl'); return getFullUrl('', 'document_srl', $this->get('document_srl')) . '#comment_' . $this->get('comment_srl');
} }
function getUpdateTime() function getUpdateTime()
{ {
$year = substr($this->get('last_update'),0,4); $year = substr($this->get('last_update'), 0, 4);
$month = substr($this->get('last_update'),4,2); $month = substr($this->get('last_update'), 4, 2);
$day = substr($this->get('last_update'),6,2); $day = substr($this->get('last_update'), 6, 2);
$hour = substr($this->get('last_update'),8,2); $hour = substr($this->get('last_update'), 8, 2);
$min = substr($this->get('last_update'),10,2); $min = substr($this->get('last_update'), 10, 2);
$sec = substr($this->get('last_update'),12,2); $sec = substr($this->get('last_update'), 12, 2);
return mktime($hour,$min,$sec,$month,$day,$year); return mktime($hour, $min, $sec, $month, $day, $year);
} }
function getUpdateGM() function getUpdateGM()
@ -344,17 +426,27 @@ class commentItem extends Object
function hasUploadedFiles() function hasUploadedFiles()
{ {
if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return false; if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
return $this->get('uploaded_count')? true : false; {
return FALSE;
}
return $this->get('uploaded_count') ? TRUE : FALSE;
} }
function getUploadedFiles() function getUploadedFiles()
{ {
if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted()) return; if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
if(!$this->get('uploaded_count')) return; {
return;
}
$oFileModel = &getModel('file'); if(!$this->get('uploaded_count'))
$file_list = $oFileModel->getFiles($this->comment_srl, array(), 'file_srl', true); {
return;
}
$oFileModel = getModel('file');
$file_list = $oFileModel->getFiles($this->comment_srl, array(), 'file_srl', TRUE);
return $file_list; return $file_list;
} }
@ -365,8 +457,11 @@ class commentItem extends Object
function getEditor() function getEditor()
{ {
$module_srl = $this->get('module_srl'); $module_srl = $this->get('module_srl');
if(!$module_srl) $module_srl = Context::get('module_srl'); if(!$module_srl)
$oEditorModel = &getModel('editor'); {
$module_srl = Context::get('module_srl');
}
$oEditorModel = getModel('editor');
return $oEditorModel->getModuleEditor('comment', $module_srl, $this->comment_srl, 'comment_srl', 'content'); return $oEditorModel->getModuleEditor('comment', $module_srl, $this->comment_srl, 'comment_srl', 'content');
} }
@ -376,10 +471,16 @@ class commentItem extends Object
*/ */
function getProfileImage() function getProfileImage()
{ {
if(!$this->isExists() || !$this->get('member_srl')) return; if(!$this->isExists() || !$this->get('member_srl'))
$oMemberModel = &getModel('member'); {
return;
}
$oMemberModel = getModel('member');
$profile_info = $oMemberModel->getProfileImage($this->get('member_srl')); $profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
if(!$profile_info) return; if(!$profile_info)
{
return;
}
return $profile_info->src; return $profile_info->src;
} }
@ -391,53 +492,96 @@ class commentItem extends Object
function getSignature() function getSignature()
{ {
// pass if the posting not exists. // pass if the posting not exists.
if(!$this->isExists() || !$this->get('member_srl')) return; if(!$this->isExists() || !$this->get('member_srl'))
{
return;
}
// get the signiture information // get the signiture information
$oMemberModel = &getModel('member'); $oMemberModel = getModel('member');
$signature = $oMemberModel->getSignature($this->get('member_srl')); $signature = $oMemberModel->getSignature($this->get('member_srl'));
// check if max height of the signiture is specified on the member module // check if max height of the signiture is specified on the member module
if(!isset($GLOBALS['__member_signature_max_height'])) if(!isset($GLOBALS['__member_signature_max_height']))
{ {
$oModuleModel = &getModel('module'); $oModuleModel = getModel('module');
$member_config = $oModuleModel->getModuleConfig('member'); $member_config = $oModuleModel->getModuleConfig('member');
$GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height;
} }
$max_signature_height = $GLOBALS['__member_signature_max_height']; $max_signature_height = $GLOBALS['__member_signature_max_height'];
if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
if($max_signature_height)
{
$signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
}
return $signature; return $signature;
} }
function thumbnailExists($width = 80, $height = 0, $type = '') function thumbnailExists($width = 80, $height = 0, $type = '')
{ {
if(!$this->comment_srl) return false; if(!$this->comment_srl)
if(!$this->getThumbnail($width, $height, $type)) return false; {
return true; return FALSE;
}
if(!$this->getThumbnail($width, $height, $type))
{
return FALSE;
}
return TRUE;
} }
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
{ {
// return false if no doc exists // return false if no doc exists
if(!$this->comment_srl) return; if(!$this->comment_srl)
{
return;
}
// If signiture height setting is omitted, create a square // If signiture height setting is omitted, create a square
if(!$height) $height = $width; if(!$height)
{
$height = $width;
}
// return false if neigher attached file nor image; // return false if neigher attached file nor image;
if(!$this->hasUploadedFiles() && !preg_match("!<img!is", $this->get('content'))) return; if(!$this->hasUploadedFiles() && !preg_match("!<img!is", $this->get('content')))
{
return;
}
// get thumbail generation info on the doc module configuration. // get thumbail generation info on the doc module configuration.
if(!in_array($thumbnail_type, array('crop','ratio'))) $thumbnail_type = 'crop'; if(!in_array($thumbnail_type, array('crop', 'ratio')))
{
$thumbnail_type = 'crop';
}
// Define thumbnail information // Define thumbnail information
$thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($this->comment_srl, 3)); $thumbnail_path = sprintf('files/cache/thumbnails/%s', getNumberingPath($this->comment_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type); $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri().$thumbnail_file; $thumbnail_url = Context::getRequestUri() . $thumbnail_file;
// return false if a size of existing thumbnail file is 0. otherwise return the file path // return false if a size of existing thumbnail file is 0. otherwise return the file path
if(file_exists($thumbnail_file)) if(file_exists($thumbnail_file))
{ {
if(filesize($thumbnail_file)<1) return false; if(filesize($thumbnail_file) < 1)
else return $thumbnail_url; {
return FALSE;
}
else
{
return $thumbnail_url;
}
} }
// Target file // Target file
$source_file = null; $source_file = NULL;
$is_tmp_file = false; $is_tmp_file = FALSE;
// find an image file among attached files // find an image file among attached files
if($this->hasUploadedFiles()) if($this->hasUploadedFiles())
{ {
@ -446,41 +590,76 @@ class commentItem extends Object
{ {
foreach($file_list as $file) foreach($file_list as $file)
{ {
if($file->direct_download!='Y') continue; if($file->direct_download != 'Y')
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue; {
continue;
}
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i", $file->source_filename))
{
continue;
}
$source_file = $file->uploaded_filename; $source_file = $file->uploaded_filename;
if(!file_exists($source_file)) $source_file = null; if(!file_exists($source_file))
else break; {
$source_file = NULL;
}
else
{
break;
}
} }
} }
} }
// get an image file from the doc content if no file attached. // get an image file from the doc content if no file attached.
if(!$source_file) if(!$source_file)
{ {
$content = $this->get('content'); $content = $this->get('content');
$target_src = null; $target_src = NULL;
preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER); preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER);
$cnt = count($matches); $cnt = count($matches);
for($i=0;$i<$cnt;$i++)
for($i = 0; $i < $cnt; $i++)
{ {
$target_src = $matches[$i][2]; $target_src = $matches[$i][2];
if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue; if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src))
{
continue;
}
else else
{ {
if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src; if(!preg_match('/^(http|https):\/\//i', $target_src))
{
$target_src = Context::getRequestUri() . $target_src;
}
$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111, 999999) . $this->comment_srl));
if(!is_dir('./files/cache/tmp'))
{
FileHandler::makeDir('./files/cache/tmp');
}
$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->comment_srl));
if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp');
FileHandler::getRemoteFile($target_src, $tmp_file); FileHandler::getRemoteFile($target_src, $tmp_file);
if(!file_exists($tmp_file)) continue;
if(!file_exists($tmp_file))
{
continue;
}
else else
{ {
list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file); list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file);
if($_w<$width || $_h<$height) continue;
if($_w < $width || $_h < $height)
{
continue;
}
$source_file = $tmp_file; $source_file = $tmp_file;
$is_tmp_file = true; $is_tmp_file = TRUE;
break; break;
} }
} }
@ -489,11 +668,22 @@ class commentItem extends Object
$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
if($is_tmp_file) FileHandler::removeFile($source_file); if($is_tmp_file)
{
FileHandler::removeFile($source_file);
}
// return the thumbnail path if successfully generated. // return the thumbnail path if successfully generated.
if($output) return $thumbnail_url; if($output)
{
return $thumbnail_url;
}
// create an empty file not to attempt to generate the thumbnail afterwards // create an empty file not to attempt to generate the thumbnail afterwards
else FileHandler::writeFile($thumbnail_file, '','w'); else
{
FileHandler::writeFile($thumbnail_file, '', 'w');
}
return; return;
} }
@ -502,6 +692,7 @@ class commentItem extends Object
{ {
return $_SESSION['comment_management'][$this->comment_srl]; return $_SESSION['comment_management'][$this->comment_srl];
} }
} }
/* End of file comment.item.php */ /* End of file comment.item.php */
/* Location: ./modules/comment/comment.item.php */ /* Location: ./modules/comment/comment.item.php */

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* commentView class * commentView class
* comment module's view class * comment module's view class
@ -9,12 +10,14 @@
*/ */
class commentView extends comment class commentView extends comment
{ {
/** /**
* Initialization * Initialization
* @return void * @return void
*/ */
function init() function init()
{ {
} }
/** /**
@ -32,23 +35,30 @@ class commentView extends comment
// get information of the selected module // get information of the selected module
$current_module_info = Context::get('current_module_info'); $current_module_info = Context::get('current_module_info');
$current_module_srl = $current_module_info->module_srl; $current_module_srl = $current_module_info->module_srl;
if(!$current_module_srl) return new Object(); if(!$current_module_srl)
{
return new Object();
}
} }
// get the comment configuration // get the comment configuration
$oCommentModel = &getModel('comment'); $oCommentModel = getModel('comment');
$comment_config = $oCommentModel->getCommentConfig($current_module_srl); $comment_config = $oCommentModel->getCommentConfig($current_module_srl);
Context::set('comment_config', $comment_config); Context::set('comment_config', $comment_config);
// get a group list // get a group list
$oMemberModel = &getModel('member'); $oMemberModel = getModel('member');
$group_list = $oMemberModel->getGroups(); $group_list = $oMemberModel->getGroups();
Context::set('group_list', $group_list); Context::set('group_list', $group_list);
// Set a template file // Set a template file
$oTemplate = &TemplateHandler::getInstance(); $oTemplate = TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'comment_module_config'); $tpl = $oTemplate->compile($this->module_path . 'tpl', 'comment_module_config');
$obj .= $tpl; $obj .= $tpl;
return new Object(); return new Object();
} }
} }
/* End of file comment.view.php */ /* End of file comment.view.php */
/* Location: ./modules/comment/comment.view.php */ /* Location: ./modules/comment/comment.view.php */