Esempio n. 1
0
	/**
	 * @return array
	 */
	protected function getGroups()
	{
		global $_PLUGINS;

		static $loaded				=	0;

		if ( ! $loaded++ ) {
			include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );

			cbimport( 'cb.html' );
			cbimport( 'language.all' );

			$_PLUGINS->loadPluginGroup( 'user' );
		}

		$groups						=	CBGroupJive::getGroupOptions();
		$options					=	array();
		$optGroup					=	0;

		foreach ( $groups as $group ) {
			if ( is_array( $group->value ) ) {
				$optGroup			=	$group->text;

				continue;
			}

			$options[$optGroup][]	=	$group;
		}

		return $options;
	}
Esempio n. 2
0
	/**
	 * @param FieldTable $field
	 * @param UserTable  $user
	 * @param bool       $raw
	 * @param bool       $joined
	 * @return stdClass[]
	 */
	private function getGroups( $field, $user, $raw = false, $joined = false )
	{
		global $_CB_database;

		$excludeCategories		=	explode( '|*|', $field->params->get( 'autojoin_exclude_categories' ) );
		$excludeGroups			=	explode( '|*|', $field->params->get( 'autojoin_exclude_groups' ) );

		if ( $user->get( 'id' ) && ( ! $joined ) ) {
			static $cache		=	array();

			$userId				=	(int) $user->get( 'id' );

			if ( ! isset( $cache[$userId] ) ) {
				$query			=	'SELECT g.' . $_CB_database->NameQuote( 'id' )
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g"
								.	"\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u"
								.	' ON u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $userId
								.	' AND u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' )
								.	"\n WHERE ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $userId
								.		' OR u.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL )';

				$_CB_database->setQuery( $query );
				$cache[$userId]	=	$_CB_database->loadResultArray();
			}

			if ( $cache[$userId] ) {
				$excludeGroups	=	array_unique( array_merge( $excludeGroups, $cache[$userId] ) );
			}
		}

		$options				=	CBGroupJive::getGroupOptions( $raw, $excludeCategories, $excludeGroups );

		return $options;
	}
Esempio n. 3
0
	/**
	 * @return array
	 */
	public function groups()
	{
		$options		=	array();

		if ( $this->installed() ) {
			$options	=	CBGroupJive::getGroupOptions();
		}

		return $options;
	}
	/**
	 * 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 );
		}
	}