Page 1 of 1

user choice FEU group assignment (FEU subscription Mod)

Posted: Wed Jan 14, 2009 2:40 am
by JeremyBASS
Hello, so before I get in on the other task I have which is editing the news on the front side, i found I need to do something first... I'm hoping that I may have over looked something but I have a need for a use to chose the group they belong to as well as be in the one I tell them to be in... plus this needs to be importable, which looks to me like you can only have one group to choose on import...

So after much reading and thinking on this I came up with this... I need to have a UDT attached to the Frontend User Management Event Name: OnCreateUser.  This way If I've read everything right I should be able to have the user pick a group via user Properties dropdown, and on import... so this is what I wrote out so far but I'm a little stuck.. before I can do much else I need to get these worked out... I'm sure I’m just missing something..  ???


I have a user Property dropdown called, shrine_club with
option_name:
Members
Moderator
CDA
Latah
Moyie
Panhandle
Shoshone
StMaries
Units
Public

And

table cms_module_feusers_groups:
id groupname
1 Members
13 Moderator
3 CDA
4 Latah
5 Moyie
6 Panhandle
7 Shoshone
8 StMaries
12 Units
11 Public

Code: Select all

<?
global $gCms;

$db = &$gCms->db;
$group_id = '';
$UDgroup = 'shrine_club';


$query = "SELECT * FROM ".cms_db_prefix()."module_feusers_users";
$dbresult = $db->Execute($query);

if ($dbresult && $dbresult->RecordCount() > 0)
    {
       $row = $dbresult->FetchRow();
       $user_id = $row['id'];
    }

$query2 = "SELECT * FROM ".cms_db_prefix()."module_feusers_groups";
$dbresult2 = $db->Execute($query2);
if ($dbresult2 && $dbresult2->RecordCount() > 0)
    {
       $row = $dbresult2->FetchRow();
       $group_id = $row['id'];
    }

$query3 = "SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE userid=" .$user_id. " AND  title=".$UDgroup;
$dbresult3 = $db->Execute($query3);
if ($dbresult3 && $dbresult3->RecordCount() > 0)
  {
      $row = $dbresult3->FetchRow();
      $data =$row['data'];
   }

switch($data)
{	
  	case "CDA":	
  	$dataVAL= "3";
	case "Latah":	
  	$dataVAL= "4";
	case "Moyie":	
  	$dataVAL= "5";
	case "Panhandle":	
  	$dataVAL= "6";
	case "Shoshone":	
  	$dataVAL= "7";
	case "StMaries":	
  	$dataVAL= "8";
	     break;
}
for($i=0;$i<count($data);$i++) {
if( $dataVAL = $group_id ){
$query = "INSERT INTO ".cms_db_prefix()."module_feusers_belongs (userid, groupid) 
          VALUES (".$userid.", ".$groupid.")";
$result = $db->Execute($query);
}
}

?>
Any help or pointers would be great...

thank you
jeremyBass

*CMSMS1.5.1 and FrontEndUsers1.5.4*

Re: user choice FEU group assignment

Posted: Wed Jan 14, 2009 3:20 am
by JeremyBASS
ok... try 539some odd...

Code: Select all

global $gCms;

$db = &$gCms->db;
$group_id = '';
$UDgroup = 'shrine_club';




switch($data)
{	
  	case "CDA":	
  	$dataVAL= "3";
	case "Latah":	
  	$dataVAL= "4";
	case "Moyie":	
  	$dataVAL= "5";
	case "Panhandle":	
  	$dataVAL= "6";
	case "Shoshone":	
  	$dataVAL= "7";
	case "StMaries":	
  	$dataVAL= "8";
	     break;
}


for($i=0;$i<count($uid);$i++) {

$query2 = "SELECT * FROM ".cms_db_prefix()."module_feusers_groups";
$dbresult2 = $db->Execute($query2);
if ($dbresult2 && $dbresult2->RecordCount() > 0)
    {
       $row = $dbresult2->FetchRow();
       $group_id = $row['id'];
    }

$query3 = "SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE userid=" .$uid. " AND  title=".$UDgroup;
$dbresult3 = $db->Execute($query3);

if ($dbresult3 && $dbresult3->RecordCount() > 0)
  {
      $row = $dbresult3->FetchRow();
      $data =$row['data'];
   }


	if( $dataVAL = $group_id ){
		$query = "INSERT INTO ".cms_db_prefix()."module_feusers_belongs (userid, groupid) 
				  VALUES (".$uid.", ".$group_id.")";
		$result = $db->Execute($query);
	}
}
just not to sure on how to test like echo or anything so I'm losted... If I can't echo I have a hard time brute forcing my way through... any ideas?

Re: user choice FEU group assignment

