Exemple #1
0
function mod_forum($mod, $cfg)
{
    $inDB = cmsDatabase::getInstance();
    $default_cfg = array('shownum' => 4, 'cat_id' => 0, 'forum_id' => 0, 'subs' => 0, 'show_hidden' => 0, 'show_pinned' => 0, 'showtext' => 1, 'showforum' => 0, 'order' => 'pubdate');
    $cfg = array_merge($default_cfg, $cfg);
    cmsCore::loadModel('forum');
    $model = new cms_model_forum();
    $inDB->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id');
    $inDB->addSelect('f.title as forum_title');
    if ($cfg['cat_id']) {
        $model->whereForumCatIs($cfg['cat_id']);
    }
    if ($cfg['forum_id']) {
        if ($cfg['subs']) {
            $forum = $model->getForum($cfg['forum_id']);
            if (!$forum) {
                return false;
            }
            $model->whereThisAndNestedForum($forum['NSLeft'], $forum['NSRight']);
        } else {
            $model->whereForumIs($cfg['forum_id']);
        }
    }
    if (!$cfg['show_hidden']) {
        $model->wherePublicThreads();
    }
    if ($cfg['show_pinned']) {
        $model->wherePinnedThreads();
    }
    $inDB->orderBy('t.' . $cfg['order'], 'DESC');
    $inDB->limit($cfg['shownum']);
    $threads = $model->getThreads();
    cmsPage::initTemplate('modules', $cfg['tpl'])->assign('threads', $threads)->assign('cfg', $cfg)->display($cfg['tpl']);
    return true;
}
Exemple #2
0
    cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'info');

    if (empty($_SESSION['editlist'])) {
        cmsCore::redirect('?view=components&do=config&id='. $id .'&opt=list_forums');
    } else {
        cmsCore::redirect('?view=components&do=config&id='. $id .'&opt=edit_forum');
    }
}

if ($opt == 'delete_forum') {
    $forum = $model->getForum(cmsCore::request('item_id', 'int'));
    if (!$forum){ cmsCore::error404(); }

    cmsCore::c('db')->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id');
    $model->whereThisAndNestedForum($forum['NSLeft'], $forum['NSRight']);

    $threads = $model->getThreads();

    foreach ($threads as $thread) {
        $model->deleteThread($thread['id']);
    }

    cmsCore::c('db')->deleteNS('cms_forums', $forum['id']);
    if (file_exists(PATH.'/upload/forum/cat_icons/'. $forum['icon'])) {
        @chmod(PATH.'/upload/forum/cat_icons/'. $forum['icon'], 0777);
        @unlink(PATH.'/upload/forum/cat_icons/'. $forum['icon']);
    }

    cmsCore::addSessionMessage($_LANG['AD_FORUM_IS_DELETE'], 'info');
    cmsCore::redirect('?view=components&do=config&id='. $id .'&opt=list_forums');