function _processSave(&$controller, &$xoopsUser)
 {
     $statusArr = $this->mActionForm->get('status');
     $comment_handler = xoops_gethandler('comment');
     foreach (array_keys($statusArr) as $cid) {
         $comment =& $comment_handler->get($cid);
         if (is_object($comment)) {
             $olddata['com_status'] = $comment->get('com_status');
             $newdata['com_status'] = $this->mActionForm->get('status', $cid);
             if (count(array_diff_assoc($olddata, $newdata)) > 0) {
                 $comment->set('com_status', $this->mActionForm->get('status', $cid));
                 if (!$comment_handler->insert($comment)) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 $add_userpost = false;
                 $call_approvefunc = false;
                 $call_updatefunc = false;
                 $notify_event = false;
                 if (!empty($newdata['com_status']) && $newdata['com_status'] != XOOPS_COMMENT_PENDING) {
                     if (XOOPS_COMMENT_PENDING == $olddata['com_status']) {
                         $add_userpost = true;
                         if (XOOPS_COMMENT_ACTIVE == $newdata['com_status']) {
                             $call_updatefunc = true;
                             $call_approvefunc = true;
                             $notify_event = 'comment';
                         }
                     } elseif (XOOPS_COMMENT_HIDDEN == $olddata['com_status'] && XOOPS_COMMENT_ACTIVE == $newdata['com_status']) {
                         $call_updatefunc = true;
                     } elseif (XOOPS_COMMENT_ACTIVE == $olddata['com_status'] && XOOPS_COMMENT_HIDDEN == $newdata['com_status']) {
                         $call_updatefunc = true;
                     }
                 }
                 $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
                 if ($comment_config && $call_approvefunc != false) {
                     $function = $comment_config['callback']['approve'];
                     if (function_exists($function)) {
                         call_user_func($function, $comment);
                     }
                 }
                 if ($comment_config && $call_updatefunc != false) {
                     $function = $comment_config['callback']['update'];
                     if (function_exists($function)) {
                         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid')));
                         $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid')));
                         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
                         $comment_count = $comment_handler->getCount($criteria);
                         call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id')));
                     }
                 }
                 $uid = $comment->getVar('com_uid');
                 if ($uid > 0 && false != $add_userpost) {
                     $member_handler =& xoops_gethandler('member');
                     $poster =& $member_handler->getUser($uid);
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') + 1);
                     }
                 }
                 //notification
                 // RMV-NOTIFY
                 // trigger notification event if necessary
                 if ($notify_event) {
                     $not_modid = $comment->getVar('com_modid');
                     include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
                     $not_catinfo =& notificationCommentCategoryInfo($not_modid);
                     $not_category = $not_catinfo['name'];
                     $not_itemid = $comment->getVar('com_itemid');
                     $not_event = $notify_event;
                     $comment_tags = array();
                     $module_handler =& xoops_gethandler('module');
                     $not_module =& $module_handler->get($not_modid);
                     $com_config =& $not_module->getInfo('comments');
                     $comment_url = $com_config['pageName'] . '?';
                     //Umm....not use com_exparams(--;;Fix Me!)
                     //$extra_params = $comment->getVar('com_exparams');
                     //$comment_url .= $extra_params;
                     $comment_url .= $com_config['itemName'];
                     $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $comment->getVar('com_itemid') . '&com_id=' . $comment->getVar('com_id') . '&com_rootid=' . $comment->getVar('com_rootid') . '#comment' . $comment->getVar('com_id');
                     $notification_handler =& xoops_gethandler('notification');
                     $notification_handler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid);
                 }
                 //notify if
             }
             //count if
         }
         //object if
     }
     //foreach
     foreach (array_keys($statusArr) as $cid) {
         if ($this->mActionForm->get('delete', $cid) == 1) {
             $comment =& $comment_handler->get($cid);
             if (is_object($comment)) {
                 if (!$comment_handler->delete($comment)) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 if ($comment->get('com_status') != 1 && $comment->get('com_uid') > 0) {
                     $memberhandler =& xoops_gethandler('member');
                     $user =& $memberhandler->getUser($comment->get('com_uid'));
                     if (is_object($user)) {
                         $count = $user->get('posts');
                         if ($count > 0) {
                             $memberhandler->updateUserByField($user, 'posts', $count - 1);
                         }
                     }
                 }
                 // get all comments posted later within the same thread
                 $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $cid);
                 include_once XOOPS_ROOT_PATH . '/class/tree.php';
                 $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid');
                 $child_comments =& $xot->getFirstChild($cid);
                 // now set new parent ID for direct child comments
                 $new_pid = $comment->getVar('com_pid');
                 $errs = array();
                 foreach (array_keys($child_comments) as $i) {
                     $child_comments[$i]->setVar('com_pid', $new_pid);
                     // if the deleted comment is a root comment, need to change root id to own id
                     if (false != $comment->isRoot()) {
                         $new_rootid = $child_comments[$i]->getVar('com_id');
                         $child_comments[$i]->setVar('com_rootid', $child_comments[$i]->getVar('com_id'));
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>. (ID: ' . $new_rootid . ')';
                         } else {
                             // need to change root id for all its child comments as well
                             $c_child_comments =& $xot->getAllChild($new_rootid);
                             $cc_count = count($c_child_comments);
                             foreach (array_keys($c_child_comments) as $j) {
                                 $c_child_comments[$j]->setVar('com_rootid', $new_rootid);
                                 if (!$comment_handler->insert($c_child_comments[$j])) {
                                     $errs[] = 'Could not change comment root ID from <b>' . $cid . '</b> to <b>' . $new_rootid . '</b>.';
                                 }
                             }
                         }
                     } else {
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>.';
                         }
                     }
                 }
                 if (count($errs) > 0) {
                     return LEGACY_FRAME_VIEW_ERROR;
                 }
                 //
                 // callback
                 //
                 $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
                 if ($comment_config) {
                     $function = $comment_config['callback']['update'];
                     if (function_exists($function)) {
                         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid')));
                         $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid')));
                         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
                         $comment_count = $comment_handler->getCount($criteria);
                         call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id')));
                     }
                 }
             }
             //if object
         }
         //if
     }
     //foreach
     return LEGACY_FRAME_VIEW_SUCCESS;
 }
 function doDelete($comment)
 {
     //
     // 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'));
         if (is_object($user)) {
             $count = $user->get('posts');
             if ($count > 0) {
                 $handler->updateUserByField($user, 'posts', $count - 1);
             }
         }
     }
     //
     // callback
     //
     $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
     if ($comment_config == false) {
         return;
     }
     $function = $comment_config['callback']['update'];
     if (function_exists($function)) {
         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->get('com_modid')));
         $criteria->add(new Criteria('com_itemid', $comment->get('com_itemid')));
         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
         $handler =& xoops_gethandler('comment');
         $commentCount = $handler->getCount($criteria);
         call_user_func($function, $comment->get('com_id'), $commentCount);
     }
 }
 function doUpdate($comment)
 {
     //
     // call back
     //
     $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment);
     if ($comment_config == false) {
         return;
     }
     $function = $comment_config['callback']['update'];
     if (function_exists($function)) {
         $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->get('com_modid')));
         $criteria->add(new Criteria('com_itemid', $comment->get('com_itemid')));
         $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
         $handler =& xoops_gethandler('comment');
         $commentCount = $handler->getCount($criteria);
         call_user_func_array($function, array($comment->get('com_itemid'), $commentCount, $comment->get('com_id')));
     }
 }