22 public function _getId()
24 return isset($_REQUEST[
'com_id']) ? xoops_getrequest(
'com_id') : 0;
27 public function &_getHandler()
29 $handler =& xoops_getmodulehandler(
'comment');
30 $handler->mDeleteSuccess->add([&$this,
'doDelete']);
34 public function _setupActionForm()
37 $this->mActionForm->prepare();
40 public function executeViewInput(&$controller, &$xoopsUser, &$render)
45 $this->mObject->loadUser();
46 $this->mObject->loadModule();
47 $this->mObject->loadStatus();
52 $handler =& xoops_getmodulehandler(
'comment');
53 $criteria =
new Criteria(
'com_pid', $this->mObject->get(
'com_id'));
54 $children =& $handler->getObjects($criteria);
56 if ((is_countable($children) ? count($children) : 0) > 0) {
57 foreach (array_keys($children) as $key) {
58 $children[$key]->loadModule();
59 $children[$key]->loadUser();
63 $render->setTemplateName(
'comment_delete.html');
64 $render->setAttribute(
'actionForm', $this->mActionForm);
65 $render->setAttribute(
'object', $this->mObject);
66 $render->setAttribute(
'children', $children);
69 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
71 $controller->executeForward(
'./index.php?action=CommentList');
74 public function executeViewError(&$controller, &$xoopsUser, &$render)
76 $controller->executeRedirect(
'./index.php?action=CommentList', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
79 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
81 $controller->executeForward(
'./index.php?action=CommentList');
84 public function doDelete($comment)
89 if (1 != $comment->get(
'com_status') && $comment->get(
'com_uid') > 0) {
90 $handler =& xoops_gethandler(
'member');
96 $user =& $handler->getUser($comment->get(
'com_uid'));
97 if (is_object($user)) {
98 $count = $user->get(
'posts');
101 $handler->updateUserByField($user,
'posts', $count - 1);
111 if (
false == $comment_config) {
115 $function = $comment_config[
'callback'][
'update'];
117 if (function_exists($function)) {
119 $criteria->add(
new Criteria(
'com_itemid', $comment->get(
'com_itemid')));
120 $criteria->add(
new Criteria(
'com_status', XOOPS_COMMENT_ACTIVE));
122 $handler =& xoops_gethandler(
'comment');
123 $commentCount = $handler->getCount($criteria);
125 call_user_func($function, $comment->get(
'com_id'), $commentCount);