27 public function prepare(&$controller, &$xoopsUser)
29 $this->_setupObject();
33 public function _getId()
35 return isset($_REQUEST[
'com_id']) ? (int)xoops_getrequest(
'com_id') : 0;
38 public function &_getHandler()
40 $handler =& xoops_getmodulehandler(
'comment');
44 public function isEnableCreate()
54 if (XOOPS_COMMENT_PENDING == $this->mObject->get(
'com_status')) {
56 $this->mObjectHandler->mUpdateSuccess->add([&$this,
'doApprove']);
57 $this->mObjectHandler->mUpdateSuccess->add([&$this,
'doUpdate']);
60 $this->mObjectHandler->mUpdateSuccess->add([&$this,
'doUpdate']);
62 $this->mActionForm->prepare();
65 public function executeViewInput(&$controller, &$xoopsUser, &$render)
67 $this->mObject->loadUser();
68 $this->mObject->loadModule();
69 $this->mObject->loadStatus();
71 $render->setTemplateName(
'comment_edit.html');
72 $render->setAttribute(
'actionForm', $this->mActionForm);
73 $render->setAttribute(
'object', $this->mObject);
75 $subjectHandler =& xoops_gethandler(
'subjecticon');
76 $subjectIconArr =& $subjectHandler->getObjects();
78 $render->setAttribute(
'subjectIconArr', $subjectIconArr);
80 $statusHandler =& xoops_getmodulehandler(
'commentstatus');
81 if (XOOPS_COMMENT_PENDING == $this->mObject->get(
'com_status')) {
82 $statusArr =& $statusHandler->getObjects();
85 $statusArr[0] =& $statusHandler->get(XOOPS_COMMENT_ACTIVE);
86 $statusArr[1] =& $statusHandler->get(XOOPS_COMMENT_HIDDEN);
89 $render->setAttribute(
'statusArr', $statusArr);
92 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
94 $controller->executeForward(
'./index.php?action=CommentList');
97 public function executeViewError(&$controller, &$xoopsUser, &$render)
99 $controller->executeRedirect(
'./index.php?action=CommentList', 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
102 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
104 $controller->executeForward(
'./index.php?action=CommentList');
114 $handler =& xoops_gethandler(
'module');
115 $module =& $handler->get($comment->get(
'com_modid'));
117 if (!is_object($module)) {
121 $comment_config = $module->getInfo(
'comments');
123 if (!isset($comment_config[
'callbackFile'])) {
130 $file = XOOPS_MODULE_PATH .
'/' . $module->get(
'dirname') .
'/' . $comment_config[
'callbackFile'];
131 if (!is_file($file)) {
137 return $comment_config;
140 public function doApprove($comment)
144 if (
false == $comment_config) {
148 $function = $comment_config[
'callback'][
'approve'];
150 if (function_exists($function)) {
151 call_user_func($function, $comment);
154 $handler =& xoops_gethandler(
'member');
160 $user =& $handler->getUser($comment->get(
'com_uid'));
161 if (is_object($user)) {
162 $handler->updateUserByField($user,
'posts', $user->get(
'posts') + 1);
166 public function doUpdate($comment)
171 $comment_config = (
new Legacy_CommentEditAction())->
loadCallbackFile($comment);
173 if (
false == $comment_config) {
177 $function = $comment_config[
'callback'][
'update'];
179 if (function_exists($function)) {
180 $criteria =
new CriteriaCompo(
new Criteria(
'com_modid', $comment->get(
'com_modid')));
181 $criteria->add(
new Criteria(
'com_itemid', $comment->get(
'com_itemid')));
182 $criteria->add(
new Criteria(
'com_status', XOOPS_COMMENT_ACTIVE));
184 $handler =& xoops_gethandler(
'comment');
185 $commentCount = $handler->getCount($criteria);
187 call_user_func_array($function, [$comment->get(
'com_itemid'), $commentCount, $comment->get(
'com_id')]);