Changeset 4263


Ignore:
Timestamp:
11/14/09 00:45:42 (10 years ago)
Author:
LucMorizur
Message:

[Event Cats] Continue duplication management

Location:
extensions/event_cats
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/duplication.inc.php

    r4247 r4263  
    11<?php 
    2  
    3 $t = read_ec_conf('reg_display'); 
    4 if ($t == '0') $reg_display = array('0', ''); 
    5 else $reg_display = explode(';', $t); 
    6  
    7 $template->assign('reg_display', $reg_display); 
    8 $template->assign('ec_conf', $ec_conf); 
    92 
    103 
    114 
    12  
    13  
    14  
    15 // A lot of below code has simply been copied-pasted from file cat_perm.php . 
    16 // Many thanks to people who wrote it ! 
    17  
    18 // +-----------------------------------------------------------------------+ 
    19 // |                          form construction                            | 
    20 // +-----------------------------------------------------------------------+ 
    21  
    22 // groups denied are the groups not granted. So we need to find all groups 
    23 // minus groups granted to find groups denied. 
    24  
    25 $groups = array(); 
    26  
    27 $query = ' 
    28 SELECT id, name 
    29   FROM '.GROUPS_TABLE.' 
    30   ORDER BY name ASC 
    31 ;'; 
    32 $groups = simple_hash_from_query($query, 'id', 'name'); 
    33 $template->assign('all_groups', $groups); 
    34  
    35 // groups granted to access the category 
    36 $query = " 
    37 SELECT `arg1` 
    38   FROM ".EVNTCATS_TABLE." 
    39   WHERE `code` IS NULL 
    40     AND `arg1` IS NOT NULL 
    41 ;"; 
    42 $group_granted_ids = array_from_query($query, 'arg1'); 
    43 $group_granted_ids = order_by_name($group_granted_ids, $groups); 
    44 $template->assign('group_granted_ids', $group_granted_ids); 
    45  
    46  
    47 // groups denied 
    48 $template->assign('group_denied_ids', 
    49     order_by_name(array_diff(array_keys($groups), $group_granted_ids), $groups) 
    50   ); 
    51  
    52 // users... 
    53 $users = array(); 
    54  
    55 $query = " 
    56 SELECT ".$conf['user_fields']['id']." AS id, 
    57        ".$conf['user_fields']['username']." AS username 
    58   FROM ".USERS_TABLE." 
    59 ;"; 
    60 $users = simple_hash_from_query($query, 'id', 'username'); 
    61 $template->assign('all_users', $users); 
    62  
    63  
    64 $query = " 
    65 SELECT `arg2` 
    66   FROM ".EVNTCATS_TABLE." 
    67   WHERE `code` IS NULL 
    68     AND `arg2` IS NOT NULL 
    69 ;"; 
    70 $user_granted_direct_ids = array_from_query($query, 'arg2'); 
    71 $user_granted_direct_ids = order_by_name($user_granted_direct_ids, $users); 
    72 $template->assign('user_granted_direct_ids', $user_granted_direct_ids); 
    73  
    74  
    75  
    76 $user_granted_indirect_ids = array(); 
    77 if (count($group_granted_ids) > 0) 
    78 { 
    79   $granted_groups = array(); 
    80  
    81   $query = " 
    82 SELECT user_id, group_id 
    83   FROM ".USER_GROUP_TABLE." 
    84   WHERE group_id IN (".implode(',', $group_granted_ids).")  
    85 "; 
    86   $result = pwg_query($query); 
    87   while ($row = mysql_fetch_array($result)) 
    88   { 
    89     if (!isset($granted_groups[$row['group_id']])) 
    90     { 
    91       $granted_groups[$row['group_id']] = array(); 
    92     } 
    93     array_push($granted_groups[$row['group_id']], $row['user_id']); 
    94   } 
    95  
    96   $user_granted_by_group_ids = array(); 
    97  
    98   foreach ($granted_groups as $group_users) 
    99   { 
    100     $user_granted_by_group_ids = array_merge($user_granted_by_group_ids, 
    101                                              $group_users); 
    102   } 
    103   $user_granted_by_group_ids = array_unique($user_granted_by_group_ids); 
    104    
    105    
    106   $user_granted_indirect_ids = array_diff($user_granted_by_group_ids, 
    107                                           $user_granted_direct_ids); 
    108   $user_granted_indirect_ids =  
    109     order_by_name($user_granted_indirect_ids, $users);   
    110   foreach ($user_granted_indirect_ids as $user_id) 
    111   { 
    112     foreach ($granted_groups as $group_id => $group_users) 
    113     { 
    114       if (in_array($user_id, $group_users)) 
    115       { 
    116         $template->append( 
    117           'user_granted_indirects', 
    118           array( 
    119             'USER'=>$users[$user_id], 
    120             'GROUP'=>$groups[$group_id] 
    121             ) 
    122           ); 
    123         break; 
    124       } 
    125     } 
    126   } 
    127 } 
    128  
    129 $user_denied_ids = array_diff(array_keys($users), 
    130                               $user_granted_indirect_ids, 
    131                               $user_granted_direct_ids); 
    132 $user_denied_ids = order_by_name($user_denied_ids, $users); 
    133 $template->assign('user_denied_ids', $user_denied_ids); 
     5build_dup_arrays(true); 
    1346 
    1357 
  • extensions/event_cats/admin/template/autolog_new.js

    r4219 r4263  
    511511   && ec_old_new_psd_text != '' 
    512512   && ec_selected_user == 'ec_sel_user_new' 
    513   ) { 
    514     de('ec_in_up_pwd_warn1').innerHTML = ec_JS_message['ec_new_pwd_gen1']; 
    515     de('ec_in_up_pwd_warn2').innerHTML = ec_JS_message['ec_new_pwd_gen2']; 
    516   } 
    517   else { 
    518     de('ec_in_up_pwd_warn1').innerHTML = ''; 
    519     de('ec_in_up_pwd_warn2').innerHTML = ''; 
    520   } 
     513  ) de('ec_in_up_pwd_warn').innerHTML = ec_JS_message['ec_new_pwd_gen']; 
     514  else de('ec_in_up_pwd_warn').innerHTML = ''; 
    521515} 
    522516 
     
    701695  de('ec_in_up_grp_txt_id').value                 = ''; 
    702696  de('ec_in_up_newgroup_id').checked              = ''; 
    703   de('ec_in_up_pwd_warn1').innerHTML              = ''; 
    704   de('ec_in_up_pwd_warn2').innerHTML              = ''; 
     697  de('ec_in_up_pwd_warn').innerHTML               = ''; 
    705698  de('ec_in_up_aps_id').selectedIndex             = '-1'; 
    706699  de('ec_in_up_cats_id').selectedIndex            = '-1'; 
  • extensions/event_cats/admin/template/autolog_new.tpl

    r4228 r4263  
    126126        {'ec_up_code_lbl_user'|@translate}<br> 
    127127        <br> 
    128         <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn1">&nbsp;</span><br> 
    129         <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn2">&nbsp;</span> 
     128        <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn">&nbsp;</span><br> 
    130129      </td> 
    131130      <td> 
     
    276275  ec_JS_message['ec_act_cat_miss']        = "{'ec_act_cat_miss'|@translate|@escape:javascript}"; 
    277276  ec_JS_message['ec_act_img_miss']        = "{'ec_act_img_miss'|@translate|@escape:javascript}"; 
    278   ec_JS_message['ec_new_pwd_gen1']        = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}"; 
    279   ec_JS_message['ec_new_pwd_gen2']        = "{'ec_new_pwd_gen2'|@translate|@escape:javascript}"; 
     277  ec_JS_message['ec_new_pwd_gen']         = "{'ec_new_pwd_gen'|@translate|@escape:javascript}"; 
    280278  ec_JS_message['ec_act_entry_miss']      = "{'ec_act_entry_miss'|@translate|@escape:javascript}"; 
    281279  ec_JS_message['ec_confirm_force']       = "{'ec_confirm_force'|@translate|@escape:javascript}"; 
  • extensions/event_cats/admin/template/config.tpl

    r4157 r4263  
    1313  ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}"; 
    1414  ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}"; 
    15   ec_JS_message['ec_new_pwd_gen1']       = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}"; 
     15  ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}"; 
    1616  ec_JS_message['ec_up_code_lbl_home']  = "{'ec_up_code_lbl_home'|@translate}"; 
    1717  ec_init(); 
  • extensions/event_cats/admin/template/duplication.tpl

    r4247 r4263  
    66<p>Bientôt disponible :-] !</p> 
    77 
    8 <!-- Aknowledgement ------------------------------------------------------ 
    9 A lot of below code has simply been copied-pasted from file cat_perm.tpl . 
    10 Many thanks to people who wrote it ! 
    11 -------------------------------------------------------------------------> 
     8<!-- Aknowledgement ---------------------------------------------------------- 
     9| A lot of below code has simply been copied-pasted from file cat_perm.tpl . | 
     10| Many thanks to people who wrote it !                                       | 
     11-----------------------------------------------------------------------------> 
    1212 
    1313{* <!-- Duplication configuration parameters --> *} 
     
    1818      <tr> 
    1919        <td> 
    20           <span style = "font-weight:bold;">{'ec_duplication_allowance'|@translate}</span> 
     20          <span style = "font-weight:bold;">{'ec_duplication_allowance'|@translate}&nbsp;&nbsp;</span> 
    2121        </td> 
    2222        <td> 
     
    2828            <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_group_id" /> 
    2929            {'ec_dup_allowance_group'|@translate} 
    30           </label><br> 
     30          </label><br> {* <!-- 
     31          <label for = "ec_dup_conf_gen_id"> 
     32            <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_gen_id" /> 
     33            {'ec_dup_allowance_gen'|@translate} 
     34          </label><br> --> *} 
    3135          <label for = "ec_dup_conf_all_id"> 
    3236            <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_all_id" /> 
    3337            {'ec_dup_allowance_all'|@translate} 
    34           </label><br> 
    35         </td> 
    36         <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td> 
    37         <td> 
    38           <span style = "font-weight:bold;">{'ec_duplication_display'|@translate}</span> 
    39         </td> 
    40         <td> 
    41           <label for = "ec_dup_disp_normal_id"> 
    42             <input type = "radio" name = "ec_dup_disp" id = "ec_dup_disp_normal_id" /> 
    43             {'ec_dup_display_normal'|@translate}{if $reg_display.0 != '0'} ("{$reg_display.1}"){/if} 
    44           </label><br> 
    45           <label for = "ec_dup_disp_dup_id"> 
    46             <input type = "radio" name = "ec_dup_disp" id = "ec_dup_disp_dup_id" /> 
    47             {'ec_dup_display_dup'|@translate} ("{'ec_duplication'|@translate}") 
    48           </label><br> 
     38          </label> 
    4939        </td> 
    5040      </tr> 
    5141    </table> 
    52     <input class = "submit" type = "submit" name = "ec_duplic_conf_submit" value = "{'ec_dup_conf_submit_lbl'|@translate}" /> 
     42    <input class = "submit" type = "submit" name = "ec_duplic_conf_submit" value = "{'ec_dup_conf_sbmt_lbl'|@translate}" /> 
    5343  </fieldset> 
    5444</form> 
    5545 
    56 {* <!-- Duplication settings by groups / user ids --> *} 
     46{* <!-- Duplication settings by groups / types / user ids --> *} 
    5747<form action = "" method = "post" name = "ec_duplic_set" id="categoryPermissions"> 
    5848 
     
    6050 
    6151  <fieldset> 
    62     <legend>{'Permission granted'|@translate}</legend> 
     52    <legend>{'ec_duplic_ok'|@translate}</legend> 
    6353    <ul> 
    6454      {foreach from=$group_granted_ids item=id} 
     
    6656      {/foreach} 
    6757    </ul> 
    68     <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'Deny selected groups'|@translate}" /> 
     58    <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'ec_dup_grp_ok_sbmt_lbl'|@translate}" /> 
    6959  </fieldset> 
    7060 
    7161  <fieldset> 
    72     <legend>{'Permission denied'|@translate}</legend> 
     62    <legend>{'ec_duplic_nok'|@translate}</legend> 
    7363    <ul> 
    7464      {foreach from=$group_denied_ids item=id} 
     
    7666      {/foreach} 
    7767    </ul> 
    78     <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'Grant selected groups'|@translate}" /> 
     68    <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'ec_dup_grp_nok_sbmt_lbl'|@translate}" /> 
     69  </fieldset> 
     70 
     71  <h4>{'ec_dup_types'|@translate}</h4> 
     72 
     73  <fieldset> 
     74    <legend>{'ec_duplic_ok'|@translate}</legend> 
     75    <ul> 
     76      <li><label><input type = "checkbox" name = "ec_dup_types_generic_ok" value = "ec_dup_types_generic_ok_id" /> {'user_status_generic'|@translate}</label></li> 
     77      <br /> 
     78      <li><label><input type = "checkbox" name = "ec_dup_types_contacts_ok" value = "ec_dup_types_contacts_ok_id" /> {'Level 1'|@translate}</label></li> 
     79      <li><label><input type = "checkbox" name = "ec_dup_types_friends_ok" value = "ec_dup_types_friends_ok_id" /> {'Level 2'|@translate}</label></li> 
     80      <li><label><input type = "checkbox" name = "ec_dup_types_family_ok" value = "ec_dup_types_family_ok_id" /> {'Level 4'|@translate}</label></li> 
     81    </ul> 
     82    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_typ_sbmt_lbl'|@translate}" /> 
    7983  </fieldset> 
    8084 
     
    8286 
    8387  <fieldset> 
    84     <legend>{'Permission granted'|@translate}</legend> 
     88    <legend>{'ec_duplic_ok'|@translate}</legend> 
    8589    <ul> 
    8690      {foreach from=$user_granted_direct_ids item=id} 
     
    8892      {/foreach} 
    8993    </ul> 
    90     <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'Deny selected users'|@translate}" /> 
     94    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_usr_ok_sbmt_lbl'|@translate}" /> 
    9195  </fieldset> 
    9296 
    9397  <fieldset> 
    94     <legend>{'Permission granted thanks to a group'|@translate}</legend> 
     98    <legend>{'ec_duplic_ok_groups'|@translate}</legend> 
    9599    {if isset($user_granted_indirects) } 
    96100    <ul> 
     
    103107 
    104108  <fieldset> 
    105     <legend>{'Permission denied'|@translate}</legend> 
     109    <legend>{'ec_duplic_nok'|@translate}</legend> 
    106110    <ul> 
    107111      {foreach from=$user_denied_ids item=id} 
     
    109113      {/foreach} 
    110114    </ul> 
    111     <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'Grant selected users'|@translate}" /> 
     115    <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'ec_dup_usr_nok_sbmt_lbl'|@translate}" /> 
    112116  </fieldset> 
    113117 
     
    123127  ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}"; 
    124128  ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}"; 
    125   ec_JS_message['ec_new_pwd_gen1']       = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}"; 
     129  ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}"; 
    126130  ec_JS_message['ec_up_code_lbl_home']  = "{'ec_up_code_lbl_home'|@translate}"; 
    127131  ec_init(); 
  • extensions/event_cats/include/ec_conf.inc.php

    r4239 r4263  
    4040    => '10',              // automatically 
    4141                          //  
    42   'reg_display'           // the way the "register" link is displayed, 
    43     => '0',               // together with the original $lang value for this 
    44                           // label 
     42  'duplic_gen'            // whether Generic accounts allow to be duplicated 
     43    => '0',               // 
     44                          //  
     45  'duplic_type'           // the kind of account type (Contacts, Friends, 
     46    => '0',               // Family) allowed to duplicate account 
    4547                          //  
    4648  'howto'                 // whether the small aknowledgement message has 
     
    7880if (!$v) { 
    7981  $ec_conf = array_values($ec_conf_default); 
    80   change_ec_conf('activated', $u); 
     82  change_ec_conf('activated', $u); // writes in the DB 
    8183} 
    8284// now : 
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r4247 r4263  
    3333 
    3434include_once(EVNTCATS_PATH.'include/ec_conf.inc.php'); 
     35 
     36if (!isset($ec_lists)) { 
     37  $ec_lists               = array(); 
     38  $ec_lists['add_pages']  = array(); 
     39  $ec_lists['categories'] = array(); 
     40  $ec_lists['user_ids']   = array(); 
     41  $ec_lists['ec_table']   = array(); 
     42} 
    3543 
    3644// +-----------------------------------------------------------------------+ 
     
    163171 
    164172/* 
     173 * build_ec_addp() 
     174 * builds $ec_lists['add_pages']. 
     175 * 
     176 * @param 
     177 *   (no parameter) 
     178 * @return 
     179 *   (no return value) 
     180 */ 
     181function build_ec_addp() { 
     182  global $ec_lists, $ec_ap_ok; 
     183  if ($ec_ap_ok) { 
     184    $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`"); 
     185    while ($r = mysql_fetch_assoc($res)) { 
     186      $c = (is_in($r['title'], '/user_id=')) ? '/user_id=' : '/group_id='; 
     187      $a = explode($c ,$r['title']); 
     188      $ec_lists['add_pages'][$r['id']] = $a[0]; 
     189    } 
     190  } 
     191} 
     192 
     193/* 
    165194 * build_ec_categories($dsp) 
    166195 * builds $ec_lists['categories']. 
     
    183212 
    184213/* 
     214 * build_ec_userids() 
     215 * builds $ec_lists['user_ids']. 
     216 * 
     217 * @param 
     218 *   (no parameter) 
     219 * @return 
     220 *   (no return value) 
     221 */ 
     222function build_ec_userids() { 
     223  global $ec_lists, $conf; 
     224  $ec_lists['user_ids'] = simple_hash_from_query(" 
     225    SELECT 
     226      ".$conf['user_fields']['id']." AS id, 
     227      ".$conf['user_fields']['username']." AS username 
     228    FROM `".USERS_TABLE."` 
     229    WHERE id > 2;", 
     230    'id', 'username' 
     231  ); 
     232} 
     233 
     234/* 
    185235 * build_ec_table() 
    186236 * builds a table showing the content of the <pwg>_event_cats database table, 
     
    195245function build_ec_table() { 
    196246  global $ec_lists, $ec_ap_ok; 
    197    
    198   $ec_lists['ec_table'] = array(); 
    199247   
    200248  $q = pwg_query(" 
     
    276324  global $ec_ap_ok, $template, $ec_lists, $conf; 
    277325   
    278   $ec_lists = array(); 
    279  
    280326  // Construction of $ec_lists['add_pages'] array var 
    281   $ec_lists['add_pages'] = array(); 
    282   if ($ec_ap_ok) { 
    283     $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`"); 
    284     while ($r = mysql_fetch_assoc($res)) { 
    285       $c = (is_in($r['title'], '/user_id=')) ? '/user_id=' : '/group_id='; 
    286       $a = explode($c ,$r['title']); 
    287       $ec_lists['add_pages'][$r['id']] = $a[0]; 
    288     } 
    289   } 
     327  build_ec_addp(); 
    290328   
    291329  // Construction of $ec_lists['categories'] array var 
     
    293331   
    294332  // Construction of $ec_lists['user_ids'] array var 
    295   $ec_lists['user_ids'] = array(); 
    296   $q = pwg_query(" 
    297     SELECT 
    298       ".$conf['user_fields']['id']." AS id, 
    299       ".$conf['user_fields']['username']." AS username 
    300     FROM `".USERS_TABLE."` 
    301     WHERE id > 2 
    302   "); 
    303   while ($r = mysql_fetch_assoc($q)) 
    304    $ec_lists['user_ids'][$r['id']] = $r['username']; 
     333  build_ec_userids(); 
    305334   
    306335  // Construction of $ec_lists['ec_table'] array var 
     
    308337} 
    309338 
     339// +-----------------------------------------------------------------------+ 
     340// | Duplication analysis functions                                        | 
     341// +-----------------------------------------------------------------------+ 
     342 
     343/* 
     344 * build_dup_arrays($append_tpl = false) 
     345 * builds arrays telling which accounts are allowed to display a duplicate 
     346 * account link. Returns an array of all the user ids allowed to duplicate. 
     347 * 
     348 * @param 
     349 *   $append_tpl : tells if $template must be appended with built arrays 
     350 * @return 
     351 *   (no return value) 
     352 */ 
     353function build_dup_arrays($append_tpl = false) { 
     354  global $template, $ec_lists, $conf, $ec_debug; 
     355   
     356  if (count($ec_lists['user_ids']) == 0) build_ec_userids(); 
     357   
     358  // A lot of below code has simply been copied from file cat_perm.php . 
     359  // Many thanks to people who wrote it ! 
     360   
     361  $groups = simple_hash_from_query(" 
     362    SELECT `id`, `name` 
     363      FROM `".GROUPS_TABLE."` 
     364      ORDER BY `name` ASC; 
     365    ", 
     366    'id', 'name' 
     367  ); 
     368   
     369  // groups granted to duplication 
     370  $group_granted_ids = order_by_name( 
     371    array_from_query(" 
     372      SELECT `arg2` 
     373        FROM ".EVNTCATS_TABLE." 
     374        WHERE `code` IS NULL 
     375          AND `arg1` = '1' 
     376          AND `arg2` IS NOT NULL 
     377      ;", 
     378      'arg2' 
     379    ), 
     380    $groups 
     381  ); 
     382   
     383  // users directly granted to duplication 
     384  $users_granted_direct_ids = order_by_name( 
     385    array_from_query(" 
     386      SELECT `arg2` 
     387        FROM ".EVNTCATS_TABLE." 
     388        WHERE `code` IS NULL 
     389          AND `arg1` = '2' 
     390          AND `arg2` IS NOT NULL 
     391      ;", 
     392      'arg2' 
     393    ), 
     394    $ec_lists['user_ids'] 
     395  ); 
     396   
     397  // Calculate users granted to duplication thanks to belonging to a 
     398  // certain group (in groups, level (friends, family, contacts), 
     399  // or user status (generic)) 
     400  $user_granted_ids = array(); 
     401 
     402  $users_granted_thks_gen_ids = array(); 
     403  if (read_ec_conf('duplic_gen') != '0') { 
     404    $users_granted_thks_gen_ids = order_by_name( 
     405      array_diff( 
     406        array_from_query(" 
     407          SELECT `user_id` 
     408          FROM `".USER_INFOS_TABLE."` 
     409          WHERE `status` = 'generic';", 
     410          'user_id' 
     411        ), 
     412        $users_granted_direct_ids 
     413      ), 
     414      $ec_lists['user_ids'] 
     415    ); 
     416    foreach ($users_granted_thks_gen_ids as $user_id) 
     417     $user_granted_ids[$user_id] = l10n('user_status_generic'); 
     418  } global $ec_debug; $ec_debug['1'] = $user_granted_ids; 
     419 
     420  $users_granted_thks_types_ids = array(); 
     421  $c = intval(read_ec_conf('duplic_type')); 
     422  if ($c != 0) { 
     423    $t = array(); 
     424    if (($c & 1) != 0) $t[] = '1'; 
     425    if (($c & 2) != 0) $t[] = '2'; 
     426    if (($c & 4) != 0) $t[] = '4'; 
     427    if (count($t) > 0) { 
     428      $types = array( 
     429        '1' => l10n('Level 1'), 
     430        '2' => l10n('Level 2'), 
     431        '4' => l10n('Level 4'), 
     432      ); 
     433      $user_granted_from_type = array(); 
     434      $result = pwg_query(" 
     435        SELECT `user_id`, `level` 
     436        FROM `".USER_INFOS_TABLE."` 
     437        WHERE `level` IN (".implode(',', $t)."); 
     438      "); 
     439      while ($row = mysql_fetch_array($result)) { 
     440        if (!isset($user_granted_from_type[$row['level']])) { 
     441          $user_granted_from_type[$row['level']] = array(); 
     442        } 
     443        $user_granted_from_type[$row['level']][] = $row['user_id']; 
     444      } 
     445      $user_granted_by_type_ids = array(); 
     446      foreach ($user_granted_from_type as $type_users) 
     447       $user_granted_by_type_ids = array_merge( 
     448        $user_granted_by_type_ids, 
     449        $type_users 
     450       ); 
     451      $users_granted_thks_types_ids = order_by_name( 
     452        array_diff( 
     453          array_unique($user_granted_by_type_ids), 
     454          $users_granted_direct_ids 
     455        ), 
     456        $ec_lists['user_ids'] 
     457      ); 
     458      foreach ($users_granted_thks_types_ids as $user_id) 
     459       foreach ($user_granted_from_type as $type_id => $type_users) { 
     460        if (in_array($user_id, $type_users)) { 
     461          $user_granted_ids[$user_id]= $types[$type_id]; 
     462          break; 
     463        } 
     464       } 
     465    } 
     466  } $ec_debug['2'] = $user_granted_ids; 
     467 
     468  $users_granted_thks_groups_ids = array(); 
     469  if (count($group_granted_ids) > 0) { 
     470    $granted_groups = array(); 
     471 
     472    $result = pwg_query(" 
     473      SELECT `user_id`, `group_id` 
     474      FROM `".USER_GROUP_TABLE."` 
     475      WHERE `group_id` IN (".implode(',', $group_granted_ids)."); 
     476    "); 
     477    while ($row = mysql_fetch_array($result)) { 
     478      if (!isset($granted_groups[$row['group_id']])) { 
     479        $granted_groups[$row['group_id']] = array(); 
     480      } 
     481      $granted_groups[$row['group_id']][] = $row['user_id']; 
     482    } 
     483     
     484    $user_granted_by_group_ids = array(); 
     485     
     486    foreach ($granted_groups as $group_users) 
     487     $user_granted_by_group_ids = array_merge( 
     488      $user_granted_by_group_ids, 
     489      $group_users 
     490     ); 
     491    $users_granted_thks_groups_ids = order_by_name( 
     492      array_diff( 
     493        array_unique($user_granted_by_group_ids), 
     494        $users_granted_direct_ids 
     495      ), 
     496      $ec_lists['user_ids'] 
     497    ); 
     498    foreach ($users_granted_thks_groups_ids as $user_id) 
     499     foreach ($granted_groups as $group_id => $group_users) 
     500      if (in_array($user_id, $group_users)) { 
     501        $user_granted_ids[$user_id]= $groups[$group_id]; 
     502        break; 
     503      } 
     504     
     505  } $ec_debug['3'] = $user_granted_ids; 
     506 
     507  if ($append_tpl) { 
     508    $user_denied_ids = order_by_name( 
     509      array_diff( 
     510        array_keys($ec_lists['user_ids']), 
     511        $users_granted_thks_gen_ids, 
     512        $users_granted_thks_types_ids, 
     513        $users_granted_thks_groups_ids, 
     514        $users_granted_direct_ids 
     515      ), 
     516      $ec_lists['user_ids'] 
     517    ); 
     518     
     519    foreach ($user_granted_ids as $u => $g) $template->append( 
     520      'user_granted_indirects', 
     521      array( 
     522        'USER'  => $ec_lists['user_ids'][$u], 
     523        'GROUP' => $g 
     524      ) 
     525    ); 
     526     
     527    $ec_debug['4'] = $user_granted_ids; 
     528    $template->assign('all_groups', $groups); 
     529    $template->assign('group_granted_ids', $group_granted_ids); 
     530    $template->assign('group_denied_ids',order_by_name( 
     531      array_diff(array_keys($groups), $group_granted_ids), $groups 
     532    )); 
     533    $template->assign('all_users', $ec_lists['user_ids']); 
     534    $template->assign('users_granted_direct_ids', $users_granted_direct_ids); 
     535    $template->assign('user_denied_ids', $user_denied_ids); 
     536  } 
     537   $user_granted_ids = array_merge( 
     538    $user_granted_ids, 
     539    $users_granted_direct_ids 
     540   ); 
     541  return $user_granted_ids; 
     542} 
     543 
     544/* 
     545 * dup_allowed($user_id) 
     546 * returns true if the user_id is allowed to display a duplicate link 
     547 * 
     548 * @param 
     549 *   $user_id : the user_id 
     550 * @return 
     551 *   true if the user_id is allowed to display a duplicate link 
     552 */ 
     553function dup_allowed($user_id) { 
     554  return true; 
     555} 
     556 
    310557?> 
  • extensions/event_cats/language/fr_FR/plugin.lang.php

    r4233 r4263  
    7575$lang['ec_duplication']           = 'Dupliquer'; 
    7676$lang['ec_duplication_config']    = 'Configuration'; 
    77 $lang['ec_duplication_allowance'] = 'Autorisation de la duplication :'; 
    78 $lang['ec_dup_allowance_none']    = 'Aucun compte'; 
     77$lang['ec_dup_types']             = 'Types d\'utilisateurs'; 
     78$lang['ec_dup_types_generic']     = 'Génériques'; 
     79$lang['ec_dup_types_contacts']    = 'Contacts'; 
     80$lang['ec_dup_types_friends']     = 'Amis'; 
     81$lang['ec_dup_types_family']      = 'Famille'; 
     82$lang['ec_duplication_allowance'] = 'Autorisation de la duplication'; 
     83$lang['ec_dup_allowance_none']    = 'Aucun compte';                       /* 
     84$lang['ec_dup_allowance_gen']     = 'Tous les comptes génériques';        */ 
    7985$lang['ec_dup_allowance_group']   = 'Sélection par groupe'; 
    80 $lang['ec_dup_allowance_all']     = 'Tous les comptes'; 
    81 $lang['ec_duplication_display']   = 'Affichage du lien de duplication :'; 
     86$lang['ec_dup_allowance_all']     = 'Tous les comptes';                   /* 
     87$lang['ec_duplication_display']   = 'Affichage du lien de duplication'; 
    8288$lang['ec_dup_display_normal']    = 'Normal'; 
    83 $lang['ec_dup_display_dup']       = 'Modifié'; 
    84 $lang['ec_dup_conf_submit_lbl']   = 'Sauvegarder la configuration de la duplication'; 
     89$lang['ec_dup_display_dup']       = 'Modifié';                            */ 
     90$lang['ec_duplic_ok']             = 'Duplication autorisée'; 
     91$lang['ec_duplic_ok_groups']      = 'Duplication autorisée grâce à l\'appartenance aux groupes et aux types'; 
     92$lang['ec_duplic_nok']            = 'Duplication refusée'; 
     93$lang['ec_dup_grp_ok_sbmt_lbl']   = 'Interdire la duplication aux groupes sélectionnés'; 
     94$lang['ec_dup_grp_nok_sbmt_lbl']  = 'Autoriser la duplication aux groupes sélectionnés'; 
     95$lang['ec_dup_usr_ok_sbmt_lbl']   = 'Interdire la duplication aux utilisateurs sélectionnés'; 
     96$lang['ec_dup_usr_nok_sbmt_lbl']  = 'Autoriser la duplication aux utilisateurs sélectionnés'; 
     97$lang['ec_dup_typ_sbmt_lbl']      = 'Sauvegarder'; 
     98$lang['ec_dup_conf_sbmt_lbl']     = 'Sauvegarder la configuration de la duplication'; 
    8599// JS checks 
    86100$lang['ec_confirm_test']          = "Vraiment tester le code sélectionné ?\n\rCela terminera votre session d'administration."; 
     
    93107$lang['ec_act_cat_miss']          = 'Catégorie ?'; 
    94108$lang['ec_act_img_miss']          = 'L\'identifiant d\'une image doit être un nombre.'; 
    95 $lang['ec_new_pwd_gen1']          = 'Pensez à NOTER'; 
    96 $lang['ec_new_pwd_gen2']          = 'le mot de passe !'; 
     109$lang['ec_new_pwd_gen']           = 'Pensez à NOTER<br>le mot de passe !'; 
    97110$lang['ec_submit_code_miss']      = 'Vous devez fournir un code.'; 
    98111$lang['ec_submit_code_bad']       = 'Un code doit comprendre entre 4 et 32 caractères inclus dans [a-zA-Z0-9_-].'; 
  • extensions/event_cats/main.inc.php

    r4247 r4263  
    4848$ec_ap_ok = defined('AP_DIR'); 
    4949 
    50 if (!isset($ec_lists)) $ec_lists = array(); 
    51  
    5250include_once(EVNTCATS_PATH.'include/evntcats_main_funcs.inc.php'); 
    5351 
     
    265263  global $lang, $template; 
    266264   
    267   if (is_admin() and read_ec_conf('reg_display') == '0') 
    268    change_ec_conf('reg_display', '1;'.$lang['Register']); 
    269265  if (!is_admin() and !is_a_guest()) { 
    270266    $template->assign( 'U_REGISTER', get_root_url().'register.php'); 
    271     $lang['Create a new account'] = l10n('Duplicate account'); 
    272     $lang['Register'] = l10n('Duplicate'); 
     267    if (isset($lang['Duplicate account'])) 
     268     $lang['Create a new account'] = l10n('Duplicate account'); 
     269    if (isset($lang['Register'])) 
     270     $lang['Register'] = l10n('Duplicate'); 
    273271  } 
    274272} 
Note: See TracChangeset for help on using the changeset viewer.