Ignore:
Timestamp:
Oct 4, 2010, 1:38:27 AM (14 years ago)
Author:
LucMorizur
Message:

At last a configuration management working as desired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/main.inc.php

    r7066 r7084  
    3232// +-----------------------------------------------------------------------+
    3333
    34 // Keeps file coded in UTF-8 without BOM : é
     34// Keeps file coded in UTF-8 without BOM: é
    3535
    3636if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     
    4343
    4444define( // -------------------------------------------------------------------
    45   'EVNTCATS_INFO_VERSION', // VERSION HISTORY :
     45  'EVNTCATS_INFO_VERSION', // VERSION HISTORY:
    4646   '1.2.3' // Re-fix bug 1432 :-/ ...
    4747// '2.1.0' // When done, will simplfy and allow EC management from categories
     
    5050// '1.2.1' // Improve EN translation thanks to Tosca
    5151// '1.2.0' // Add feature 1335, Possibility to display the 'Connection'
    52 //         // link in identification block menu for generic users ;
     52//         // link in identification block menu for generic users;
    5353//         // finish (yes !) english translation
    5454// '1.1.5' // Fix bugs 1324 and 1325
    5555// '1.1.4' // Improve help banner
    56 // '1.1.3' // Better help banner management ; finalize banner texts
    57 // '1.1.2' // Better help banner example : some examples
    58 // '1.1.1' // Better help banner example ; but still no text in it
    59 // '1.1.0' // First bugs (1305 and 1306) corrected ;
     56// '1.1.3' // Better help banner management; finalize banner texts
     57// '1.1.2' // Better help banner example: some examples
     58// '1.1.1' // Better help banner example; but still no text in it
     59// '1.1.0' // First bugs (1305 and 1306) corrected;
    6060           // add newly created user/group association with cat/AP (was
    61            // forgotten) ; begin help banner
     61           // forgotten); begin help banner
    6262// '1.0.0' // Conception version
    6363); // ------------------------------------------------------------------------
     
    103103  return (
    104104   $help_content = (is_admin() and $page == 'help') ?
    105     load_language($page.'.html', EVNTCATS_PATH, array('return' => true)) : false
     105    load_language($page.'.html',EVNTCATS_PATH,array('return' => true)) : false
    106106  ) ? $popup_help_content.$help_content : $popup_help_content;
    107107}
     
    112112 *
    113113 * auto_log_user()
    114  * the function uses the value of the argument "autolog" of the posted URL, as a code
    115  * to know which username has to be logged in.
     114 * the function uses the value of the argument "autolog" of the posted URL,
     115 * as a code to know which username has to be logged in.
    116116 *
    117117 * @param no parameter
     
    128128  $ec_img = NULL;
    129129 
    130   if (isset($_GET['autolog']) and (read_ec_conf('activated') == 1)) {
     130  if (isset($_GET['autolog']) and (read_ec_conf('activated') == '1')) {
    131131    if (!is_a_guest()) {
    132132      $url = '';
     
    166166            if (isset($ec_img)) {
    167167              if (ec_image_exists($ec_cat, $ec_img)) {
    168                 redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
     168       redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
    169169              }
    170170            }
     
    230230  global $user;
    231231
    232   if (!is_a_guest() and !is_admin()) if (
    233     read_ec_conf('dup_allow') == '1' or (
    234       read_ec_conf('dup_allow') == '2' and
    235       dup_allowed($user['id'])
    236     )
    237   ) {
    238     // User access
    239     $result = pwg_query("
    240       SELECT `cat_id`
    241       FROM `".USER_ACCESS_TABLE."`
    242       WHERE `user_id` = ".$user['id'].";
    243     ");
    244     $insert = array();
    245     while ($row = pwg_db_fetch_assoc($result))
    246      $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
    247     if (!empty($insert)) pwg_query("
    248       INSERT INTO `".USER_ACCESS_TABLE."`
    249       VALUES ".implode(',', $insert).";
    250     ");
    251 
    252     // User groups
    253     $result = pwg_query("
    254       SELECT `group_id`
    255       FROM `".USER_GROUP_TABLE."`
    256       WHERE `user_id` = ".$user['id'].";
    257     ");
    258     $insert = array();
    259     while ($row = pwg_db_fetch_assoc($result))
    260      $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
    261     if (!empty($insert)) pwg_query("
    262       INSERT INTO `".USER_GROUP_TABLE."`
    263       VALUES ".implode(',', $insert).";
    264     ");
    265 
    266     // User infos
    267     $result = pwg_query("
    268       SELECT `level`
    269       FROM `".USER_INFOS_TABLE."`
    270       WHERE `user_id` = ".$user['id'].";
    271     ");
    272     $insert = array();
    273     while ($row = pwg_db_fetch_assoc($result))
    274      $insert[] = "(".$new_user['id'].",".$row['level'].")";
    275     if (!empty($insert)) pwg_query("
    276       UPDATE `".USER_INFOS_TABLE."`
    277       SET `level` = ".$user['level']."
    278       WHERE `user_id` = ".$new_user['id'].";
    279     ");
     232  if (read_ec_conf('activated') == '1') {
     233    if (
     234      !is_a_guest() and !is_admin() and (
     235        read_ec_conf('dup_allow') == '1' or (
     236          read_ec_conf('dup_allow') == '2' and (
     237            dup_allowed($user['id']) or (
     238              read_ec_conf('simple_mode_on') == '1' and
     239              is_generic()
     240            )
     241          )
     242        )
     243      )
     244    ) {
     245      // User access
     246      $result = pwg_query("
     247        SELECT `cat_id`
     248        FROM `".USER_ACCESS_TABLE."`
     249        WHERE `user_id` = ".$user['id'].";
     250      ");
     251      $insert = array();
     252      while ($row = pwg_db_fetch_assoc($result))
     253       $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
     254      if (!empty($insert)) pwg_query("
     255        INSERT INTO `".USER_ACCESS_TABLE."`
     256        VALUES ".implode(',', $insert).";
     257      ");
     258
     259      // User groups
     260      $result = pwg_query("
     261        SELECT `group_id`
     262        FROM `".USER_GROUP_TABLE."`
     263        WHERE `user_id` = ".$user['id'].";
     264      ");
     265      $insert = array();
     266      while ($row = pwg_db_fetch_assoc($result))
     267       $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
     268      if (!empty($insert)) pwg_query("
     269        INSERT INTO `".USER_GROUP_TABLE."`
     270        VALUES ".implode(',', $insert).";
     271      ");
     272
     273      // User infos
     274      $result = pwg_query("
     275        SELECT `level`
     276        FROM `".USER_INFOS_TABLE."`
     277        WHERE `user_id` = ".$user['id'].";
     278      ");
     279      $insert = array();
     280      while ($row = pwg_db_fetch_assoc($result))
     281       $insert[] = "(".$new_user['id'].",".$row['level'].")";
     282      if (!empty($insert)) pwg_query("
     283        UPDATE `".USER_INFOS_TABLE."`
     284        SET `level` = ".$user['level']."
     285        WHERE `user_id` = ".$new_user['id'].";
     286      ");
     287    }
    280288  }
    281289}
     
    313321  global $lang, $template, $user;
    314322 
    315   if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
    316     // Makes the "quick connect" fieldset able to redirect to current page
    317     // after user identification, just as does the "connection" link.
    318     $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
    319     $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
    320   }
    321  
    322   // Adds duplication link, if needed
    323   if (!is_admin() and !is_a_guest()) if (
    324     read_ec_conf('dup_allow') == '1' or (
    325       read_ec_conf('dup_allow') == '2' and
    326       dup_allowed($user['id'])
    327     )
    328   ) {
    329     $template->assign('U_REGISTER', get_root_url().'register.php');
     323  if (read_ec_conf('activated') == '1') {
     324    if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
     325      // Makes the "quick connect" fieldset able to redirect to current page
     326      // after user identification, just as does the "connection" link.
     327      $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
     328      $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
     329    }
     330   
     331    // Add duplication link, if needed
    330332    if (
    331       read_ec_conf('duplic_display') == '1' or (
    332         read_ec_conf('duplic_display') == '2' and
    333         !is_generic()
     333      !is_admin() and !is_a_guest() and (
     334        read_ec_conf('dup_allow') == '1' or (
     335          read_ec_conf('dup_allow') == '2' and (
     336            dup_allowed($user['id']) or (
     337              read_ec_conf('simple_mode_on') == '1' and
     338              is_generic()
     339            )
     340          )
     341        )
    334342      )
    335343    ) {
    336       $lang['Register'] = $lang['Duplicate'];
    337       $lang['Create a new account'] =
    338        $lang['Create a new account with same properties'];
    339     }
    340   }
    341  
    342   // Adds connection link, if needed
    343   if (read_ec_conf('display_connection') == '1' and is_generic()) {
    344     // Adds connection link
    345     $template->assign(
    346       'U_LOGIN',
    347       get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
    348     );
     344      $template->assign('U_REGISTER', get_root_url().'register.php');
     345      if (
     346        read_ec_conf('duplic_display') == '1' or (
     347          read_ec_conf('duplic_display') == '2' and
     348          !is_generic()
     349        )
     350      ) {
     351        $lang['Register'] = $lang['Duplicate'];
     352        $lang['Create a new account'] =
     353         $lang['Create a new account with same properties'];
     354      }
     355    }
     356   
     357    // Adds connection link, if needed
     358    if (read_ec_conf('display_connection') == '1' and is_generic()) {
     359      // Adds connection link
     360      $template->assign(
     361        'U_LOGIN',
     362        get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
     363      );
     364    }
    349365  }
    350366}
Note: See TracChangeset for help on using the changeset viewer.