Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: AEC microintegration support for multiple user groups

AEC microintegration support for multiple user groups 3 years 2 months ago #6165

I have discovered that the FUA made mi for AEC does not support multiple usergroups. By this I mean that if I allow users to belong to multiple user groups based on AEC subscription plans, the user cannot be removed from a specific user group, but can be removed from all user groups. Has there been any improvement of this functionality? It would seem this is a drastic dis-functionality on Frontend User Groups part. This seriously limits the usability of the component and it would seem if I want it to work I will have to pay someone to make it do so. I am hopeful that this functionality has been addressed and a fix is available. If anyone has information regarding this bug please post.
Thanks,
Chris
The administrator has disabled public write access.

Re: AEC microintegration support for multiple user groups 3 years 2 months ago #6166

For support on the AEC mi, please post on the AEC forum.
The administrator has disabled public write access.

Re: AEC microintegration support for multiple user groups 3 years 2 months ago #6167

I have discovered that the MI for AEC is created by FUA and it does not work as it is supposed to. I have been trying to 'fix' your MI for AEC and the forums are mildly helpful in my attempt. That being said, there are several posts regarding FUA and they are not favorable. I would make a suggestion that you attempt to make it right since your component works only as well as the components that support it. There are others out there that work as well or better with full support integration with other components. i don't mean to nor do I want to sound brash, but as a developer trying to make something work this is only my suggestion and opinion. I would love to see this work seamlessly and I believe the MI is almost there. Perhaps if I develop a solution I will post here as it seems that you have no plans to fix this bug. Thanks
The administrator has disabled public write access.

Re: AEC microintegration support for multiple user groups 3 years 2 months ago #6168

