Ignore:
Timestamp:
06/27/10 22:37:23 (10 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

Location:
extensions/virtualAutoGrant
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/virtualAutoGrant/VAG_admin.php

    r6610 r6613  
    99$infos = array(); 
    1010 
    11         // '' => 1, 
    12         // 'set_private_by_API' => 1, 
    13         // 'grant_to_creator' => 1, 
    14         // 'grant_to_webmaster' => 1, 
    15         // 'set_who_can_see' => 1, 
    16         // 'webmaster_set_who_can_see' => 1, 
    17         // 'ignore_who_can_see_on_private' => 1, 
    18         // 'Dir' => VAG_DIR, 
    19         // 'Path' => VAG_PATH, 
    20         // 'Ver' => VAG_VER, 
    2111$vag = & $conf['virtual_AutoGrant']; 
    2212 
     
    2515if ( $sub ) { 
    2616  $nsp = array_merge($vag, $_POST); 
    27         if ( $nsp['set_private'] == 1 and $nsp['set_private_by_API'] == 0 ) { 
    28     $nsp['set_private_by_API'] = 1; 
    29     array_push($infos, l10n('New virtual categories from external API will be forced to "private" due to previous choice.')); 
    30   } 
    3117  if ( $user['id'] != $conf['webmaster_id'] and $nsp['grant_to_webmaster'] != $vag['grant_to_webmaster']) { 
    3218    $nsp['grant_to_webmaster'] = $vag['grant_to_webmaster']; 
     
    4531        array_push($infos, l10n('Your configuration is saved.')); 
    4632  } 
    47   $vag = $nsp; 
     33  $vag = array_merge($vag, $nsp); 
    4834} 
    4935$template->set_filenames( array('VAG_admin' => dirname(__FILE__).'/template/VAG_admin.tpl') ); 
  • 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.