Ignore:
Timestamp:
07/01/10 22:55:30 (10 years ago)
Author:
vdigital
Message:

Version: 2.1.a
extension:410

Location:
extensions/virtualAutoGrant
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/virtualAutoGrant/language/en_UK/plugin.lang.php

    r6619 r6650  
    11<?php 
     2$lang['On'] = 'Yes, maybe'; 
     3$lang['Off'] = 'No, in general'; 
    24$lang['Virtual AutoGrant configuration'] = 'Virtual AutoGrant configuration'; 
    35$lang['New virtual categories will be assumed private, access granted to creator and webmaster and/or uploaded pictures will have "Who can see" set to creator privacy level']  
     
    1012 
    1113$lang['Force "Who can see" at the creator privacy level'] = 'Force "Who can see" at the creator privacy level'; 
    12 $lang['"Who can see" is not forced for private categories'] = '"Who can see" is not forced for private categories'; 
     14$lang['"Who can see" is free for private categories'] = '"Who can see" is free for private categories'; 
    1315$lang['"Who can see" is free on webmasters uploads'] = '"Who can see" is free on webmasters uploads'; 
    1416 
     
    1820$lang['You are not authorized to change this configuration (Webmaster only).'] = 'You are not authorized to change this configuration (Webmaster only).'; 
    1921$lang['Your configuration is saved.'] = 'Your configuration is saved.'; 
     22$lang['You have got a private access to %s'] = 'You have got a private access to %s'; 
     23$lang['Virtual AutoGrant has forced "Who can see" on %d image']  = 'Virtual AutoGrant has forced "Who can see" on %d image'; 
     24$lang['Virtual AutoGrant has forced "Who can see" on %d images'] = 'Virtual AutoGrant has forced "Who can see" on %d images'; 
    2025?> 
  • extensions/virtualAutoGrant/language/fr_FR/plugin.lang.php

    r6619 r6650  
    1212 
    1313$lang['Force "Who can see" at the creator privacy level'] = 'Force le "Qui peut voir" au niveau de confidentialité du créateur'; 
    14 $lang['"Who can see" is not forced for private categories'] = '"Qui peut voir" n\'est pas forcé en cas de categories privées'; 
    15 $lang['"Who can see" is free on webmasters uploads'] = '"Qui peut voir" est libre pour les chargements du webmaster'; 
     14$lang['"Who can see" is free for private categories'] = 'Le "Qui peut voir" reste libre en cas de categories privées'; 
     15$lang['"Who can see" is free on webmasters uploads'] = 'Le "Qui peut voir" est libre pour les chargements du webmaster'; 
    1616 
    1717$lang['Only the default webmaster can change this option.'] = 'Uniquement le webmaster par défaut peut modifier cette option.'; 
     
    2222$lang['Your configuration is NOT saved due to above reasons.'] = 'Votre configuration n\'a PAS été enregistré suite aux erreurs ci-dessus.'; 
    2323$lang['Your configuration is saved.'] = 'Votre configuration a été enregistrée.'; 
    24  
     24$lang['You have got a private access to %s'] = 'Vous avez obtenu un accès privé à %s'; 
     25$lang['Virtual AutoGrant has forced "Who can see" on %d image']  = 'Virtual AutoGrant a forcé le "Qui peut voir" pour %d élément'; 
     26$lang['Virtual AutoGrant has forced "Who can see" on %d images'] = 'Virtual AutoGrant a forcé le "Qui peut voir" pour %d éléments'; 
    2527?> 
  • extensions/virtualAutoGrant/main.inc.php

    r6603 r6650  
    44Version: 2.1.a 
    55Description: External uploaders assume New virtual categories as Private, and authorize access only to creator 
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=xxx 
     6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=410 
    77Author: VDigital 
    88Author URI: http://piwigo.org/ 
  • extensions/virtualAutoGrant/template/VAG_admin.tpl

    r6619 r6650  
    6060   </tr> 
    6161   <tr> 
    62     <td class="label">{'"Who can see" is not forced for private categories'|@translate}</td> 
     62    <td class="label">{'"Who can see" is free for private categories'|@translate}</td> 
    6363        <td> 
    6464                <input type="radio" value="1"  name="ignore_who_can_see_on_private" {if ($VAG.ignore_who_can_see_on_private)}  checked="checked" {/if}/>{'On'|@translate} 
  • extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php

    r6619 r6650  
    44global $conf; 
    55include_once( VAG_PATH . 'VAG_default.php'); 
    6 $vag = & $conf['virtual_AutoGrant']; 
    76 
    8 // General case for set private (exception synchronisation (categories are not virtual ones)) 
    9 if ( $conf['newcat_default_status'] == 'public' and $vag['set_private'] == 1  
    10     and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_set_private' ) ) { 
    11   add_event_handler('get_admin_plugin_menu_links', 'VAG_set_private'); 
    12   function VAG_set_private($menu) { 
    13     global $page, $conf; 
    14     if ( isset($page['page']) and $page['page'] != 'site_manager' ) 
    15       $conf['newcat_default_status'] = 'private'; 
    16     return $menu; 
    17   } 
    18 }  
    19 // General case for set public (exception synchronisation (categories are not virtual ones)) 
    20 if ( $conf['newcat_default_status'] == 'private' and $vag['set_private'] == 0  
    21     and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_set_public' ) ) { 
    22   add_event_handler('get_admin_plugin_menu_links', 'VAG_set_public'); 
    23   function VAG_set_public($menu) { 
    24     global $page, $conf; 
    25     if ( isset($page['page']) and $page['page'] != 'site_manager' ) 
    26       $conf['newcat_default_status'] = 'public'; 
    27     return $menu; 
    28   } 
    29 }  
    30 // General case for grant to someone 
    31 // Don't grant on physical categories  
    32 if ( ($vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1) 
    33     and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_grant_to_prepare' ) ) { 
    34                 add_event_handler('get_admin_plugin_menu_links', 'VAG_grant_to_prepare'); 
    35   function VAG_grant_to_prepare($menu) { 
    36     global $conf, $page, $vag; 
    37     if ( !isset($page['page']) or $page['page'] == 'site_manager' ) return false; # Not Virtual 
    38     list($max_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE . ';')); 
    39     $vag['lastcat before'] == $max_id; 
    40     list($max_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.IMAGES_TABLE . ';')); 
    41     $vag['lastimg before'] == $max_id; 
    42     add_event_handler('loc_end_admin', 'VAG_grant_to_somebody'); 
    43     return $menu; 
    44   } 
    45   if ( !function_exists( 'VAG_grant_to_somebody' ) ) { 
    46     function VAG_grant_to_somebody() { 
    47       global $conf, $vag, $user; 
    48       if ( empty($vag['lastcat before']) ) $vag['lastcat before'] = 0; 
    49       if ( empty($vag['lastimg before']) ) $vag['lastimg before'] = 0; 
    50       list($new_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE 
    51       . ' WHERE id > ' . $vag['lastcat before'] . ' AND site_id IS NULL;')); 
    52       if ( empty($newid) ) return false; 
    53       if ( $vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1 ) { 
    54         if ( $vag['grant_to_creator'] == 1 ) $insert[] = array('user_id' => $user['id'], 'cat_id' => $newid); 
    55         if ( $user['id'] != $conf['webmaster_id'] and $vag['grant_to_webmaster'] == 1 ) 
    56           $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $newid); 
     7// Internal case  
     8if ( defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_internal_add_case' ) ) { 
     9                add_event_handler('invalidate_user_cache', 'VAG_internal_add_case', 21 ); 
     10  function VAG_internal_add_case($full) { 
     11    if ( !defined('PHOTOS_ADD_BASE_URL') ) return false; # Nothing else to do 
     12    global $conf, $user, $page, $category_id, $image_ids, $category_name; 
     13    load_language('plugin.lang', VAG_PATH); 
     14    $vag = & $conf['virtual_AutoGrant']; 
     15      # Note:  don't change it if existing 
     16    if ( 'new' == $_POST['category_type'] ) { 
     17      if ( $vag['set_private'] == 1 ) set_cat_status(array($category_id), 'private'); 
     18        else set_cat_status(array($category_id), 'public'); 
     19      if ( $vag['grant_to_creator'] == 1 ) $insert[] = array('user_id' => $user['id'], 'cat_id' => $category_id); 
     20      if ( $user['id'] != $conf['webmaster_id'] and $vag['grant_to_webmaster'] == 1 ) 
     21        $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $category_id); 
     22      if ( $vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1 and $vag['set_private'] == 1 ) 
    5723        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert); 
    58       } 
    59       // Who can see 
    60       if ( $vag['set_who_can_see'] == 0 ) return false; 
    61       if ( is_webmaster() and $vag['webmaster_set_who_can_see'] == 1) return false; 
    62       // New image_ids 
    63       $img_ids = array_from_query('SELECT id FROM ' . IMAGES_TABLE . ' WHERE id > ' . $vag['lastimg before'] . ';', 'id'); 
    64       if (count($img_ids) == 0) return false; 
    65       // New image_ids which are associated to a public category at least 
    66       if ($vag['ignore_who_can_see_on_private'] == 1) 
    67         $img_ids = array_from_query('SELECT image_id FROM ' . IMAGE_CATEGORY_TABLE  
    68             . ' WHERE category_id IN (SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE status = \'public\')' 
    69             . ' AND image_id IN ('.implode(',', $img_ids).');'); 
     24      array_push( $page['infos'], sprintf( l10n('You have got a private access to %s'), '<em>'.$category_name.'</em>') ); 
     25    } 
     26    // Who can see New image_ids 
     27    if (count($image_ids) == 0) return true; 
     28    if ( $vag['set_who_can_see'] == 0 ) return true; 
     29    if ( is_webmaster() and $vag['webmaster_set_who_can_see'] == 1) return true; 
     30    // New image_ids which are associated to a public category at least 
     31    if ($vag['ignore_who_can_see_on_private'] == 1) 
     32      $image_ids = array_from_query('SELECT image_id FROM ' . IMAGE_CATEGORY_TABLE  
     33          . ' WHERE category_id IN (SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE status = \'public\')' 
     34          . ' AND image_id IN ('.implode(',', $image_ids).');'); 
     35    if (count($image_ids) > 0) {  
    7036      $r = pwg_query('UPDATE '.IMAGES_TABLE.' SET level = ' . $user['level'] . ' WHERE level < '. $user['level']  
    71             . ' AND id IN ('.implode(',', $img_ids).');'); 
     37            . ' AND id IN ('.implode(',', $image_ids).');'); 
     38      array_push( $page['infos'],  
     39        l10n_dec( 'Virtual AutoGrant has forced "Who can see" on %d image',  
     40                  'Virtual AutoGrant has forced "Who can see" on %d images',  
     41                  pwg_db_changes($r) ) . ' - ' . 
     42        sprintf( l10n('Privacy level set to "%s"'), l10n( sprintf('Level %d', $user['level']) ) ) 
     43        ); 
    7244    } 
     45    return true; 
    7346  } 
    7447}  
    7548 
    7649// API cases : Just do it    
    77 if ( !function_exists( 'VAG_set_private_by_API' ) ) { 
    78         add_event_handler('invalidate_user_cache', 'VAG_set_private_by_API', 20); 
     50if ( !function_exists( 'VAG_add_case_by_API' ) ) { 
     51        add_event_handler('invalidate_user_cache', 'VAG_add_case_by_API', 22 ); 
    7952 
    80         function  VAG_set_private_by_API($full) { 
     53        function  VAG_add_case_by_API($full) { 
    8154    if ( !function_exists( 'ws_categories_add' ) ) return false; // That isn't an API request 
    8255          global $user, $conf; 
     
    9467        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert); 
    9568      } 
    96       $vag['lastcat before'] = $inserted_id; # Admin Photos Add does not need to redo the job 
    9769    } 
    9870    // "Who can see" management ( only for API, Synchro or old HTTP management on gallery side are ignored ) 
     
    129101                add_event_handler('get_admin_plugin_menu_links', 'VAG_admin_menu'); 
    130102    function VAG_admin_menu($menu) { 
     103        global $conf; 
    131104        array_push($menu, array( 
    132105                'NAME' => 'Virtual AutoGrant', 
Note: See TracChangeset for help on using the changeset viewer.