Пример #1
0
function newModerator($option, $id = null)
{
    $kunena_app =& JFactory::getApplication();
    $kunena_db =& JFactory::getDBO();
    //die ("New Moderator");
    //$limit = intval(JRequest::getVar( 'limit', 10));
    //$limitstart = intval(JRequest::getVar( 'limitstart', 0));
    $limit = $kunena_app->getUserStateFromRequest("global.list.limit", 'limit', $kunena_app->getCfg('list_limit'), 'int');
    $limitstart = $kunena_app->getUserStateFromRequest("{$option}.limitstart", 'limitstart', 0, 'int');
    $kunena_db->setQuery("SELECT COUNT(*) FROM #__users AS a LEFT JOIN #__kunena_users AS b ON a.id=b.userid WHERE b.moderator=1");
    $total = $kunena_db->loadResult();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    if ($limitstart >= $total) {
        $limitstart = 0;
    }
    if ($limit == 0 || $limit > 100) {
        $limit = 100;
    }
    $kunena_db->setQuery("SELECT * FROM #__users AS a LEFT JOIN #__kunena_users AS b ON a.id=b.userid WHERE b.moderator=1", $limitstart, $limit);
    $userList = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    $countUL = count($userList);
    jimport('joomla.html.pagination');
    $pageNav = new JPagination($total, $limitstart, $limit);
    //$id = intval( JRequest::getVar('id') );
    //get forum name
    $forumName = '';
    $kunena_db->setQuery("SELECT name FROM #__kunena_categories WHERE id={$id}");
    $forumName = $kunena_db->loadResult();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    //get forum moderators
    $kunena_db->setQuery("SELECT userid FROM #__kunena_moderation WHERE catid={$id}");
    $moderatorList = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    $moderators = 0;
    $modIDs[] = array();
    if (count($moderatorList) > 0) {
        foreach ($moderatorList as $ml) {
            $modIDs[] = $ml->userid;
        }
        $moderators = 1;
    } else {
        $moderators = 0;
    }
    html_Kunena::newModerator($option, $id, $moderators, $modIDs, $forumName, $userList, $countUL, $pageNav);
}
Пример #2
0
function newModerator($option, $id = null)
{
    $app =& JFactory::getApplication();
    $kunena_db =& JFactory::getDBO();
    //die ("New Moderator");
    //$limit = intval(JRequest::getVar( 'limit', 10));
    //$limitstart = intval(JRequest::getVar( 'limitstart', 0));
    $limit = $app->getUserStateFromRequest("global.list.limit", 'limit', $app->getCfg('list_limit'), 'int');
    $limitstart = $app->getUserStateFromRequest("{$option}.limitstart", 'limitstart', 0, 'int');
    $kunena_db->setQuery("SELECT COUNT(*) FROM #__users AS a" . "\n LEFT JOIN #__fb_users AS b" . "\n ON a.id=b.userid where b.moderator=1");
    $kunena_db->query() or trigger_dberror('Unable to load moderators w/o limit.');
    $total = $kunena_db->loadResult();
    if ($limitstart >= $total) {
        $limitstart = 0;
    }
    if ($limit == 0 || $limit > 100) {
        $limit = 100;
    }
    $kunena_db->setQuery("SELECT * FROM #__users AS a" . "\n LEFT JOIN #__fb_users AS b" . "\n ON a.id=b.userid" . "\n WHERE b.moderator=1", $limitstart, $limit);
    $userList = $kunena_db->loadObjectList();
    check_dberror('Unable to load moderators.');
    $countUL = count($userList);
    jimport('joomla.html.pagination');
    $pageNav = new JPagination($total, $limitstart, $limit);
    //$id = intval( JRequest::getVar('id') );
    //get forum name
    $forumName = '';
    $kunena_db->setQuery("select name from #__fb_categories where id={$id}");
    $kunena_db->query() or trigger_dberror('Unable to load forum name.');
    $forumName = $kunena_db->loadResult();
    //get forum moderators
    $kunena_db->setQuery("select userid from #__fb_moderation where catid={$id}");
    $moderatorList = $kunena_db->loadObjectList();
    check_dberror('Unable to load moderator.');
    $moderators = 0;
    $modIDs[] = array();
    if (count($moderatorList) > 0) {
        foreach ($moderatorList as $ml) {
            $modIDs[] = $ml->userid;
        }
        $moderators = 1;
    } else {
        $moderators = 0;
    }
    html_Kunena::newModerator($option, $id, $moderators, $modIDs, $forumName, $userList, $countUL, $pageNav);
}