User relationship module is super. but i think we need a search box in it so that we can search users in our relationships, and users throughout the site so as we add relationships with them. For this i will work on creating a small module in UR API or submit a patch for this. I think this will be the great improvement in user relationships

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

63reasons-AS’s picture

Assigned: MisterSpeed » 63reasons-AS
alex.k’s picture

Just came across this issue. Could you explain why core user search would not work for this? Curious to know how discoverability would be improved. Although a solid suggestion feature would probably go a longer way to get social networks built.

MisterSpeed’s picture

The issue with the generic search is that a) It is not hinted; I cannot limit my search among friends of friends for example; b) It falls under the slightly less than entirely stellar Drupal Search experience (and becomes entirely irrelevant when you switch the search system), and c) looking at some actual users using a site with UR, not one of them thought of using the search box for finding users; all were diddling around the friends box hoping to find there the search functionality that they need.

In short, having a dedicated search facility that returns profile information a la Facebook instead of a (giant morass of everything on the site, unless as a casual user you happen to know the magic incantations, if any, to limit search to users) would improve the user experience and the search relevancy.

alex.k’s picture

We've had pretty good results in general user search using Solr and keeping profile data in nodes with Content Profile. Search within friends of friends would be a great use case. Looking forward to see what you come up with - should likely be a module rather than a patch unless it's small. Appreciate the background info.

ajayg’s picture

Genric Search is expensive (CPU Cycles) so we use google custom search instead drupal search. So the user search is disabled for us (since default drupal search is disabled). I would love to see a module. We currently use members module for user search so this could be a bridge between UR and some kind of members module.

The more I am thinking about this, why you would need a module? Would a more customzed view or a plugin for views2 would be a better option? You cna use views2 built in search for searching on all users and perhaps a custom filter for searching among the visitor's (logged in user's) friends.

63reasons-AS’s picture

Assigned: 63reasons-AS » Unassigned
63reasons-LS’s picture

Assigned: Unassigned » 63reasons-LS
63reasons-LS’s picture

Status: Active » Needs review
FileSize
4.06 KB

Im adding a module here as attachment for searching users in and outside relationships and manage them. The search contains different filters.
1) Searching users of the site and add them to relationships.
2) Searching users within relationships.
3) Searching users within pending relationships.
4) Searching users in particular relationships.

We can set number of search results per page from user relationships settings search options.

Let me know if it needs further improvement.

Thanks

MisterSpeed’s picture

Good work Lakhvinder !

Plazmus’s picture

Thanks 63reasons-LS it's useful feature.

