[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.314,1.315

vinny at iowaoutdoors.org vinny at iowaoutdoors.org
Mon Apr 26 15:09:41 EDT 2004


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv6354

Modified Files:
	lib-common.php 
Log Message:
Various optimizations to reduce SQL calls
  1. changed order of caching $_GROUPS and $_RIGHTS
  2. cached 'noboxes' for COM_showBlock/COM_showBlocks
  3. Fixed usage of $_GROUPS cache in COM_getPermSQL


Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.314
retrieving revision 1.315
diff -C2 -d -r1.314 -r1.315
*** lib-common.php	10 Apr 2004 18:42:57 -0000	1.314
--- lib-common.php	26 Apr 2004 19:09:37 -0000	1.315
***************
*** 322,341 ****
  
  /**
! * Global array of current user permissions [read,edit]
  *
! * @global array $_RIGHTS
  *
  */
  
! $_RIGHTS = explode( ',', SEC_getUserPermissions() );
  
  /**
! * Global array of groups current user belongs to
  *
! * @global array $_GROUPS
  *
  */
  
! $_GROUPS = SEC_getUserGroups( $_USER['uid'] );
  
  if( isset( $HTTP_GET_VARS['topic'] ))
--- 322,341 ----
  
  /**
! * Global array of groups current user belongs to
  *
! * @global array $_GROUPS
  *
  */
  
! $_GROUPS = SEC_getUserGroups( $_USER['uid'] );
  
  /**
! * Global array of current user permissions [read,edit]
  *
! * @global array $_RIGHTS
  *
  */
  
! $_RIGHTS = explode( ',', SEC_getUserPermissions() );
  
  if( isset( $HTTP_GET_VARS['topic'] ))
***************
*** 3422,3432 ****
      $retval = '';
  
!     if( !empty( $_USER['uid'] ))
!     {
!         $U['noboxes'] = DB_getItem( $_TABLES['userindex'], 'noboxes', "uid = {$_USER['uid']}" );
!     }
!     else
!     {
!         $U['noboxes'] = 0;
      }
  
--- 3422,3434 ----
      $retval = '';
  
!     if ( isset( $_USER['noboxes'] ) ) {
!         if( !empty( $_USER['uid'] ) )
!         {
!             $_USER['noboxes'] = DB_getItem( $_TABLES['userindex'], 'noboxes', "uid = {$_USER['uid']}" );
!         }
!         else
!         {
!             $_USER['noboxes'] = 0;
!         }
      }
  
***************
*** 3449,3453 ****
  
          case 'events_block':
!             if( !$U['noboxes'] && $_CONF['showupcomingevents'] )
              {
                  $retval .= COM_printUpcomingEvents( $help, $title );
--- 3451,3455 ----
  
          case 'events_block':
!             if( !$_USER['noboxes'] && $_CONF['showupcomingevents'] )
              {
                  $retval .= COM_printUpcomingEvents( $help, $title );
***************
*** 3456,3460 ****
  
          case 'poll_block':
!             if( !$U['noboxes'] )
              {
                  $retval .= COM_showPoll( 60 );
--- 3458,3462 ----
  
          case 'poll_block':
!             if( !$_USER['noboxes'] )
              {
                  $retval .= COM_showPoll( 60 );
***************
*** 3463,3467 ****
  
          case 'whats_new_block':
!             if( !$U['noboxes'] )
              {
                  $retval .= COM_whatsNewBlock( $help, $title );
--- 3465,3469 ----
  
          case 'whats_new_block':
!             if( !$_USER['noboxes'] )
              {
                  $retval .= COM_whatsNewBlock( $help, $title );
***************
*** 3494,3507 ****
  
      // Get user preferences on blocks
! 
!     if( !empty( $_USER['uid'] ))
!     {
!         $result = DB_query( "SELECT boxes,noboxes FROM {$_TABLES['userindex']} WHERE uid = '{$_USER['uid']}'" );
!         $U = DB_fetchArray( $result );
!     }
!     else
!     {
!         $U['boxes'] = '';
!         $U['noboxes'] = 0;
      }
  
--- 3496,3510 ----
  
      // Get user preferences on blocks
!     if ( isset( $_USER['noboxes'] ) || isset( $_USER['boxes'] ) ) {
!         if( !empty( $_USER['uid'] ) )
!         {
!             $result = DB_query( "SELECT boxes,noboxes FROM {$_TABLES['userindex']} WHERE uid = '{$_USER['uid']}'" );
!             list($_USER['boxes'], $_USER['noboxes']) = DB_fetchArray( $result );
!         }
!         else
!         {
!             $_USER['boxes'] = '';
!             $_USER['noboxes'] = 0;
!         }
      }
  
***************
*** 3532,3538 ****
      }
  
!     if( !empty( $U['boxes'] ))
      {
!         $BOXES = str_replace( ' ', ',', $U['boxes'] );
  
          $sql .= " AND (bid NOT IN ($BOXES) OR bid = '-1')";
--- 3535,3541 ----
      }
  
!     if( !empty( $_USER['boxes'] ))
      {
!         $BOXES = str_replace( ' ', ',', $_USER['boxes'] );
  
          $sql .= " AND (bid NOT IN ($BOXES) OR bid = '-1')";
***************
*** 3564,3568 ****
              }
  
!             if( $A['type'] == 'phpblock' && !$U['noboxes'] )
              {
                  if( !($A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0 ))
--- 3567,3571 ----
              }
  
!             if( $A['type'] == 'phpblock' && !$_USER['noboxes'] )
              {
                  if( !($A['name'] == 'whosonline_block' AND DB_getItem( $_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0 ))
***************
*** 3593,3597 ****
              }
  
!             if( !empty( $A['content'] ) && !$U['noboxes'] )
              {
                  $blockcontent = stripslashes( $A['content'] );
--- 3596,3600 ----
              }
  
!             if( !empty( $A['content'] ) && !$_USER['noboxes'] )
              {
                  $blockcontent = stripslashes( $A['content'] );
***************
*** 5200,5204 ****
          }
  
! 	$rel[] = '<a href="' . $matches[1][$i] . '">' . $matches[2][$i] . '</a>';
      }
  
--- 5203,5207 ----
          }
  
!         $rel[] = '<a href="' . $matches[1][$i] . '">' . $matches[2][$i] . '</a>';
      }
  
***************
*** 5268,5273 ****
          $table .= '.';
      }
! 
!     if( $u_id <= 0 )
      {
          $uid = $_USER['uid'];    
--- 5271,5275 ----
          $table .= '.';
      }
!     if( ($u_id <= 0) || ($u_id == $_USER['uid']) )
      {
          $uid = $_USER['uid'];    




More information about the geeklog-cvs mailing list