vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   [BETA] Favorite Threads (https://vborg.vbsupport.ru/showthread.php?t=4099)

10-24-2000 01:46 PM

Later today (hopefully) after I add the code to check if threads or invisible or unavailable to a user. The scenario is possible that a user adds a thread and then loses access to the forum the thread lives in or the thread is moved to a forum the user doesn't have access to.

10-24-2000 04:20 PM

Ok I hacked the hack so that if a thread is "invisible" it will not be shown in the users favorites.

Also it nows checks if a user has access to a thread before showing it in their favorites.

The idea is that a user may have added a thread and now has lost access to it for reasons shown in my previous post. The thread isn't actually removed from his/her list but is just not shown to them. This will allow it to "re-appear" to them if they are again given access to it. The thread table is very small as it only contains 3 id fields, the thread id, the id of the folder it goes in (if it has one) and the id of the field itself.

Below is my access checking code. My main goal has been as little database access as possible and I believe John needs to do this sort of thing in other places to help the optimization. I could have queried the database for every thread to decide to post it or not but that is bad design and something vB is very guilty of doing. My way of doing it is to build parts of your query using logic and then put your constructed query to work in the main query:

Code:

  // These usergroups really need to be re-done, this is a nightmare!
  // This gets the forums that our usergroup has SPECIFIC canview access to (0 or 1)
  $q_perms = $DB_site->query("SELECT forumid,canview FROM forumpermission
                              WHERE usergroupid = $bbusergroupid");
  // This gets our generic canview access
  // If we do not have a specific access defined in the first query than we use the second query
  // for our access to that forum.
  $q_uperms = $DB_site->query_first("SELECT canview FROM usergroup WHERE usergroupid = $bbusergroupid");
  $canview = $q_uperms[canview]; 
  // $canview = 0 / We can't view any forums unless we have specific access to above
  // $canview = 1 / We can view all forums unless we have specific access not to above
  if ($canview == 1) // We view all forums by default, hide those we have explicit non access to
  {
      while ($query = $DB_site->fetch_array($q_perms))
      {
        $onethread = 0;
        if ($query[canview] == 0)
        {
            if ($onethread == 0) 
            {
              $forums .= " AND (forumid <> $query[forumid] ";
              $onethread = 1;
            }
            else
            {
              $forums .= " OR forumid <> $query[forumid] ";
            }
        }
      }
      if ($onethread == 1)
      {
        $forums .= ")"; 
      }     
  }
  else // We can view no forums by default, show those we have explicit read access to
  {
      while ($query = $DB_site->fetch_array($q_perms))
      {
        $onethread = 0;
        if ($query[canview] == 1)
        {
            if ($onethread == 0) 
            {
              $forums .= " AND (forumid = $query[forumid] ";
              $onethread = 1;
            }
            else
            {
              $forums .= " OR forumid = $query[forumid] ";
            }
        }
      }
      if ($onethread == 1)
      {
        $forums .= ")"; 
      }     
  }

  $q_thread = $DB_site->query("SELECT thread.iconid, icon.title AS icontitle, icon.iconpath, open, thread.title AS threadtitle,
                        lastpost, postusername,lastposter, views, replycount, fav_threads.userid, fav_threads.threadid,
                        fav_threads.folderid, folder                     
                        FROM fav_threads,thread
                        LEFT JOIN fav_folders ON (fav_threads.folderid = fav_folders.folderid)
                        LEFT JOIN icon ON (icon.iconid = thread.iconid)
                        WHERE fav_threads.userid = $bbuserid
                              AND thread.threadid = fav_threads.threadid
                              AND thread.visible = 1
                              $forums
                        ORDER by folder,thread.title");

I then take "$forums" and place it into my main query that retrieves the threads. Remember I only have one query that gets everything for showing the threads (it gets the icons, the posters, everything that is shown normally when you look at a list of threads in a normal forum). Can we say forumdisplay is need of a query optimization (I think so).

Let me put in page breaks for long pages and I will be done (which isn't easy as I like to make sure to return you to the page you were on from any function you may access)

[Edited by rangersfan on 10-24-2000 at 01:12 PM]

10-24-2000 10:01 PM

Ok I do believe the hack is finished. Pageing is in place and no problems so far. Give me time to convert the templates to the proper vB format and I will release it. (My templates are different as I put all the links and graphics in an include file so I can use them across other pages outside the actual forum)

10-24-2000 10:14 PM

glad its working ok :)

10-25-2000 12:23 AM

This is really cool.. I think though that TWTCommish deserves at least partial credit. If at least only for the Idea.. I can use this for another feature I wanted to do as well... Very Very Nice.

10-25-2000 12:51 AM

Wow! This is great! I feel like a kid on Christmas morning waiting to see what the great Rangersfan is gonna bring for presents!

Great job on the hack so far Rangersfan, and thanks for invoking the inspiration TWTCommish...You deserve a great deal of credit indeed.

Thanks for making a great product better guys! This hack should definately be looked at for inclusion in the default code. Bravo for the reduction in sql queries as well, mySQL DB would not be able to handle much more than she is.

rick

10-25-2000 04:02 PM

Please close this thread Ed.

12-30-2000 05:26 PM

Who install this hack ?

i want to see other demo .


cos i am worry about editing the database .


Thank you :)

12-30-2000 06:34 PM

I installed it and it was simple to work.

Not much editing to your database as it adds a few tables.

12-30-2000 07:01 PM

Quote:

Originally posted by freddie
Please close this thread Ed.
Sorry 'bout that -- missed it :) If you need to discuss for whatever reason, use a new thread or something.


All times are GMT. The time now is 05:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01044 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete