/**
	 * prepare frontend group invites render
	 *
	 * @param GroupTable $group
	 * @param UserTable  $user
	 * @return mixed
	 */
	private function showGroupInvites( &$group, $user )
	{
		global $_CB_framework, $_CB_database;

		if ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) {
			if ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $group->get( 'type' ) != 3 ) ) {
				return null;
			} elseif ( ( CBGroupJive::getGroupStatus( $user, $group ) < 1 ) ) {
				return null;
			}
		}

		CBGroupJive::getTemplate( 'invites' );

		$limit					=	(int) $this->params->get( 'groups_invites_limit', 15 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_group_invites_limitstart{com_comprofiler}', 'gj_group_invites_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_group_invites_search{com_comprofiler}', 'gj_group_invites_search' );
		$where					=	null;

		if ( $search && $this->params->get( 'groups_invites_search', 0 ) ) {
			$where				.=	"\n AND ( i." . $_CB_database->NameQuote( 'email' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR j." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR j." . $_CB_database->NameQuote( 'username' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$searching				=	( $where ? true : false );

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = i.' . $_CB_database->NameQuote( 'user' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE i." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.	"\n AND i." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND ( ( cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	' AND cb.' . $_CB_database->NameQuote( 'confirmed' ) . ' = 1'
								.	' AND j.' . $_CB_database->NameQuote( 'block' ) . ' = 0 )'
								.	' OR i.' . $_CB_database->NameQuote( 'user' ) . ' = 0 )'
								.	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'invites' ) ) ) {
			return null;
		}

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_group_invites_' );

		switch( (int) $this->params->get( 'groups_invites_orderby', 1 ) ) {
			case 1:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'invited' ) . ' ASC';
				break;
			case 3:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'accepted' ) . ' ASC';
				break;
			case 4:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'accepted' ) . ' DESC';
				break;
			case 2:
			default:
				$orderBy		=	'i.' . $_CB_database->NameQuote( 'invited' ) . ' DESC';
				break;
		}

		$query					=	'SELECT i.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = i.' . $_CB_database->NameQuote( 'user' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE i." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.	"\n AND i." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND ( ( cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	' AND cb.' . $_CB_database->NameQuote( 'confirmed' ) . ' = 1'
								.	' AND j.' . $_CB_database->NameQuote( 'block' ) . ' = 0 )'
								.	' OR i.' . $_CB_database->NameQuote( 'user' ) . ' = 0 )'
								.	"\n ORDER BY " . $orderBy;
		if ( $this->params->get( 'groups_invites_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\InviteTable', array( $_CB_database ) );

		$input['search']		=	'<input type="text" name="gj_group_invites_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupInvitesForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Invites...' ) ) . '" class="form-control" />';

		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_invites', $pageNav->total );

		return HTML_groupjiveInvites::showInvites( $rows, $pageNav, $searching, $input, $group, $user, $this );
	}
 /**
  * Writes the html links for pages, eg, previous 1 2 3 ... x next
  *
  * @deprecated 2.0 use cbPageNav
  * @see cbPageNav
  *
  * @param  int           $limitstart  The record number to start dislpaying from
  * @param  int           $limit       Number of rows to display per page
  * @param  int           $total       Total number of rows
  * @param  string        $baseUrl     Base url (without SEF): cbSef done inside this function
  * @param  string|array  $search      String: search parameter added as &$prefix.search=... if NOT NULL ; array: each added as $prefix.&key=$val
  * @param  string        $prefix      Prefix on the &limitstart and &search URL items
  * @return string
  */
 function writePagesLinks($limitstart, $limit, $total, $baseUrl, $search = null, $prefix = null)
 {
     global $_PLUGINS;
     $_PLUGINS->trigger('onBeforeWritePagesLinks', array($limitstart, $limit, $total, &$baseUrl, &$search, $prefix));
     $pagingUrl = $baseUrl;
     if ($search) {
         $append = strpos($baseUrl, '?') !== false ? '&' : '?';
         if (is_array($search)) {
             foreach ($search as $k => $v) {
                 if ($k != 'limitstart' && $v) {
                     $pagingUrl .= $append . urlencode($prefix . $search) . '=' . urlencode($search);
                     $append = '&';
                 }
             }
         } else {
             $pagingUrl .= $append . 'search=' . urlencode($search);
         }
     }
     cbimport('cb.pagination');
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     $pageNav->setInputNamePrefix($prefix);
     $pageNav->setBaseURL($pagingUrl);
     $return = $pageNav->getListLinks();
     $_PLUGINS->trigger('onAfterWritePagesLinks', array(&$return, $limitstart, $limit, $total, $baseUrl, $search, $prefix));
     return $return;
 }
