/**
	 * save group
	 *
	 * @param int $id
	 * @param string $task
	 * @param moscomprofilerUser $user
	 * @param object $plugin
	 */
	private function saveGroupEdit( $id, $task, $user, $plugin ) {
		$row			=	cbgjData::getGroups( null, array( 'id', '=', (int) $id ), null, null, false );
		$category		=	$row->getCategory();

		$row->set( 'published', (int) cbgjClass::getCleanParam( true, 'published', $row->get( 'published', ( $plugin->params->get( 'group_approve', 0 ) ? 0 : 1 ) ) ) );
		$row->set( '_previousCategory', $row->get( 'category', $category->get( 'id' ) ) );
		$row->set( 'category', (int) cbgjClass::getCleanParam( true, 'category', $row->get( 'category', $category->get( 'id' ) ) ) );
		$row->set( 'parent', (int) cbgjClass::getCleanParam( true, 'parent', $row->get( 'parent', 0 ) ) );
		$row->set( 'user_id', (int) cbgjClass::getCleanParam( true, 'user_id', $row->get( 'user_id', $user->id ) ) );
		$row->set( 'name', cbgjClass::getWordFiltering( cbgjClass::getCleanParam( true, 'name', $row->get( 'name' ) ) ) );

		if ( $plugin->params->get( 'group_editor', 1 ) >= 2 ) {
			$row->set( 'description', cbgjClass::getWordFiltering( cbgjClass::getHTMLCleanParam( true, 'description', $row->get( 'description' ) ) ) );
		} else {
			$row->set( 'description', cbgjClass::getWordFiltering( cbgjClass::getCleanParam( true, 'description', $row->get( 'description' ) ) ) );
		}

		$row->set( 'type', (int) cbgjClass::getCleanParam( true, 'type', $row->get( 'type', $plugin->params->get( 'group_type_default', 1 ) ) ) );
		$row->set( 'access', (int) cbgjClass::getCleanParam( true, 'access', $row->get( 'access', $plugin->params->get( 'group_access_default', -2 ) ) ) );
		$row->set( 'invite', (int) cbgjClass::getCleanParam( true, 'invite', $row->get( 'invite', $plugin->params->get( 'group_invite_default', 0 ) ) ) );
		$row->set( 'users', (int) cbgjClass::getCleanParam( true, 'users', $row->get( 'users', $plugin->params->get( 'group_users_default', 1 ) ) ) );
		$row->set( 'nested', (int) cbgjClass::getCleanParam( true, 'nested', $row->get( 'nested', $plugin->params->get( 'group_nested_default', 1 ) ) ) );
		$row->set( 'nested_access', (int) cbgjClass::getCleanParam( true, 'nested_access', $row->get( 'nested_access', $plugin->params->get( 'group_nestedaccess_default', -1 ) ) ) );
		$row->set( 'date', $row->get( 'date', cbgjClass::getUTCDate() ) );
		$row->set( 'ordering', (int) $row->get( 'ordering', 1 ) );

		if ( $row->get( 'name' ) == '' ) {
			$row->set( '_error', CBTxt::T( 'Name not specified!' ) );
		} elseif ( ! $row->get( 'user_id' ) ) {
			$row->set( '_error', CBTxt::T( 'Owner not specified!' ) );
		} elseif ( ! $row->get( 'category' ) ) {
			$row->set( '_error', CBTxt::T( 'Category not specified!' ) );
		} elseif ( ! $row->get( 'type' ) ) {
			$row->set( '_error', CBTxt::T( 'Type not specified!' ) );
		}

		if ( (int) cbgjClass::getCleanParam( true, 'del_logo', 0 ) ) {
			$row->unsetLogo();
		}

		if ( $row->getError() || ( ! $row->store() ) ) {
			$this->showGroupEdit( $row->get( 'id' ), $user, $plugin, CBTxt::P( 'Group failed to save! Error: [error]', array( '[error]' => $row->getError() ) ) ); return;
		}

		$successMsg		=	CBTxt::T( 'Group saved successfully!' );

		$row->storeLogo( 'logo' );

		if ( $row->getError() ) {
			cbgjClass::displayMessage( $successMsg, 'message' );

			$this->showGroupEdit( $row->get( 'id' ), $user, $plugin, CBTxt::P( 'Logo failed to upload! Error: [error]', array( '[error]' => $row->getError() ) ) ); return;
		}

		$row->storeOwner( $row->get( 'user_id' ) );

		if ( $task == 'apply' ) {
			cbgjClass::getPluginURL( array( 'groups', 'edit', (int) $row->get( 'id' ) ), $successMsg, false, true );
		} else {
			cbgjClass::getPluginURL( array( 'groups' ), $successMsg, false, true );
		}
	}