Example #1
0
	static public function getForum( $tabs, $row, $user, $plugin ) {
		global $_CB_database;

		if ( ! class_exists( 'KunenaForumMessageHelper' ) ) {
			return CBTxt::T( 'Kunena not installed, enabled, or failed to load.' );
		}

		$params				=	$row->getParams();
		$forumId			=	$params->get( 'forum_id', null );

		cbgjClass::getTemplate( 'cbgroupjiveforums' );

		$paging				=	new cbgjPaging( 'forum' );

		$limit				=	$paging->getlimit( (int) $plugin->params->get( 'forum_limit', 15 ) );
		$limitstart			=	$paging->getLimistart();
		$search				=	$paging->getFilter( 'search' );
		$where				=	array();

		if ( isset( $search ) && ( $search != '' ) ) {
			$where[]		=	'( m.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
							.	' OR t.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
		}

		$params				=	array(	'starttime' => -1,
										'where' => ( count( $where ) ? implode( ' AND ', $where ) : null )
									);

		$rows				=	KunenaForumMessageHelper::getLatestMessages( $forumId, 0, 0, $params );
		$total				=	array_shift( $rows );

		if ( $total <= $limitstart ) {
			$limitstart		=	0;
		}

		$pageNav			=	$paging->getPageNav( $total, $limitstart, $limit );

		if ( $plugin->params->get( 'forum_paging', 1 ) ) {
			$rows			=	KunenaForumMessageHelper::getLatestMessages( $forumId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
			$rows			=	array_pop( $rows );
		} else {
			$rows			=	array_pop( $rows );
		}

		$pageNav->search	=	$paging->getInputSearch( 'gjForm_forum', 'search', CBTxt::T( 'Search Forums...' ), $search );
		$pageNav->searching	=	( $search ? true : false );
		$pageNav->limitbox	=	$paging->getLimitbox( $pageNav );
		$pageNav->pagelinks	=	$paging->getPagesLinks( $pageNav );

		if ( class_exists( 'HTML_cbgroupjiveforums' ) ) {
			return HTML_cbgroupjiveforums::showForums( $rows, $pageNav, $tabs, $row, $user, $plugin );
		} else {
			return cbgjForumsPlugin::showForum( $rows, $pageNav, $tabs, $row, $user, $plugin );
		}
	}
Example #2
0
	static public function getForum( $tabs, $row, $user, $plugin ) {
		global $_CB_database;

		$params				=	$row->getParams();
		$forumId			=	$params->get( 'forum_id', null );

		cbgjClass::getTemplate( 'cbgroupjiveforums' );

		$paging				=	new cbgjPaging( 'forum' );

		$limit				=	$paging->getlimit( (int) $plugin->params->get( 'forum_limit', 15 ) );
		$limitstart			=	$paging->getLimistart();
		$search				=	$paging->getFilter( 'search' );
		$where				=	array();

		if ( isset( $search ) && ( $search != '' ) ) {
			$where[]		=	'( a.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
							.	' OR b.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
		}

		$query				=	'SELECT COUNT(*)'
							.	"\n FROM " . $_CB_database->NameQuote( '#__kunena_messages' ) . " AS a"
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_messages_text' ) . " AS b"
							.	' ON a.' . $_CB_database->NameQuote( 'id' ) . ' = b.' . $_CB_database->NameQuote( 'mesid' )
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_categories' ) . " AS c"
							.	' ON a.' . $_CB_database->NameQuote( 'catid' ) . ' = c.' . $_CB_database->NameQuote( 'id' )
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_messages' ) . " AS d"
							.	' ON a.' . $_CB_database->NameQuote( 'thread' ) . ' = d.' . $_CB_database->NameQuote( 'id' )
							.	"\n WHERE a." . $_CB_database->NameQuote( 'hold' ) . " = 0"
							.	"\n AND a." . $_CB_database->NameQuote( 'catid' ) . " = " . (int) $forumId
							.	"\n AND c." . $_CB_database->NameQuote( 'published' ) . " = 1"
							.	( count( $where ) ? "\n AND " . implode( "\n AND ", $where ) : null );
		$_CB_database->setQuery( $query );
		$total				=	$_CB_database->loadResult();

		if ( $total <= $limitstart ) {
			$limitstart		=	0;
		}

		$pageNav			=	$paging->getPageNav( $total, $limitstart, $limit );

		$query				=	'SELECT a.*'
							.	', c.' . $_CB_database->NameQuote( 'id' ) . ' AS category'
							.	', c.' . $_CB_database->NameQuote( 'name' ) . ' AS catname'
							.	', b.' . $_CB_database->NameQuote( 'message' )
							.	"\n FROM " . $_CB_database->NameQuote( '#__kunena_messages' ) . " AS a"
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_messages_text' ) . " AS b"
							.	' ON a.' . $_CB_database->NameQuote( 'id' ) . ' = b.' . $_CB_database->NameQuote( 'mesid' )
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_categories' ) . " AS c"
							.	' ON a.' . $_CB_database->NameQuote( 'catid' ) . ' = c.' . $_CB_database->NameQuote( 'id' )
							.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__kunena_messages' ) . " AS d"
							.	' ON a.' . $_CB_database->NameQuote( 'thread' ) . ' = d.' . $_CB_database->NameQuote( 'id' )
							.	"\n WHERE a." . $_CB_database->NameQuote( 'hold' ) . " = 0"
							.	"\n AND a." . $_CB_database->NameQuote( 'catid' ) . " = " . (int) $forumId
							.	"\n AND c." . $_CB_database->NameQuote( 'published' ) . " = 1"
							.	( count( $where ) ? "\n AND " . implode( "\n AND ", $where ) : null )
							.	"\n ORDER BY a." . $_CB_database->NameQuote( 'time' ) . " DESC";
		if ( $plugin->params->get( 'forum_paging', 1 ) ) {
			$_CB_database->setQuery( $query, (int) $pageNav->limitstart, (int) $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows				=	$_CB_database->loadObjectList();

		$pageNav->search	=	$paging->getInputSearch( 'gjForm_forum', 'search', CBTxt::T( 'Search Forums...' ), $search );
		$pageNav->searching	=	( $search ? true : false );
		$pageNav->limitbox	=	$paging->getLimitbox( $pageNav );
		$pageNav->pagelinks	=	$paging->getPagesLinks( $pageNav );

		if ( class_exists( 'HTML_cbgroupjiveforums' ) ) {
			return HTML_cbgroupjiveforums::showForums( $rows, $pageNav, $tabs, $row, $user, $plugin );
		} else {
			return cbgjForumsPlugin::showForum( $rows, $pageNav, $tabs, $row, $user, $plugin );
		}
	}