예제 #3
0
	/**
	 * @param string    $type
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param UserTable $viewer
	 * @param bool|int  $start
	 * @return null|string
	 */
	private function getItems( $type, $tab, $user, $viewer, $start = false )
	{
		global $_CB_framework, $_CB_database, $_PLUGINS;

		/** @var Registry $params */
		$params							=	$tab->params;
		$tabPrefix						=	'tab_' . (int) $tab->get( 'tabid' ) . '_';
		$publishedOnly					=	( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) );
		$input							=	array();

		// Items:
		$typePrefix						=	$tabPrefix . $type . '_items_';
		$limit							=	(int) $params->get( 'tab_' . $type . '_items_limit', 15 );
		$limitstart						=	( $start !== false ? (int) $start : $_CB_framework->getUserStateFromRequest( $typePrefix . 'limitstart{com_comprofiler}', $typePrefix . 'limitstart' ) );
		$search							=	$_CB_framework->getUserStateFromRequest( $typePrefix . 'search{com_comprofiler}', $typePrefix . 'search' );
		$where							=	null;

		if ( $search && $params->get( 'tab_' . $type . '_items_search', 1 ) ) {
			$where						.=	"\n AND ( " . $_CB_database->NameQuote( 'value' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
										.	" OR " . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
										.	" OR " . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$itemsSearching					=	( $where ? true : false );

		$query							=	'SELECT COUNT(*)'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type )
										.	"\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
										.	"\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0"
										.	( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null )
										.	$where;
		$_CB_database->setQuery( $query );
		$total							=	(int) $_CB_database->loadResult();

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

		$itemsPageNav					=	new cbPageNav( $total, $limitstart, $limit );

		$itemsPageNav->setInputNamePrefix( $typePrefix );

		$orderBy						=	$params->get( 'tab_' . $type . '_items_orderby', 'date_desc' );

		if ( ! $orderBy ) {
			$orderBy					=	'date_desc';
		}

		$orderBy						=	explode( '_', $orderBy );

		$query							=	'SELECT *'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( $type )
										.	"\n AND " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
										.	"\n AND " . $_CB_database->NameQuote( 'folder' ) . " = 0"
										.	( $publishedOnly ? "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" : null )
										.	$where
										.	"\n ORDER BY " . $_CB_database->NameQuote( $orderBy[0] ) . " " . strtoupper( $orderBy[1] );
		if ( $params->get( 'tab_' . $type . '_items_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $itemsPageNav->limitstart, $itemsPageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$items							=	$_CB_database->loadObjectList( null, 'cbgalleryItemTable', array( $_CB_database ) );
		$itemsCount						=	count( $items );

		$_PLUGINS->trigger( 'gallery_onLoadItems', array( &$items, $user ) );

		if ( $itemsCount && ( ! count( $items ) ) ) {
			return $this->getItems( $type, $tab, $user, $viewer, ( $limitstart + $limit ) );
		}

		switch( $type ) {
			case 'photos':
				$placeholder			=	CBTxt::T( 'Search Photos...' );
				break;
			case 'files':
				$placeholder			=	CBTxt::T( 'Search Files...' );
				break;
			case 'videos':
				$placeholder			=	CBTxt::T( 'Search Videos...' );
				break;
			case 'music':
				$placeholder			=	CBTxt::T( 'Search Music...' );
				break;
			default:
				$placeholder			=	CBTxt::T( 'Search...' );
				break;
		}

		$input['search_items']			=	'<input type="text" name="' . htmlspecialchars( $typePrefix . 'search' ) . '" value="' . htmlspecialchars( $search ) . '" onchange="document.' . htmlspecialchars( $type ) . 'ItemsForm.submit();" placeholder="' . htmlspecialchars( $placeholder ) . '" class="form-control" />';

		return array( $items, $itemsPageNav, $itemsSearching, $input );
	}
예제 #4
0
	/**
	 * Generates the HTML to display the user profile tab
	 *
	 * @param  \CB\Database\Table\TabTable   $tab       the tab database entry
	 * @param  \CB\Database\Table\UserTable  $user      the user being displayed
	 * @param  int                           $ui        1 for front-end, 2 for back-end
	 * @return string|boolean                           Either string HTML for tab content, or false if ErrorMSG generated
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database, $_LANG;

		outputCbJs( 1 );
		outputCbTemplate( 1 );
		cbimport( 'cb.pagination' );
                
                

		$plugin				=	cbhangoutClass::getPlugin();
		$model				=	cbhangoutClass::getModel();
		$viewer				=	CBuser::getMyUserDataInstance();

		cbhangoutClass::getTemplate( 'tab' );

		$limit				=	(int) $this->params->get( 'tab_limit', 15 );
		$limitstart			=	$_CB_framework->getUserStateFromRequest( 'tab_hangout_limitstart{com_comprofiler}', 'tab_hangout_limitstart' );
		$filterSearch		=	$_CB_framework->getUserStateFromRequest( 'tab_hangout_search{com_comprofiler}', 'tab_hangout_search' );
		$where				=	null;

		if ( isset( $filterSearch ) && ( $filterSearch != '' ) ) {
			if ( $model->type != 2 ) {
				$where		.=	"\n AND ( a." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
							.	" OR a." . $_CB_database->NameQuote( 'introtext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
							.	" OR a." . $_CB_database->NameQuote( 'fulltext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )";
			} else {
				$where		.=	"\n AND ( a." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
							.	" OR a." . $_CB_database->NameQuote( 'hangout_intro' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
							.	" OR a." . $_CB_database->NameQuote( 'hangout_full' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )";
			}
		}

		$searching			=	( $where ? true : false );

		$total				=	cbhangoutModel::getHangoutTotal( $where, $viewer, $user, $plugin );

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

		$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'tab_hangout_' );

		$rows				=	cbhangoutModel::getHangout( ( $this->params->get( 'tab_paging', 1 ) ? array( $pageNav->limitstart, $pageNav->limit ) : null ), $where, $viewer, $user, $plugin );

		$input				=	array();
		$input['search']	=	'<input type="text" name="tab_hangout_search" value="' . htmlspecialchars( $filterSearch ) . '" onchange="document.hangoutForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Поиск...' ) ) . '" class="form-control" />';

		$tab->params		=	$this->params;

		$class				=	$plugin->params->get( 'general_class', null );

		$return				=	'<div id="cbHangout" class="cbBlogs' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
							.		'<div id="cbHangoutsInner" class="cbBlogsInner">'
							.			HTML_cbhangoutTab::showHangoutTab( $rows, $pageNav, $searching, $input, $viewer, $user, $model, $tab, $plugin )
							.		'</div>'
							.	'</div>';

		return $return;
	}
예제 #5
0
	/**
	 * prepare frontend tab render
	 *
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database;

		if ( ! ( $tab->params instanceof ParamsInterface ) ) {
			$tab->params		=	new Registry( $tab->params );
		}

		$viewer					=	CBuser::getMyUserDataInstance();
		$isModerator			=	CBGroupJive::isModerator( $viewer->get( 'id' ) );
		$isOwner				=	( $viewer->get( 'id' ) == $user->get( 'id' ) );

		CBGroupJive::getTemplate( 'tab' );

		$limit					=	(int) $tab->params->get( 'tab_limit', 30 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_tab_limitstart{com_comprofiler}', 'gj_tab_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_tab_search{com_comprofiler}', 'gj_tab_search' );
		$where					=	null;

		if ( $search && $tab->params->get( 'tab_search', 1 ) ) {
			$where				.=	"\n AND ( g." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR g." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$searching				=	( $where ? true : false );

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g";

		if ( ! $isModerator ) {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c"
								.	' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_CB_database->NameQuote( 'category' );
		}

		$query					.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
								.	' ON u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( i.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) )
								.	' AND i.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( i.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )';

		if ( $isOwner ) {
			$query				.=	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )';
			}
		} else {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS mu"
								.	' ON mu.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mu.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $viewer->get( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS mi"
								.	' ON mi.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( mi.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $viewer->get( 'email' ) )
								.	' AND mi.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( mi.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )'
								.	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) ) )'
								.	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
								.		' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR mi.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) )';
			}
		}

		if ( ! $isModerator ) {
			$query				.=	"\n AND ( ( c." . $_CB_database->NameQuote( 'published' ) . " = 1"
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $user->get( 'id' ) ) )
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $viewer->get( 'id' ) ) ) . ' )'
								.		( $this->params->get( 'groups_uncategorized', 1 ) ? ' OR g.' . $_CB_database->NameQuote( 'category' ) . ' = 0 )' : ' )' );
		}

		$query					.=	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ( ! $isOwner ) || ( $isOwner && ( ! CBGroupJive::canCreateGroup( $user ) ) ) ) && ( ! Application::Config()->get( 'showEmptyTabs', 1 ) ) ) {
			return null;
		}

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_tab_' );

		switch( (int) $tab->params->get( 'tab_orderby', 1 ) ) {
			case 2:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'ordering' ) . ' DESC';
				break;
			case 3:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'date' ) . ' ASC';
				break;
			case 4:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'date' ) . ' DESC';
				break;
			case 5:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'name' ) . ' ASC';
				break;
			case 6:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'name' ) . ' DESC';
				break;
			case 7:
				$orderBy		=	$_CB_database->NameQuote( '_users' ) . ' ASC';
				break;
			case 8:
				$orderBy		=	$_CB_database->NameQuote( '_users' ) . ' DESC';
				break;
			case 1:
			default:
				$orderBy		=	'g.' . $_CB_database->NameQuote( 'ordering' ) . ' ASC';
				break;
		}

		$users					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS uc"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS uccb"
								.	' ON uccb.' . $_CB_database->NameQuote( 'id' ) . ' = uc.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS ucj"
								.	' ON ucj.' . $_CB_database->NameQuote( 'id' ) . ' = uccb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE uc." . $_CB_database->NameQuote( 'group' ) . " = g." . $_CB_database->NameQuote( 'id' )
								.	"\n AND uccb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND uccb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND ucj." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $isModerator ) {
			$users				.=	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		( ! $isOwner ? ' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' >= 2' : null )
								.		' OR uc.' . $_CB_database->NameQuote( 'status' ) . ' >= 1 )';
		}

		if ( ! $this->params->get( 'groups_users_owner', 1 ) ) {
			$users				.=	"\n AND uc." . $_CB_database->NameQuote( 'status' ) . " != 4";
		}

		$query					=	'SELECT g.*'
								.	', c.' . $_CB_database->NameQuote( 'name' ) . ' AS _category_name';

		if ( $isOwner ) {
			$query				.=	', u.' . $_CB_database->NameQuote( 'status' ) . ' AS _user_status'
								.	', i.' . $_CB_database->NameQuote( 'id' ) . ' AS _invite_id';
		} else {
			$query				.=	', mu.' . $_CB_database->NameQuote( 'status' ) . ' AS _user_status'
								.	', mi.' . $_CB_database->NameQuote( 'id' ) . ' AS _invite_id';
		}

		$query					.=	', ( ' . $users . ' ) AS _users'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c"
								.	' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_CB_database->NameQuote( 'category' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
								.	' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS i"
								.	' ON i.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( i.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) )
								.	' AND i.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( i.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND i.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )';

		if ( $isOwner ) {
			$query				.=	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )';
			}
		} else {
			$query				.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS mu"
								.	' ON mu.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mu.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_invites' ) . " AS mi"
								.	' ON mi.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'accepted' ) . ' = ' . $_CB_database->Quote( '0000-00-00 00:00:00' )
								.	' AND ( ( mi.' . $_CB_database->NameQuote( 'email' ) . ' = ' . $_CB_database->Quote( $viewer->get( 'email' ) )
								.	' AND mi.' . $_CB_database->NameQuote( 'email' ) . ' != "" )'
								.	' OR ( mi.' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $viewer->get( 'id' )
								.	' AND mi.' . $_CB_database->NameQuote( 'user' ) . ' > 0 ) )'
								.	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );

			if ( ! $isModerator ) {
				$query			.=		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) ) )'
								.	"\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $viewer->get( 'id' )
								.		' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1'
								.		' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )'
								.		' OR mu.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )'
								.		' OR mi.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )';
			} else {
				$query			.=		' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 1, 2, 3 ) )';
			}
		}

		if ( ! $isModerator ) {
			$query				.=	"\n AND ( ( c." . $_CB_database->NameQuote( 'published' ) . " = 1"
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $user->get( 'id' ) ) )
								.		' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $viewer->get( 'id' ) ) ) . ' )'
								.		( $this->params->get( 'groups_uncategorized', 1 ) ? ' OR g.' . $_CB_database->NameQuote( 'category' ) . ' = 0 )' : ' )' );
		}

		$query					.=	$where
								.	"\n ORDER BY " . $orderBy;
		if ( $tab->params->get( 'tab_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\GroupTable', array( $_CB_database ) );

		$input['search']		=	'<input type="text" name="gj_tab_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjTabForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Groups...' ) ) . '" class="form-control" />';

		CBGroupJive::getGroup( $rows );
		CBGroupJive::preFetchUsers( $rows );

		$class					=	$this->params->get( 'general_class', null );

		$return					=	'<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
								.		'<div class="cbGroupJiveInner">'
								.			HTML_groupjiveTab::showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $this )
								.		'</div>'
								.	'</div>';

		return $return;
	}
예제 #6
0
	/**
	 * prepare frontend events render
	 *
	 * @param string     $return
	 * @param GroupTable $group
	 * @param string     $users
	 * @param string     $invites
	 * @param array      $counters
	 * @param array      $buttons
	 * @param array      $menu
	 * @param cbTabs     $tabs
	 * @param UserTable  $user
	 * @return array|null
	 */
	public function showEvents( &$return, &$group, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user )
	{
		global $_CB_framework, $_CB_database;

		CBGroupJive::getTemplate( 'events', true, true, $this->element );

		$canModerate			=	( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( CBGroupJive::getGroupStatus( $user, $group ) >= 2 ) );
		$limit					=	(int) $this->params->get( 'groups_events_limit', 15 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_group_events_limitstart{com_comprofiler}', 'gj_group_events_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_group_events_search{com_comprofiler}', 'gj_group_events_search' );
		$where					=	null;

		if ( $search && $this->params->get( 'groups_events_search', 1 ) ) {
			$where				.=	"\n AND ( e." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR e." . $_CB_database->NameQuote( 'event' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR e." . $_CB_database->NameQuote( 'address' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR e." . $_CB_database->NameQuote( 'location' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$searching				=	( $where ? true : false );

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events' ) . " AS e"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = e.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE e." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( e." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR e.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'events' ) ) ) {
			return null;
		}

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_group_events_' );

		$guests					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events_attendance' ) . " AS ea"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS eacb"
								.	' ON eacb.' . $_CB_database->NameQuote( 'id' ) . ' = ea.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS eaj"
								.	' ON eaj.' . $_CB_database->NameQuote( 'id' ) . ' = eacb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE ea." . $_CB_database->NameQuote( 'event' ) . " = e." . $_CB_database->NameQuote( 'id' )
								.	"\n AND eacb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND eacb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND eaj." . $_CB_database->NameQuote( 'block' ) . " = 0";

		$now					=	Application::Database()->getUtcDateTime();

		$query					=	'SELECT e.*'
								.	', TIMESTAMPDIFF( SECOND, ' . $_CB_database->Quote( $now ) . ',e.' . $_CB_database->NameQuote( 'start' ) . ' ) AS _start_ordering'
								.	', TIMESTAMPDIFF( SECOND, ' . $_CB_database->Quote( $now ) . ', e.' . $_CB_database->NameQuote( 'end' ) . ' ) AS _end_ordering'
								.	', a.' . $_CB_database->NameQuote( 'id' ) . ' AS _attending'
								.	', ( ' . $guests . ' ) AS _guests'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events' ) . " AS e"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = e.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_plugin_events_attendance' ) . " AS a"
								.	' ON a.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' )
								.	' AND a.' . $_CB_database->NameQuote( 'event' ) . ' = e.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE e." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( e." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR e.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where
								.	"\n ORDER BY IF( _start_ordering < 0 AND _end_ordering > 0, 1, IF( _start_ordering > 0, 2, 3 ) ), ABS( _start_ordering )";
		if ( $this->params->get( 'groups_events_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveEvents\Table\EventTable', array( $_CB_database ) );

		$input					=	array();

		$input['search']		=	'<input type="text" name="gj_group_events_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupEventsForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Events...' ) ) . '" class="form-control" />';

		CBGroupJiveEvents::getEvent( $rows );
		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_events', $pageNav->total );

		return array(	'id'		=>	'events',
						'title'		=>	CBTxt::T( 'Events' ),
						'content'	=>	HTML_groupjiveEvents::showEvents( $rows, $pageNav, $searching, $input, $counters, $group, $user, $this )
					);
	}
예제 #7
0
	/**
	 * @param UserTable  $user
	 * @param GroupTable $group
	 * @param array      $counters
	 * @return array|null
	 */
	public function getTopics( $user, &$group, &$counters )
	{
		global $_CB_framework, $_CB_database;

		$categoryId					=	(int) $group->params()->get( 'forum_id' );

		if ( ( ! $categoryId ) || ( ! $group->params()->get( 'forums', 1 ) ) || ( $group->category()->get( 'id' ) && ( ! $group->category()->params()->get( 'forums', 1 ) ) ) ) {
			return null;
		}

		CBGroupJive::getTemplate( 'forums', true, true, $this->plugin->element );

		$limit						=	(int) $this->params->get( 'groups_forums_limit', 15 );
		$limitstart					=	$_CB_framework->getUserStateFromRequest( 'gj_group_forums_limitstart{com_comprofiler}', 'gj_group_forums_limitstart' );
		$search						=	$_CB_framework->getUserStateFromRequest( 'gj_group_forums_search{com_comprofiler}', 'gj_group_forums_search' );
		$where						=	null;

		if ( $search && $this->params->get( 'groups_forums_search', 1 ) ) {
			$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 ) . ' )';
		}

		$searching					=	( $where ? true : false );

		$params						=	array(	'starttime' => -1,
												'where' => $where
											);

		$posts						=	\KunenaForumMessageHelper::getLatestMessages( $categoryId, 0, 0, $params );
		$total						=	array_shift( $posts );

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'forums' ) ) ) {
			return null;
		}

		$pageNav					=	new \cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_group_forums_' );

		switch( (int) $this->params->get( 'groups_forums_orderby', 2 ) ) {
			case 1:
				$params['orderby']	=	'm.' . $_CB_database->NameQuote( 'time' ) . ' ASC';
				break;
		}

		if ( $this->params->get( 'groups_forums_paging', 1 ) ) {
			$posts					=	\KunenaForumMessageHelper::getLatestMessages( $categoryId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
			$posts					=	array_pop( $posts );
		} else {
			$posts					=	array_pop( $posts );
		}

		$rows						=	array();

		/** @var \KunenaForumMessage[] $posts */
		foreach ( $posts as $post ) {
			$row					=	new PostTable();

			$row->post( $post );

			$rows[]					=	$row;
		}

		$input						=	array();

		$input['search']			=	'<input type="text" name="gj_group_forums_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupForumsForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Posts...' ) ) . '" class="form-control" />';

		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_forums', $pageNav->total );

		return array(	'id'		=>	'forums',
						'title'		=>	CBTxt::T( 'Forums' ),
						'content'	=>	\HTML_groupjiveForums::showForums( $rows, $pageNav, $searching, $input, $counters, $group, $user, $this )
					);
	}
	/**
	 * prepare frontend event attending render
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function showEventAttending( $id, $user )
	{
		global $_CB_framework, $_CB_database;

		$event			=	CBGroupJiveEvents::getEvent( (int) $id );
		$returnUrl		=	$_CB_framework->pluginClassUrl( $this->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $event->get( 'group' ) ) );

		if ( $event->get( 'id' ) ) {
			if ( ! CBGroupJive::canAccessGroup( $event->group(), $user ) ) {
				cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' );
			} elseif ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) {
				if ( ( $event->get( 'published' ) != 1 ) && ( CBGroupJive::getGroupStatus( $user, $event->group() ) < 2 ) ) {
					cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to this event.' ), 'error' );
				}
			}
		} else {
			cbRedirect( $returnUrl, CBTxt::T( 'Event does not exist.' ), 'error' );
		}

		CBGroupJive::getTemplate( 'attending', true, true, $this->element );

		$canModerate			=	( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( CBGroupJive::getGroupStatus( $user, $event->group() ) >= 2 ) );
		$limit					=	(int) $this->params->get( 'groups_events_attending_limit', 30 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_event_attending_limitstart{com_comprofiler}', 'gj_event_attending_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_event_attending_search{com_comprofiler}', 'gj_event_attending_search' );
		$where					=	null;

		if ( $search && $this->params->get( 'groups_events_attending_search', 0 ) ) {
			$where				.=	"\n AND ( j." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR j." . $_CB_database->NameQuote( 'username' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$searching				=	( $where ? true : false );

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events_attendance' ) . " AS a"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_plugin_events' ) . " AS e"
								.	' ON e.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'event' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE a." . $_CB_database->NameQuote( 'event' ) . " = " . (int) $event->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( e." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR e.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_event_attending_' );

		$query					=	'SELECT a.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events_attendance' ) . " AS a"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_plugin_events' ) . " AS e"
								.	' ON e.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'event' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE a." . $_CB_database->NameQuote( 'event' ) . " = " . (int) $event->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( e." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR e.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where
								.	"\n ORDER BY a." . $_CB_database->NameQuote( 'date' ) . " DESC";
		if ( $this->params->get( 'groups_events_attending_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveEvents\Table\AttendanceTable', array( $_CB_database ) );

		$input					=	array();

		$input['search']		=	'<input type="text" name="gj_event_attending_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjEventAttendingForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Attending...' ) ) . '" class="form-control" />';

		CBGroupJive::preFetchUsers( $rows );

		HTML_groupjiveAttending::showAttending( $rows, $pageNav, $searching, $input, $event, $user, $this );
	}
예제 #9
0
	/**
	 * prepare frontend photos render
	 *
	 * @param string     $return
	 * @param GroupTable $group
	 * @param string     $users
	 * @param string     $invites
	 * @param array      $counters
	 * @param array      $buttons
	 * @param array      $menu
	 * @param cbTabs     $tabs
	 * @param UserTable  $user
	 * @return array|null
	 */
	public function showPhotos( &$return, &$group, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user )
	{
		global $_CB_framework, $_CB_database;

		CBGroupJive::getTemplate( 'photos', true, true, $this->element );

		$canModerate			=	( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( CBGroupJive::getGroupStatus( $user, $group ) >= 2 ) );
		$limit					=	(int) $this->params->get( 'groups_photo_limit', 15 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_group_photo_limitstart{com_comprofiler}', 'gj_group_photo_limitstart' );
		$search					=	$_CB_framework->getUserStateFromRequest( 'gj_group_photo_search{com_comprofiler}', 'gj_group_photo_search' );
		$where					=	null;

		if ( $search && $this->params->get( 'groups_photo_search', 1 ) ) {
			$where				.=	"\n AND ( p." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR p." . $_CB_database->NameQuote( 'filename' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
								.	" OR p." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . " )";
		}

		$searching				=	( $where ? true : false );

		$query					=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_photo' ) . " AS p"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = p.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE p." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( p." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR p.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where;
		$_CB_database->setQuery( $query );
		$total					=	(int) $_CB_database->loadResult();

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'photo' ) ) ) {
			return null;
		}

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_group_photo_' );

		switch( (int) $this->params->get( 'groups_photo_orderby', 2 ) ) {
			case 1:
				$orderBy		=	'p.' . $_CB_database->NameQuote( 'date' ) . ' ASC';
				break;
			case 3:
				$orderBy		=	'p.' . $_CB_database->NameQuote( 'filename' ) . ' ASC';
				break;
			case 4:
				$orderBy		=	'p.' . $_CB_database->NameQuote( 'filename' ) . ' DESC';
				break;
			case 2:
			default:
				$orderBy		=	'p.' . $_CB_database->NameQuote( 'date' ) . ' DESC';
				break;
		}

		$query					=	'SELECT p.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_photo' ) . " AS p"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = p.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE p." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

		if ( ! $canModerate ) {
			$query				.=	"\n AND ( p." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR p.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
		}

		$query					.=	$where
								.	"\n ORDER BY " . $orderBy;
		if ( $this->params->get( 'groups_photo_paging', 1 ) ) {
			$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
		} else {
			$_CB_database->setQuery( $query );
		}
		$rows					=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJivePhoto\Table\PhotoTable', array( $_CB_database ) );

		$input					=	array();

		$input['search']		=	'<input type="text" name="gj_group_photo_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupPhotoForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Photos...' ) ) . '" class="form-control" />';

		CBGroupJivePhoto::getPhoto( $rows );
		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_photos', $pageNav->total );

		return array(	'id'		=>	'photo',
						'title'		=>	CBTxt::T( 'Photos' ),
						'content'	=>	HTML_groupjivePhoto::showPhotos( $rows, $pageNav, $searching, $input, $counters, $group, $user, $this )
					);
	}
예제 #10
0
	/**
	 * prepare frontend wall replies render
	 *
	 * @param WallTable  $reply
	 * @param GroupTable $group
	 * @param UserTable  $user
	 * @return array|null
	 */
	public function showReplies( $reply, $group, $user )
	{
		global $_CB_framework, $_CB_database;

		CBGroupJive::getTemplate( 'replies', true, true, $this->element );

		$canModerate			=	( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( CBGroupJive::getGroupStatus( $user, $group ) >= 2 ) );
		$limit					=	(int) $this->params->get( 'groups_wall_replies_limit', 15 );
		$limitstart				=	$_CB_framework->getUserStateFromRequest( 'gj_group_wall_replies_limitstart{com_comprofiler}', 'gj_group_wall_replies_limitstart' );

		if ( $reply->get( '_replies' ) ) {
			$query				=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_wall' ) . " AS r"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = r.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE r." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND r." . $_CB_database->NameQuote( 'reply' ) . " = " . (int) $reply->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

			if ( ! $canModerate ) {
				$query			.=	"\n AND ( r." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR r.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
			}

			$_CB_database->setQuery( $query );
			$total				=	(int) $_CB_database->loadResult();
		} else {
			$total				=	0;
		}

		if ( ( ! $total ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'wall' ) ) ) {
			return null;
		}

		$pageNav				=	new cbPageNav( $total, $limitstart, $limit );

		$pageNav->setClasses( array( 'cbPaginationLinks' => 'cbPaginationLinks pagination pagination-sm' ) );
		$pageNav->setInputNamePrefix( 'gj_group_wall_replies_' );

		if ( $reply->get( '_replies' ) ) {
			switch( (int) $this->params->get( 'groups_wall_replies_orderby', 2 ) ) {
				case 1:
					$orderBy	=	'r.' . $_CB_database->NameQuote( 'date' ) . ' ASC';
					break;
				case 2:
				default:
					$orderBy	=	'r.' . $_CB_database->NameQuote( 'date' ) . ' DESC';
					break;
			}

			$query				=	'SELECT r.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_wall' ) . " AS r"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb"
								.	' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = r.' . $_CB_database->NameQuote( 'user_id' )
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j"
								.	' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE r." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' )
								.	"\n AND r." . $_CB_database->NameQuote( 'reply' ) . " = " . (int) $reply->get( 'id' )
								.	"\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1"
								.	"\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1"
								.	"\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0";

			if ( ! $canModerate ) {
				$query			.=	"\n AND ( r." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
								.		' OR r.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )';
			}

			$query				.=	"\n ORDER BY " . $orderBy;
			if ( $this->params->get( 'groups_wall_replies_paging', 1 ) ) {
				$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
			} else {
				$_CB_database->setQuery( $query );
			}
			$rows				=	$_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveWall\Table\WallTable', array( $_CB_database ) );

			CBGroupJiveWall::getPost( $rows );
			CBGroupJive::preFetchUsers( $rows );
		} else {
			$rows				=	array();
		}

		return HTML_groupjiveWallReplies::showReplies( $reply, $rows, $pageNav, $group, $user, $this );
	}
