Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Commit

Permalink
# [#20153] Administration: Show missing categories in admin
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/oratzes/svn/kunena@2248 daf2aa89-cb5b-0410-b8ee-fe93ebc9b27d
  • Loading branch information
mahagr committed Apr 13, 2010
1 parent 6b6ff17 commit e9bf41c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 49 deletions.
106 changes: 57 additions & 49 deletions administrator/components/com_kunena/admin.kunena.php
Expand Up @@ -369,59 +369,67 @@

html_Kunena::showFbFooter();

function showAdministration($option)
{
$app =& JFactory::getApplication();
$kunena_db = &JFactory::getDBO();
function showAdministration($option) {
$kunena_app = & JFactory::getApplication ();
$kunena_db = &JFactory::getDBO ();

$limit = $kunena_app->getUserStateFromRequest ( "global.list.limit", 'limit', $kunena_app->getCfg ( 'list_limit' ), 'int' );
$limitstart = $kunena_app->getUserStateFromRequest ( "{$option}.limitstart", 'limitstart', 0, 'int' );
$levellimit = $kunena_app->getUserStateFromRequest ( "{$option}.limit", 'levellimit', 10, 'int' );

$kunena_db->setQuery ( "SELECT a.*, a.parent>0 AS category, u.name AS editor, g.name AS groupname, h.name AS admingroup
FROM #__fb_categories AS a
LEFT JOIN #__users AS u ON u.id = a.checked_out
LEFT JOIN #__core_acl_aro_groups AS g ON g.id = a.pub_access
LEFT JOIN #__core_acl_aro_groups AS h ON h.id = a.admin_access
ORDER BY a.ordering, a.name" );

$rows = $kunena_db->loadObjectList ('id');
check_dberror ( "Unable to load categories." );

// establish the hierarchy of the categories
$children = array (0 => array());

// first pass - collect children
foreach ( $rows as $v ) {
$list = array();
$vv = $v;
while ($vv->parent>0 && isset($rows[$vv->parent]) && !in_array($vv->parent, $list)) {
$list[] = $vv->id;
$vv = $rows[$vv->parent];
}
if ($vv->parent) {
$v->parent = -1;
$v->published = 0;
$v->name = _KUNENA_CATEGORY_ORPHAN.' : '.$v->name;
}
$children [$v->parent][] = $v;
$v->location = count ( $children [$v->parent] )-1;
}

$limit = $app->getUserStateFromRequest("global.list.limit", 'limit', $app->getCfg('list_limit'), 'int');
$limitstart = $app->getUserStateFromRequest("{$option}.limitstart", 'limitstart', 0, 'int');
$levellimit = $app->getUserStateFromRequest("{$option}.limit", 'levellimit', 10, 'int');
/*
* danial
*/
$kunena_db->setQuery("SELECT a.*, a.parent>0 AS category, u.name AS editor, g.name AS groupname, h.name AS admingroup"
. "\nFROM #__fb_categories AS a"
. "\nLEFT JOIN #__users AS u ON u.id = a.checked_out"
. "\nLEFT JOIN #__core_acl_aro_groups AS g ON g.id = a.pub_access"
. "\nLEFT JOIN #__core_acl_aro_groups AS h ON h.id = a.admin_access"
. "\n GROUP BY a.id"
. "\n ORDER BY a.ordering, a.name");

$rows = $kunena_db->loadObjectList();
check_dberror("Unable to load categories.");

// establish the hierarchy of the categories
$children = array ();
if (isset($children [-1])) {
$children [0] = array_merge($children [-1], $children [0]);
$kunena_app->enqueueMessage ( _KUNENA_CATEGORY_ORPHAN_DESC, 'notice' );
}

// first pass - collect children
foreach ($rows as $v)
{
$pt = $v->parent;
$list = isset($children[$pt]) ? $children[$pt] : array ();
$v->location = count($list);
array_push($list, $v);
$children[$pt] = $list;
}
// second pass - get an indent list of the items
$list = fbTreeRecurse ( 0, '', array (), $children, max ( 0, $levellimit - 1 ) );
$total = count ( $list );
if ($limitstart >= $total)
$limitstart = 0;

// second pass - get an indent list of the items
$list = fbTreeRecurse(0, '', array (), $children, max(0, $levellimit - 1));
$total = count($list);
if ($limitstart >= $total) $limitstart = 0;

jimport('joomla.html.pagination');
$pageNav = new JPagination( $total, $limitstart, $limit );

$levellist = JHTML::_('select.integerList' , 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit);
// slice out elements based on limits
$list = array_slice($list, $pageNav->limitstart, $pageNav->limit);
/**
*@end
*/

html_Kunena::showAdministration($list, $children, $pageNav, $option);
}
jimport ( 'joomla.html.pagination' );
$pageNav = new JPagination ( $total, $limitstart, $limit );

$levellist = JHTML::_ ( 'select.integerList', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit );
// slice out elements based on limits
$list = array_slice ( $list, $pageNav->limitstart, $pageNav->limit );
/**
*@end
*/

html_Kunena::showAdministration ( $list, $children, $pageNav, $option );
}


//---------------------------------------
Expand Down
Expand Up @@ -23,6 +23,8 @@
defined( '_JEXEC' ) or defined ('_VALID_MOS') or die('Restricted access');

// 1.5.12
define('_KUNENA_CATEGORY_ORPHAN','ORPHAN');
define('_KUNENA_CATEGORY_ORPHAN_DESC','You have orphaned or lost categories! Please change their parent to be a valid category.');
define('_KUNENA_SECTION','Section');
define('_KUNENA_NOBODY','Nobody');
// Disable userlist
Expand Down
1 change: 1 addition & 0 deletions components/com_kunena/CHANGELOG.php
Expand Up @@ -37,6 +37,7 @@
# [#20107] Regression: Trunk is missing fix for #20008: Subject splits into two
# [#20150] Administration: Show Category configuration option has no effect
^ [#20152] Moving message: Category list is unordered and unintuitive
# [#20153] Administration: Show missing categories in admin
05-Apr-2010 Matias
^ [#20106] Updated version info to 1.5.12-DEV Calificar (Spanish, meaning describe)
Expand Down

0 comments on commit e9bf41c

Please sign in to comment.