Carsten,
I hacked the file to work as it should. I created my own function which essentially is a copy of the update function(the same function to add a user to a group is called to remove a user from a group, that's part of the reason it does not work). Here is what I did:
/public_html/components/com_acctexp/micro_integration/mi_frontenduseraccess.php
First added the following function to the file;
function update_fua_group_ex( $user_id, $fua_group, $keep_groups )
	{
		$db = &JFactory::getDBO();

		$query = 'SELECT user_id, group_id'
				. ' FROM #__fua_userindex'
				. ' WHERE user_id = \'' . $user_id . '\' '
				." LIMIT 1 "			
				;
		$db->setQuery( $query );

		$fua_user = $db->loadObject();

		if ( ( $fua_user->user_id == $user_id ) && $keep_groups ) {
			$groups = array_unique( array_merge( $fua_group, $this->csv_to_array( $fua_user->group_id ) ) );
			
			#// remove the elements who's values equal usergroup to be removed
			#

			$groups = array_diff($groups, $fua_group);

			// optionally you could reindex the array
			#
			$groups = array_values($groups);

		} else {
			$groups =  array();  //$fua_group; = 
		}

		sort( $groups );

		$fua_group = $this->array_to_csv( $groups );

		if ( $fua_user->user_id == $user_id ) {		
			$query = 'UPDATE #__fua_userindex'
					. ' SET `group_id` = \'' . $fua_group . '\''
					. ' WHERE `user_id` = \'' . $user_id . '\''
					;
		} else {	
			$query = 'INSERT INTO #__fua_userindex'
					. ' SET group_id = \'' . $fua_group . '\', user_id = \'' . $user_id . '\' '
					;
		}

		$db->setQuery( $query );
		$db->query();
	}
Then I modified the following call to the expiration action (function expiration_action( $request )) around line 122;
$this->update_fua_group_ex( $request->metaUser->userid, $this->settings['group'], $this->settings['keep_groups_exp'] );
I hope this makes sense to all. As for the AEC forum, not only does it require someone to pay to be a member of the conversation, but the search of the forum is non-existent or just really bad and therefore information such as this forum topic gets lost.
~Chris
The administrator has disabled public write access.

Re: AEC microintegration support for multiple user groups 3 years 1 month ago #6176

I have discovered that the MI for AEC is created by FUA and it does not work as it is supposed to.
I once programmed the mi and it worked like it should. Then AEC changed the code. Now some things do not work. I told them a number of times, but, as you found out, they are really hard to comunicate with. It is their code now, they told me they do not want me to distribute my 'fixed' plugin. So I rest my case. That is why I tell people to get support and complain at AEC, so eventually maybe they will fix the plugin.

Thank you very much for posting the code, I hope this will be helpfull to those who need it.

If you ever manage to get on the AEC forum, please post about this, and post the code there.
The administrator has disabled public write access.

Re: AEC microintegration support for multiple user groups 3 years 2 weeks ago #6369

I came upon this topic by accident, while trying to find a way to check users group membership in PHP code while using FUA's own classes (one client asked me to solve this for him). But when i saw there were complaints about the FUA MI, i figured to share that I actually rewrote the FUA MI file for AEC.

I do understand that some people disagree with Valanx about Forum being by subscription only, and God knows i do agree. But unfortunately that's their decision to which they didn't come lightly. AEC used to be free completely (if some of you didn't know it), but after long abuse from users AEC was made commercial with very strict rules on website membership.

I guess if people would've treated the Developer with more respect he wouldn't have made this drastic move, but from many years in the industry i noticed that the more you give the unhappier and more audacious/demanding people become. Even with commercial forum access, forum is constantly filled with questions about problems which 85% has nothing to do with AEC - mostly problems that get solved are just regular Joomla, CB, and JomSocial/JSPT issues. That is not to say AEC does not have issues at all.

When i used AEC for first time i thought i was going to go crazy.... I almost literally ripped some of my hair. But in the end once i learned to use it properly, it became my #1 choice for account management. Basically PROs of the AEC outweigh the CONs. It's most flexible component that i have ever seen. But it does take time to learn it and configure it for live/production use.

Before rewriting FUA MI for AEC, i actually used MySQL MI which is part of AEC build, which allowed me to do all the things which FUA MI wasn't equipped to do at the time. MySQL MI lets you do ANYTHING what you want with the Joomla site, as long as you're skillful enough in SQL.

Anyway... About the new FUA MI...

Since linking didn't work i guess I'll just give you the source:
<?php
/*
AEC micro-integration plugin
for Frontend-User-Access
connects subscription plans to Frontend-User-Access-usergroups
version 2.0.2
*/


// Dont allow direct linking
( defined('_JEXEC') || defined( '_VALID_MOS' ) ) or die( 'Direct Access to this location is not allowed.' );

class mi_frontenduseraccess
{

	function Info()
	{
		$info = array();
		$info['name'] = JText::_('AEC_MI_NAME_FRONTENDUSERACCESS');
		$info['desc'] = JText::_('AEC_MI_DESC_FRONTENDUSERACCESS');

		return $info;
	}

	function Settings()
	{
		$db = &JFactory::getDBO();

		$query = 'SELECT `id`, `name`'
				. ' FROM #__fua_usergroups'
				. ' WHERE id <> 9 AND id <> 10'
				. ' ORDER BY name ASC'
				;
		$db->setQuery( $query );

		$groups = $db->loadObjectList();

		$fuagroups = array();
		$fuagroups[] = JHTML::_('select.option', 0, 'no group');

		if ( !empty( $groups ) ) {
			foreach ( $groups as $group ) {
				$fuagroups[] = JHTML::_('select.option', $group->id, $group->name );
			}
		}

		//if no array, reformat to make into array, as of version 2 of this MI, needed for FUA from version 3.1.0 and up.
		if ( !empty( $this->settings['group'] ) ) {
			if( !is_array( $this->settings['group'] ) ) {
				$this->settings['group'] = array( $this->settings['group'] );
			}
		} else {
			$this->settings['group'] = array();
		}

		if ( !empty( $this->settings['group_remove'] ) ) {
			if( !is_array( $this->settings['group_remove'] ) ) {
				$this->settings['group_remove'] = array( $this->settings['group_remove'] );
			}
		} else {
			$this->settings['group_remove'] = array();
		}

		if ( isset( $this->settings['group_exp'] ) ) {
			if ( !is_array($this->settings['group_exp'] ) ) {
				$this->settings['group_exp'] = array( $this->settings['group_exp'] );
			}
		} else {
			$this->settings['group_exp'] = array();
		}

		if ( isset( $this->settings['group_exp_remove'] ) ) {
			if ( !is_array($this->settings['group_exp_remove'] ) ) {
				$this->settings['group_exp_remove'] = array( $this->settings['group_exp_remove'] );
			}
		} else {
			$this->settings['group_exp_remove'] = array();
		}

		if ( !empty( $this->settings['group'] ) ) {
			$fua_groups = array();

			foreach ( $this->settings['group'] as $temp ) {
				$fua_groups[]->value = $temp;
			}
		} else {
			$fua_groups	= '';
		}

		if ( !empty( $this->settings['group_remove'] ) ) {
			$fua_groups_remove = array();

			foreach ( $this->settings['group_remove'] as $temp ) {
				$fua_groups_remove[]->value = $temp;
			}
		} else {
			$fua_groups_remove	= '';
		}

		if ( !empty( $this->settings['group_exp'] ) ) {
			$fua_groups_exp = array();

			foreach ( $this->settings['group_exp'] as $temp ) {
				$fua_groups_exp[]->value = $temp;
			}
		} else {
			$fua_groups_exp	= '';
		}

		if ( !empty( $this->settings['group_exp_remove'] ) ) {
			$fua_groups_exp_remove = array();

			foreach ( $this->settings['group_exp_remove'] as $temp ) {
				$fua_groups_exp_remove[]->value = $temp;
			}
		} else {
			$fua_groups_exp_remove	= '';
		}

		$settings = array();

		$settings['lists']['group']		= JHTML::_('select.genericlist', $fuagroups, 'group[]', 'size="7" multiple="true"', 'value', 'text', $fua_groups );
		$settings['lists']['group_exp'] = JHTML::_('select.genericlist', $fuagroups, 'group_exp[]', 'size="7" multiple="true"', 'value', 'text', $fua_groups_exp );
		$settings['lists']['group_exp_remove'] = JHTML::_('select.genericlist', $fuagroups, 'group_exp_remove[]', 'size="7" multiple="true"', 'value', 'text', $fua_groups_exp_remove );

		$settings['set_group']			= array( 'list_yesno' );
		$settings['group']				= array( 'list' );
		$settings['group_remove']		= array( 'list' );
		$settings['keep_groups']		= array( 'list_yesno' );
		$settings['set_group_exp']		= array( 'list_yesno' );
		$settings['group_exp']			= array( 'list' );
		$settings['group_exp_remove']	= array( 'list', 'Remove From Group(s) (expiration)', 'Groups from which user needs to be removed when expiration action happens' );
		$settings['keep_groups_exp']	= array( 'list_yesno' );
		$settings['rebuild']			= array( 'list_yesno' );
		$settings['remove']				= array( 'list_yesno' );

		return $settings;
	}

	function action( $request )
	{
		if ( !empty( $this->settings['set_group'] ) && ( !empty( $this->settings['group'] ) || !empty( $this->settings['group_remove'] ) ) ) {
			if ( !isset( $this->settings['keep_groups'] ) ) {
				$this->settings['keep_groups'] = false;
			}

			$this->update_fua_group( $request->metaUser->userid, $this->settings['group'], $this->settings['group_remove'], $this->settings['keep_groups'] );
		}

		return true;
	}

	function expiration_action( $request )
	{
		if ( !empty( $this->settings['set_group_exp'] ) && ( !empty( $this->settings['group_exp'] ) || !empty( $this->settings['group_exp_remove'] ) ) ) {
			if ( !isset( $this->settings['keep_groups_exp'] ) ) {
				$this->settings['keep_groups_exp'] = false;
			}

			$this->update_fua_group( $request->metaUser->userid, $this->settings['group_exp'], $this->settings['group_exp_remove'], $this->settings['keep_groups_exp'] );
		}

		return true;
	}

	function update_fua_group( $user_id, $fua_group, $remove_groups, $keep_groups )
	{
		$db = &JFactory::getDBO();

		$query = 'SELECT user_id, group_id'
				. ' FROM #__fua_userindex'
				. ' WHERE user_id = \'' . $user_id . '\' '
				." LIMIT 1 "			
				;
		$db->setQuery( $query );

		$fua_user = $db->loadObject();

		if ( ( $fua_user->user_id == $user_id ) && $keep_groups ) {
			$groups = array_unique( array_merge( $fua_group, $this->csv_to_array( $fua_user->group_id ) ) );
		} else {
			$groups = $fua_group;
		}

		if ( !empty( $groups ) && !empty( $remove_groups ) ) {
			$groups = array_unique( array_diff( $groups, $remove_groups ) );
		}

		sort( $groups );

		$fua_group = $this->array_to_csv( $groups );

		if ( $fua_user->user_id == $user_id ) {		
			$query = 'UPDATE #__fua_userindex'
					. ' SET `group_id` = \'' . $fua_group . '\''
					. ' WHERE `user_id` = \'' . $user_id . '\''
					;
		} else {	
			$query = 'INSERT INTO #__fua_userindex'
					. ' SET group_id = \'' . $fua_group . '\', user_id = \'' . $user_id . '\' '
					;
		}

		$db->setQuery( $query );
		$db->query();
	}

	function csv_to_array($json){		
		$array = array();
		$temp = explode(',', $json);
		for($n = 0; $n < count($temp); $n++){
			$value = str_replace('"','',$temp[$n]);
			$array[] = $value;
		}
		return $array;
	}

	function array_to_csv($array){	
		$return = '';	
		for($n = 0; $n < count($array); $n++){
			if($n){
				$return .= ',';
			}
			$row = each($array);
			$value = $row['value'];
			if(is_string($value)){
				$value = addslashes($value);
			}	
			$return .= '"'.$value.'"';		
		}		
		return $return;
	}
	
	function detect_application()
	{
		return is_dir( JPATH_SITE . '/components/com_frontenduseraccess' );
	}

}

?>

(This one works with only newer versions of FUA, one person complained about it and when i looked at his setup he was using FUA 3.0.2 version or something. I know this is obvious to most, but mentioning this just in case....)

Also for it to display properly you need to add these lines into a en-GB.com_acctexp.microintegrations.ini language file:
MI_MI_FRONTENDUSERACCESS_GROUP_REMOVE_NAME="Remove From Group"
MI_MI_FRONTENDUSERACCESS_GROUP_REMOVE_DESC="The Frontend-User-Access group you wish to remove the user from when user subscription starts"
MI_MI_FRONTENDUSERACCESS_GROUP_EXP_REMOVE_NAME="Remove From Group(s) (expiration)"
MI_MI_FRONTENDUSERACCESS_GROUP_EXP_REMOVE_DESC="Remove user from group(s) upon expiration action"

This FUA MI now has 4 group multi-selection boxes:

1. Add user to group(s) on subscription
2. Remove user from group(s) on subscription
3. Add user to group(s) on expiration
4. Remove user from group(s) on expiration

So this should let you do really flexible user group assignments.


I hope this helps somebody.

Cheers.
Last Edit: 3 years 2 weeks ago by crashedfx.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.337 seconds
Powered by Kunena Forum
 
Follow Us On Twitter
spicy-sacerdotal