Ejemplo n.º 1
0
	/**
	 * loops categories for display in dropdown lists
	 *
	 * @param string $access
	 * @param int $parent
	 * @param array $exclude
	 * @param array $options
	 * @param array $children
	 * @return array
	 */
	static public function getCategoryOptions( $access = 'cat_grp_create', $parent = 0, $exclude = array(), &$options = array(), &$children = array() ) {
		static $categoryCache		=	null;

		if ( ! isset( $categoryCache ) ) {
			$categoryCache			=	cbgjData::getCategories( array( 'cat_access', 'mod_lvl1' ) );
		}

		$categories					=	array();

		if ( $categoryCache ) foreach ( $categoryCache as $cat ) {
			if ( $parent == $cat->get( 'parent' ) && ( ( ! $exclude ) || ( $exclude && ( ! in_array( $cat->get( 'id' ), $exclude ) ) ) ) ) {
				$categories[]		=	$cat;
			}
		}

		if ( $categories ) foreach ( $categories as $category ) {
			if ( $access ) {
				$authorized			=	cbgjClass::getAuthorization( $category );
			} else {
				$authorized			=	array();
			}

			$indent					=	null;

			if ( $parent ) {
				$depth				=	$category->getDepth( $parent );

				if ( $depth ) {
					for ( $i = 0, $n = $depth; $i < $n; $i++ ) {
						$indent		.=	'- - ';
					}
				}

				$children[]			=	$category->get( 'id' );
			}

			$optGroup				=	false;

			if ( ( ! $authorized ) || cbgjClass::hasAccess( $access, $authorized ) ) {
				$options[]			=	moscomprofilerHTML::makeOption( $category->get( 'id' ), $indent . $category->getName() );
			} else {
				$optGroup			=	true;

				$options[]			=	moscomprofilerHTML::makeOptGroup( $indent . $category->getName() );
				$options[]			=	moscomprofilerHTML::makeOptGroup( null );

				$children			=	array();
			}

			cbgjClass::getCategoryOptions( $access, $category->get( 'id' ), $exclude, $options, $children );

			if ( $optGroup && ( ! $children ) ) {
				$options			=	array_slice( $options, 0, -2 );
			}
		}

		return $options;
	}
Ejemplo n.º 2
0
	/**
	 * Function for the backend XML
	 *
	 * @param  string  $name          Name of the control
	 * @param  string  $value         Current value
	 * @param  string  $control_name  Name of the controlling array (if any)
	 * @return string                 HTML for the control data part or FALSE in case of error
	 */
	public function loadGJParentCategoryList( $name, $value, $control_name ) {
 		global $_CB_framework;

		$api				=	$_CB_framework->getCfg( 'absolute_path' ) . '/components/com_comprofiler/plugin/user/plug_cbgroupjive/cbgroupjive.class.php';

		if ( ! file_exists( $api ) ) {
			return CBPTXT::Th( 'GroupJive 2.x is not installed!' );
		}

		/** @noinspection PhpIncludeInspection */
		require_once( $api );

		$gj_categories		=	cbgjClass::getCategoryOptions( null );

		if ( $gj_categories ) {
			array_unshift( $gj_categories, moscomprofilerHTML::makeOption( '0', CBPTXT::T( 'No Parent' ) ) );

			if ( isset( $value ) ) {
				$valAsObj	=	array_map( create_function( '$v', '$o=new stdClass(); $o->value=$v; return $o;' ), explode( '|*|', $value ) );
			} else {
				$valAsObj	=	null;
			}

			$categories		=	moscomprofilerHTML::selectList( $gj_categories, $control_name ? $control_name .'['. $name .'][]' : $name, null, 'value', 'text', $valAsObj, 0, false, false );
		} else {
			$categories		=	CBPTXT::T( 'No categories exist!' );;
		}

		return $categories;
	}
