Filter in FEUsers User page

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
jimmyb
Forum Members
Forum Members
Posts: 35
Joined: Wed Sep 20, 2006 12:40 pm

Filter in FEUsers User page

Post by jimmyb »

Having a problem with the filter system in the FEUsers 'Users' tab.

Have setup around 200 users which has all gone fine. When I filter by username in the 'Username Regular Expression' field it works fine. The list produced brings up the correct users and I can then edit all the details.

When I try and filter by the 'Value (regular expression)' and the 'Property' field, the list produced is correct on screen but the links to edit (either by clicking the username or the edit image) and delete do not work. Looking at the URL it would appear that the "user_id=" portion is pulling data from the cms_module_feusers_properties ID column rather than the cms_module_feusers_properties userid column. By directing me to the property id rather than the user id, I am obviously getting wrong account details or no account details at all.

Can anybody help? This has been driving me mad for hours!!

Many thanks
jimmyb
Forum Members
Forum Members
Posts: 35
Joined: Wed Sep 20, 2006 12:40 pm

Re: Filter in FEUsers User page

Post by jimmyb »

OK... With my somewhat limited knowledge of PHP and MySQL I think I have managed to track the problem down but still not sure how to get around it.

The SQL for the User list generation seems to appear in the FrontEndUsers.api.php file (1.1.3-beta1) around line 690 and looks like this

Code: Select all

  function GetUsersInGroup( $groupid = '', $userregex = '', $limit = '', $sort = '',
			    $property = '', $propregex = '')
  {
    $db =& $this->GetDb();

    $parms = array();
    $where = array();
    $ordersort = "";
    $q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users A"; 
    if( $property != '' && $propregex != '' )
      {
	$q .= ",".cms_db_prefix()."module_feusers_properties B";
	$where[] = " A.id = B.userid";
      }
    if( $groupid != '' && $groupid >= 0 )
      {
	$q .= ",".cms_db_prefix()."module_feusers_belongs C";
	$where[] = " A.id = C.userid";
	$where[] = " groupid = ?";
	$parms[] = $groupid;
      }
    if( $property != '' && $propregex != '' )
      {
	$where[] = " B.title = ? and B.data REGEXP ?";
	$parms[] = $property;
	$parms[] = $propregex;
      }
    if( $userregex != '' )
      {
	$where[] = " username REGEXP ?";
	$parms[] = $userregex;
      }
    if( $sort != '' )
      {
	$ordersort .= " ORDER BY $sort";
      }
    if( $limit != '' && $limit > 0 )
      {
	$ordersort .= " LIMIT $limit"; 
      }

    // put the query together
    if( count($where ) )
      {
	$q .= " WHERE " . implode(" AND ",$where);
      }
    $q .= $ordersort;
    $dbresult = $db->Execute( $q, $parms );
    if( !$dbresult )
      {
	return false;
      }

    $result = array();
    while( $row = $dbresult->FetchRow() )
      {
	array_push( $result, $row );
      }
    return $result;
  }
The first mention of

Code: Select all

 if( $property != '' && $propregex != '' )
is where the problem is occuring as far as I can see.

The

Code: Select all

$where[] = " A.id = B.userid";
generates a set of results that include 2 ID columns (module_feusers_users.id and module_feusers_properties.id)

The file that actually governs the display of the users list is action.defaultadmin.php and the related code exists at around line 259

Code: Select all

$onerow->username = $module->CreateLink($id, 'edituser', $returnid, $row['username'],
						      array('user_id' => $row['id']));
The

Code: Select all

$row['id']
is extracting the id from the module_feusers_properties.id column rather than the module_feusers_users.id column.

Is there any way to specify that it takes the data form the other column. I have tried changing the

Code: Select all

$row['id']
to

Code: Select all

$row['module_feusers_users.id']
and various combinations but it returns nothing. There's probably a very simple workaround but I think I've been looking at it to long!! ??? ??? ???
Post Reply

Return to “Modules/Add-Ons”