Ignore:
Timestamp:
Nov 16, 2009, 1:26:06 AM (14 years ago)
Author:
LucMorizur
Message:

[Event Cats] Duplication management, add table and begin $_POST analysis

Location:
extensions/event_cats/admin
Files:
3 edited

Legend:

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

    r4263 r4276  
    11<?php
     2
     3
     4
     5
     6
     7
     8/* */
     9
     10
     11
     12
     13
    214
    315
     
    1628
    1729
    18 /* */
    19 
    20 
    2130?>
  • extensions/event_cats/admin/evntcats_admin.php

    r4247 r4276  
    7171if (!isset($ec_debug)) $ec_debug = array();
    7272
     73// +-----------------------------------------------------------------------+
     74// | $_POST analysis, to determine which tab to display (tabsheet prep.)
     75// +-----------------------------------------------------------------------+
     76
     77// If needed, stores in the DB the new value of the number of digits of
     78// automatically created codes
    7379if (
    7480  isset($_POST['ec_in_up_auto_code_length']) and
     
    7682) change_ec_conf('auto_code_dg_nb', $_POST['ec_in_up_auto_code_length']);
    7783
     84
     85// If needed, stores in the DB that acknowledgement message has been displayed
    7886if ($ec_howto = (read_ec_conf('howto') == '0')) change_ec_conf('howto', '1');
    7987
    8088build_ec_lists(); // in evntcats_main_funcs.php
    8189
    82 // +-----------------------------------------------------------------------+
    83 // |                            Tabsheet
    84 // +-----------------------------------------------------------------------+
    85 
     90// If no entry exist, default page is 'autolog_new'.
    8691$page['tab'] = (!($ec_exist_entries = (mysql_num_rows(pwg_query("
    87   SELECT * FROM `".EVNTCATS_TABLE."`
    88   WHERE `code` IS NOT NULL
     92  SELECT * FROM `".EVNTCATS_AUTOLOG_TABLE."`
     93  WHERE `code` IS NOT NULL ;
    8994")) != 0))) ? 'autolog_new' : 'autolog_entries';
    9095
    91 // Rajouter un test pour que si $ec_exist_entries est faux, mais qu'il y a
    92 // quand même des entrées dans la table (donc pour gérer la duplication de
    93 // compte), l'onglet sélectionné par défaut soit celui de la gestion de la
    94 // duplication de compte.
     96$ec_exist_duplic = ((mysql_num_rows(pwg_query("
     97    SELECT * FROM `".EVNTCATS_DUPLIC_TABLE."` ;
     98  ")) != 0) or
     99  (read_ec_conf('duplic_gen') != 0) or
     100  (read_ec_conf('duplic_type') != 0)
     101);
     102
     103// If no entry exist, but some duplication management entries exist, default tab is 'duplication'.
     104if (!$ec_exist_entries and $ec_exist_duplic) $page['tab'] = 'duplication';
     105
     106
     107/*
     108
     109if (isset($_POST[''])) {
     110}
     111
     112
     113if (isset($_POST['ec_duplic_conf_submit'])) {
     114}
     115
     116if (isset($_POST['deny_groups_submit'])) {
     117}
     118
     119if (isset($_POST['grant_groups_submit'])) {
     120}
     121
     122if (isset($_POST['deny_types_submit'])) {
     123}
     124
     125if (isset($_POST['grant_types_submit'])) {
     126}
     127
     128if (isset($_POST['deny_users_submit'])) {
     129}
     130
     131if (isset($_POST['grant_users_submit'])) {
     132}
     133
     134
     135
     136
     137*/
     138
     139
     140
     141
    95142
    96143if (isset($_POST['ec_act1'])) {
     
    140187  if (isset($_GET['tab'])) switch ($_GET['tab']) {
    141188    case 'autolog_modif':
     189      if ($ec_exist_entries) $page['tab'] = $_GET['tab'];
     190    break;
     191    case 'duplication':
     192      if ($ec_exist_duplic) $page['tab'] = $_GET['tab'];
     193    break;
    142194    case 'autolog_new':
    143     case 'duplication':
    144195    case 'config':
    145196      $page['tab'] = $_GET['tab'];
     
    148199}
    149200
     201// +-----------------------------------------------------------------------+
     202// |                            Tabsheet
     203// +-----------------------------------------------------------------------+
     204
    150205$ec_exist_entries = (mysql_num_rows(pwg_query("
    151   SELECT * FROM `".EVNTCATS_TABLE."`
     206  SELECT * FROM `".EVNTCATS_AUTOLOG_TABLE."`
    152207  WHERE `code` IS NOT NULL
    153208")) != 0);
     209
     210$ec_exist_duplic = ((mysql_num_rows(pwg_query("
     211    SELECT * FROM `".EVNTCATS_DUPLIC_TABLE."` ;
     212  ")) != 0) or
     213  (read_ec_conf('duplic_gen') != 0) or
     214  (read_ec_conf('duplic_type') != 0)
     215);
    154216
    155217$tabsheet = new tabsheet();
     
    165227               l10n('ec_tab_autoid_new'),
    166228               $my_base_url.'&amp;tab=autolog_new');
    167 $tabsheet->add('duplication',
     229if ($ec_exist_duplic) $tabsheet->add('duplication',
    168230               l10n('ec_tab_duplication'),
    169231               $my_base_url.'&amp;tab=duplication');
  • extensions/event_cats/admin/template/duplication.tpl

    r4263 r4276  
    1212
    1313{* <!-- Duplication configuration parameters --> *}
    14 <form class = "titrePage" name = "ec_duplic_conf">
     14<form action = "" method = "post" class = "titrePage" name = "ec_duplic_conf">
    1515  <fieldset>
    1616    <legend>{'ec_duplication_config'|@translate}</legend>
     
    2222        <td>
    2323          <label for = "ec_dup_conf_none_id">
    24             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_none_id" />
     24            <input type = "radio" name = "ec_dup_conf[]" value = "none" id = "ec_dup_conf_none_id" />
    2525            {'ec_dup_allowance_none'|@translate}
    2626          </label><br>
    2727          <label for = "ec_dup_conf_group_id">
    28             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_group_id" />
     28            <input type = "radio" name = "ec_dup_conf[]" value = "group" id = "ec_dup_conf_group_id" />
    2929            {'ec_dup_allowance_group'|@translate}
    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> --> *}
     30          </label><br>
    3531          <label for = "ec_dup_conf_all_id">
    36             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_all_id" />
     32            <input type = "radio" name = "ec_dup_conf[]" value = "all" id = "ec_dup_conf_all_id" />
    3733            {'ec_dup_allowance_all'|@translate}
    3834          </label>
     
    4642{* <!-- Duplication settings by groups / types / user ids --> *}
    4743<form action = "" method = "post" name = "ec_duplic_set" id="categoryPermissions">
    48 
     44 
    4945  <h4>{'Groups'|@translate}</h4>
    50 
     46 
    5147  <fieldset>
    5248    <legend>{'ec_duplic_ok'|@translate}</legend>
    5349    <ul>
    54       {foreach from=$group_granted_ids item=id}
     50      {foreach from=$groups_granted_ids item=id}
    5551      <li><label><input type = "checkbox" name = "deny_groups[]" value = "{$id}" /> {$all_groups[$id]}</label></li>
    5652      {/foreach}
     
    5854    <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'ec_dup_grp_ok_sbmt_lbl'|@translate}" />
    5955  </fieldset>
    60 
     56 
    6157  <fieldset>
    6258    <legend>{'ec_duplic_nok'|@translate}</legend>
    6359    <ul>
    64       {foreach from=$group_denied_ids item=id}
     60      {foreach from=$groups_denied_ids item=id}
    6561      <li><label><input type = "checkbox" name = "grant_groups[]" value = "{$id}"> {$all_groups[$id]}</label></li>
    6662      {/foreach}
     
    6864    <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'ec_dup_grp_nok_sbmt_lbl'|@translate}" />
    6965  </fieldset>
    70 
     66 
    7167  <h4>{'ec_dup_types'|@translate}</h4>
    72 
     68 
    7369  <fieldset>
    7470    <legend>{'ec_duplic_ok'|@translate}</legend>
    7571    <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>
     72      {if $ec_gen_granted}
     73      <li><label><input type = "checkbox" name = "deny_generic" {* id = "ec_dup_types_generic_nok_id" *} /> {'user_status_generic'|@translate}</label></li>
    7774      <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>
     75      {/if}
     76      {foreach from=$types_granted_ids item=id}
     77        <li><label><input type = "checkbox" name = "deny_types[]" value = "{$id}" /> {$all_types[$id]}</label></li>
     78      {/foreach}
    8179    </ul>
    82     <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_typ_sbmt_lbl'|@translate}" />
     80    <input class = "submit" type = "submit" name = "deny_types_submit" value = "{'ec_dup_typ_sbmt_nok_lbl'|@translate}" />
    8381  </fieldset>
    84 
     82 
     83  <fieldset>
     84    <legend>{'ec_duplic_nok'|@translate}</legend>
     85    <ul>
     86      {if !$ec_gen_granted}
     87      <li><label><input type = "checkbox" name = "grant_generic" {* id = "ec_dup_types_generic_ok_id" *} /> {'user_status_generic'|@translate}</label></li>
     88      <br />
     89      {/if}
     90      {foreach from=$types_denied_ids item=id}
     91        <li><label><input type = "checkbox" name = "grant_types[]" value = "{$id}" /> {$all_types[$id]}</label></li>
     92      {/foreach}
     93    </ul>
     94    <input class = "submit" type = "submit" name = "grant_types_submit" value = "{'ec_dup_typ_sbmt_ok_lbl'|@translate}" />
     95  </fieldset>
     96 
    8597  <h4>{'Users'|@translate}</h4>
    86 
     98 
    8799  <fieldset>
    88100    <legend>{'ec_duplic_ok'|@translate}</legend>
    89101    <ul>
    90       {foreach from=$user_granted_direct_ids item=id}
     102      {foreach from=$users_granted_direct_ids item=id}
    91103      <li><label><input type = "checkbox" name = "deny_users[]" value = "{$id}" /> {$all_users[$id]}</label></li>
    92104      {/foreach}
     
    94106    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_usr_ok_sbmt_lbl'|@translate}" />
    95107  </fieldset>
    96 
     108 
    97109  <fieldset>
    98110    <legend>{'ec_duplic_ok_groups'|@translate}</legend>
     
    105117    {/if}
    106118  </fieldset>
    107 
     119 
    108120  <fieldset>
    109121    <legend>{'ec_duplic_nok'|@translate}</legend>
    110122    <ul>
    111       {foreach from=$user_denied_ids item=id}
     123      {foreach from=$users_denied_ids item=id}
    112124      <li><label><input type = "checkbox" name = "grant_users[]" value = "{$id}"> {$all_users[$id]}</label></li>
    113125      {/foreach}
     
    115127    <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'ec_dup_usr_nok_sbmt_lbl'|@translate}" />
    116128  </fieldset>
    117 
     129 
    118130</form>
    119131
Note: See TracChangeset for help on using the changeset viewer.