Posted: Wed Jan 14, 2009 5:12 am
by JeremyBASS
Ok... this was the last try of the night... I'm really spinning my wheels bad here... I don't ever get errors  but as I read the code for adduser.php it looks like to me that the group and properties have been created already... so I thought this should work... I'm sure I'm doing some bone head thing.... please any help on this would be great... even how to get errors or some way to test so I have a straw lol... thank you

jeremyBass

Code: Select all

<?
global $gCms;

$db = &$gCms->db;
$group_id = '';
$data='';
$dataVAL='';
$UDgroup = 'shrine_club';
	$query2 = "SELECT * FROM ".cms_db_prefix()."module_feusers_groups";
	$dbresult2 = $db->Execute($query2);
	if ($dbresult2 && $dbresult2->RecordCount() > 0)
		{
		   $row = $dbresult2->FetchRow();
		   $group_id = $row['id'];
		}

	$query3 = "SELECT * FROM ".cms_db_prefix()."module_feusers_properties WHERE userid=" .$parms['id']. " AND  title=".$UDgroup;
	$dbresult3 = $db->Execute($query3);
	
	if ($dbresult3 && $dbresult3->RecordCount() > 0)
	  {
		  $row = $dbresult3->FetchRow();
		  $data =$row['data'];
	   }

	switch($data)
	{	
		case "CDA":	
		$dataVAL= "3";
		case "Latah":	
		$dataVAL= "4";
		case "Moyie":	
		$dataVAL= "5";
		case "Panhandle":	
		$dataVAL= "6";
		case "Shoshone":	
		$dataVAL= "7";
		case "StMaries":	
		$dataVAL= "8";
			 break;
	}
	if( $dataVAL = $group_id ){
		$query = "INSERT INTO ".cms_db_prefix()."module_feusers_belongs (userid, groupid) 
				  VALUES (".$parms['id'].", ".$group_id.")";
		$result = $db->Execute($query);
	}

?>


Re: user choice FEU group assignment

Posted: Thu Jan 15, 2009 1:40 am
by JeremyBASS
Hello, I thought I'd share this... It was pointed out that a user property could do the same thing... few draw backs but it'd work mostly... but there was a reason I was separating them out besides the forums and the 10+ unique properties by the 7-8 groups (80+up’s) I had formed...  but when asked I just couldn’t think of it at the moment...

I remember now, and may-be some can pipe in on this... but as I see it ... from a db stand point using the separate groups saves space... may-be nothing that would help a small site but as it grows and/or for a site that is planed for have a large user base, space can become an issue before the funds are open to upgrade...

A few of the others things, was that  this idea to allows the user to chose the group, as the change is "dynamic", this would allow and lay the ground work for the “admins” to set a user to auto join groups based on the data gathered.... so in an ecommerce site for example you could have a buyer, customer, VIP customer, Customer Service user etc but still have a forum set of users. 

Now I know , because I have a hospital set up this way, that you can run it all out of one user... it's the size thing again plus there are a few mods that work of group based FEU interactions...

Now put all those points together plus the fact that you can only import under one group and that was the driving force be hide this...

Hope that makes sense and I'd welcome a correction in my thoughts... And I'm just trying to think ahead... :)

cheers
jeremyBass

Re: user choice FEU group assignment

Posted: Thu Feb 05, 2009 4:44 am
by JeremyBASS
So I moved ahead on this... the user can now chose which group the belong to...

Code: Select all

global $gCms;
$db = &$gCms->db;

$feusers = &$gCms->modules['FrontEndUsers']['object'];
$uid = $feusers->LoggedInID();
$username = $feusers->LoggedInName();
$Key =  $_POST['var1'];
////up to this point I only have the user information so I need to get the groups they add join
$query2 = "SELECT groupid, groupname FROM ".
    cms_db_prefix()."module_feusers_groups_keys JOIN ".
    cms_db_prefix()."module_feusers_groups ON id=groupid where theCODEkeyid='$Key'";
$dbresult2 = $db->Execute($query2);
if ($dbresult2 && $dbresult2->RecordCount() > 0)
    {
       $row = $dbresult2->FetchRow();
       $groupid = $row['groupid'];
       $groupname = $row['groupname'];
    } else die('Error: '.mysql_error());


/// know assign the user the to a group based on the key in the post
if(isset($Key)){
$query = "INSERT INTO ".cms_db_prefix()."module_feusers_belongs (userid, groupid) VALUES (".$uid.", ".$groupid.")";
$result = $db->Execute($query);
if(!$result) 
  echo 'Error: '.mysql_error();
else
  echo "Congratulations ".$username .", you have been upgraded to ".$groupname."!.";

} else {
echo "<br/>sorry charlie";
}


the end goal is to have the key be add from the back end... and then have tag for the button and for the  general receiver... soo... I need to do the button script (thinking a template base so you could use paypal in there) and and a way to leave the group.

FEU subscription Mod... just need more time lol... I wish I could work for free lol....

cheers
jeremyBass