Ejemplo n.º 3
0
	/**
	 * prepare backend group edit render
	 *
	 * @param int $id
	 * @param moscomprofilerUser $user
	 * @param object $plugin
	 * @param string $message
	 */
	private function showGroupEdit( $id, $user, $plugin, $message = null ) {
		global $_CB_framework;

		$groupEditor						=	$plugin->params->get( 'group_editor', 1 );

		$row								=	cbgjData::getGroups( null, array( 'id', '=', (int) $id ), null, null, false );
		$category							=	$row->getCategory();

		$input								=	array();

		$input['publish']					=	moscomprofilerHTML::yesnoSelectList( 'published', null, (int) cbgjClass::getCleanParam( true, 'published', $row->get( 'published', ( $plugin->params->get( 'group_approve', 0 ) ? 0 : 1 ) ) ) );

		$categories							=	cbgjClass::getCategoryOptions();

		if ( $categories ) {
			$input['category']				=	moscomprofilerHTML::selectList( $categories, 'category', null, 'value', 'text', (int) cbgjClass::getCleanParam( true, 'category', $row->get( 'category', $category->get( 'id' ) ) ), 1, false, false );
		} else {
			$input['category']				=	CBTxt::Th( 'There currently are no categories.' );
		}

		if ( $row->get( 'id' ) ) {
			$groups							=	cbgjClass::getGroupOptions( null, $category->get( 'id' ), 0, array( $row->get( 'id' ) ) );
		} else {
			$groups							=	cbgjClass::getGroupOptions( null, $category->get( 'id' ) );
		}

		if ( $groups ) {
			array_unshift( $groups, moscomprofilerHTML::makeOption( '0', CBTxt::T( 'No Parent' ) ) );

			$input['parent']				=	moscomprofilerHTML::selectList( $groups, 'parent', null, 'value', 'text', (int) cbgjClass::getCleanParam( true, 'parent', $row->get( 'parent', 0 ) ), 1, false, false );
		} else {
			if ( $category->get( 'id' ) ) {
				$input['parent']			=	CBTxt::Th( 'There currently are no groups.' );
			} else {
				$input['parent']			=	CBTxt::Th( 'Please save group with category before selecting parent group.' );
			}
		}

		$input['name']						=	'<input type="text" id="name" name="name" value="' . htmlspecialchars( cbgjClass::getCleanParam( true, 'name', $row->get( 'name' ) ) ) . '" class="inputbox required" size="40" />';

		if ( $groupEditor >= 2 ) {
			$description					=	cbgjClass::getHTMLCleanParam( true, 'description', $row->get( 'description' ) );
		} else {
			$description					=	cbgjClass::getCleanParam( true, 'description', $row->get( 'description' ) );
		}

		if ( $groupEditor == 3 ) {
			$input['description']			=	$_CB_framework->displayCmsEditor( 'description', $description, 400, 200, 40, 5 );
		} else {
			$input['description']			=	'<textarea id="description" name="description" class="inputbox" cols="40" rows="5">' . htmlspecialchars( $description ) . '</textarea>';
		}

		$input['file']						=	'<input type="file" id="logo" name="logo" class="inputbox" size="40" />';
		$input['del_logo']					=	'<input type="checkbox" id="del_logo" name="del_logo" class="inputbox" value="1" /> <label for="del_logo">' . CBTxt::T( 'Delete logo?' ) . '</label>';

		$listType							=	array();
		$listType[]							=	moscomprofilerHTML::makeOption( '1', CBTxt::T( 'Open' ) );
		$listType[]							=	moscomprofilerHTML::makeOption( '2', CBTxt::T( 'Approval' ) );
		$listType[]							=	moscomprofilerHTML::makeOption( '3', CBTxt::T( 'Invite' ) );
		$input['type']						=	moscomprofilerHTML::selectList( $listType, 'type', 'class="inputbox required"', 'value', 'text', (int) cbgjClass::getCleanParam( true, 'type', $row->get( 'type', $plugin->params->get( 'group_type_default', 1 ) ) ), 1, false, false );

		$listAccess							=	array();
		$listAccess[]						=	moscomprofilerHTML::makeOption( '-2', CBTxt::T( '- Everybody' ) );
		$listAccess[]						=	moscomprofilerHTML::makeOption( '-1', CBTxt::T( '- All Registered Users' ) );
		$listAccess							=	array_merge( $listAccess, $_CB_framework->acl->get_group_children_tree( null, 'USERS', false ) );
		$input['access']					=	moscomprofilerHTML::selectList( $listAccess, 'access', 'class="inputbox required"', 'value', 'text', (int) cbgjClass::getCleanParam( true, 'access', $row->get( 'access', $plugin->params->get( 'group_access_default', -2 ) ) ), 1, false, false );

		$listInvite							=	array();
		$listInvite[]						=	moscomprofilerHTML::makeOption( '0', CBTxt::T( 'Group Users' ) );
		$listInvite[]						=	moscomprofilerHTML::makeOption( '1', '.&nbsp;-&nbsp;' . CBTxt::T( 'Group Moderators' ) );
		$listInvite[]						=	moscomprofilerHTML::makeOption( '2', '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;' . CBTxt::T( 'Group Admins' ) );
		$listInvite[]						=	moscomprofilerHTML::makeOption( '3', '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;' . CBTxt::T( 'Group Owner' ) );
		$input['invite']					=	moscomprofilerHTML::selectList( $listInvite, 'invite', 'class="inputbox required"', 'value', 'text', (int) cbgjClass::getCleanParam( true, 'invite', $row->get( 'invite', $plugin->params->get( 'group_invite_default', 0 ) ) ), 1, false, false );

		$input['users']						=	moscomprofilerHTML::yesnoSelectList( 'users', null, (int) cbgjClass::getCleanParam( true, 'users', $row->get( 'users', $plugin->params->get( 'group_users_default', 1 ) ) ) );

		$input['nested']					=	moscomprofilerHTML::yesnoSelectList( 'nested', null, (int) cbgjClass::getCleanParam( true, 'nested', $row->get( 'nested', $plugin->params->get( 'group_nested_default', 1 ) ) ), CBTxt::T( 'Enable' ), CBTxt::T( 'Disable' ) );
		$input['nested_access']				=	moscomprofilerHTML::selectList( $listInvite, 'nested_access', 'class="inputbox"', 'value', 'text', (int) cbgjClass::getCleanParam( true, 'nested_access', $row->get( 'nested_access', $plugin->params->get( 'group_nestedaccess_default', -1 ) ) ), 1, false, false );

		$input['owner']						=	'<input type="text" id="user_id" name="user_id" value="' . (int) cbgjClass::getCleanParam( true, 'user_id', $row->get( 'user_id', $user->id ) ) . '" class="inputbox required digits" size="6" />';

		cbgjClass::displayMessage( $message );

		HTML_cbgjAdmin::showGroupEdit( $row, $category, $input, $user, $plugin );
	}