Ignore:
Timestamp:
Jun 27, 2010, 10:37:23 PM (14 years ago)
Author:
vdigital
Message:

Fix: some issues with globals and access by ref
Next: Add missing translations + Set "who can read" on non API cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php

    r6610 r6613  
    1111  add_event_handler('get_admin_plugin_menu_links', 'VAG_set_private');
    1212  function VAG_set_private($menu) {
    13     global $page;
     13    global $page, $conf;
    1414    if ( isset($page['page']) and $page['page'] != 'site_manager' )
    1515      $conf['newcat_default_status'] = 'private';
     
    2222  add_event_handler('get_admin_plugin_menu_links', 'VAG_set_public');
    2323  function VAG_set_public($menu) {
    24     global $page;
     24    global $page, $conf;
    2525    if ( isset($page['page']) and $page['page'] != 'site_manager' )
    2626      $conf['newcat_default_status'] = 'public';
     
    3535  function VAG_grant_to_prepare($menu) {
    3636    global $conf, $page, $vag;
    37     if ( !isset($page['page']) or $page['page'] == 'site_manager' ) return false;
     37    if ( !isset($page['page']) or $page['page'] == 'site_manager' ) return false; # Not Virtual
    3838    list($max_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE . ';'));
    3939    $vag['lastcat before'] == $max_id;
     
    5454        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert);
    5555      }
     56      // To do set level
    5657    }
    5758  }
    5859}
    5960
    60 // API cases : Just do it (even in Admin Photos Add case or other plugins cases) 
     61// API cases : Just do it  
    6162if ( !function_exists( 'VAG_set_private_by_API' ) ) {
    6263        add_event_handler('invalidate_user_cache', 'VAG_set_private_by_API', 20);
     
    6465        function  VAG_set_private_by_API($full) {
    6566    if ( !function_exists( 'ws_categories_add' ) ) return false; // That isn't an API request
    66           global $user, $conf, $vag;
    67     if ( $_REQUEST['method'] == 'pwg.categories.add' ) {
     67          global $user, $conf;
     68    $vag = & $conf['virtual_AutoGrant'];
     69    if ( isset($_REQUEST['method']) and $_REQUEST['method'] == 'pwg.categories.add' ) {
    6870      list($inserted_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE
    6971      . ' WHERE name = \'' .pwg_db_real_escape_string($_REQUEST['name']) . '\' AND site_id IS NULL;'));
     
    8082    }
    8183    // "Who can see" management ( only for API, Synchro or old HTTP management on gallery side are ignored )
    82     if ( $_REQUEST['method'] == 'pwg.images.add' and isset($_REQUEST['original_sum'])
     84    if ( isset($_REQUEST['method']) and $_REQUEST['method'] == 'pwg.images.add' and isset($_REQUEST['original_sum'])
    8385        and $vag['set_who_can_see'] == 1 ) {
    8486      # image to update
Note: See TracChangeset for help on using the changeset viewer.