Beispiel #1
0
 /**
  * Add pages to $this->pages from a category tree
  *
  * @param XoopsObjectTree $tree
  * @param int $parentid key to start from
  * @param int $level
  * @param int $offset integer added to location
  *
  * @return void
  */
 function traversePageTree($tree, $parentid = 0, $level = 0)
 {
     $pages =& $tree->getFirstChild($parentid);
     $level++;
     foreach (array_keys($pages) as $i) {
         $this->pages[] = array('location' => $pages[$i]->getVar('categoryid'), 'name' => $pages[$i]->getVar('name', 'n'), 'level' => $level);
         $this->traversePageTree($tree, $pages[$i]->getVar('categoryid'), $level);
     }
 }
 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;
 }
Beispiel #3
0
         $comment_config['callback']['update']($com_itemid, $comment_count);
     }
 }
 // update user posts if its not an anonymous post
 if ($comment->getVar('com_uid') != 0) {
     $member_handler =& xoops_gethandler('member');
     $com_poster =& $member_handler->getUser($comment->getVar('com_uid'));
     if (is_object($com_poster)) {
         $member_handler->updateUserByField($com_poster, 'posts', $com_poster->getVar('posts') - 1);
     }
 }
 // get all comments posted later within the same thread
 $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $com_id);
 include_once XOOPS_ROOT_PATH . '/class/tree.php';
 $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid');
 $child_comments =& $xot->getFirstChild($com_id);
 // 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>' . $com_id . '</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);
Beispiel #4
0
 public function displayDelete()
 {
     $xoops = Xoops::getInstance();
     $op = Request::getCmd('op', 'delete', 'POST');
     $mode = Request::getString('com_mode', 'flat');
     $order = Request::getString('com_order', COMMENTS_OLD1ST);
     $id = Request::getInt('com_id');
     /* @var $comment CommentsComment */
     /* @var $comment_handler CommentsCommentHandler */
     $comment_handler = $this->getHandlerComment();
     $comment = $comment_handler->get($id);
     if (!is_object($comment)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $module = $xoops->getModuleById($comment->getVar('modid'));
     if (!is_object($module)) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     if (!$xoops->isAdminSide && COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname')) || !$xoops->isUser() && !$xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) || !$xoops->isModule()) {
         $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
     }
     $modid = $module->getVar('mid');
     /* @var $plugin CommentsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'comments')) {
         if ($xoops->isAdminSide) {
             $redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&amp;com_itemid');
         } else {
             $redirect_page = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $plugin->pageName() . '?');
             $comment_confirm_extra = array();
             if (is_array($extraParams = $plugin->extraParams())) {
                 foreach ($extraParams as $extra_param) {
                     if (isset($_GET[$extra_param])) {
                         $redirect_page .= $extra_param . '=' . $_GET[$extra_param] . '&amp;';
                         // for the confirmation page
                         $comment_confirm_extra[$extra_param] = $_GET[$extra_param];
                     }
                 }
             }
             $redirect_page .= $plugin->itemName();
         }
         $accesserror = false;
         if (!$xoops->isUser()) {
             $accesserror = true;
         } else {
             if (!$xoops->user->isAdmin($modid)) {
                 $accesserror = true;
             }
         }
         if (false != $accesserror) {
             $ref = $xoops->getEnv('HTTP_REFERER');
             if ($ref != '') {
                 $xoops->redirect($ref, 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
             } else {
                 $xoops->redirect($redirect_page . '?' . $plugin->itemName() . '=' . (int) $id, 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
             }
         }
         switch ($op) {
             case 'delete_one':
                 if (!$comment_handler->delete($comment)) {
                     $xoops->header();
                     echo $xoops->alert('error', _MD_COMMENTS_COMDELETENG . ' (ID: ' . $comment->getVar('id') . ')');
                     $xoops->footer();
                 }
                 $itemid = $comment->getVar('itemid');
                 $criteria = new CriteriaCompo(new Criteria('modid', $modid));
                 $criteria->add(new Criteria('itemid', $itemid));
                 $criteria->add(new Criteria('status', COMMENTS_ACTIVE));
                 $comment_count = $comment_handler->getCount($criteria);
                 $plugin->update($itemid, $comment_count);
                 // update user posts if its not an anonymous post
                 if ($comment->getVar('uid') != 0) {
                     $member_handler = $xoops->getHandlerMember();
                     $poster = $member_handler->getUser($comment->getVar('uid'));
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - 1);
                     }
                 }
                 // get all comments posted later within the same thread
                 $thread_comments = $comment_handler->getThread($comment->getVar('rootid'), $id);
                 $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid');
                 $child_comments = $xot->getFirstChild($id);
                 // now set new parent ID for direct child comments
                 $new_pid = $comment->getVar('pid');
                 $errs = array();
                 foreach (array_keys($child_comments) as $i) {
                     $child_comments[$i]->setVar('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('id');
                         $child_comments[$i]->setVar('rootid', $child_comments[$i]->getVar('id'));
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>. (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('rootid', $new_rootid);
                                 if (!$comment_handler->insert($c_child_comments[$j])) {
                                     $errs[] = 'Could not change comment root ID from <strong>' . $id . '</strong> to <strong>' . $new_rootid . '</strong>.';
                                 }
                             }
                         }
                     } else {
                         if (!$comment_handler->insert($child_comments[$i])) {
                             $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>.';
                         }
                     }
                 }
                 if (count($errs) > 0) {
                     $xoops->header();
                     echo $xoops->alert('error', $errs);
                     $xoops->footer();
                     exit;
                 }
                 $xoops->redirect($redirect_page . '=' . $itemid . '&amp;com_order=' . $order . '&amp;com_mode=' . $mode, 1, _MD_COMMENTS_COMDELETED);
                 break;
             case 'delete_all':
                 $rootid = $comment->getVar('rootid');
                 // get all comments posted later within the same thread
                 $thread_comments = $comment_handler->getThread($rootid, $id);
                 // construct a comment tree
                 $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid');
                 $child_comments = $xot->getAllChild($id);
                 // add itself here
                 $child_comments[$id] = $comment;
                 $msgs = array();
                 $deleted_num = array();
                 $member_handler = $xoops->getHandlerMember();
                 foreach (array_keys($child_comments) as $i) {
                     if (!$comment_handler->delete($child_comments[$i])) {
                         $msgs[] = _MD_COMMENTS_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('id') . ')';
                     } else {
                         $msgs[] = _MD_COMMENTS_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('id') . ')';
                         // store poster ID and deleted post number into array for later use
                         $poster_id = $child_comments[$i]->getVar('uid');
                         if ($poster_id > 0) {
                             $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1;
                         }
                     }
                 }
                 foreach ($deleted_num as $user_id => $post_num) {
                     // update user posts
                     $poster = $member_handler->getUser($user_id);
                     if (is_object($poster)) {
                         $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - $post_num);
                     }
                 }
                 $itemid = $comment->getVar('itemid');
                 $criteria = new CriteriaCompo(new Criteria('modid', $modid));
                 $criteria->add(new Criteria('itemid', $itemid));
                 $criteria->add(new Criteria('status', COMMENTS_ACTIVE));
                 $comment_count = $comment_handler->getCount($criteria);
                 $plugin->update($itemid, $comment_count);
                 $xoops->header();
                 echo $xoops->alert('info', $msgs);
                 echo '<br /><a href="' . $redirect_page . '=' . $itemid . '&amp;com_order=' . $order . '&amp;com_mode=' . $mode . '">' . XoopsLocale::GO_BACK . '</a>';
                 $xoops->footer();
                 break;
             case 'delete':
             default:
                 $xoops->header();
                 $comment_confirm = array('com_id' => $id, 'com_mode' => $mode, 'com_order' => $order, 'op' => array(_MD_COMMENTS_DELETEONE => 'delete_one', _MD_COMMENTS_DELETEALL => 'delete_all'));
                 if (!empty($comment_confirm_extra) && is_array($comment_confirm_extra)) {
                     $comment_confirm = $comment_confirm + $comment_confirm_extra;
                 }
                 echo $xoops->confirm($comment_confirm, 'comment_delete.php', _MD_COMMENTS_DELETESELECT);
                 $xoops->footer();
                 break;
         }
     }
 }
 function deleteComment($com_id)
 {
     $delete_op = isset($_POST['delete_op']) ? xoops_trim($_POST['delete_op']) : 'delete_one';
     switch ($delete_op) {
         case 'delete_one':
             $comment_handler = xoops_gethandler('comment');
             $comment =& $comment_handler->get($com_id);
             if (!$comment_handler->delete($comment)) {
                 return xoops_error(_CM_COMDELETENG . ' (ID: ' . $comment->getVar('com_id') . ')');
                 exit;
             }
             $com_itemid = $comment->getVar('com_itemid');
             // update user posts if its not an anonymous post
             if ($comment->getVar('com_uid') != 0) {
                 $member_handler =& xoops_gethandler('member');
                 $com_poster =& $member_handler->getUser($comment->getVar('com_uid'));
                 if (is_object($com_poster)) {
                     $member_handler->updateUserByField($com_poster, 'posts', $com_poster->getVar('posts') - 1);
                 }
             }
             // get all comments posted later within the same thread
             $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $com_id);
             include_once XOOPS_ROOT_PATH . '/class/tree.php';
             $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid');
             $child_comments =& $xot->getFirstChild($com_id);
             // now set new parent ID for direct child comments
             $new_pid = $comment->getVar('com_pid');
             //				$errs = array();
             $msgs = '';
             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>'.$com_id.'</b> to <b>'.$new_pid.'</b>. (ID: '.$new_rootid.')';
                         $msgs .= 'Could not change comment parent ID from <b>' . $com_id . '</b> to <b>' . $new_pid . '</b>. (ID: ' . $new_rootid . ')<br />';
                     } 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>'.$com_id.'</b> to <b>'.$new_rootid.'</b>.';
                                 $msgs .= 'Could not change comment root ID from <b>' . $com_id . '</b> to <b>' . $new_rootid . '</b>.<br />';
                             }
                         }
                     }
                 } else {
                     if (!$comment_handler->insert($child_comments[$i])) {
                         //							$errs[] = 'Could not change comment parent ID from <b>'.$com_id.'</b> to <b>'.$new_pid.'</b>.';
                         $msgs .= 'Could not change comment parent ID from <b>' . $com_id . '</b> to <b>' . $new_pid . '</b>.<br />';
                     }
                 }
             }
             //				if(count($errs) > 0)
             if ($msgs != '') {
                 //					return xoops_error($errs);
                 return $msgs;
                 exit;
             }
             //			redirect_header($redirect_page.'='.$com_itemid.'&amp;com_order='.$com_order.'&amp;com_mode='.$com_mode, 1, _CM_COMDELETED);
             return _CM_COMDELETED;
             break;
         case 'delete_all':
             $comment_handler = xoops_gethandler('comment');
             $comment =& $comment_handler->get($com_id);
             $com_rootid = $comment->getVar('com_rootid');
             // get all comments posted later within the same thread
             $thread_comments =& $comment_handler->getThread($com_rootid, $com_id);
             // construct a comment tree
             include_once XOOPS_ROOT_PATH . '/class/tree.php';
             $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid');
             $child_comments =& $xot->getAllChild($com_id);
             // add itself here
             $child_comments[$com_id] =& $comment;
             //				$msgs = array();
             $msgs = '';
             $deleted_num = array();
             $member_handler =& xoops_gethandler('member');
             foreach (array_keys($child_comments) as $i) {
                 if (!$comment_handler->delete($child_comments[$i])) {
                     //						$msgs[] = _CM_COMDELETENG.' (ID: '.$child_comments[$i]->getVar('com_id').')';
                     $msgs .= _CM_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')<br />';
                 } else {
                     //						$msgs[] = _CM_COMDELETED.' (ID: '.$child_comments[$i]->getVar('com_id').')';
                     $msgs .= _CM_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')<br />';
                     // store poster ID and deleted post number into array for later use
                     $poster_id = $child_comments[$i]->getVar('com_uid');
                     if ($poster_id > 0) {
                         $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1;
                     }
                 }
             }
             foreach ($deleted_num as $user_id => $post_num) {
                 // update user posts
                 $com_poster = $member_handler->getUser($user_id);
                 if (is_object($com_poster)) {
                     $member_handler->updateUserByField($com_poster, 'posts', $com_poster->getVar('posts') - $post_num);
                 }
             }
             $com_itemid = $comment->getVar('com_itemid');
             // execute updateStat callback function if set
             if (isset($comment_config['callback']['update']) && trim($comment_config['callback']['update']) != '') {
                 $skip = false;
                 if (!function_exists($comment_config['callback']['update'])) {
                     if (isset($comment_config['callbackFile'])) {
                         $callbackfile = trim($comment_config['callbackFile']);
                         if ($callbackfile != '' && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) {
                             include_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile;
                         }
                         if (!function_exists($comment_config['callback']['update'])) {
                             $skip = true;
                         }
                     } else {
                         $skip = true;
                     }
                 }
                 if (!$skip) {
                     $criteria = new CriteriaCompo(new Criteria('com_modid', $this->mid));
                     $criteria->add(new Criteria('com_itemid', $com_itemid));
                     $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
                     $comment_count = $comment_handler->getCount($criteria);
                     $comment_config['callback']['update']($com_itemid, $comment_count);
                 }
             }
             //				return xoops_result($msgs);
             return $msgs;
             break;
     }
 }
Beispiel #6
0
 $homePath = "<a href='" . XOOPSMYLINKURL . "/index.php'>" . _MD_MYLINKS_MAIN . "</a>&nbsp;:&nbsp;";
 $itemPath = $catObj->getVar('title');
 $path = '';
 $myParent = $catObj->getVar('pid');
 while ($myParent != 0) {
     $ancestorObj = $myCatTree->getByKey($myParent);
     $path = "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid=" . $ancestorObj->getVar('cid') . "'>" . $ancestorObj->getVar('title') . "</a>&nbsp;:&nbsp;{$path}";
     $myParent = $ancestorObj->getVar('pid');
 }
 $path = "{$homePath}{$path}{$itemPath}";
 $path = str_replace("&nbsp;:&nbsp;", " <img src='" . mylinksGetIconURL('arrow.gif') . "' style='border-width: 0px;' alt='' /> ", $path);
 $xoopsTpl->assign('category_path', $path);
 $xoopsTpl->assign('category_id', $cid);
 $subCatLimit = 5;
 // get all the subcats for this category
 $subCatObjs = $myCatTree->getFirstChild($cid);
 $count = 1;
 foreach ($subCatObjs as $subCatObj) {
     // get 3rd level cats
     $gchildCatObjs = $myCatTree->getFirstChild($subCatObj->getVar('cid'));
     $gchildCategories = '';
     $subCatCount = count($gchildCatObjs);
     $lpLimit = min(array($subCatLimit, $subCatCount));
     $i = 0;
     foreach ($gchildCatObjs as $gchildCatObj) {
         $gchtitle = $myts->htmlSpecialChars($gchildCatObj->getVar('title'));
         $gchildCategories .= $i > 0 ? ', ' : '';
         $gchildCategories .= "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid=" . $gchildCatObj->getVar('cid') . "'>{$gchtitle}</a>";
         if ($i < $lpLimit) {
             $i++;
         } else {
Beispiel #7
0
    if ($xoopsOption['storytopic'] > 0) {
        if (!isset($xt)) {
            $xt = new AmsTopic($xoopsDB->prefix('ams_topics'));
        }
        $xt->getTopic($xoopsOption['storytopic']);
        $pagetitle .= ' - ' . $xt->topic_title();
        $xoopsTpl->assign('breadcrumb', $xt->getTopicPath(true));
    } else {
        $xoopsTpl->assign('breadcrumb', '');
    }
} else {
    include_once XOOPS_ROOT_PATH . "/class/tree.php";
    $xt = new AmsTopic($xoopsDB->prefix("ams_topics"));
    $allTopics = $xt->getAllTopics($xoopsModuleConfig['restrictindex']);
    $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
    $alltopics = $topic_obj_tree->getFirstChild(0);
    $article_counts = AmsStory::countPublishedOrderedByTopic();
    $smarty_topics = array();
    foreach (array_keys($alltopics) as $i) {
        $allstories[$i] = AmsStory::getAllPublished($xoopsOption['storynum'], 0, false, $i, 0);
        if (count($allstories[$i]) > 0) {
            foreach ($allstories[$i] as $thisstory) {
                $uids[$thisstory->uid()] = $thisstory->uid();
            }
        }
        if (!isset($article_counts[$i])) {
            $article_counts[$i] = 0;
        }
    }
    if (count($uids) > 0) {
        $member_handler =& xoops_gethandler('member');