Search Posts Download 2.3

This component/theme works with latest OSSN version.
5.0
Indonesian Arsalan Shah 7 years ago

This component allows users to search for text that was used in a post that was written to the wall or to a group. Adds a "view post" button to each returned result. Adds a "Posts" link to the search menu.

2.3

Updated to make it work on latest version $arsalanshah

  • Shows group posts if user is group member
  • Users groups and user posts.
  • Hide showing group posts if user is not member

Know issue

  • It did not filter blocked users post syet.
Comments
us Bryce alvord Replied 6 years ago

Hey Jason,

I am wondering if I could have permission to fork your code OR enhance it with a pull request. I wanted to add some more ways to search for posts and this seems like a great start to what I had in mind. Your thoughts?

Bryce

gb Rishi B Replied 7 years ago

nice job =)

us Jason Denang Replied 7 years ago

Hey Bryce,
Yep, It's good to go!

us Bryce alvord Replied 7 years ago

Any more development on this to fix issues, I would love to have this component

German Michael Zülsdorff Replied 7 years ago

Next: You can't always be sure your site is accessed from a logged in user. Log off and try

https://yoursite.com/search?type=posts

and most likely you'll get a crash

You'd better make use of if(ossn_isLoggedin()) { ....

German Michael Zülsdorff Replied 7 years ago

Another step ahead, yes!
Still irritating:

$count_options = array("search_type" => true, "description" => $query, "count" => true);

What is it good for?

us Jason Denang Replied 7 years ago

Hi Z-Man,
Thanks for the help with this. Moving the friends part into !isadmin of course only saves time and resources for admin users, but still a good call. Thank you for helping me understand the pagination a bit better. I have uploaded V1.3 ;)

Best,
Jason

German Michael Zülsdorff Replied 7 years ago

Aside from that you should think about moving your friends part completely inside the !ossn_isAdminLoggedin() condition to avoid unnecessary queries if the admin is logged in. Actually I don't think this is the final solution anyway because it's missing all public records.

(Sorry, but I was unable to post the complete stuff all in one.)

German Michael Zülsdorff Replied 7 years ago
  if(ossn_loggedin_user()->guid){
    		//bof build array of friends user id's
    		$user    = new OssnUser;
    		$friends = $user->getFriends(ossn_loggedin_user()->guid);
    		//add self user id so we can find self's posts too
    		$fuid_list = array(ossn_loggedin_user()->guid);
    		// suppress PHP warning if we have no friends !
    		if ($friends) {
    			foreach($friends as $friend){
    				$fuid_list[] = $friend->guid;
    			}
    		}
    		//eof build array of friends user id's
    		
    		$wall = new OssnWall;
    		$query = input('q');
    		$search_options = array("search_type" => true, "description" => $query);
    		
    		//if not admin user add where caluse to limit reach
    		if(!ossn_isAdminLoggedin()){
    			$search_options['wheres'] = 'owner_guid IN ('.implode(",",$fuid_list) .')';
    		}
    		
    		// since we use 2 different (admin/no admin) record queries now, we can't stay with only 1 count query any longer
    		// $count_options = array("search_type" => true, "description" => $query, "count" => true);
    		// get posts
    		$posts = $wall->GetPosts($search_options);
    		// take currently in use query - plus count option in order to return the number of records found
    		$search_options['count'] = true;
    		// get count
    		$count = $wall->GetPosts($search_options);
    		// $data = $posts;  no idea for what reason we need an extra array here ?
    		$found['users'] = $posts;
    		// $found['count'] = $count; no idea why this is passed to the view.php ? there's no 'count' being use in the code
    		$search         = ossn_plugin_view('searchposts/search/view', $found);
    		$search .= ossn_view_pagination($count);
    		if(empty($posts)) {
    			return ossn_print('ossn:search:no:result');
    		}
    		return $search;
    	}else{
    		return ossn_print('ossn:search:no:result');
    	}

Component

Developer: Arsalan
License ossnv4
Type: Communication
Requires OSSN Version : 8.0
Latest Version: 2.3
Last Updated 2 months ago
Repository Url View Repository