本文整理汇总了PHP中CKunenaTools::decreaseCategoryStats方法的典型用法代码示例。如果您正苦于以下问题:PHP CKunenaTools::decreaseCategoryStats方法的具体用法?PHP CKunenaTools::decreaseCategoryStats怎么用?PHP CKunenaTools::decreaseCategoryStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKunenaTools
的用法示例。
在下文中一共展示了CKunenaTools::decreaseCategoryStats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fbDeletePosts
function fbDeletePosts($isMod, $return)
{
$app =& JFactory::getApplication();
$backUrl = $app->getUserState("com_kunena.ActionBulk");
$kunena_my =& JFactory::getUser();
$kunena_db =& JFactory::getDBO();
if (!CKunenaTools::isModOrAdmin() && !$isMod) {
$app->redirect($return, _POST_NOT_MODERATOR);
}
$items = fbGetArrayInts("fbDelete");
$dellattach = 1;
// start iterating here
foreach ($items as $id => $value) {
$kunena_db->setQuery("SELECT id, catid, parent, thread, subject, userid FROM #__fb_messages WHERE id='{$id}'");
if (!$kunena_db->query()) {
return -2;
}
$mes = $kunena_db->loadObject();
$thread = $mes->thread;
if ($mes->parent == 0) {
// this is the forum topic; if removed, all children must be removed as well.
$children = array();
$userids = array();
$kunena_db->setQuery("SELECT userid, id, catid FROM #__fb_messages WHERE thread='{$id}' OR id='{$id}'");
foreach ($kunena_db->loadObjectList() as $line) {
$children[] = $line->id;
if ($line->userid > 0) {
$userids[] = $line->userid;
}
}
$children = implode(',', $children);
} else {
//this is not the forum topic, so delete it and promote the direct children one level up in the hierarchy
$kunena_db->setQuery('UPDATE #__fb_messages SET parent=\'' . $mes->parent . '\' WHERE parent=\'' . $id . '\'');
if (!$kunena_db->query()) {
return -1;
}
$children = $id;
$userids = $mes->userid > 0 ? $mes->userid : '';
}
//Delete the post (and it's children when it's the first post)
$kunena_db->setQuery('DELETE FROM #__fb_messages WHERE id=' . $id . ' OR thread=' . $id);
if (!$kunena_db->query()) {
return -2;
}
// now update stats
CKunenaTools::decreaseCategoryStats($id, $mes->catid);
//Delete message text(s)
$kunena_db->setQuery('DELETE FROM #__fb_messages_text WHERE mesid IN (' . $children . ')');
if (!$kunena_db->query()) {
return -3;
}
//Update user post stats
if (count($userids) > 0) {
$userids = implode(',', $userids);
$kunena_db->setQuery('UPDATE #__fb_users SET posts=posts-1 WHERE userid IN (' . $userids . ')');
if (!$kunena_db->query()) {
return -4;
}
}
//Delete (possible) ghost post
$kunena_db->setQuery("SELECT mesid FROM #__fb_messages_text WHERE message='catid={$mes->catid}&id={$id}'");
$int_ghost_id = $kunena_db->loadResult();
if ($int_ghost_id > 0) {
$kunena_db->setQuery('DELETE FROM #__fb_messages WHERE id=' . $int_ghost_id);
$kunena_db->query();
$kunena_db->setQuery('DELETE FROM #__fb_messages_text WHERE mesid=' . $int_ghost_id);
$kunena_db->query();
}
//Delete attachments
if ($dellattach) {
$kunena_db->setQuery("SELECT filelocation FROM #__fb_attachments WHERE mesid IN ({$children})");
$fileList = $kunena_db->loadObjectList();
check_dberror("Unable to load attachments.");
if (count($fileList) > 0) {
foreach ($fileList as $fl) {
unlink($fl->filelocation);
}
$kunena_db->setQuery('DELETE FROM #__fb_attachments WHERE mesid IN (' . $children . ')');
$kunena_db->query();
}
}
}
//end foreach
CKunenaTools::reCountBoards();
$app->redirect($return, _KUNENA_BULKMSG_DELETED);
}