/** * @param bool $count * @param array $select * @param array $where * @param array $join * @param CB\Plugin\Activity\Activity $stream */ public function activityQuery( $count, &$select, &$where, &$join, &$stream ) { global $_CB_database; $join[] = 'LEFT JOIN ' . $_CB_database->NameQuote( '#__groupjive_plugin_photo' ) . ' AS gj_p' . ' ON a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' ) . ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' ) . ' AND a.' . $_CB_database->NameQuote( 'item' ) . ' = gj_p.' . $_CB_database->NameQuote( 'id' ); if ( ! CBGroupJive::isModerator() ) { $user = CBuser::getMyUserDataInstance(); $where[] = '( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' ) . ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' ) . ' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL' . ' AND ( gj_p.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $user->get( 'id' ) . ' OR ( gj_p.' . $_CB_database->NameQuote( 'published' ) . ' = 1' . ' AND ( gj_g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )' . ' OR gj_u.' . $_CB_database->NameQuote( 'status' ) . ' > 0 ) ) ) )' . ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' ) . ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' ) . ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )'; } else { $where[] = '( ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' ) . ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' = ' . $_CB_database->Quote( 'group.photo' ) . ' AND gj_p.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )' . ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' != ' . $_CB_database->Quote( 'groupjive' ) . ' OR ( a.' . $_CB_database->NameQuote( 'type' ) . ' = ' . $_CB_database->Quote( 'groupjive' ) . ' AND a.' . $_CB_database->NameQuote( 'subtype' ) . ' != ' . $_CB_database->Quote( 'group.photo' ) . ' ) ) )'; } }
/** * @param TabTable $tab Current tab * @param UserTable $user Current user * @param int $ui 1 front, 2 admin UI * @param array $postdata Raw unfiltred POST data * @return string HTML */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { $format = $this->input( 'format', null, GetterInterface::STRING ); if ( $format != 'raw' ) { outputCbJs(); outputCbTemplate(); } $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $id = (int) $this->input( 'id', null, GetterInterface::INT ); $user = CBuser::getMyUserDataInstance(); if ( $format != 'raw' ) { ob_start(); } switch ( $action ) { case 'wall': switch ( $function ) { case 'publish': $this->stateWall( 1, $id, $user ); break; case 'unpublish': $this->stateWall( 0, $id, $user ); break; case 'delete': $this->deleteWall( $id, $user ); break; case 'new': $this->showWallEdit( null, $user ); break; case 'edit': $this->showWallEdit( $id, $user ); break; case 'save': cbSpoofCheck( 'plugin' ); $this->saveWallEdit( $id, $user ); break; } break; } if ( $format != 'raw' ) { $html = ob_get_contents(); ob_end_clean(); $class = $this->_gjParams->get( 'general_class', null ); $return = '<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div class="cbGroupJiveInner">' . $html . '</div>' . '</div>'; echo $return; } }
/** * @param null $tab * @param UserTable $user * @param int $ui * @param array $postdata */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { global $_CB_framework; outputCbJs( 1 ); outputCbTemplate( 1 ); $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $id = $this->input( 'id', null, GetterInterface::INT ); $user = CBuser::getMyUserDataInstance(); $profileUrl = $_CB_framework->userProfileUrl( $user->get( 'id' ), false ); if ( ! $user->get( 'id' ) ) { $profileUrl = 'index.php'; } ob_start(); switch ( $action ) { case 'privacy': switch ( $function ) { case 'disable': $this->disableProfile( $id, $user ); break; case 'disableuser': cbSpoofCheck( 'plugin' ); $this->disableUser( $id, $user ); break; case 'delete': $this->deleteProfile( $id, $user ); break; case 'deleteuser': cbSpoofCheck( 'plugin' ); $this->deleteUser( $id, $user ); break; default: cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); break; } break; default: cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); break; } $html = ob_get_contents(); ob_end_clean(); $class = $this->params->get( 'general_class', null ); $return = '<div id="cbPrivacy" class="cbPrivacy' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbPrivacyInner" class="cbPrivacyInner">' . $html . '</div>' . '</div>'; echo $return; }
/** * @param null $tab * @param UserTable $user * @param int $ui * @param array $postdata */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { global $_CB_framework; outputCbJs( 1 ); outputCbTemplate( 1 ); $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $id = $this->input( 'id', null, GetterInterface::INT ); $user = CBuser::getMyUserDataInstance(); $tab = new TabTable(); $tab->load( array( 'pluginclass' => 'cbinvitesTab' ) ); $profileUrl = $_CB_framework->userProfileUrl( $user->get( 'id' ), false, 'cbinvitesTab' ); if ( ! ( $tab->enabled && Application::MyUser()->canViewAccessLevel( $tab->viewaccesslevel ) ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } ob_start(); switch ( $action ) { case 'preparaty': switch ( $function ) { case 'delete': $this->deletePreparaty( $id, $user ); break; } break; default: cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); break; } $html = ob_get_contents(); ob_end_clean(); $class = $this->params->get( 'general_class', null ); $return = '<div id="cbInvites" class="cbInvites' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbInvitesInner" class="cbInvitesInner">' . $html . '</div>' . '</div>'; echo $return; }
/** * Cleans the field value by type in a secure way for SQL * * @param mixed $fieldValue * @param string $type const,sql,param : string,int,float,datetime,formula * @param GetterInterface $pluginParams * @param DatabaseDriverInterface $db * @param array|null $extDataModels * @return string|boolean STRING: sql-safe value, Quoted or type-casted to int or float, or FALSE in case of type error */ public static function sqlCleanQuote($fieldValue, $type, GetterInterface $pluginParams, DatabaseDriverInterface $db, array $extDataModels = null) { $typeArray = explode(':', $type, 3); if (count($typeArray) < 2) { $typeArray = array('const', $type); } if ($typeArray[0] == 'param') { $fieldValue = $pluginParams->get($fieldValue); } elseif ($typeArray[0] == 'user') { // TODO: Change this to use Inversion Of Control, and allow XML valuetypes to be extended dynamically (e.g. instead of calling specifically CBLib\CB\User or similar when available, it is CB that adds the type and a closure to handle that type. if ($fieldValue == 'viewaccesslevels') { $fieldValue = Application::MyUser()->getAuthorisedViewLevels(); } else { if ($fieldValue == 'usergroups') { $fieldValue = Application::MyUser()->getAuthorisedGroups(false); } else { $fieldValue = \CBuser::getMyUserDataInstance()->get($fieldValue); } } } elseif (in_array($typeArray[0], array('request', 'get', 'post', 'cookie', 'cbcookie', 'session', 'server', 'env'))) { $fieldValue = self::_globalConv($typeArray[0], $fieldValue); } elseif ($typeArray[0] == 'ext') { if (isset($typeArray[2]) && $extDataModels && isset($extDataModels[$typeArray[2]])) { $model = $extDataModels[$typeArray[2]]; if (is_object($model)) { if ($model instanceof ParamsInterface) { $fieldValue = $model->get($fieldValue); } elseif (isset($model->{$fieldValue})) { $fieldValue = $model->{$fieldValue}; } } elseif (is_array($model)) { if (isset($model[$fieldValue])) { $fieldValue = $model[$fieldValue]; } } else { $fieldValue = $model; } } else { trigger_error('SQLXML::sqlCleanQuote: ERROR: ext valuetype "' . htmlspecialchars($type) . '" has not been setExternalDataTypeValues.', E_USER_NOTICE); } // } elseif ( ( $typeArray[0] == 'const' ) || ( $cnt_valtypeArray[0] == 'sql' ) { // $fieldValue = $fieldValue; } if (is_array($fieldValue)) { return self::cleanArrayType($fieldValue, $typeArray[1], $db); } return self::cleanScalarType($fieldValue, $typeArray[1], $db); }
/** * Constructor for stream object * * @param null|string $source * @param null|UserTable $user */ public function __construct( $source = null, $user = null ) { global $_PLUGINS; parent::__construct(); $_PLUGINS->loadPluginGroup( 'user' ); if ( $source === null ) { $source = 'stream'; } if ( $user === null ) { $user = \CBuser::getMyUserDataInstance(); } $this->source = $source; $this->user = $user; if ( ! $this->id ) { $this->id = uniqid(); } }
/** * @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; }
/** * @param TabTable $tab Current tab * @param UserTable $user Current user * @param int $ui 1 front, 2 admin UI * @param array $postdata Raw unfiltred POST data * @return string HTML */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { global $_CB_framework; $format = $this->input( 'format', null, GetterInterface::STRING ); $raw = ( $format == 'raw' ); if ( ! $raw ) { outputCbJs(); outputCbTemplate(); } $action = null; $function = null; $id = null; $viewer = CBuser::getMyUserDataInstance(); $user = $viewer; $stream = null; $inline = false; $data = true; if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof StreamInterface ) ) { $stream = $postdata['stream']; if ( $stream instanceof ActivityInterface ) { $action = 'activity'; $function = 'show'; } elseif ( $stream instanceof CommentsInterface ) { $action = 'comments'; $function = 'show'; } elseif ( $stream instanceof TagsInterface ) { $action = 'tags'; $function = 'show'; } if ( isset( $postdata['inline'] ) ) { $inline = $postdata['inline']; } if ( isset( $postdata['data'] ) ) { $data = $postdata['data']; } $user = $stream->user(); } else { $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); if ( $action == 'recentactivity' ) { $action = 'activity'; $function = 'recent'; } elseif ( $action == 'myactivity' ) { $action = 'activity'; $function = 'my'; } elseif ( $action == 'hiddenactivity' ) { $action = 'hidden'; $function = 'activity'; } elseif ( $action == 'hiddencomments' ) { $action = 'hidden'; $function = 'comments'; } if ( ( $action == 'activity' ) || ( $function == 'activity' ) ) { $stream = new Activity(); } elseif ( ( $action == 'comments' ) || ( $function == 'comments' ) ) { $stream = new Comments(); } elseif ( ( $action == 'tags' ) || ( $function == 'tags' ) ) { $stream = new Tags(); } if ( $stream && $raw ) { $token = $this->input( 'token', null, GetterInterface::STRING ); $post = new Registry( base64_decode( $this->input( 'stream', null, GetterInterface::BASE64 ) ) ); $source = $post->get( 'source', null, GetterInterface::STRING ); $userId = $post->get( 'user', null, GetterInterface::INT ); $direction = $post->get( 'direction', null, GetterInterface::INT ); if ( $source !== null ) { $stream->source( $source ); } if ( $userId !== null ) { $user = CBuser::getUserDataInstance( (int) $userId ); $stream->user( $user ); } if ( ! ( $stream instanceof TagsInterface ) ) { if ( $direction !== null ) { $stream->direction( $direction ); } } $stream->load( $post ); if ( ( $stream->token() != $token ) || ( ! $token ) ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } $id = $stream->get( 'id', null, GetterInterface::INT ); } } if ( $stream && ( ! ( ( $stream instanceof CommentsInterface ) || ( $stream instanceof TagsInterface ) ) ) ) { $hashtag = $this->input( 'hashtag', null, GetterInterface::STRING ); if ( $hashtag !== null ) { $stream->set( 'filter', '#' . $hashtag ); } } if ( ! $raw ) { ob_start(); } switch ( $action ) { case 'comments': if ( ! $stream ) { if ( $raw ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } } switch ( $function ) { case 'new': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->saveComment( null, $stream, $user, $viewer ); break; case 'save': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->saveComment( $id, $stream, $user, $viewer ); break; case 'delete': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->deleteComment( $id, $stream, $user, $viewer ); break; case 'hide': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->hideComment( $id, $stream, $user, $viewer ); break; case 'unhide': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->unhideComment( $id, $stream, $user, $viewer ); break; case 'load': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->showComments( $id, $stream, 3, true, $user, $viewer ); break; case 'show': default: if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof CommentsInterface ) ) { $this->showComments( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer ); } else { $this->showComments( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer ); } break; } break; case 'activity': if ( ! $stream ) { if ( $raw ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } } switch ( $function ) { case 'new': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->saveActivity( null, $stream, $user, $viewer ); break; case 'save': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->saveActivity( $id, $stream, $user, $viewer ); break; case 'delete': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->deleteActivity( $id, $stream, $user, $viewer ); break; case 'hide': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->hideActivity( $id, $stream, $user, $viewer ); break; case 'unhide': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->unhideActivity( $id, $stream, $user, $viewer ); break; case 'load': if ( ! $raw ) { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } $this->showActivity( $id, $stream, 3, true, $user, $viewer ); break; case 'recent': $stream->source( 'recent' ); $menu = JFactory::getApplication()->getMenu()->getActive(); if ( $menu && isset( $menu->id ) ) { CBActivity::loadStreamDefaults( $stream, $menu->params, 'activity_' ); } $this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer ); $_CB_framework->setMenuMeta(); break; case 'my': $tab = new TabTable(); $tab->load( array( 'pluginclass' => 'cbactivityTab' ) ); if ( ! ( $tab->get( 'enabled' ) && CBActivity::canAccess( (int) $tab->get( 'viewaccesslevel' ), (int) $viewer->get( 'id' ) ) ) ) { if ( $raw ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, 'cbactivityTab' ), CBTxt::T( 'Not authorized.' ), 'error' ); } } if ( ! ( $tab->params instanceof ParamsInterface ) ) { $tab->params = new Registry( $tab->params ); } $stream->source( 'profile' ); CBActivity::loadStreamDefaults( $activity, $tab->params, 'tab_activity_' ); $this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer ); $_CB_framework->setMenuMeta(); break; case 'show': default: if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof ActivityInterface ) ) { $this->showActivity( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer ); } else { $this->showActivity( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer ); } break; } break; case 'hidden': if ( ! $stream ) { if ( $raw ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } } switch ( $function ) { case 'users': break; case 'types': break; case 'comments': $stream->source( 'hidden' ); $stream->set( 'create_access', -1 ); $stream->set( 'replies', 0 ); $this->showComments( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer ); break; case 'activity': $stream->source( 'hidden' ); $stream->set( 'create_access', -1 ); $stream->set( 'comments', 0 ); $this->showActivity( $id, $stream, ( $raw ? 1 : 0 ), true, $user, $viewer ); break; } $_CB_framework->setMenuMeta(); break; case 'tags': if ( ! $stream ) { if ( $raw ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); } } switch ( $function ) { case 'show': default: if ( isset( $postdata['stream'] ) && ( $postdata['stream'] instanceof TagsInterface ) ) { $this->showTags( $id, $stream, ( $inline ? 2 : 0 ), $data, $user, $viewer ); } else { $this->showTags( $id, $stream, ( $inline ? 2 : ( $raw ? 1 : 0 ) ), true, $user, $viewer ); } break; } break; case 'cleanup': if ( ( ! $raw ) || ( $this->input( 'token', null, GetterInterface::STRING ) != md5( $_CB_framework->getCfg( 'secret' ) ) ) ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } $this->cleanUp(); break; } if ( ! $raw ) { $html = ob_get_contents(); ob_end_clean(); if ( ! $inline ) { $class = $this->params->get( 'general_class', null ); $html = '<div id="cbActivity" class="cbActivity' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbActivityInner" class="cbActivityInner">' . $html . '</div>' . '</div>'; } echo $html; } }
/** * 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; }
public function delete( $id = null ) { global $_PLUGINS; $plugin = cbconsultationsClass::getPlugin(); $user = CBuser::getMyUserDataInstance(); $key = $this->get( '_tbl_key' ); if ( $id !== null ) { $this->set( $key, $id ); } $id = $this->get( $key ); $article = JTable::getInstance( 'K2Item', 'Table' ); if ( ! $article->load( (int) $id ) ) { return false; } $_PLUGINS->trigger( 'cbconsultations_onBeforeDeleteconsultation', array( &$this, &$article, $user, $plugin ) ); if ( ! $article->delete( (int) $id ) ) { return false; } $_PLUGINS->trigger( 'cbconsultations_onAfterDeleteconsultation', array( $this, $article, $user, $plugin ) ); $article->reorder( $this->_db->NameQuote( 'catid' ) . ' = ' . (int) $article->get( 'catid' ) ); return true; }
static function loginForm( /** @noinspection PhpUnusedParameterInspection */ $option, &$postvars, $regErrorMSG = null, $messagesToUser = null, $alertmessages = null ) { global $_CB_framework, $_CB_database, $_PLUGINS; $results = $_PLUGINS->trigger( 'onBeforeLoginFormDisplay', array( &$postvars, &$regErrorMSG, &$messagesToUser, &$alertmessages ) ); if ( $_PLUGINS->is_errors() ) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit(); } if ( $regErrorMSG ) { $_CB_framework->enqueueMessage( $regErrorMSG, 'error' ); } outputCbTemplate( 1 ); outputCbJs( 1 ); initToolTip( 1 ); $params = null; $moduleFile = $_CB_framework->getCfg( 'absolute_path' ) . '/modules/' . ( checkJversion() > 0 ? 'mod_cblogin/' : '' ) . 'mod_cblogin.php'; if ( file_exists( $moduleFile ) ) { $language = CBuser::getMyUserDataInstance()->getUserLanguage(); if ( ! $language ) { $language = Application::Cms()->getLanguageTag(); } define( '_UE_LOGIN_FROM', 'loginform' ); $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__modules' ) . "\n WHERE " . $_CB_database->NameQuote( 'module' ) . " = " . $_CB_database->Quote( 'mod_cblogin' ) . "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND " . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND " . $_CB_database->NameQuote( 'language' ) . " IN ( " . $_CB_database->Quote( $language ) . ", " . $_CB_database->Quote( '*' ) . ", " . $_CB_database->Quote( '' ) . " )" . "\n ORDER BY " . $_CB_database->NameQuote( 'position' ) . ", " . $_CB_database->NameQuote( 'ordering' ); $_CB_database->setQuery( $query, 0, 1 ); $module = null; $_CB_database->loadObject( $module ); if ( $module ) { $moduleContent = JModuleHelper::renderModule( $module, array( 'style' => 'xhtml' ) ); } else { $moduleContent = CBTxt::T( 'Error: CB Login module not created (required).' ); } } else { $moduleContent = CBTxt::T( 'Error: CB Login module not installed (required).' ); } $return = null; if ( ( is_array( $messagesToUser ) && $messagesToUser ) || ( is_array( $results ) && $results ) ) { $pageClass = $_CB_framework->getMenuPageClass(); $return .= '<div class="cbLoginPage cb_template cb_template_' . selectTemplate( 'dir' ) . ( $pageClass ? ' ' . htmlspecialchars( $pageClass ) : null ) . '">' . ( is_array( $messagesToUser ) && $messagesToUser ? '<div>' . implode( '</div><div>', $messagesToUser ) . '</div>' : null ) . ( is_array( $results ) && $results ? implode( '', $results ) : null ) . '</div>'; } $return .= $moduleContent; echo $return; $_CB_framework->setMenuMeta(); }
/** * @param TabTable $tab * @param UserTable $user * @param int $ui * @return null|string */ public function getDisplayTab( $tab, $user, $ui ) { if ( ! ( $tab->params instanceof ParamsInterface ) ) { $tab->params = new Registry( $tab->params ); } $photosEnabled = $tab->params->get( 'tab_photos', $this->tabPhotos ); $filesEnabled = $tab->params->get( 'tab_files', $this->tabFiles ); $videosEnabled = $tab->params->get( 'tab_videos', $this->tabVideos ); $musicEnabled = $tab->params->get( 'tab_music', $this->tabMusic ); $return = null; if ( $photosEnabled || $filesEnabled || $videosEnabled || $musicEnabled ) { $viewer = CBuser::getMyUserDataInstance(); outputCbJs( 1 ); outputCbTemplate( 1 ); cbimport( 'cb.pagination' ); cbgalleryClass::getTemplate( 'tab' ); $photos = null; if ( $photosEnabled ) { $photos = $this->getGallery( 'photos', $tab, $user, $viewer ); } $files = null; if ( $filesEnabled ) { $files = $this->getGallery( 'files', $tab, $user, $viewer ); } $videos = null; if ( $videosEnabled ) { $videos = $this->getGallery( 'videos', $tab, $user, $viewer ); } $music = null; if ( $musicEnabled ) { $music = $this->getGallery( 'music', $tab, $user, $viewer ); } if ( $photos || $files || $videos || $music ) { $class = $this->params->get( 'general_class', null ); $return = '<div id="cbGallery" class="cbGallery' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbGalleryInner" class="cbGalleryInner">' . HTML_cbgalleryTab::showTab( $photos, $files, $videos, $music, $viewer, $user, $tab, $this ) . '</div>' . '</div>'; } } return $return; }
/** * Checks if a page is executed https, and if not, if it should be according to login module HTTPS posts specifications * * @param boolean $return [default: false] : True: returns if https switchover is needed for the POST form (if not already on HTTPS and login module asks for it). False: errors 403 if not in https and it's configured in login module. * @return boolean True: switchover needed (returned only if $return = true) */ function checkCBPostIsHTTPS($return = false) { global $_CB_framework, $_CB_database, $_SERVER; $isHttps = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; if (!$isHttps && file_exists($_CB_framework->getCfg('absolute_path') . '/modules/' . (checkJversion() > 0 ? 'mod_cblogin/' : null) . 'mod_cblogin.php')) { $language = CBuser::getMyUserDataInstance()->getUserLanguage(); if (!$language) { $language = Application::Cms()->getLanguageTag(); } $query = 'SELECT ' . $_CB_database->NameQuote('params') . "\n FROM " . $_CB_database->NameQuote('#__modules') . "\n WHERE " . $_CB_database->NameQuote('module') . " = " . $_CB_database->Quote('mod_cblogin') . "\n AND " . $_CB_database->NameQuote('published') . " = 1" . "\n AND " . $_CB_database->NameQuote('access') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()) . "\n AND " . $_CB_database->NameQuote('language') . " IN ( " . $_CB_database->Quote($language) . ", " . $_CB_database->Quote('*') . ", " . $_CB_database->Quote('') . " )" . "\n ORDER BY " . $_CB_database->NameQuote('position') . ", " . $_CB_database->NameQuote('ordering'); $_CB_database->setQuery($query, 0, 1); $module = $_CB_database->loadResult(); if ($module) { $params = new Registry($module); $https_post = $params->get('https_post', 0) != 0; } else { $https_post = false; } } else { $https_post = false; } if ($return) { return $https_post; } else { if ($https_post && !$isHttps) { header('HTTP/1.0 403 Forbidden'); exit(CBTxt::T('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!')); } } return null; }
/** * Returns a provider button * * @param string $provider * @param int $horizontal * @return null|string */ public function getButton( $provider, $horizontal = 1 ) { global $_CB_framework; if ( ! ( $provider && isset( $this->providers[$provider] ) ) ) { return null; } $fieldName = $this->providers[$provider]['field']; $siteName = $this->providers[$provider]['name']; $iconClass = $this->providers[$provider]['icon']; $buttonClass = $this->providers[$provider]['button']; $user = CBuser::getMyUserDataInstance(); $style = (int) $this->params->get( $provider . '_button_style', 2, GetterInterface::INT ); if ( $style == 1 ) { $horizontal = 1; } static $returnUrl = null; if ( ! isset( $returnUrl ) ) { $returnUrl = $this->input->get( 'return', null, GetterInterface::BASE64 ); if ( $returnUrl ) { $returnUrl = base64_decode( $returnUrl ); } else { $isHttps = ( isset( $_SERVER['HTTPS'] ) && ( ! empty( $_SERVER['HTTPS'] ) ) && ( $_SERVER['HTTPS'] != 'off' ) ); $returnUrl = 'http' . ( $isHttps ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST']; if ( ( ! empty( $_SERVER['PHP_SELF'] ) ) && ( ! empty( $_SERVER['REQUEST_URI'] ) ) ) { $returnUrl .= $_SERVER['REQUEST_URI']; } else { $returnUrl .= $_SERVER['SCRIPT_NAME']; if ( isset( $_SERVER['QUERY_STRING'] ) && ( ! empty( $_SERVER['QUERY_STRING'] ) ) ) { $returnUrl .= '?' . $_SERVER['QUERY_STRING']; } } } $returnUrl = cbUnHtmlspecialchars( preg_replace( '/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', preg_replace( '/eval\((.*)\)/', '', htmlspecialchars( urldecode( $returnUrl ) ) ) ) ); if ( preg_match( '/index\.php\?option=com_comprofiler&view=login|index\.php\?option=com_comprofiler&view=pluginclass&plugin=cbconnect/', $returnUrl ) ) { $returnUrl = 'index.php'; } $returnUrl = base64_encode( $returnUrl ); } $return = null; if ( $this->params->get( $provider . '_enabled', false, GetterInterface::BOOLEAN ) ) { if ( $user->get( 'id' ) ) { if ( $this->params->get( $provider . '_link', true, GetterInterface::BOOLEAN ) && ( ! $user->get( $fieldName ) ) ) { $link = $this->params->get( $provider . '_button_link', null, GetterInterface::STRING ); $return = '<button class="cbConnectButton cbConnectButton' . ucfirst( $provider ) . ' btn btn-' . $buttonClass . ' btn-sm' . ( ! $horizontal ? ' btn-block' : null ) . '" onclick="window.location=\'' . $_CB_framework->pluginClassUrl( $this->plugin->element, false, array( 'provider' => $provider, 'action' => 'authenticate', 'return' => $returnUrl ) ) . '\'; return false;" title="' . htmlspecialchars( CBTxt::T( 'LINK_YOUR_SITENAME_ACCOUNT', 'Link your [sitename] account', array( '[sitename]' => $siteName ) ) ) . '">' . ( in_array( $style, array( 1, 2 ) ) ? '<span class="fa fa-' . $iconClass . ' fa-lg' . ( $style != 1 ? ' cbConnectButtonPrefix' : null ) . '"></span>' : null ) . ( in_array( $style, array( 2, 3 ) ) ? ( $link ? $link : CBTxt::T( 'LINK_WITH_SITENAME', 'Link with [sitename]', array( '[sitename]' => $siteName ) ) ) : null ) . '</button>' . ( $horizontal ? ' ' : null ); } } else { $signin = $this->params->get( $provider . '_button_signin', null, GetterInterface::STRING ); $return = '<button class="cbConnectButton cbConnectButton' . ucfirst( $provider ) . ' btn btn-' . $buttonClass . ' btn-sm' . ( ! $horizontal ? ' btn-block' : null ) . '" onclick="window.location=\'' . $_CB_framework->pluginClassUrl( $this->plugin->element, false, array( 'provider' => $provider, 'action' => 'authenticate', 'return' => $returnUrl ) ) . '\'; return false;" title="' . htmlspecialchars( CBTxt::T( 'LOGIN_WITH_YOUR_SITENAME_ACCOUNT', 'Login with your [sitename] account', array( '[sitename]' => $siteName ) ) ) . '">' . ( in_array( $style, array( 1, 2 ) ) ? '<span class="fa fa-' . $iconClass . ' fa-lg' . ( $style != 1 ? ' cbConnectButtonPrefix' : null ) . '"></span>' : null ) . ( in_array( $style, array( 2, 3 ) ) ? ( $signin ? $signin : CBTxt::T( 'SIGN_IN_WITH_SITENAME', 'Sign in with [sitename]', array( '[sitename]' => $siteName ) ) ) : null ) . '</button>' . ( $horizontal ? ' ' : null ); } } return $return; }
/** * render frontend group activity * * @param CB\Plugin\Activity\Table\ActivityTable $row * @param string $title * @param string $message * @param CB\Plugin\Activity\Activity $stream * @param GroupTable $group * @param cbgjPlugin $plugin * @return string */ static function showActivity( $row, &$title, &$message, $stream, $group, $plugin ) { global $_CB_framework; initToolTip(); $message = null; switch( $row->get( 'subtype' ) ) { case 'group.join': $title = CBTxt::T( 'joined a group' ); break; case 'group.leave': $title = CBTxt::T( 'left a group' ); break; case 'group': $title = CBTxt::T( 'created a group' ); break; } $user = CBuser::getMyUserDataInstance(); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $groupOwner = ( $user->get( 'id' ) == $group->get( 'user_id' ) ); $userStatus = CBGroupJive::getGroupStatus( $user, $group ); $return = '<div class="gjActivity">' . '<div class="gjGroupCanvas gjPageHeader border-default">' . '<div class="gjPageHeaderCanvas">' . '<div class="gjPageHeaderCanvasBackground">' . $group->canvas() . '</div>' . '<div class="gjPageHeaderCanvasLogo">' . $group->logo( false, true, true ) . '</div>'; if ( $isModerator || $groupOwner || ( ( ! $groupOwner ) && ( ( $userStatus === null ) || ( $userStatus === 0 ) || ( $userStatus >= 1 ) ) ) ) { $return .= '<div class="gjPageHeaderCanvasButtons text-right">'; if ( $isModerator && ( $group->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>' . '</span>'; } elseif ( ! $groupOwner ) { if ( $userStatus === null ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . ( $group->get( '_invite_id' ) ? '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to reject all invites to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'reject', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })" class="gjButton gjButtonReject btn btn-xs btn-danger">' . CBTxt::T( 'Reject' ) . '</button> ' : null ) . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'join', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\';" class="gjButton gjButtonJoin btn btn-xs btn-success">' . ( $group->get( '_invite_id' ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) . '</button>' . '</span>'; } elseif ( $userStatus === 0 ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel your pending join request to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'cancel', 'id' => (int) $group->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) . '\'; })" class="gjButton gjButtonCancel btn btn-xs btn-danger">' . CBTxt::T( 'Cancel' ) . '</button> ' . '<span class="gjButton gjButtonPending btn btn-xs btn-warning disabled">' . CBTxt::T( 'Pending Approval' ) . '</span>' . '</span>'; } } $return .= '</div>'; } $return .= '</div>' . '<div class="gjPageHeaderBar border-default">' . '<div class="gjPageHeaderBarTitle text-primary">' . '<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $group->get( 'name' ) ) ) . '</a></strong>' . '</div>' . '<div class="gjPageHeaderBarCounters text-muted small">'; if ( $group->get( 'category' ) ) { $return .= '<span class="gjPageHeaderBarCounter"><span class="gjGroupCategoryIcon fa-before fa-folder">' . ' <a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $group->get( 'category' ) ) ) . '">' . CBTxt::T( $group->category()->get( 'name' ) ) . '</a>' . '</span></span>'; } $return .= ' <span class="gjPageHeaderBarCounter"><span class="gjGroupTypeIcon fa-before fa-globe"> ' . $group->type() . '</span></span>' . ' <span class="gjPageHeaderBarCounter"><span class="gjGroupUsersIcon fa-before fa-user"> ' . CBTxt::T( 'GROUP_USERS_COUNT', '%%COUNT%% User|%%COUNT%% Users', array( '%%COUNT%%' => (int) $group->get( '_users', 0 ) ) ) . '</span></span>' . '</div>' . ( $group->get( 'description' ) ? ' <div class="gjPageHeaderBarDescription">' . cbTooltip( 1, CBTxt::T( $group->get( 'description' ) ), CBTxt::T( $group->get( 'name' ) ), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null ) . '</div>' . '</div>' . '</div>'; return $return; }
/** * render frontend event activity * * @param CB\Plugin\Activity\Table\ActivityTable $row * @param string $title * @param string $message * @param CB\Plugin\Activity\Activity $stream * @param EventTable $event * @param cbgjEventsPlugin $plugin * @return string */ static function showEventActivity( $row, &$title, &$message, $stream, $event, $plugin ) { global $_CB_framework; $title = CBTxt::T( 'GROUP_EVENT_ACTIVITY_TITLE', 'scheduled an event in [group]', array( '[group]' => '<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $event->group()->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $event->group()->get( 'name' ) ) ) . '</a></strong>' ) ); $user = CBuser::getMyUserDataInstance(); $userStatus = CBGroupJive::getGroupStatus( $user, $event->group() ); $eventOwner = ( $user->get( 'id' ) == $event->get( 'user_id' ) ); $showAddress = $plugin->params->get( 'groups_events_address', 1 ); $address = htmlspecialchars( $event->get( 'location' ) ); if ( $showAddress ) { if ( $event->get( 'address' ) ) { $mapUrl = CBTxt::T( 'GROUP_EVENT_ADDRESS_MAP_URL', 'https://www.google.com/maps/place/[address]', array( '[location]' => urlencode( $event->get( 'location' ) ), '[address]' => urlencode( $event->get( 'address' ) ) ) ); } else { $mapUrl = CBTxt::T( 'GROUP_EVENT_LOCATION_MAP_URL', 'https://www.google.com/maps/search/[location]', array( '[location]' => urlencode( $event->get( 'location' ) ), '[address]' => urlencode( $event->get( 'address' ) ) ) ); } if ( $mapUrl ) { $address = '<a href="' . htmlspecialchars( $mapUrl ) . '" target="_blank" rel="nofollow">' . $address . '</a>'; } } $canAttend = ( ( ! $eventOwner ) && ( $event->status() != 1 ) && ( ! $event->get( '_attending' ) ) && ( $userStatus >= 1 ) && ( ( ! $event->get( 'limit' ) ) || ( $event->get( 'limit' ) && ( $event->get( '_guests' ) < $event->get( 'limit' ) ) ) ) ); $return = '<div class="gjEventActivity">' . '<div class="gjGroupEventsRow row' . ( $event->status() == 1 ? ' gjGroupEventExpired' : ( $event->status() == 2 ? ' gjGroupEventActive' : null ) ) . '">' . '<div class="gjGroupEventCalendar col-md-2 hidden-sm hidden-xs">' . '<div class="panel panel-default text-center">' . '<div class="gjGroupEventMonth panel-body">' . cbFormatDate( $event->get( 'start' ), true, false, 'M' ) . '</div>' . '<div class="gjGroupEventDay panel-footer">' . cbFormatDate( $event->get( 'start' ), true, false, 'j' ) . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventContainer col-md-10 col-sm-12 col-xs-12">' . '<div class="panel ' . ( $event->status() == 1 ? 'panel-warning' : ( $event->status() == 2 ? 'panel-primary' : 'panel-default' ) ) . '">' . '<div class="gjGroupEventHeader panel-heading">' . '<div class="row">' . '<div class="gjGroupEventTitle ' . ( $canAttend ? 'col-sm-8' : 'col-sm-12' ) . '">' . htmlspecialchars( $event->get( 'title' ) ) . '</div>'; if ( $canAttend ) { $return .= '<div class="gjGroupEventMenu col-sm-4 text-right">' . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'attend', 'id' => (int) $event->get( 'id' ) ) ) . '\';" class="gjButton gjButtonAttend btn btn-xs btn-success">' . CBTxt::T( 'Attend' ) . '</button>' . '</div>'; } $return .= '</div>' . '</div>' . '<div class="gjGroupEventDetails panel-body small">'; if ( $event->status() == 1 ) { $return .= '<div class="gjGroupEventNotice text-warning text-right">' . CBTxt::T( 'This event has ended.' ) . '</div>'; } elseif ( $event->status() == 2 ) { if ( $event->get( 'end' ) ) { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'GROUP_EVENT_ENDS_IN', 'This event is currently in progress and ends in [timeago].', array( '[timeago]' => cbFormatDate( $event->get( 'end' ), true, 'exacttimeago' ) ) ) . '</div>'; } else { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'This event is currently in progress.' ) . '</div>'; } } else { $return .= '<div class="gjGroupEventNotice text-right">' . CBTxt::T( 'GROUP_EVENT_STARTS_IN', 'This event starts in [timeago].', array( '[timeago]' => cbFormatDate( $event->get( 'start' ), true, 'exacttimeago' ) ) ) . '</div>'; } $return .= '<div class="gjGroupEventDate">' . '<span class="gjGroupEventIcon fa fa-clock-o text-center"></span> ' . $event->date() . '</div>' . '<div class="gjGroupEventLocation">' . '<span class="gjGroupEventIcon fa fa-map-marker text-center"></span> ' . $address . '</div>' . '<div class="gjGroupEventAttending">' . '<div class="gjGroupEventGuests">' . '<span class="gjGroupEventIcon fa fa-users text-center"></span> ' . '<a href="' . htmlspecialchars( $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'attending', 'id' => (int) $event->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) ) . '">' . ( $event->get( 'limit' ) ? CBTxt::T( 'GROUP_GUESTS_COUNT_LIMITED', '%%COUNT%% of [limit] Guest|%%COUNT%% of [limit] Guests', array( '%%COUNT%%' => (int) $event->get( '_guests', 0 ), '[limit]' => (int) $event->get( 'limit' ) ) ) : CBTxt::T( 'GROUP_GUESTS_COUNT', '%%COUNT%% Guest|%%COUNT%% Guests', array( '%%COUNT%%' => (int) $event->get( '_guests', 0 ) ) ) ) . '</a>' . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventDescription panel-footer">' . '<div class="cbMoreLess">' . '<div class="cbMoreLessContent">' . ( $plugin->params->get( 'groups_events_content_plugins', 0 ) ? Application::Cms()->prepareHtmlContentPlugins( $event->get( 'event' ) ) : $event->get( 'event' ) ) . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; return $return; }
/** * @param string $text * @param string $phrase * @param string $ordering * @param null $areas * @return array|null */ public function onContentSearch( $text, $phrase = '', $ordering = '', $areas = null ) { global $_CB_database, $_CB_framework; if ( ( ( ! $this->getCategorySearching() ) && ( ! $this->getGroupSearching() ) ) || ( ! $text ) || ( ! $this->_gjPlugin ) ) { return array(); } $user = CBuser::getMyUserDataInstance(); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $results = array(); $excludeCategories = $this->params->get( 'search_category_exclude', null ); if ( $excludeCategories ) { $excludeCategories = explode( '|*|', $excludeCategories ); } $excludeGroups = $this->params->get( 'search_group_exclude', null ); if ( $excludeGroups ) { $excludeGroups = explode( '|*|', $excludeGroups ); } if ( $this->getCategorySearching() ) { $resultTitle = $this->params->get( 'results_category_title', '[name]' ); $resultText = $this->params->get( 'results_category_text', '[description]' ); $resultsLimit = (int) $this->params->get( 'results_category_limit', 50 ); $resultsLinks = (int) $this->params->get( 'results_category_link', 0 ); switch( $phrase ) { case 'exact': $where = "\n WHERE ( c." . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( $text ) . " OR c." . $_CB_database->NameQuote( 'description' ) . " = " . $_CB_database->Quote( $text ) . " )"; break; case 'any': case 'all': default: $words = explode( ' ', $text ); $search = array(); foreach ( $words as $word ) { $search[] = "( c." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $word, true ) . '%', false ) . " OR c." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $word, true ) . '%', false ) . " )"; } $where = "\n WHERE ( " . implode( ( $phrase == 'any' ? " OR " : " AND " ), $search ) . " )"; break; } switch( $ordering ) { case 'oldest': $orderBy = 'c.' . $_CB_database->NameQuote( 'ordering' ) . ' ASC'; break; case 'popular': $orderBy = $_CB_database->NameQuote( '_groups' ) . ' DESC'; break; case 'alpha': $orderBy = 'c.' . $_CB_database->NameQuote( 'name' ) . ' ASC'; break; case 'newest': case 'category': default: $orderBy = 'c.' . $_CB_database->NameQuote( 'ordering' ) . ' DESC'; break; } $groups = null; if ( $ordering == 'popular' ) { $groups = 'SELECT COUNT(*)' . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_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' ); if ( ! $isModerator ) { $groups .= "\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 ) )'; } $groups .= "\n WHERE g." . $_CB_database->NameQuote( 'category' ) . " = c." . $_CB_database->NameQuote( '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 ( ! $isModerator ) { $groups .= "\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . ' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1' . ' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )' . ' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )' . ' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )'; } } $query = 'SELECT c.*' . ( $ordering == 'popular' ? ', ( ' . $groups . ' ) AS _groups' : null ) . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c" . $where; if ( ! $isModerator ) { $query .= "\n AND c." . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND c." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( $user->get( 'id' ) ) ); } $query .= ( $excludeCategories ? "\n AND c." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeCategories ) : null ) . "\n ORDER BY " . $orderBy; if ( $resultsLimit ) { $_CB_database->setQuery( $query, 0, $resultsLimit ); } else { $_CB_database->setQuery( $query ); } $rows = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\CategoryTable', array( $_CB_database ) ); /** @var CategoryTable[] $rows */ foreach ( $rows as $row ) { $url = $_CB_framework->pluginClassUrl( $this->_gjPlugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ); $extras = array( '[id]' => $row->get( 'id' ), '[name]' => CBTxt::T( $row->get( 'name' ) ), '[description]' => CBTxt::T( $row->get( 'description' ) ), '[logo]' => $row->logo( true, false, true ), '[canvas]' => $row->canvas( true ), '[url]' => $url ); $result = new stdClass(); $result->href = $url; $result->title = CBTxt::T( 'CATEGORY_SEARCH_TITLE', $resultTitle, $extras ); $result->text = CBTxt::T( 'CATEGORY_SEARCH_TEXT', $resultText, $extras ); $result->created = null; $result->browsernav = $resultsLinks; $result->section = 0; $results[] = $result; } } if ( $this->getGroupSearching() ) { $resultTitle = $this->params->get( 'results_group_title', '[name]' ); $resultText = $this->params->get( 'results_group_text', '[description]' ); $resultsLimit = (int) $this->params->get( 'results_group_limit', 50 ); $resultsLinks = (int) $this->params->get( 'results_group_link', 0 ); switch( $phrase ) { case 'exact': $where = "\n AND ( g." . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( $text ) . " OR g." . $_CB_database->NameQuote( 'description' ) . " = " . $_CB_database->Quote( $text ) . " )"; break; case 'any': case 'all': default: $words = explode( ' ', $text ); $search = array(); foreach ( $words as $word ) { $search[] = "( g." . $_CB_database->NameQuote( 'name' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $word, true ) . '%', false ) . " OR g." . $_CB_database->NameQuote( 'description' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $word, true ) . '%', false ) . " )"; } $where = "\n AND ( " . implode( ( $phrase == 'any' ? " OR " : " AND " ), $search ) . " )"; break; } switch( $ordering ) { case 'oldest': $orderBy = 'g.' . $_CB_database->NameQuote( 'date' ) . ' ASC'; break; case 'popular': $orderBy = $_CB_database->NameQuote( '_users' ) . ' DESC'; break; case 'alpha': $orderBy = 'g.' . $_CB_database->NameQuote( 'name' ) . ' ASC'; break; case 'category': $orderBy = 'c.' . $_CB_database->NameQuote( 'ordering' ) . ' ASC'; break; case 'newest': default: $orderBy = 'g.' . $_CB_database->NameQuote( 'date' ) . ' DESC'; break; } $users = null; if ( $ordering == 'popular' ) { $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) $user->get( 'id' ) . ' OR u.' . $_CB_database->NameQuote( 'status' ) . ' >= 2' . ' OR uc.' . $_CB_database->NameQuote( 'status' ) . ' >= 1 )'; } if ( ! $this->_gjParams->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' . ( $ordering == 'popular' ? ', ( ' . $users . ' ) AS _users' : null ) . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_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_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 ) )' . "\n WHERE cb." . $_CB_database->NameQuote( 'approved' ) . " = 1" . "\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1" . "\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0"; if ( ! $isModerator ) { $query .= "\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . ' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1' . ' AND ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 )' . ' OR u.' . $_CB_database->NameQuote( 'status' ) . ' IN ( 0, 1, 2, 3 )' . ' OR i.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) )' . "\n AND ( ( c." . $_CB_database->NameQuote( 'published' ) . " = 1" . ' AND c.' . $_CB_database->NameQuote( 'access' ) . ' IN ' . $_CB_database->safeArrayOfIntegers( CBGroupJive::getAccess( (int) $user->get( 'id' ) ) ) . ' )' . ( $this->_gjParams->get( 'groups_uncategorized', 1 ) ? ' OR g.' . $_CB_database->NameQuote( 'category' ) . ' = 0 )' : ' )' ); } $query .= $where . ( $excludeCategories ? "\n AND c." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeCategories ) : null ) . ( $excludeGroups ? "\n AND g." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeGroups ) : null ) . "\n ORDER BY " . $orderBy; if ( $resultsLimit ) { $_CB_database->setQuery( $query, 0, $resultsLimit ); } else { $_CB_database->setQuery( $query ); } $rows = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\GroupTable', array( $_CB_database ) ); /** @var GroupTable[] $rows */ foreach ( $rows as $row ) { $url = $_CB_framework->pluginClassUrl( $this->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ); $extras = array( '[id]' => $row->get( 'id' ), '[name]' => CBTxt::T( $row->get( 'name' ) ), '[description]' => CBTxt::T( $row->get( 'description' ) ), '[logo]' => $row->logo( true, false, true ), '[canvas]' => $row->canvas( true ), '[url]' => $url, '[date]' => cbFormatDate( $row->get( 'date' ) ) ); $result = new stdClass(); $result->href = $url; $result->title = CBTxt::T( 'GROUP_SEARCH_TITLE', $resultTitle, $extras ); $result->text = CBTxt::T( 'GROUP_SEARCH_TEXT', $resultText, $extras ); $result->created = $row->get( 'date' ); $result->browsernav = $resultsLinks; $result->section = 0; $results[] = $result; } } return $results; }
/** * @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; }
/** * @param TabTable $tab Current tab * @param UserTable $user Current user * @param int $ui 1 front, 2 admin UI * @param array $postdata Raw unfiltred POST data * @return string HTML */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { global $_CB_framework; $format = $this->input( 'format', null, GetterInterface::STRING ); if ( $format != 'raw' ) { outputCbJs( 1 ); outputCbTemplate( 1 ); } $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $type = $this->input( 'type', null, GetterInterface::STRING ); $id = (int) $this->input( 'id', null, GetterInterface::INT ); $userId = (int) $this->input( 'user', null, GetterInterface::INT ); $tabId = (int) $this->input( 'tab', null, GetterInterface::INT ); if ( ! $tabId ) { switch( $type ) { case 'photos': $tabId = 'cbgalleryTabPhotos'; break; case 'files': $tabId = 'cbgalleryTabFiles'; break; case 'videos': $tabId = 'cbgalleryTabVideos'; break; case 'music': $tabId = 'cbgalleryTabMusic'; break; } } $viewer = CBuser::getMyUserDataInstance(); if ( $userId ) { $user = CBuser::getUserDataInstance( (int) $userId ); } else { $user = CBuser::getMyUserDataInstance(); } $profileUrl = $_CB_framework->userProfileUrl( (int) $user->get( 'id' ), false, $tabId ); if ( ! in_array( $type, array( 'photos', 'files', 'videos', 'music' ) ) ) { if ( ( $action == 'items' ) && in_array( $function, array( 'download', 'preview', 'show' ) ) ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } } $tab = new TabTable(); $tab->load( ( is_integer( $tabId ) ? $tabId : array( 'pluginclass' => $tabId ) ) ); if ( ! ( $tab->get( 'enabled' ) && Application::User( (int) $viewer->get( 'id' ) )->canViewAccessLevel( $tab->get( 'viewaccesslevel' ) ) ) ) { if ( ( $action == 'items' ) && in_array( $function, array( 'download', 'preview', 'show' ) ) ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } else { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } } if ( ! ( $tab->params instanceof ParamsInterface ) ) { $tab->params = new Registry( $tab->params ); } if ( $format != 'raw' ) { ob_start(); } switch ( $action ) { case 'items': switch ( $function ) { case 'download': $this->outputItem( false, false, $id, $type, $tab, $user, $viewer ); break; case 'edit': $this->showItemEdit( $id, $type, $tab, $user, $viewer ); break; case 'new': $this->showItemEdit( null, $type, $tab, $user, $viewer ); break; case 'save': cbSpoofCheck( 'plugin' ); $this->saveItemEdit( $id, $type, $tab, $user, $viewer ); break; case 'publish': $this->stateItem( 1, $id, $type, $tab, $user, $viewer ); break; case 'unpublish': $this->stateItem( 0, $id, $type, $tab, $user, $viewer ); break; case 'delete': $this->deleteItem( $id, $type, $tab, $user, $viewer ); break; case 'preview': $this->outputItem( true, true, $id, $type, $tab, $user, $viewer ); break; case 'show': default: $this->outputItem( true, false, $id, $type, $tab, $user, $viewer ); break; } break; case 'folders': if ( ! $tab->params->get( 'tab_' . $type . '_folders', 1 ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } switch ( $function ) { case 'edit': $this->showFolderEdit( $id, $type, $tab, $user, $viewer ); break; case 'new': $this->showFolderEdit( null, $type, $tab, $user, $viewer ); break; case 'save': cbSpoofCheck( 'plugin' ); $this->saveFolderEdit( $id, $type, $tab, $user, $viewer ); break; case 'publish': $this->stateFolder( 1, $id, $type, $tab, $user, $viewer ); break; case 'unpublish': $this->stateFolder( 0, $id, $type, $tab, $user, $viewer ); break; case 'delete': $this->deleteFolder( $id, $type, $tab, $user, $viewer ); break; case 'show': default: $this->showFolder( $id, $type, $tab, $user, $viewer ); break; } break; default: cbRedirect( 'index.php', CBTxt::T( 'Not authorized.' ), 'error' ); break; } if ( $format != 'raw' ) { $html = ob_get_contents(); ob_end_clean(); $class = $this->params->get( 'general_class', null ); $return = '<div id="cbGallery" class="cbGallery' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbGalleryInner" class="cbGalleryInner">' . $html . '</div>' . '</div>'; echo $return; } }
/** * Prepares the action to be executed from trigger * * @param cbautoactionsActionTable|int $trigger * @param string $event * @param mixed $var1 * @param mixed $var2 * @param mixed $var3 * @param mixed $var4 * @param mixed $var5 * @param mixed $var6 * @param mixed $var7 * @param mixed $var8 * @param mixed $var9 * @param mixed $var10 * @return mixed */ public function getTrigger( $trigger, $event, &$var1 = null, &$var2 = null, &$var3 = null, &$var4 = null, &$var5 = null, &$var6 = null, &$var7 = null, &$var8 = null, &$var9 = null, &$var10 = null ) { if ( is_integer( $trigger ) ) { $triggerId = $trigger; $trigger = new cbautoactionsActionTable(); $trigger->load( $triggerId ); } if ( $trigger->get( 'id' ) ) { $vars = array( 'trigger' => $event, 'var1' => &$var1, 'var2' => &$var2, 'var3' => &$var3, 'var4' => &$var4, 'var5' => &$var5, 'var6' => &$var6, 'var7' => &$var7, 'var8' => &$var8, 'var9' => &$var9, 'var10' => &$var10 ); if ( $trigger->get( 'object' ) == 3 ) { $user = CBuser::getUserDataInstance( (int) $trigger->get( 'variable' ) ); } elseif ( $trigger->get( 'object' ) == 2 ) { $user = CBuser::getMyUserDataInstance(); } elseif ( $trigger->get( 'object' ) == 1 ) { $user = $this->prepareUser( ${ 'var' . (int) $trigger->get( 'variable' ) } ); if ( $user->get( 'id' ) && $trigger->getParams()->get( 'reload', false, GetterInterface::BOOLEAN ) ) { $user->load( (int) $user->get( 'id' ) ); } } else { $user = $this->getUser( $vars ); if ( $user->get( 'id' ) && $trigger->getParams()->get( 'reload', false, GetterInterface::BOOLEAN ) ) { $user->load( (int) $user->get( 'id' ) ); } } if ( $user->get( 'id' ) ) { $rawPassword = $this->input( 'post/passwd', null, GetterInterface::STRING ); if ( ! $rawPassword ) { $rawPassword = $this->input( 'post/password', null, GetterInterface::STRING ); } } else { $rawPassword = null; } return $this->getAction( $trigger, $user, $rawPassword, $vars ); } return null; }
/** * @param string $return * @param CB\Plugin\Activity\Table\ActivityTable[] $rows * @param CB\Plugin\Activity\Activity $stream * @param int $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save */ public function activityPrefetch( &$return, &$rows, $stream, $output ) { global $_CB_database; $eventIds = array(); foreach ( $rows as $row ) { if ( ! ( ( $row->get( 'type' ) == 'groupjive' ) && ( $row->get( 'subtype' ) == 'group.event' ) ) ) { continue; } $eventId = (int) $row->get( 'item' ); if ( $eventId && ( ! in_array( $eventId, $eventIds ) ) ) { $eventIds[] = $eventId; } } if ( ! $eventIds ) { return; } $user = CBuser::getMyUserDataInstance(); $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"; $query = 'SELECT e.*' . ', 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( '#__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( 'id' ) . " IN " . $_CB_database->safeArrayOfIntegers( $eventIds ); $_CB_database->setQuery( $query ); $events = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveEvents\Table\EventTable', array( $_CB_database ) ); if ( ! $events ) { return; } CBGroupJiveEvents::getEvent( $events ); CBGroupJive::preFetchUsers( $events ); }
/** * @param cbautoactionsActionTable $trigger * @param UserTable $user * @return null|string */ public function execute( $trigger, $user ) { global $_CB_framework, $_CB_database; if ( ! $this->installed() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NOT_INSTALLED', ':: Action [action] :: CB Activity is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } return null; } $return = null; foreach ( $trigger->getParams()->subTree( 'activity' ) as $row ) { /** @var ParamsInterface $row */ $mode = $row->get( 'mode', 'activity', GetterInterface::STRING ); $method = $row->get( 'method', 'create', GetterInterface::STRING ); $owner = $row->get( 'owner', null, GetterInterface::STRING ); if ( ! $owner ) { $owner = (int) $user->get( 'id' ); } else { $owner = (int) $trigger->getSubstituteString( $owner ); } $type = $trigger->getSubstituteString( $row->get( 'type', null, GetterInterface::STRING ) ); $subtype = $trigger->getSubstituteString( $row->get( 'subtype', null, GetterInterface::STRING ) ); $item = $trigger->getSubstituteString( $row->get( 'item', null, GetterInterface::STRING ) ); $parent = $trigger->getSubstituteString( $row->get( 'parent', null, GetterInterface::STRING ) ); if ( $mode == 'stream' ) { if ( $owner ) { $streamUser = CBuser::getUserDataInstance( (int) $owner ); } else { $streamUser = CBuser::getMyUserDataInstance(); } $source = $trigger->getSubstituteString( $row->get( 'source', null, GetterInterface::STRING ) ); $direction = (int) $row->get( 'direction', 0, GetterInterface::INT ); if ( $row->get( 'stream', 'activity', GetterInterface::STRING ) == 'comments' ) { $object = new Comments( $source, $streamUser, $direction ); CBActivity::loadStreamDefaults( $object, $row->subTree( 'comments_stream' ), 'comments_' ); } else { $object = new Activity( $source, $streamUser, $direction ); CBActivity::loadStreamDefaults( $object, $row->subTree( 'activity_stream' ), 'activity_' ); } if ( $type ) { $object->set( 'type', $type ); } if ( $subtype ) { $object->set( 'subtype', $subtype ); } if ( $item ) { $object->set( 'item', $item ); } if ( $parent ) { $object->set( 'parent', $parent ); } if ( $row->get( 'output', 'echo', GetterInterface::STRING ) == 'echo' ) { echo $object->stream( false ); } else { $return .= $object->stream( false ); } } elseif ( $method == 'delete' ) { $where = array(); if ( $owner ) { $where[] = $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $owner; } if ( $type ) { $where[] = $_CB_database->NameQuote( 'type' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $type ); } if ( $item ) { $where[] = $_CB_database->NameQuote( 'item' ) . ' = ' . $_CB_database->Quote( $item ); } if ( $mode != 'hidden' ) { if ( $subtype ) { $where[] = $_CB_database->NameQuote( 'subtype' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $subtype ); } if ( $parent ) { $where[] = $_CB_database->NameQuote( 'parent' ) . ' = ' . $_CB_database->Quote( $parent ); } } switch ( $mode ) { case 'hidden': $table = '#__comprofiler_plugin_activity_hidden'; $class = '\CB\Plugin\Activity\Table\HiddenTable'; break; case 'tag': $table = '#__comprofiler_plugin_activity_tags'; $class = '\CB\Plugin\Activity\Table\TagTable'; break; case 'comment': $table = '#__comprofiler_plugin_activity_comments'; $class = '\CB\Plugin\Activity\Table\CommentTable'; break; case 'activity': default: $table = '#__comprofiler_plugin_activity'; $class = '\CB\Plugin\Activity\Table\ActivityTable'; break; } $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( $table ) . ( $where ? "\n WHERE " . implode( "\n AND ", $where ) : null ); $_CB_database->setQuery( $query ); $objects = $_CB_database->loadObjectList( null, $class, array( $_CB_database ) ); /** @var TableInterface[] $objects */ foreach ( $objects as $object ) { $object->delete(); } } else { if ( ! $owner ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_OWNER', ':: Action [action] :: CB Activity skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } if ( ! $type ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_TYPE', ':: Action [action] :: CB Activity skipped due to missing type', array( '[action]' => (int) $trigger->get( 'id' ) ) ) ); } continue; } switch ( $mode ) { case 'hidden': $object = new HiddenTable( $_CB_database ); break; case 'tag': $object = new TagTable( $_CB_database ); break; case 'comment': $object = new CommentTable( $_CB_database ); break; case 'activity': default: $object = new ActivityTable( $_CB_database ); break; } if ( $item ) { $load = array( 'user_id' => $owner, 'type' => $type, 'item' => $item ); if ( $mode != 'hidden' ) { if ( $subtype ) { $load['subtype'] = $subtype; } if ( $parent ) { $load['parent'] = $parent; } } $object->load( $load ); } $object->set( 'user_id', $owner ); if ( $type ) { $object->set( 'type', $type ); } if ( $mode != 'hidden' ) { if ( $subtype ) { $object->set( 'subtype', $subtype ); } if ( $parent ) { $object->set( 'parent', $parent ); } } if ( $item ) { $object->set( 'item', $item ); } if ( $mode == 'activity' ) { $title = $trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::RAW ) ); if ( $title ) { $object->set( 'title', $title ); } $date = $trigger->getSubstituteString( $row->get( 'date', null, GetterInterface::STRING ) ); if ( $date ) { $object->set( 'date', $_CB_framework->getUTCDate( 'Y-m-d H:i:s', $date ) ); } $action = $row->subTree( 'action' ); $actionId = $action->get( 'id', null, GetterInterface::INT ); if ( $actionId ) { $actionMessage = $trigger->getSubstituteString( $action->get( 'message', null, GetterInterface::STRING ) ); if ( $actionMessage ) { $newAction = array( 'id' => $actionId, 'message' => $actionMessage, 'emote' => $action->get( 'emote', '', GetterInterface::STRING ) ); $object->params()->set( 'action', $newAction ); } } $location = $row->subTree( 'location' ); $locationId = $location->get( 'id', null, GetterInterface::INT ); if ( $locationId ) { $locationPlace = $trigger->getSubstituteString( $location->get( 'place', null, GetterInterface::STRING ) ); if ( $locationPlace ) { $newLocation = array( 'id' => $locationId, 'place' => $locationPlace, 'address' => $trigger->getSubstituteString( $location->get( 'address', null, GetterInterface::STRING ) ) ); $object->params()->set( 'location', $newLocation ); } } $newLinks = array(); foreach ( $row->subTree( 'links' ) as $link ) { /** @var ParamsInterface $link */ $linkType = $trigger->getSubstituteString( $link->get( 'type', null, GetterInterface::STRING ) ); $linkUrl = $trigger->getSubstituteString( $link->get( 'url', null, GetterInterface::STRING ) ); if ( ( ! $linkType ) || ( ! $linkUrl ) ) { continue; } $linkMedia = $link->subTree( 'media' ); $newLinks[] = array( 'url' => $linkUrl, 'text' => $trigger->getSubstituteString( $link->get( 'text', null, GetterInterface::STRING ) ), 'title' => $trigger->getSubstituteString( $link->get( 'title', null, GetterInterface::STRING ) ), 'description' => $trigger->getSubstituteString( $link->get( 'description', null, GetterInterface::RAW ) ), 'media' => array( 'url' => $trigger->getSubstituteString( $linkMedia->get( 'url', null, GetterInterface::STRING ) ), 'mimetype' => $trigger->getSubstituteString( $linkMedia->get( 'mimetype', null, GetterInterface::STRING ) ), 'extension' => $trigger->getSubstituteString( $linkMedia->get( 'extension', null, GetterInterface::STRING ) ), 'custom' => $trigger->getSubstituteString( $linkMedia->get( 'custom', null, GetterInterface::RAW ) ) ), 'type' => $linkType, 'thumbnail' => $link->get( 'thumbnail', 1, GetterInterface::INT ), 'internal' => $link->get( 'internal', 0, GetterInterface::INT ) ); } if ( $newLinks ) { $object->params()->set( 'links', $newLinks ); } $comments = $row->subTree( 'comments' ); $object->params()->set( 'comments', array( 'display' => (int) $comments->get( 'display', 1, GetterInterface::INT ), 'source' => (int) $comments->get( 'source', 1, GetterInterface::INT ) )); $tags = $row->subTree( 'tags' ); $object->params()->set( 'tags', array( 'display' => (int) $tags->get( 'display', 1, GetterInterface::INT ), 'source' => (int) $tags->get( 'source', 1, GetterInterface::INT ) )); $object->set( 'params', $object->params()->asJson() ); } elseif ( $mode == 'comment' ) { $tags = $row->subTree( 'replies' ); $object->params()->set( 'replies', array( 'display' => (int) $tags->get( 'display', 1, GetterInterface::INT ) )); $object->set( 'params', $object->params()->asJson() ); } if ( in_array( $mode, array( 'activity', 'comment' ) ) ) { $message = $trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false ); if ( $message ) { $object->set( 'message', $message ); } } if ( ! $object->store() ) { if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) { var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_CREATE_FAILED', ':: Action [action] :: CB Activity failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $object->getError() ) ) ); } continue; } } } return $return; }
/** * Generates the HTML to display the user profile tab * * @param TabTable $tab the tab database entry * @param 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; $viewer = CBuser::getMyUserDataInstance(); if (!$this->isInstalled() || !$viewer->get('id') || !$user->get('id') || $viewer->get('id') == $user->get('id')) { return null; } if (!$tab->params instanceof ParamsInterface) { $tab->params = new Registry($tab->params); } $showTitle = (int) $tab->params->get('pmsShowTitle', 1); $showSubject = (int) $tab->params->get('pmsShowSubject', 0); $description = $this->_writeTabDescription($tab, $user); cbValidator::loadValidation(); $return = '<form action="' . $_CB_framework->pluginClassUrl($this->element, true, array('id' => (int) $user->get('id'))) . '" method="post" name="quickMsgForm" id="quickMsgForm" class="cb_form quickMsgForm cbValidation">' . '<div class="panel panel-default">' . ($showTitle ? '<div class="panel-heading">' . CBTxt::T($tab->title) . '</div>' : null) . '<div class="panel-body">'; if ($description) { $return .= '<div class="cbft_delimiter form-group cb_form_line clearfix">' . '<div class="cb_field col-sm-12">' . $description . '</div>' . '</div>'; } if ($showSubject) { $return .= '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="subject" class="col-sm-3 control-label">' . CBTxt::T('PM_SUBJECT', 'Subject') . '</label>' . '<div class="cb_field col-sm-9">' . '<input type="text" name="subject" value="" class="form-control" />' . '</div>' . '</div>'; } $return .= '<div class="cbft_textarea cbtt_textarea cb_form_line clearfix">' . ($showSubject ? '<label for="subject" class="col-sm-3 control-label">' . CBTxt::T('PM_MESSAGE', 'Message') . '</label>' : null) . '<div class="cb_field col-sm-' . ($showSubject ? 9 : 12) . '">' . '<textarea name="message" class="form-control required" rows="5"></textarea>' . '</div>' . '</div>' . '</div>' . '<div class="panel-footer">' . '<div class="cb_form_line clearfix">' . '<div class="' . ($showSubject ? 'col-sm-offset-3 col-sm-9' : 'col-sm-12') . '">' . '<input type="submit" value="' . htmlspecialchars(CBTxt::T('PM_SEND_MESSAGE', 'Send Message')) . '" class="quickMsgButton quickMsgButtonSubmit btn btn-primary" ' . cbValidator::getSubmitBtnHtmlAttributes() . ' /> ' . '</div>' . '</div>' . '</div>' . '</div>' . cbGetSpoofInputTag('plugin') . '</form>'; return $return; }
/** * Intercepts CB User Manager list Viewer to add filters * * @param int $listId * @param UserTable $rows * @param cbPageNav $pageNav * @param string $search * @param string[] $lists * @param string $option * @param string $select_tag_attribs * @return array */ public function onAfterBackendUsersList($listId, &$rows, &$pageNav, &$search, &$lists, $option, $select_tag_attribs) { if (!cbpaidApp::authoriseAction('cbsubs.usersubscriptionview')) { return array(); } $this->outputRegTemplate(); // 1. Filters: // 1.a. prepare dropdown selector filter with the list of published plans: $plansMgr = cbpaidPlansMgr::getInstance(); $plans = $plansMgr->loadPublishedPlans(CBuser::getMyUserDataInstance(), true, 'any', null); $plansList = array(); $plansList[] = moscomprofilerHTML::makeOption(0, CBPTXT::T('- Select Subscription Plan - ')); foreach ($plans as $k => $plan) { $plansList[] = moscomprofilerHTML::makeOption($k, $plan->get('alias')); } if (count($plans) > 0) { $plansList[] = moscomprofilerHTML::makeOption(-1, CBPTXT::T('ANY PLAN ACTIVE')); $plansList[] = moscomprofilerHTML::makeOption(-2, CBPTXT::T('NO PLAN ACTIVE')); } $lists['cbpaidplan'] = moscomprofilerHTML::selectList($plansList, 'filter_cbpaidplan', $select_tag_attribs, 'value', 'text', $this->filter_cbpaidplan, 2); // 1.b. prepare additional selector filter for status of subscriptions: if ($this->filter_cbpaidplan && $this->filter_cbpaidplan != -2) { // any plan or specific plan: // no plan: nothing for now to do $statesList = array(); $statesList[] = moscomprofilerHTML::makeOption('A', CBPTXT::T('Active')); $statesList[] = moscomprofilerHTML::makeOption('X', CBPTXT::T('Expired')); $statesList[] = moscomprofilerHTML::makeOption('C', CBPTXT::T('Cancelled')); $statesList[] = moscomprofilerHTML::makeOption('U', CBPTXT::T('Upgraded')); $lists['cbpaidsubstate'] = moscomprofilerHTML::selectList($statesList, 'filter_cbpaidsubstate', $select_tag_attribs, 'value', 'text', $this->filter_cbpaidsubstate, 1); $datesList = array(); $datesList[] = moscomprofilerHTML::makeOption('', CBPTXT::T('- Select expiry date -')); if ($this->filter_cbpaidsubstate == 'A') { $datesList[] = moscomprofilerHTML::makeOption('1 DAY', sprintf(CBPTXT::T('Expiring within %s hours'), 24)); foreach (array(2, 3, 4, 5, 6, 7) as $v) { $datesList[] = moscomprofilerHTML::makeOption($v . ' DAY', sprintf(CBPTXT::T('Expiring within %s days'), $v)); } foreach (array(2, 3, 4) as $v) { $datesList[] = moscomprofilerHTML::makeOption($v . ' WEEK', sprintf(CBPTXT::T('Expiring within %s weeks'), $v)); } $datesList[] = moscomprofilerHTML::makeOption('1 MONTH', CBPTXT::T('Expiring within in 1 month')); foreach (array(2, 3, 4, 6, 9, 12) as $v) { $datesList[] = moscomprofilerHTML::makeOption($v . ' MONTH', sprintf(CBPTXT::T('Expiring within %s months'), $v)); } } else { $datesList[] = moscomprofilerHTML::makeOption('-1 DAY', sprintf(CBPTXT::T('Expired last %s hours'), 24)); foreach (array(2, 3, 4, 5, 6, 7) as $v) { $datesList[] = moscomprofilerHTML::makeOption('-' . $v . ' DAY', sprintf(CBPTXT::T('Expired last %s days'), $v)); } foreach (array(2, 3, 4) as $v) { $datesList[] = moscomprofilerHTML::makeOption('-' . $v . ' WEEK', sprintf(CBPTXT::T('Expired last %s weeks'), $v)); } $datesList[] = moscomprofilerHTML::makeOption('-1 MONTH', CBPTXT::T('Expired last month')); foreach (array(2, 3, 4, 6, 9, 12) as $v) { $datesList[] = moscomprofilerHTML::makeOption('-' . $v . ' MONTH', sprintf(CBPTXT::T('Expired last %s months'), $v)); } } $lists['cbpaidsubexpdate'] = moscomprofilerHTML::selectList($datesList, 'filter_cbpaidsubexpdate', $select_tag_attribs, 'value', 'text', $this->filter_cbpaidsubexpdate, 1); } // 2. add subscriptions colum to backend users-lists: $pluginColumns = array(); foreach ($rows as $row) { $paidUserExtension = cbpaidUserExtension::getInstance((int) $row->id); $subscriptions = $paidUserExtension->getUserSubscriptions('A', true); $displayPlans = array(); foreach ($subscriptions as $sub) { $plan = $sub->getPlan(); if ($plan) { $cssclass = $plan->get('cssclass'); $aliasHtml = htmlspecialchars($plan->get('alias')); } else { $cssclass = null; $aliasHtml = CBPTXT::Ph("PLAN OF SUBSCRIPTION ID [SUB_ID] IS DELETED", array('[SUB_ID]' => $sub->id)); } $displayPlans[] = '<span' . ($cssclass ? ' class="' . htmlspecialchars($cssclass) . '"' : '') . '>' . $aliasHtml . '</span>'; } $pluginColumns[$row->id] = implode(', ', $displayPlans); } return array(CBPTXT::T('Subscriptions') => $pluginColumns); }
/** * 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; }
/** * Returns safe PHP-typed values with type-defined sources * $type can be: * 'const:type' for constant of $fieldValue * 'param:type' for the actual data from the model * 'pluginparam:type' for a parameter from the plugin * 'cmsversion:type' for the cmsversion attribute of type * 'cbconfig:type' for the config parameter of CB * 'datavalue:type' for the actual data from the model, but allowing a path * * @param mixed $fieldValue The value to PHP-format safely * @param string $type The type of the value that is wanted (see above for types) * @param SimpleXMLElement $element The element for additional attributes * @param string $leftRight The prefix for additional attributes * @return string|float|int The safely formatted PHP value */ function phpCleanType( $fieldValue, $type, $element, $leftRight ) { $typeArray = explode( ':', $type, 3 ); if ( count( $typeArray ) < 2 ) { $typeArray = array( 'const' , $type ); } switch ( $typeArray[0] ) { case 'const': break; case 'param': $fieldValue = $this->getModelOfData()->get( $fieldValue ); break; case 'pluginparams': $fieldValue = $this->_pluginParams->get( $fieldValue ); break; case 'cmsversion': $fieldValue = checkJversion( ( $fieldValue ? $fieldValue : 'api' ) ); break; case 'cbconfig': global $ueConfig; $fieldValue = ( array_key_exists( $fieldValue, $ueConfig ) ? $ueConfig[$fieldValue] : '' ); break; case 'datavalue': $fieldValue = $this->get( $fieldValue ); //TBD: missing default value, but not easy to find, as it's in the view param for now: $param->attributes( 'default' ) ); break; case 'data': $leftRightElem = $element->getChildByNameAttributes( $leftRight ); if ( $leftRightElem ) { $fieldValue = $this->renderAllParams( $leftRightElem, 'params', null, 'view', 'none' ); } else { trigger_error( 'XMLifCondition::phpCleanQuote:name: missing ' . $leftRight . ' element for type ' . htmlspecialchars( $type ), E_USER_NOTICE ); } break; case 'user': // TODO: Change this to use Inversion Of Control, and allow XML valuetypes to be extended dynamically (e.g. instead of calling specifically CBLib\CB\User or similar when available, it is CB that adds the type and a closure to handle that type. if ( $fieldValue == 'viewaccesslevels' ) { $fieldValue = Application::MyUser()->getAuthorisedViewLevels(); } else { if ( $fieldValue == 'usergroups' ) { $fieldValue = Application::MyUser()->getAuthorisedGroups( false ); } else { $fieldValue = \CBuser::getMyUserDataInstance()->get( $fieldValue ); } } break; case 'request': $fieldValue = $this->input->get( $fieldValue, 0, GetterInterface::STRING ); break; case 'get': case 'post': case 'cookie': case 'server': case 'env': $fieldValue = $this->input->get( $typeArray[0] . '/' . $fieldValue, 0, GetterInterface::STRING ); break; case 'session': $fieldValue = Application::Session()->get( $fieldValue, null, GetterInterface::STRING ); break; default: trigger_error( 'XMLifCondition::phpCleanQuote:name: ERROR_UNKNOWN_TYPE: ' . htmlspecialchars( $type ), E_USER_NOTICE ); break; } if ( is_array( $fieldValue ) ) { $fieldValue = implode( '|*|', $fieldValue ); } switch ( $typeArray[1] ) { case 'int': case 'integer': $value = (int) $fieldValue; break; case 'float': case 'number': $value = (float) $fieldValue; break; case 'formula': $value = $fieldValue; break; case 'bool': case 'boolean': $value = (bool) $fieldValue; break; case 'datetime': if ( preg_match( '/[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9](:[0-5][0-9]){2}/', $fieldValue ) ) { $value = $fieldValue; } else { $value = ''; } break; case 'date': if ( preg_match( '/[0-9]{4}-[01][0-9]-[0-3][0-9]/', $fieldValue ) ) { $value = $fieldValue; } else { $value = ''; } break; case 'time': if ( preg_match( '/-?[0-9]{1,3}(:[0-5][0-9]){2}/', $fieldValue ) ) { $value = $fieldValue; } else { $value = ''; } break; case 'string': $value = (string) $fieldValue; break; case 'null': $value = null; break; default: //CB2.0: uncomment: trigger_error( 'XMLifCondition::phpCleanQuote:value: ERROR_UNKNOWN_TYPE: ' . htmlspecialchars( $type ), E_USER_NOTICE ); $value = $fieldValue; break; } return $value; }
/** * @param TabTable $tab Current tab * @param UserTable $user Current user * @param int $ui 1 front, 2 admin UI * @param array $postdata Raw unfiltred POST data * @return string HTML */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { $format = $this->input( 'format', null, GetterInterface::STRING ); if ( $format != 'raw' ) { outputCbJs(); outputCbTemplate(); } $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $id = (int) $this->input( 'id', null, GetterInterface::INT ); $user = CBuser::getMyUserDataInstance(); if ( $format != 'raw' ) { ob_start(); } // TODO: For B/C: remove $cat = (int) $this->input( 'cat', null, GetterInterface::INT ); $grp = (int) $this->input( 'grp', null, GetterInterface::INT ); switch ( $action ) { case 'overview': // TODO: For B/C: remove case 'allcategories': $action = 'categories'; $function = 'all'; break; case 'allgroups': $action = 'groups'; $function = 'all'; break; case 'panel': // TODO: For B/C: remove case 'mygroups': $action = 'groups'; $function = 'my'; break; case 'joinedgroups': $action = 'groups'; $function = 'joined'; break; case 'invitedgroups': $action = 'groups'; $function = 'invited'; break; case 'groupsapproval': $action = 'groups'; $function = 'approval'; break; case 'newgroup': $action = 'groups'; $function = 'new'; if ( $id ) { $this->getInput()->set( 'category', $id ); } break; case 'editgroup': $action = 'groups'; $function = 'edit'; break; case 'messagegroup': $action = 'groups'; $function = 'message'; break; case 'groupnotifications': $action = 'groups'; $function = 'notifications'; break; case 'categories': // TODO: For B/C: remove if ( $cat ) { $id = $cat; } break; case 'groups': // TODO: For B/C: remove if ( $cat ) { $this->getInput()->set( 'category', $cat ); } if ( $grp ) { $id = $grp; } break; default: // TODO: For B/C: remove if ( $cat ) { $this->getInput()->set( 'category', $cat ); } if ( $grp ) { $this->getInput()->set( 'group', $grp ); } break; } switch ( $action ) { case 'groups': switch ( $function ) { case 'reject': $this->rejectGroupInvites( $id, $user ); break; case 'cancel': $this->cancelGroupJoin( $id, $user ); break; case 'join': $this->joinGroup( $id, $user ); break; case 'leave': $this->leaveGroup( $id, $user ); break; case 'publish': $this->stateGroup( 1, $id, $user ); break; case 'unpublish': $this->stateGroup( 0, $id, $user ); break; case 'delete': $this->deleteGroup( $id, $user ); break; case 'new': $this->showGroupEdit( null, $user ); break; case 'edit': $this->showGroupEdit( $id, $user ); break; case 'save': cbSpoofCheck( 'plugin' ); $this->saveGroupEdit( $id, $user ); break; case 'message': $this->showGroupMessage( $id, $user ); break; case 'send': cbSpoofCheck( 'plugin' ); $this->sendMessage( $id, $user ); break; case 'notifications': $this->showGroupNotifications( $id, $user ); break; case 'all': $this->showGroups( 0, $user ); break; case 'allmy': // TODO: For B/C: remove case 'my': $this->showGroups( 1, $user ); break; case 'joined': $this->showGroups( 2, $user ); break; case 'invited': $this->showGroups( 3, $user ); break; case 'approval': $this->showGroups( 4, $user ); break; case 'show': default: $this->showGroup( $id, $user ); break; } break; case 'users': switch ( $function ) { case 'ban': $this->statusUser( -1, $id, $user ); break; case 'active': $this->statusUser( 1, $id, $user ); break; case 'moderator': $this->statusUser( 2, $id, $user ); break; case 'admin': $this->statusUser( 3, $id, $user ); break; case 'owner': $this->statusUser( 4, $id, $user ); break; case 'delete': $this->deleteUser( $id, $user ); break; } break; case 'invites': switch ( $function ) { case 'send': $this->sendInvite( $id, $user ); break; case 'new': $this->showInviteEdit( null, $user ); break; case 'edit': $this->showInviteEdit( $id, $user ); break; case 'save': cbSpoofCheck( 'plugin' ); $this->saveInviteEdit( $id, $user ); break; case 'delete': $this->deleteInvite( $id, $user ); break; } break; case 'notifications': switch ( $function ) { case 'save': cbSpoofCheck( 'plugin' ); $this->saveNotifications( $id, $user ); break; } break; case 'categories': default: switch ( $function ) { case 'all': $this->showCategories( $user ); break; case 'show': default: $this->showCategory( $id, $user ); break; } break; } if ( $format != 'raw' ) { $html = ob_get_contents(); ob_end_clean(); $class = $this->params->get( 'general_class', null ); $return = '<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div class="cbGroupJiveInner">' . $html . '</div>' . '</div>'; echo $return; } }
/** * Authorizes the provider, registers or links, then logs in as needed */ private function authenticate() { global $_CB_database; try { /** @var Hybrid_Provider_Adapter $adapter */ $adapter = $this->_hybridAuth->authenticate( $this->_providerId ); } catch ( Exception $e ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'AUTH_TO_PROVIDER_FAILED', 'Authentication to [provider] failed. Error: [error]', array( '[provider]' => $this->_providerName, '[error]' => $e->getMessage() ) ), 'error' ); return; } if ( $adapter ) { if ( ! $this->_hybridAuth->isConnectedWith( $this->_providerId ) ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'CONNECTION_TO_PROVIDER_NOT_ESTABLISHED', 'Connection to [provider] not established.', array( '[provider]' => $this->_providerName ) ), 'error' ); return; } try { /** @var Hybrid_User_Profile $profile */ /** @noinspection PhpUndefinedMethodInspection */ $profile = $adapter->getUserProfile(); $this->profile( $profile ); $myUser = CBuser::getMyUserDataInstance(); $query = 'SELECT ' . $_CB_database->NameQuote( 'id' ) . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler' ) . "\n WHERE " . $_CB_database->NameQuote( $this->_providerField ) . " = " . $_CB_database->Quote( $profile->identifier ); $_CB_database->setQuery( $query ); $userId = (int) $_CB_database->loadResult(); $user = CBuser::getUserDataInstance( $userId ); if ( $myUser->get( 'id' ) ) { if ( ( ! $this->params->get( $this->_provider . '_link', true, GetterInterface::BOOLEAN ) ) && ( ! $myUser->get( $this->_providerField ) ) ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'LINKING_FOR_PROVIDER_NOT_PERMITTED', 'Linking for [provider] is not permitted.', array( '[provider]' => $this->_providerName ) ), 'error' ); return; } if ( ! $myUser->get( $this->_providerField ) ) { if ( $user->get( 'id' ) && ( $myUser->get( 'id' ) != $user->get( 'id' ) ) ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'PROVIDER_ALREADY_LINKED', '[provider] account already linked to another user.', array( '[provider]' => $this->_providerName ) ), 'error' ); return; } if ( ! $myUser->storeDatabaseValue( $this->_providerField, $profile->identifier ) ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'PROVIDER_FAILED_TO_LINK', '[provider] account failed to link. Error: [error]', array( '[provider]' => $this->_providerName, '[error]' => $myUser->getError() ) ), 'error' ); return; } cbRedirect( $this->_returnUrl, CBTxt::T( 'PROVIDER_LINKED_SUCCESSFULLY', '[provider] account linked successfully!', array( '[provider]' => $this->_providerName ) ) ); return; } cbRedirect( $this->_returnUrl, CBTxt::T( 'ALREADY_LINKED_TO_PROVIDER', 'You are already linked to a [provider] account.', array( '[provider]' => $this->_providerName ) ), 'error' ); return; } else { if ( ( ! $this->params->get( $this->_provider . '_register', true, GetterInterface::BOOLEAN ) ) && ( ! $user->get( 'id' ) ) ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'SIGN_UP_WITH_PROVIDER_NOT_PERMITTED', 'Sign up with [provider] is not permitted.', array( '[provider]' => $this->_providerName ) ), 'error' ); return; } $login = true; if ( ! $user->get( 'id' ) ) { $login = $this->register( $user, $profile ); } if ( $login ) { $this->login( $user ); } } } catch( Exception $e ) { cbRedirect( $this->_returnUrl, CBTxt::T( 'FAILED_TO_RETRIEVE_PROVIDER_PROFILE', 'Failed to retrieve [provider] profile. Error: [error]', array( '[provider]' => $this->_providerName, '[error]' => $e->getMessage() ) ), 'error' ); return; } } }
/** * CB messaging spam protections: * * @param null $salt0 * @param null $salt1 * @param bool $allowPublic * @return array */ function cbGetAntiSpams($salt0 = null, $salt1 = null, $allowPublic = false) { global $_CB_framework; if ($salt0 === null || $salt1 === null) { $salt0 = cbMakeRandomString(32); $salt1 = $salt0; } $myId = (int) $_CB_framework->myId(); if (!$myId && $allowPublic) { $messageNumberSent = (int) $_CB_framework->getUserState('cb_message_number_sent', 0); $messageLastSent = $_CB_framework->getUserState('cb_message_last_sent', '0000-00-00 00:00:00'); $canSendMessage = true; } else { $user = CBuser::getMyUserDataInstance(); if ($user) { $messageNumberSent = (int) $user->message_number_sent; $messageLastSent = $user->message_last_sent; $canSendMessage = true; } else { $messageNumberSent = 0; $messageLastSent = '0000-00-00 00:00:00'; $canSendMessage = false; } } if (strlen($salt0) == 32 && strlen($salt1) == 32 && $canSendMessage) { $validate = array(); $validate[0] = 'cbsv1_' . md5($salt0 . $_CB_framework->getCfg('secret') . $_CB_framework->getCfg('db') . $messageNumberSent . $messageLastSent . $_CB_framework->myId()) . '_' . $salt0; $validate[1] = 'cbsv1_' . md5($salt1 . $_CB_framework->getCfg('secret') . $_CB_framework->getCfg('db') . $messageNumberSent . $messageLastSent . $_CB_framework->myUsername()) . '_' . $salt1; return $validate; } else { _cbExpiredSessionJSterminate(); exit; } }
/** * integrates with kunena model * * @param string $event * @param $config * @param $params */ public function kunena( $event, &$config, &$params ) { global $_CB_database; if ( ( ! $this->_forumModel ) || ( $this->_forumModel->type != 'kunena' ) ) { return; } if ( $event == 'loadGroups' ) { $groups = CBGroupJive::getGroupOptions(); $options = array(); foreach ( $groups as $group ) { $option = new stdClass(); $option->id = ( is_array( $group->value ) ? uniqid() : (int) $group->value ); $option->parent_id = 0; $option->level = ( is_array( $group->value ) ? 0 : 1 ); $option->name = $group->text; $options[$option->id] = $option; } $params['groups'] = $options; } elseif ( $event == 'getAllowedForumsRead' ) { static $cache = array(); $mydId = Application::MyUser()->getUserId(); if ( ! $mydId ) { return; } if ( ! isset( $cache[$mydId] ) ) { $user = CBuser::getMyUserDataInstance(); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $query = 'SELECT g.*' . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_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_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 WHERE cb." . $_CB_database->NameQuote( 'approved' ) . " = 1" . "\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1" . "\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0"; if ( ! $isModerator ) { $query .= "\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' ) . ' OR ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1' . ' AND u.' . $_CB_database->NameQuote( 'status' ) . ' > 0 ) )'; } $_CB_database->setQuery( $query ); $groups = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJive\Table\GroupTable', array( $_CB_database ) ); $allowed = array(); /** @var GroupTable[] $groups */ foreach ( $groups as $group ) { if ( $group->params()->get( 'forums', 1 ) ) { $froumId = (int) $group->params()->get( 'forum_id' ); if ( $froumId && CBGroupJive::canCreateGroupContent( $user, $group, 'forums' ) ) { $allowed[] = $froumId; } } } $cache[$mydId] = $allowed; } if ( ! $cache[$mydId] ) { return; } $existingAccess = explode( ',', $params[1] ); $cleanAccess = array_diff( $cache[$mydId], $existingAccess ); $newAccess = array_merge( $existingAccess, $cleanAccess ); cbArrayToInts( $newAccess ); $params[1] = implode( ',', $newAccess ); } elseif ( $event == 'authoriseUsers' ) { /** @var KunenaForumCategory $category */ $category = $params['category']; $groupId = $category->get( 'access' ); if ( ( $category->get( 'accesstype' ) != 'communitybuilder' ) || ( ! $groupId ) ) { return; } $users = $params['userids']; if ( ! $users ) { return; } static $allowed = array(); if ( ! isset( $allowed[$groupId] ) ) { $allowed[$groupId] = array(); $group = CBGroupJive::getGroup( $groupId ); if ( $group->get( 'id' ) ) { $query = 'SELECT u.' . $_CB_database->NameQuote( 'user_id' ) . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = u.' . $_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 u." . $_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" . "\n AND u." . $_CB_database->NameQuote( 'status' ) . " >= 1"; $_CB_database->setQuery( $query ); $allowed[$groupId] = $_CB_database->loadResultArray(); } foreach ( $users as $userId ) { if ( ( ! in_array( $userId, $allowed[$groupId] ) ) && CBGroupJive::isModerator( $userId ) ) { $allowed[$groupId][] = $userId; } } cbArrayToInts( $allowed[$groupId] ); } if ( ! $allowed[$groupId] ) { return; } $params['allow'] = $allowed[$groupId]; } elseif ( $this->params->get( 'groups_forums_back', 1 ) && ( $event == 'onStart' ) && ( $this->input( 'view', null, GetterInterface::STRING ) == 'category' ) ) { $categoryId = (int) $this->input( 'catid', 0, GetterInterface::INT ); if ( ! $categoryId ) { return; } $model = CBGroupJiveForums::getModel(); if ( ! $model ) { return; } $category = $model->getCategory( $categoryId ); if ( ! $category->get( 'id' ) ) { return; } $category = $category->category(); if ( ( $category->get( 'accesstype' ) != 'communitybuilder' ) || ( ! $category->get( 'access' ) ) ) { return; } $group = CBGroupJive::getGroup( (int) $category->get( 'access' ) ); if ( ! $group->get( 'id' ) ) { return; } CBGroupJive::getTemplate( 'backlink', true, true, $this->element ); echo HTML_groupjiveForumsBacklink::showBacklink( $group, $category, $this ); } }