I've tested it and tab appears when you go to the "relationships" path but it's not visible when you go to "user/%/realationships" (when I'm looking on friends list for other users.)
Can you please fix it ?

Cheers

63reasons-LS’s picture

Thanks Plazmus,

I will check this and update the module as soon as possible.

Thanks

Plazmus’s picture

I just want to ask one more thing as I hope this functionality will be included in next 'User Relationships' beta release.

I use realname module and don't display usernames anywhere, is it possible to use realnames for this search module?

Thanks

alex.k’s picture

Status: Needs review » Needs work

Apologies for the delay in reviewing the module. It looks pretty good and works well. I would only do a couple of things before it's ready for more general usage:
* Use theming functions and a template page for showing search results. Pls. see for an example how relationship listing pages are done. This will allow themers to override how results are displayed. Relevant sequence of functions are user_relationships_page(), user_relationships_page() (where actual search would take place), and then user_relationships.tpl.php
* Please format using Drupal code formatting guidelines, and run it through coder.module suggestions
If you don't have any more developer cycles to dedicate to it, let me know. Thanks much!

alex.k’s picture

Also, if I select 'All users' it does not include my relationships in search results. Is it intended? When I select "All in relationships" it correctly searches only within my relationships.

MisterSpeed’s picture

Hey Alex,

Lakhvinder is working on an internal project for a few more days but will be available for this right afterwards. Lots of momentum on the Issue list in the last few days so we'll try to get it in for your next release.

Cheers,

Louis-Eric

alex.k’s picture

Great, thanks for the heads up.

63reasons-LS’s picture

Status: Needs work » Needs review
FileSize
4.74 KB

I have done with the necessary changes of adding template files, theming functions and search criteria. Also there is search tab in other users relationships for searching (For admin and user as they has access to the relationships). All the changes are in the attachment

Let me know if it has any issue or need further improvement.

Thanks

ezar’s picture

I add content_profile search for user.

Add in template_preprocess_user_relationships_search()
With this you can search every field in profile and list user/users.

function template_preprocess_user_relationships_search(&$variables) {
        // genral variables
     $keys  = $variables['keys'];
     $type  = $variables['type'];
     $user  = $variables['account'];
			
		 if (module_exists('content_profile')) {
     	$find = do_search($keys, 'node', "INNER JOIN {node} n ON n.nid = i.sid ", "n.type = 'profile'");
     	foreach ($find as $item) {
	      $unode = node_load($item->sid);
	  	 	if ($type=='users')   {  
					check_user_relationships(&$unode, $user);
	      	$variables['relationships'][$unode->uid] = $unode;
  	   	} 
    	 	else if ($type=='in_relation') {
    	 	  $args = array('requester_id' => $user->uid, 'requestee_id' => $unode->uid, 'approved' => 1);
				  $count = user_relationships_load($args, array('count' => TRUE));
  				if ($count > 0) {
  					check_user_relationships(&$unode, $user);
		      	$variables['relationships'][$unode->uid] = $unode;
		      }
      	}
      	else if ($type=='pending') {
    	 	  $args = array('requester_id' => $user->uid, 'requestee_id' => $unode->uid, 'approved' => 0);
				  $count = user_relationships_load($args, array('count' => TRUE));
  				if ($count > 0) {
						check_user_relationships(&$unode, $user);
		      	$variables['relationships'][$unode->uid] = $unode;
		      }
      	} 
      	else {
    	 	  $args = array('requester_id' => $user->uid, 'requestee_id' => $unode->uid, 'approved' => 1, 'name' => $type);
				  $count = user_relationships_load($args, array('count' => TRUE));
				  var_dump($count);
					if ($count > 0) {
						check_user_relationships(&$unode, $user);
		      	$variables['relationships'][$unode->uid] = $unode;
		      }
      	}
     	}
     }
     $query['query']= "SELECT DISTINCT ur.rid,ur.*,urt.*, u.uid as uid FROM {user_relationships} ur INNER JOIN {user_relationship_types} urt USING ( rtid ) INNER JOIN {users} requestees ON ur.requester_id = requestees.uid INNER JOIN {users} requesters ON ur.requestee_id = requesters.uid,{users} u WHERE ((ur.requester_id = %d and ur.requestee_id = u.uid) or (ur.requester_id = u.uid and ur.requestee_id = %d)) and u.name like '%%%s%%'";
     $query['count']= "SELECT COUNT(DISTINCT rid) AS count FROM {user_relationships} ur INNER JOIN {user_relationship_types} urt USING ( rtid ) INNER JOIN {users} requestees ON ur.requester_id = requestees.uid INNER JOIN {users} requesters ON ur.requestee_id = requesters.uid,users u WHERE ((ur.requester_id = %d and ur.requestee_id = u.uid) or (ur.requester_id = u.uid and ur.requestee_id = %d)) and u.name like '%%%s%%'";
     if ($type=='users')   {  
     	    $query['query']="select u.uid,u.name from users u where u.name like '%%%s%%' and u.uid!=%d";
         	$query['count']="select count(*) from users u where u.name like '%%%s%%' and u.uid!=%d";
         	$query['arguments']=array(1 => $keys, 2 => $user->uid);
     	} 
     	else if ($type=='in_relation') {
       	  $query['query'] .=" and ur.approved=1 group by ur.rid";
	        $query['count'] .=" and ur.approved=1";
  	      $query['arguments']=array(0 => $user->uid, 1 => $user->uid, 2 => $keys);
     	}
     	else if ($type=='pending') {
         	$query['query'] .=" and ur.approved=0  group by ur.rid";
         	$query['count'] .=" and ur.approved=0";
         	$query['arguments']=array(0 => $user->uid, 1 => $user->uid, 2 => $keys);
     	} 
     	else {
         	$query['query'] .= " and ur.approved=1 and urt.plural_name='%s'  group by ur.rid";
         	$query['count'] .=" and ur.approved=1 and urt.plural_name='%s'";
         	$query['arguments']=array(0 => $user->uid, 1 => $user->uid, 2 => $keys, 3 => $type);
     	}
  	// To Page or not to Page
  	if ($variables['relationships_search_results_per_page'] = variable_get('relationships_search_results_per_page', 15)) {
    	$results = pager_query($query['query'], $variables['relationships_search_results_per_page'], 0, $query['count'], $query['arguments']);
  	}
  	else {
    	$results = db_query($query['query'], $query['arguments']);
  	}
  	if ($type=='users') {
    	  if (!is_array($variables['relationships']))
					$variables['relationships'] = array();
      	while ($relationship = db_fetch_object($results)) {
      			if (!$variables['relationships'][$relationship->uid]) {
	          	check_user_relationships(&$relationship, $user);
  	        	$variables['relationships'][$relationship->uid] = $relationship;
    	      }
	      }
  	}
  	else {
    	 if (!is_array($variables['relationships']))
			 	$variables['relationships'] = array();
     	while ($relationship = db_fetch_object($results)) {
	     	$variables['relationships'][$relationship->rid] = $relationship;
     	}
  	}
}
southsideslim03’s picture

Can you add this to search the regular profile fields instead of content_profile

apmsooner’s picture

An option:
I've created a search block based on exposed filters in views with exposed form in block checked as a feature. I havn't figured out a way for the search results to only show users that aren't already related to the logged in user so I just have it return all users filtered by user profile and it serves me fine. In this way, clicking on a user in the search results loads the user's profile and then the logged in user can then request relationship with the user there. I've used panels with rules applied to panes that only certain profile content is displayed when logged in user has relationship with user being viewed. It works great this way. If anyone needs detailed instruction on how to do this, i could explain further.

ebtjoe’s picture

I installed the module and when I search for someone on it I get the following error:

user warning: Table 'ebt48_drpl1.users' doesn't exist query: select count(*) from users u where u.name like '%joe%' and u.uid!=3 in /home/ebt48/public_html/sites/all/modules/user_relationships_search/user_relationships_search.module on line 280.
user warning: Table 'ebt48_drpl1.users' doesn't exist query: select u.uid,u.name from users u where u.name like '%joe%' and u.uid!=3 LIMIT 0, 15 in /home/ebt48/public_html/sites/all/modules/user_relationships_search/user_relationships_search.module on line 280.

bfvr074’s picture

apmsooner! I need to do that too please help me!

apmsooner’s picture

Answer to bfvr074,

Are you comfortable using panels? I'll touch on how I set this up but will leave it up to you to learn more about panels if you are unfamiliar.

As far as the search user setup, you can setup a really basic view based on either user or node (if you use the content profile module). You can either setup exposed filters on that view and specify in the exposed form in block option... or you can use the finder module which I'm actually doing now to pull that view into a finder form which looks and acts a little better in my opinion. Since its just a form to search all users, you don't have to specify any user-relationship fields in the view but rather just setup filters based on roles or any other criteria you want. The search box would just appear as a block or within a page on your site. The output should show a list of names associated with the filtered search and when you click on a name, it goes to the user profile linked to the panel user profile template. This template basically allows you to customize what is shown in a user's profile page based on the content you add to each variant described below.

Panels Example- What I'm doing with panels is just modifying the User Profile Template that comes with panels and setup 3 different variants. Theres other approaches but this is just an example of mine...

1. self - variant to show user profile for logged in user only.
Example usage - This page could contain all private information that only the logged in user has access to. You could for example display a view here of all related users to the logged in user like you would see on facebook.
* selection rules - user:compare = logged in user is user being viewed.

2. related - variant to show profile for related users to the logged in user.
Example usage - This page could contain all information that a related user should see for the user being viewed. Example, if user has photo albums that only "friends" should have access to, then set this page up accordingly. You could also add view here showing all related users to the user being viewed like facebook.
* selection rules - User Relationship = Logged in user can have relationships: "friend" to User being viewed
NOTE: "friend" is the name of the relationship type I setup, yours may be different.

3. unrelated - variant to show profile for unrelated users to the logged in user
Example usage - This page could serve as a message to the logged in user that says the user they are trying to view only shares information with "friends". You could place the user relationship actions links in this variant along with a custom message to the user. If user being viewed approves relationship request for the logged in user then the logged in user will of course see variant 2 the next time they view that user's profile.
* no selection rule because this variant serves as a catch all for profiles that do not belong to the logged in user and are not related to the logged in user.

As you can see, the selection rules control the behavior of who sees what based on relationship status. This setup really functions very similarly to facebook as long as you have the selection rules correctly applied. I've never seen any better or easier way of creating a social network type site with drupal but let me know if anyone has a better solution. Hope that helps.

bfvr074’s picture

Thanks!! apmsooner!! finder module is great!!, I use with views, now I want that search box show in my appbar!!! But thanks!

okday’s picture

subscribing

oxford-dev’s picture

I also get the error described in #21.

I also have error:Warning: Call-time pass-by-reference has been deprecated in C:\Websites\Qinqime\sites\all\modules\user_relationships\user_relationships_search\user_relationships_search.module on line 288

At the top of every page.

This is a really useful add-on when its working fully. As an extra note, it does not return anyone which in not in my relationships (All Users)

good effort

alex.k’s picture

Status: Needs review » Postponed (maintainer needs more info)

If someone wants to bring this module up to date and post as a separate project that would be great. I can't accept maintainership of this feature as I don't use it, and including it in UR proper will make the package too big with an additional feature that only some sites will use.

mrf’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Not going o be included in the main module.