Search Posts Download 1.4

5.0
us Jason Denang 6 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.

Comments
German Michael Zülsdorff Replied 6 years ago

Hi Jason,

great improvement on privacy in 1.2, but still issues with the pagination if a 'normal' user is logged in.
If you have a look into some classes you'll find that throughout Ossn adding a count=true to a query will return the number of records found instead of the data itself. But of course it always depends on the base query how many records will be returned.
That said, you can not use the admin base query for counting all the time, but you need to adapt it to your different rules when a normal user is logged in.
Otherwise you'll get a lot of pagination tabs at the bottom but no postings behind. So the corrected code should look something like this ...

us Jason Denang Replied 6 years ago

Hi Z-Man,
I can not believe I did that. I checked the zip that I made last night and it did in fact contain the core search file. That is too funny. I have zipped and uploaded the correct fileset. LMAO!

Best,
Jason

German Michael Zülsdorff Replied 6 years ago

I removed 1.2 because the zip archive did not contain a newer version of your own component but the core OssnSearch component!

us Jason Denang Replied 6 years ago

Ok. I've made some very necessary updates. The most important are in the ossn_com.php file. I've added a new revision V1.2 which allows only search results by logged in user, for 'normal users' returns only results posted by self or friends, if logged in as admin will return all matching results regardless of friend status.

Let me know what you think!

Best, Jason

us Jason Denang Replied 6 years ago

Hi Z-man,
Wow. Yeah I see your point. I believe the $user... was left over from initial testing and 'trying' to get this working as desired. Removing those two lines does not impact search results or 'view post' link/button. Moving the hook to just above the function also has no impact.

I wasn't concerned with privacy, but now that you mention it... do you have any suggestions? Also, do you have any type of blueprint for OSSN. Some type of framework and functions documentation? I've been programming for a while now, but am certainly not great. I just do my best to make things happen.

Thank you so much for your feedback as it is greatly appreciated!

Best, Jason

German Michael Zülsdorff Replied 6 years ago

Good idea, basically working, but I found some strange parts in view.php

foreach ($comments as $comment) {
    $user = new OssnUser;
    $user = ossn_user_by_guid($comment->owner_guid);

    ossn_add_hook('wall', 'post:menu', 'ossn_wall_post_menu_view_post');
    $wall_comment = ossn_wallpost_to_item($comment);
    echo  ossn_wall_view_template($wall_comment);
}
  1. $user - what is it good for?
  2. why are you adding that hook in the loop?

Aside from that the search results don't take privacy settings into account - that is: any member will be able to view any post. That said, $wall->GetPosts is okay for Admins, but you should think about a different retrieval method for regualar members.

Component

Developer: Jason
License ossnv3
Type: Communication
Requires Ossn Version : 5.x
Latest Version: 1.4
Last Updated 6 years ago
Repository Url View Repository

Versions