[xoops-cvslog 2715] CVS update: xoops2jp/html/modules/base/admin/actions

Back to archive index

Minahito minah****@users*****
2006年 4月 11日 (火) 12:09:23 JST


Index: xoops2jp/html/modules/base/admin/actions/CommentDeleteAction.class.php
diff -u xoops2jp/html/modules/base/admin/actions/CommentDeleteAction.class.php:1.1.2.5 xoops2jp/html/modules/base/admin/actions/CommentDeleteAction.class.php:1.1.2.6
--- xoops2jp/html/modules/base/admin/actions/CommentDeleteAction.class.php:1.1.2.5	Thu Mar 30 23:56:27 2006
+++ xoops2jp/html/modules/base/admin/actions/CommentDeleteAction.class.php	Tue Apr 11 12:09:23 2006
@@ -4,9 +4,18 @@
 
 require_once XOOPS_MODULE_PATH . "/base/class/AbstractDeleteAction.class.php";
 require_once XOOPS_MODULE_PATH . "/base/admin/forms/CommentAdminDeleteForm.class.php";
+require_once XOOPS_MODULE_PATH . "/base/admin/actions/CommentEditAction.class.php";
 
 class Legacy_CommentDeleteAction extends Legacy_AbstractDeleteAction
 {
+	function prepare(&$controller, &$xoopsUser)
+	{
+		parent::prepare($controller, $xoopsUser);
+				
+		$root =& XCube_Root::getSingleton();
+		$root->mEventManager->add("Module.Legacy.Comment.Delete.Success", new XCube_InstanceDelegate($this, "doDelete"));
+	}
+	
 	function _getId()
 	{
 		return isset($_REQUEST['com_id']) ? $_REQUEST['com_id'] : 0;
@@ -62,6 +71,43 @@
 	{
 		redirect_header("./index.php?action=CommentList", 1, _AD_BASE_ERROR_DBUPDATE_FAILED);
 	}
+	
+	function doDelete(&$sender, &$eventArgs)
+	{
+		//
+		// Adjust user's post count.
+		//
+		if ($comment->get('com_status') != 1 && $comment->get('com_uid') > 0) {
+			$handler =& xoops_gethandler('member');
+
+			//
+			// TODO We should adjust the following lines and handler's design.
+			// We think we should not use getUser() and updateUserByField in XCube 2.1.
+			//
+			$user =& $handler->getUser($comment->get('com_uid'));
+			$count = $user->get('posts');
+			
+			if($count > 0) {
+				$handler->updateUserByField($user, 'posts', $count - 1);
+			}
+		}
+		
+		//
+		// callback
+		//
+		$comment =& $eventArgs['comment'];
+		$comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
+		
+		if ($comment_config == false) {
+			return;
+		}
+		
+		$function = $comment_config['callback']['update'];
+		
+		if (function_exists($function)) {
+			call_user_func($function, $comment);
+		}
+	}
 }
 
 ?>


xoops-cvslog メーリングリストの案内
Back to archive index