Example #1
0
	/**
	 * @return array|stdClass[]
	 */
	protected function getOptions()
	{
		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' );
		}

		return CBGroupJive::getCategoryOptions();
	}
	/**
	 * prepare frontend group edit render
	 *
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function showGroupEdit( $id, $user )
	{
		global $_CB_framework;

		$row								=	CBGroupJive::getGroup( $id );
		$isModerator						=	CBGroupJive::isModerator( $user->get( 'id' ) );
		$categoryId							=	$this->input( 'category', null, GetterInterface::INT );

		if ( $categoryId === null ) {
			$category						=	$row->category();
		} else {
			$category						=	CBGroupJive::getCategory( $categoryId );
		}

		if ( $row->get( 'id' ) ) {
			$returnUrl						=	$_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) );
		} else {
			$returnUrl						=	$_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $category->get( 'id' ) ) );
		}

		if ( ! $isModerator ) {
			if ( ( $categoryId !== null ) && ( ! $category->get( 'id' ) ) && ( ! $this->params->get( 'groups_uncategorized', 1 ) ) ) {
				CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Category does not exist.' ), 'error' );
			} elseif ( $category->get( 'id' ) && ( ( ! $category->get( 'published' ) ) || ( ! CBGroupJive::canAccess( (int) $category->get( 'access' ), (int) $user->get( 'id' ) ) ) ) ) {
				CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have access to this category.' ), 'error' );
			} elseif ( $row->get( 'id' ) ) {
				if ( $user->get( 'id' ) != $row->get( 'user_id' ) ) {
					CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this group.' ), 'error' );
				}
			} elseif ( ! CBGroupJive::canCreateGroup( $user, ( $categoryId === null ? null : $category ) ) ) {
				if ( $category->get( 'id' ) ) {
					CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group in this category.' ), 'error' );
				} else {
					CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group.' ), 'error' );
				}
			}
		}

		CBGroupJive::getTemplate( 'group_edit' );

		$input								=	array();

		$publishedTooltip					=	cbTooltip( null, CBTxt::T( 'Select publish state of this group. Unpublished groups will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['published']					=	moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) );

		$categories							=	CBGroupJive::getCategoryOptions();

		if ( $row->get( 'id' ) && $category->get( 'id' ) ) {
			$available						=	array();

			foreach ( $categories as $option ) {
				$available[]				=	(int) $option->value;
			}

			if ( ! in_array( (int) $category->get( 'id' ), $available ) ) {
				array_unshift( $categories, moscomprofilerHTML::makeOption( (int) $category->get( 'id' ), CBTxt::T( $category->get( 'name' ) ) ) );
			}
		}

		if ( $categories ) {
			if ( $this->params->get( 'groups_uncategorized', 1 ) || $isModerator ) {
				array_unshift( $categories, moscomprofilerHTML::makeOption( 0, CBTxt::T( 'Uncategorized' ) ) );
			}

			$categoryTooltip				=	cbTooltip( null, CBTxt::T( 'Select the group category. This is the category a group will belong to and decide its navigation path.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

			$input['category']				=	moscomprofilerHTML::selectList( $categories, 'category', 'class="form-control"' . $categoryTooltip, 'value', 'text', (int) $category->get( 'id' ), 1, false, false );
		} else {
			$input['category']				=	null;

			if ( ! $this->params->get( 'groups_uncategorized', 1 ) ) {
				CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create a group in any categories.' ), 'error' );
			}
		}

		$types								=	explode( '|*|', $category->get( 'types' ) );
		$listType							=	array();

		if ( in_array( 1, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) {
			$listType[]						=	moscomprofilerHTML::makeOption( '1', CBTxt::T( 'Open' ) );
		}

		if ( in_array( 2, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) {
			$listType[]						=	moscomprofilerHTML::makeOption( '2', CBTxt::T( 'Approval' ) );
		}

		if ( in_array( 3, $types ) || $isModerator || ( ! $category->get( 'id' ) ) || ( ! $types ) ) {
			$listType[]						=	moscomprofilerHTML::makeOption( '3', CBTxt::T( 'Invite' ) );
		}

		$typeTooltip						=	cbTooltip( null, CBTxt::T( 'Select the group type. Type determines the way your group is joined (e.g. Invite requires new users to be invited to join your group).' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['type']						=	moscomprofilerHTML::selectList( $listType, 'type', 'class="form-control"' . $typeTooltip, 'value', 'text', (int) $this->input( 'post/type', $row->get( 'type', 1 ), GetterInterface::INT ), 1, false, false );

		$nameTooltup						=	cbTooltip( null, CBTxt::T( 'Input the group name. This is the name that will distinguish this group from others. Suggested to input something unique and intuitive.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['name']						=	'<input type="text" id="name" name="name" value="' . htmlspecialchars( $this->input( 'post/name', $row->get( 'name' ), GetterInterface::STRING ) ) . '" class="form-control" size="25"' . $nameTooltup . ' />';

		$descriptionTooltip					=	cbTooltip( null, CBTxt::T( 'Optionally input the group description. The group description should be short and to the point; describing what your group is all about.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['description']				=	'<textarea id="description" name="description" class="form-control" cols="40" rows="5"' . $descriptionTooltip . '>' . htmlspecialchars( $this->input( 'post/description', $row->get( 'description' ), GetterInterface::STRING ) ) . '</textarea>';

		$listMethods						=	array();
		$listMethods[]						=	moscomprofilerHTML::makeOption( 0, CBTxt::T( 'No Change' ) );
		$listMethods[]						=	moscomprofilerHTML::makeOption( 1, CBTxt::T( 'Upload' ) );
		$listMethods[]						=	moscomprofilerHTML::makeOption( 2, CBTxt::T( 'Delete' ) );

		$input['canvas_method']				=	moscomprofilerHTML::selectList( $listMethods, 'canvas_method', 'class="form-control"', 'value', 'text', $this->input( 'post/canvas_method', 0, GetterInterface::INT ), 1, false, false );

		$canvasMinFileSize					=	(int) $this->params->get( 'canvas_min_size', 0 );
		$canvasMaxFileSize					=	(int) $this->params->get( 'canvas_max_size', 1024 );

		$canvasValidation					=	array();

		if ( $canvasMinFileSize || $canvasMaxFileSize ) {
			$canvasValidation[]				=	cbValidator::getRuleHtmlAttributes( 'filesize', array( $canvasMinFileSize, $canvasMaxFileSize, 'KB' ) );
		}

		$canvasValidation[]					=	cbValidator::getRuleHtmlAttributes( 'extension', 'jpg,jpeg,gif,png' );

		$canvasTooltip						=	cbTooltip( null, CBTxt::T( 'Optionally select the group canvas. A canvas should represent the topic of your group; please be respectful and tasteful when selecting a canvas.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['canvas']					=	'<input type="file" id="canvas" name="canvas" value="" class="form-control"' . $canvasTooltip . implode( ' ', $canvasValidation ) . ' />';

		$input['canvas_limits']				=	array( CBTxt::T( 'CANVAS_UPLOAD_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => 'jpg, jpeg, gif, png' ) ) );

		if ( $canvasMinFileSize ) {
			$input['canvas_limits'][]		=	CBTxt::T( 'CANVAS_UPLOAD_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $canvasMinFileSize * 1024 ) ) );
		}

		if ( $canvasMaxFileSize ) {
			$input['canvas_limits'][]		=	CBTxt::T( 'CANVAS_UPLOAD_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $canvasMaxFileSize * 1024 ) ) );
		}

		$input['logo_method']				=	moscomprofilerHTML::selectList( $listMethods, 'logo_method', 'class="form-control"', 'value', 'text', $this->input( 'post/logo_method', 0, GetterInterface::INT ), 1, false, false );

		$logoMinFileSize					=	(int) $this->params->get( 'logo_min_size', 0 );
		$logoMaxFileSize					=	(int) $this->params->get( 'logo_max_size', 1024 );

		$logoValidation						=	array();

		if ( $logoMinFileSize || $logoMaxFileSize ) {
			$logoValidation[]				=	cbValidator::getRuleHtmlAttributes( 'filesize', array( $logoMinFileSize, $logoMaxFileSize, 'KB' ) );
		}

		$logoValidation[]					=	cbValidator::getRuleHtmlAttributes( 'extension', 'jpg,jpeg,gif,png' );

		$logoTooltip						=	cbTooltip( null, CBTxt::T( 'Optionally select the group logo. A logo should represent the topic of your group; please be respectful and tasteful when selecting a logo.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['logo']						=	'<input type="file" id="logo" name="logo" value="" class="form-control"' . $logoTooltip . implode( ' ', $logoValidation ) . ' />';

		$input['logo_limits']				=	array( CBTxt::T( 'LOGO_UPLOAD_LIMITS_EXT', 'Your file must be of [ext] type.', array( '[ext]' => 'jpg, jpeg, gif, png' ) ) );

		if ( $logoMinFileSize ) {
			$input['logo_limits'][]			=	CBTxt::T( 'LOGO_UPLOAD_LIMITS_MIN', 'Your file should exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $logoMinFileSize * 1024 ) ) );
		}

		if ( $logoMaxFileSize ) {
			$input['logo_limits'][]			=	CBTxt::T( 'LOGO_UPLOAD_LIMITS_MAX', 'Your file should not exceed [size].', array( '[size]' => CBGroupJive::getFormattedFileSize( $logoMaxFileSize * 1024 ) ) );
		}

		$invitesTooltip						=	cbTooltip( null, CBTxt::T( 'Optionally enable or disable usage of invites. Invites allow group users to invite other users to join the group. Group owner and group administrators are exempt from this configuration and can always invite users. Note existing invites will still be accessible.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['invites']					=	moscomprofilerHTML::yesnoSelectList( 'params[invites]', 'class="form-control"' . $invitesTooltip, (int) $this->input( 'post/params.invites', $row->params()->get( 'invites', 1 ), GetterInterface::INT ), CBTxt::T( 'Enable' ), CBTxt::T( 'Disable' ), false );

		$ownerTooltip						=	cbTooltip( null, CBTxt::T( 'Input the group owner id. Group owner determines the creator of the group specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' );

		$input['user_id']					=	'<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />';

		HTML_groupjiveGroupEdit::showGroupEdit( $row, $input, $category, $user, $this );
	}
Example #3
0
	/**
	 * @return array
	 */
	public function categories()
	{
		$options		=	array();

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

		return $options;
	}