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

Zurück zum Archiv-Index

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


Index: xoops2jp/html/modules/base/admin/actions/CommentEditAction.class.php
diff -u xoops2jp/html/modules/base/admin/actions/CommentEditAction.class.php:1.1.2.6 xoops2jp/html/modules/base/admin/actions/CommentEditAction.class.php:1.1.2.7
--- xoops2jp/html/modules/base/admin/actions/CommentEditAction.class.php:1.1.2.6	Thu Mar 30 23:56:54 2006
+++ xoops2jp/html/modules/base/admin/actions/CommentEditAction.class.php	Tue Apr 11 12:09:29 2006
@@ -39,9 +39,15 @@
 	{
 		if ($this->mObject->get('com_status') == 1) {
 			$this->mActionForm =& new Legacy_PendingCommentAdminEditForm();
+
+			$root =& XCube_Root::getSingleton();
+			$root->mEventManager->add("Module.Legacy.Comment.Update.Success", new XCube_InstanceDelegate($this, "doApprove"));
 		}
 		else {
 			$this->mActionForm =& new Legacy_ApprovalCommentAdminEditForm();
+		
+			$root =& XCube_Root::getSingleton();
+			$root->mEventManager->add("Module.Legacy.Comment.Update.Success", new XCube_InstanceDelegate($this, "doUpdate"));
 		}
 		$this->mActionForm->prepare();
 	}
@@ -83,6 +89,85 @@
 	{
 		redirect_header("./index.php?action=CommentList", 1, _AD_BASE_ERROR_DBUPDATE_FAILED);
 	}
+	
+	/**
+	 * @static
+	 * @return Return array as the informations of comments. If $comment has fatal status, return false.
+	 */
+	function loadCallbackFile(&$comment)
+	{
+		$handler =& xoops_gethandler('module');
+		$module =& $handler->get($comment->get('com_modid'));
+		
+		if (!is_object($module)) {
+			return false;
+		}
+		
+		$comment_config = $module->getInfo('comments');
+		
+		//
+		// Load call-back file
+		//
+		$file = XOOPS_MODULE_PATH . "/" . $module->get('dirname') . "/" . $comment_config['callbackFile'];
+		if (!file_exists($file)) {
+			return false;
+		}
+		
+		require_once $file;
+		
+		return $comment_config;
+	}
+	
+	function doApprove(&$sender, &$eventArgs)
+	{
+		$comment =& $eventArgs['comment'];
+		$comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
+		
+		if ($comment_config == false) {
+			return;
+		}
+		
+		$function = $comment_config['callback']['approve'];
+		
+		if (function_exists($function)) {
+			call_user_func($function, $comment);
+		}
+		
+		Legacy_CommentEditAction::addUserPost($comment);		
+	}
+	
+	function doUpdate(&$sender, &$eventArgs)
+	{
+		//
+		// Adjust user's post count.
+		//
+		if ($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'));
+			$handler->updateUserByField($user, 'posts', $user->get('posts') + 1);
+		}
+		
+		//
+		// call back
+		//
+		$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 メーリングリストの案内
Zurück zum Archiv-Index