Ignore:
Timestamp:
Sep 14, 2005, 11:57:05 PM (19 years ago)
Author:
plg
Message:
  • improvement: long localized messages are in HTML files instead of $lang array. This is the case of admin/help and about pages.
  • deletion: of unused functions (ts_to_mysqldt, is_image, TN_exists, check_date_format, date_convert, get_category_directories, get_used_metadata_list, array_remove, pwg_write_debug, get_group_restrictions, get_all_group_restrictions, is_group_allowed, style_select, deprecated_getAttribute).
  • new: many new contextual help pages to replace descriptions previously included in pages.
  • modification: reorganisation of language files. Deletion of unused language keys, alphabetical sort. No faq.lang.php anymore (replaced by help.html). Only done for en_UK.iso-8859-1.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_group.inc.php

    r675 r862  
    2626// +-----------------------------------------------------------------------+
    2727
    28 // get_group_restrictions returns an array containing all unaccessible
    29 // category ids.
    30 function get_group_restrictions( $group_id )
    31 {
    32   // 1. retrieving ids of private categories
    33   $query = 'SELECT id FROM '.CATEGORIES_TABLE;
    34   $query.= " WHERE status = 'private'";
    35   $query.= ';';
    36   $result = pwg_query( $query );
    37   $privates = array();
    38   while ( $row = mysql_fetch_array( $result ) )
    39   {
    40     array_push( $privates, $row['id'] );
    41   }
    42   // 2. retrieving all authorized categories for the group
    43   $authorized = array();
    44   $query = 'SELECT cat_id FROM '.GROUP_ACCESS_TABLE;
    45   $query.= ' WHERE group_id = '.$group_id;
    46   $query.= ';';
    47   $result = pwg_query( $query );
    48   while ( $row = mysql_fetch_array( $result ) )
    49   {
    50     array_push( $authorized, $row['cat_id'] );
    51   }
     28// with 1.5 preparation, no group dedicated function is used.
    5229
    53   $forbidden = array();
    54   foreach ( $privates as $private ) {
    55     if ( !in_array( $private, $authorized ) )
    56     {
    57       array_push( $forbidden, $private );
    58     }
    59   }
    60 
    61   return $forbidden;
    62 }
    63 
    64 // get_all_group_restrictions returns an array with ALL unaccessible
    65 // category ids, including sub-categories
    66 function get_all_group_restrictions( $group_id )
    67 {
    68   $restricted_cats = get_group_restrictions( $group_id );
    69   foreach ( $restricted_cats as $restricted_cat ) {
    70     $sub_restricted_cats = get_subcats_id( $restricted_cat );
    71     foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
    72       array_push( $restricted_cats, $sub_restricted_cat );
    73     }
    74   }
    75   return $restricted_cats;
    76 }
    77 
    78 // The function is_group_allowed returns :
    79 //      - 0 : if the category is allowed with this $restrictions array
    80 //      - 1 : if this category is not allowed
    81 //      - 2 : if an uppercat category is not allowed
    82 function is_group_allowed( $category_id, $restrictions )
    83 {
    84   $lowest_category_id = $category_id;
    85                
    86   $is_root = false;
    87   while ( !$is_root and !in_array( $category_id, $restrictions ) )
    88   {
    89     $query = 'SELECT id_uppercat FROM '.CATEGORIES_TABLE;
    90     $query.= ' WHERE id = '.$category_id;
    91     $query.= ';';
    92     $row = mysql_fetch_array( pwg_query( $query ) );
    93     if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
    94     if ( $row['id_uppercat'] == '' ) $is_root = true;
    95     $category_id = $row['id_uppercat'];
    96   }
    97                
    98   if ( in_array( $lowest_category_id, $restrictions ) )
    99   {
    100     return 1;
    101   }
    102   if ( in_array( $category_id, $restrictions ) )
    103   {
    104     return 2;
    105   }
    106   // this group is allowed to go in this category
    107   return 0;
    108 }
    10930?>
Note: See TracChangeset for help on using the changeset viewer.