/** * 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 ) ); }
/** * 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 ); }
/** * 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; }
/** * 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 ); }
/** * @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 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 ) ); }
/** * 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 ); }