예제 #11
0
	/**
	 * @param moscomprofilerTabs $tab
	 * @param UserTable          $user
	 * @param int                $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database,$_PLUGINS;

		$viewer					=	CBuser::getMyUserDataInstance();
                $absPath							=	$_PLUGINS->getPluginPath( $plugin );
                require $absPath . '/templates/default/tab.php';
                //cbmedizdClass::getTemplate();
		if ( $viewer->id == $user->id ) {
			outputCbJs( 1 );
			outputCbTemplate( 1 );
			cbimport( 'cb.pagination' );

			cbinvitesClass::getTemplate( 'tab' );

			$limit				=	(int) $this->params->get( 'tab_limit', 15 );
			$limitstart			=	$_CB_framework->getUserStateFromRequest( 'tab_medizd_limitstart{com_comprofiler}', 'tab_medizd_limitstart' );
			$filterSearch		=	$_CB_framework->getUserStateFromRequest( 'tab_medizd_search{com_comprofiler}', 'tab_medizd_search' );
			$where				=	null;
			$join				=	null;

			if ( isset( $filterSearch ) && ( $filterSearch != '' ) ) {
				$where			.=	"\n AND ( a." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
								.	" OR b." . $_CB_database->NameQuote( 'id' ) . " = " . $_CB_database->Quote( $filterSearch )
								.	" OR a." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false )
								.	" OR b." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )";

				$join			.=	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS b"
								.	' ON b.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'user_id' );
			}

			$searching			=	( $where ? true : false );

			$query				=	'SELECT COUNT(*)'
								.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_cbmedizd' ) . " AS a"
								.	$join
								.	"\n WHERE a." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->id
								.	$where
								.	"\n ORDER BY " . $_CB_database->NameQuote( 'created' ) . " DESC";
			$_CB_database->setQuery( $query );
			$total				=	$_CB_database->loadResult();

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

			$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

			$pageNav->setInputNamePrefix( 'tab_medizd_' );

			$query				=	'SELECT a.*'
								.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_cbmedizd' ) . " AS a"
								.	$join
								.	"\n WHERE a." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->id
								.	$where
								.	"\n ORDER BY " . $_CB_database->NameQuote( 'created' ) . " DESC";
			if ( $this->params->get( 'tab_paging', 1 ) ) {
				$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
			} else {
				$_CB_database->setQuery( $query );
			}
			$rows				=	$_CB_database->loadObjectList( null, 'cbmedizdProductTable', array( $_CB_database ) );

			$input				=	array();
			$input['search']	=	'<input type="text" name="tab_medizd_search" value="' . htmlspecialchars( $filterSearch ) . '" onchange="document.medizdForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'MEDPR_SEARCH_PRODUCT' ) ) . '" class="form-control" />';

			$class				=	$this->params->get( 'general_class', null );

			$return				=	'<div id="cbmedizd" class="cbmedizd' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
								.		'<div id="cbmedizdInner" class="cbmedizdInner">'
								.			HTML_cbmedizdTab::showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $this )
								.		'</div>'
								.	'</div>';

			return $return;
		}

		return null;
	}
예제 #12
0
	/**
	 * @param TabTable  $tab
	 * @param UserTable $user
	 * @param int       $ui
	 * @return null|string
	 */
	public function getDisplayTab( $tab, $user, $ui )
	{
		global $_CB_framework, $_CB_database;

		if ( ( ! Application::MyUser()->isGlobalModerator() ) || Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) {
			return null;
		}

		if ( ! ( $tab->params instanceof ParamsInterface ) ) {
			$tab->params			=	new Registry( $tab->params );
		}

		$blocksEnabled				=	( $this->params->get( 'general_block', 1 ) && $tab->params->get( 'tab_block', $this->tabBlock ) );
		$whitelistsEnabled			=	( $this->params->get( 'general_whitelist', 1 ) && $tab->params->get( 'tab_whitelist', $this->tabWhitelist ) );
		$attemptsEnabled			=	( $this->params->get( 'general_attempts', 1 ) && $tab->params->get( 'tab_attempts', $this->tabAttempts ) );
		$logsEnabled				=	( $this->params->get( 'general_log', 1 ) && $tab->params->get( 'tab_logs', $this->tabLogs ) );
		$return						=	null;

		if ( $blocksEnabled || $whitelistsEnabled || $attemptsEnabled || $logsEnabled ) {
			$tabPrefix				=	'tab_' . (int) $tab->get( 'tabid' ) . '_';
			$viewer					=	CBuser::getMyUserDataInstance();

			outputCbJs( 1 );
			outputCbTemplate( 1 );
			cbimport( 'cb.pagination' );

			cbantispamClass::getTemplate( 'tab' );

			$ipAddress				=	cbantispamClass::getUserIP( $user );
			$emailParts				=	explode( '@', $user->get( 'email' ) );
			$emailDomain			=	null;

			if ( count( $emailParts ) > 1 ) {
				$emailDomain		=	array_pop( $emailParts );
			}

			$blocks					=	null;

			if ( $blocksEnabled ) {
				cbantispamClass::getTemplate( 'blocks' );

				$blocksPrefix		=	$tabPrefix . 'blocks_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $blocksPrefix . 'limitstart{com_comprofiler}', $blocksPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_block' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

				$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

				$pageNav->setInputNamePrefix( $blocksPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_block' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$query				.=	"\n ORDER BY " . $_CB_database->NameQuote( 'id' ) . " ASC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamBlockTable', array( $_CB_database ) );

				$blocks				=	HTML_cbantispamBlocks::showBlocks( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$whitelists				=	null;

			if ( $whitelistsEnabled ) {
				cbantispamClass::getTemplate( 'whitelists' );

				$whitelistsPrefix	=	$tabPrefix . 'whitelists_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $whitelistsPrefix . 'limitstart{com_comprofiler}', $whitelistsPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_whitelist' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

				$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

				$pageNav->setInputNamePrefix( $whitelistsPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_whitelist' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'user' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . (int) $user->get( 'id' ) . ' )'
									.	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'email' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $user->get( 'email' ) ) . ' )';
				if ( $ipAddress ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'ip' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $ipAddress ) . ' )';
				}
				if ( $emailDomain ) {
					$query			.=	' OR ( ' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'domain' )
									.	' AND ' . $_CB_database->NameQuote( 'value' ) . ' = ' . $_CB_database->Quote( $emailDomain ) . ' )';
				}
				$query				.=	"\n ORDER BY " . $_CB_database->NameQuote( 'id' ) . " ASC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamWhitelistTable', array( $_CB_database ) );

				$whitelists			=	HTML_cbantispamWhitelists::showWhitelists( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$attempts				=	null;

			if ( $attemptsEnabled ) {
				cbantispamClass::getTemplate( 'attempts' );

				$attemptsPrefix		=	$tabPrefix . 'attempts_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $attemptsPrefix . 'limitstart{com_comprofiler}', $attemptsPrefix . 'limitstart' );

				if ( $ipAddress ) {
					$query			=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_attempts' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'ip_address' ) . " = " . $_CB_database->Quote( $ipAddress );
					$_CB_database->setQuery( $query );
					$total			=	$_CB_database->loadResult();
				} else {
					$total			=	0;
				}

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

				$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

				$pageNav->setInputNamePrefix( $attemptsPrefix );

				if ( $ipAddress ) {
					$query			=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_attempts' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'ip_address' ) . " = " . $_CB_database->Quote( $ipAddress )
									.	"\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC";
					if ( $tab->params->get( 'tab_paging', 1 ) ) {
						$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
					} else {
						$_CB_database->setQuery( $query );
					}
					$rows			=	$_CB_database->loadObjectList( null, 'cbantispamAttemptsTable', array( $_CB_database ) );
				} else {
					$rows			=	array();
				}

				$attempts			=	HTML_cbantispamAttempts::showAttempts( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$logs					=	null;

			if ( $logsEnabled ) {
				cbantispamClass::getTemplate( 'logs' );

				$logsPrefix			=	$tabPrefix . 'logs_';
				$limit				=	(int) $tab->params->get( 'tab_limit', 15 );
				$limitstart			=	$_CB_framework->getUserStateFromRequest( $logsPrefix . 'limitstart{com_comprofiler}', $logsPrefix . 'limitstart' );

				$query				=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_log' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' );
				$_CB_database->setQuery( $query );
				$total				=	$_CB_database->loadResult();

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

				$pageNav			=	new cbPageNav( $total, $limitstart, $limit );

				$pageNav->setInputNamePrefix( $logsPrefix );

				$query				=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_antispam_log' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
									.	"\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC";
				if ( $tab->params->get( 'tab_paging', 1 ) ) {
					$_CB_database->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
				} else {
					$_CB_database->setQuery( $query );
				}
				$rows				=	$_CB_database->loadObjectList( null, 'cbantispamLogTable', array( $_CB_database ) );

				$logs				=	HTML_cbantispamLogs::showLogs( $rows, $pageNav, $viewer, $user, $tab, $this );
			}

			$class					=	$this->params->get( 'general_class', null );

			$return					=	'<div id="cbAntiSpam" class="cbAntiSpam' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
									.		'<div id="cbAntiSpamInner" class="cbAntiSpamInner">'
									.			HTML_cbantispamTab::showTab( $blocks, $whitelists, $attempts, $logs, $viewer, $user, $tab, $this )
									.		'</div>'
									.	'</div>';
		}

		return $return;
	}
예제 #13
0
 /**
  * View Forum Category Subscriptions
  *
  * @param  UserTable    $viewer  Viewing User
  * @param  UserTable    $user    Viewed at User
  * @param  TabTable     $tab     Current Tab
  * @param  PluginTable  $plugin  Current Plugin
  * @return string|boolean        HTML or FALSE
  */
 public static function getCategorySubscriptions($viewer, $user, $tab, $plugin)
 {
     global $_CB_framework, $_CB_database;
     if (!class_exists('KunenaForumCategoryHelper')) {
         return CBTxt::T('Kunena not installed, enabled, or failed to load.');
     }
     cbimport('cb.pagination');
     cbforumsClass::getTemplate('tab_subs_cats');
     $limit = (int) $tab->params->get('tab_subs_limit', 15);
     $limitstart = $_CB_framework->getUserStateFromRequest('tab_subs_cats_limitstart{com_comprofiler}', 'tab_subs_cats_limitstart');
     $filterSearch = $_CB_framework->getUserStateFromRequest('tab_subs_cats_search{com_comprofiler}', 'tab_subs_cats_search');
     $where = array();
     if (isset($filterSearch) && $filterSearch != '') {
         $where[] = '( c.' . $_CB_database->NameQuote('name') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($filterSearch, true) . '%', false) . ' )';
     }
     $searching = count($where) ? true : false;
     $params = array('where' => count($where) ? ' AND ' . implode(' AND ', $where) : null);
     $categories = KunenaForumCategoryHelper::getLatestSubscriptions((int) $user->id, 0, 0, $params);
     $total = array_shift($categories);
     if ($total <= $limitstart) {
         $limitstart = 0;
     }
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     $pageNav->setInputNamePrefix('tab_subs_cats_');
     if ($tab->params->get('tab_subs_paging', 1)) {
         $categories = KunenaForumCategoryHelper::getLatestSubscriptions((int) $user->id, (int) $pageNav->limitstart, (int) $pageNav->limit, $params);
         $categories = array_pop($categories);
     } else {
         $categories = array_pop($categories);
     }
     $rows = array();
     /** @var KunenaForumCategory[] $categories */
     if ($categories) {
         foreach ($categories as $category) {
             $row = new stdClass();
             $row->id = $category->id;
             $row->category_id = $category->id;
             $row->category_name = $category->name;
             $row->category_url = $category->getUrl();
             $rows[] = $row;
         }
     }
     $input = array();
     $input['search'] = '<input type="text" name="tab_subs_cats_search" value="' . htmlspecialchars($filterSearch) . '" onchange="document.forumCatSubsForm.submit();" placeholder="' . htmlspecialchars(CBTxt::T('Search Category Subscriptions...')) . '" class="form-control" />';
     if (!$rows && !$searching) {
         return false;
     } else {
         return HTML_cbforumsTabCatSubs::showCategorySubscriptions($rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin);
     }
 }