Ignore:
Timestamp:
Jan 28, 2011, 8:56:39 AM (13 years ago)
Author:
LucMorizur
Message:

Fix bug:2135

File:
1 edited

Legend:

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

    r7165 r8956  
    33/*
    44Plugin Name: Event Cats
    5 Version: 2.0.dev
     5Version: 1.2.3
    66Description: A single URL can be enough to be identified, and a user can duplicate his account to create a new one getting immediately the same properties. / On peut être identifié grâce à un simple URL, et on peut dupliquer son compte pour créer un nouveau compte ayant immédiatement les mêmes propriétés.
    77Plugin URI: http://piwigo.org/ext/extension_view.php?eid=326
     
    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:
    46    '2.0.dev' // Currently developping ;-)
     45  'EVNTCATS_INFO_VERSION', // VERSION HISTORY :
     46   '1.2.4' // Fix bug 2135: Constant ROOT_URL already defined; replaced by
     47//         // EC_ROOT_URL
    4748// '1.2.3' // Re-fix bug 1432 :-/ ...
    4849// '2.1.0' // When done, will simplfy and allow EC management from categories
     
    5152// '1.2.1' // Improve EN translation thanks to Tosca
    5253// '1.2.0' // Add feature 1335, Possibility to display the 'Connection'
    53 //         // link in identification block menu for generic users;
     54//         // link in identification block menu for generic users ;
    5455//         // finish (yes !) english translation
    5556// '1.1.5' // Fix bugs 1324 and 1325
    5657// '1.1.4' // Improve help banner
    57 // '1.1.3' // Better help banner management; finalize banner texts
    58 // '1.1.2' // Better help banner example: some examples
    59 // '1.1.1' // Better help banner example; but still no text in it
    60 // '1.1.0' // First bugs (1305 and 1306) corrected;
     58// '1.1.3' // Better help banner management ; finalize banner texts
     59// '1.1.2' // Better help banner example : some examples
     60// '1.1.1' // Better help banner example ; but still no text in it
     61// '1.1.0' // First bugs (1305 and 1306) corrected ;
    6162           // add newly created user/group association with cat/AP (was
    62            // forgotten); begin help banner
     63           // forgotten) ; begin help banner
    6364// '1.0.0' // Conception version
    6465); // ------------------------------------------------------------------------
     
    7273);
    7374define(
    74   'ROOT_URL',
     75  'EC_ROOT_URL',
    7576   get_absolute_root_url()
    7677);
     
    8182// Sets the administration panel of the plugin
    8283  function plugin_admin_menu($menu) {
    83                                                                                 // to be removed in final version :
    84                                                                                 global $template;
    85                                                                                 $template->delete_compiled_templates();
    8684    array_push($menu,
    8785      array(
     
    107105  return (
    108106   $help_content = (is_admin() and $page == 'help') ?
    109     load_language($page.'.html',EVNTCATS_PATH,array('return' => true)) : false
     107    load_language($page.'.html', EVNTCATS_PATH, array('return' => true)) : false
    110108  ) ? $popup_help_content.$help_content : $popup_help_content;
    111109}
     
    116114 *
    117115 * auto_log_user()
    118  * the function uses the value of the argument "autolog" of the posted URL,
    119  * as a code to know which username has to be logged in.
     116 * the function uses the value of the argument "autolog" of the posted URL, as a code
     117 * to know which username has to be logged in.
    120118 *
    121119 * @param no parameter
     
    132130  $ec_img = NULL;
    133131 
    134   if (isset($_GET['autolog']) and (read_ec_conf('activated') == '1')) {
     132  if (isset($_GET['autolog']) and (read_ec_conf('activated') == 1)) {
    135133    if (!is_a_guest()) {
    136134      $url = '';
     
    170168            if (isset($ec_img)) {
    171169              if (ec_image_exists($ec_cat, $ec_img)) {
    172        redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
     170                redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
    173171              }
    174172            }
     
    234232  global $user;
    235233
    236   if (read_ec_conf('activated') == '1') {
    237     if (
    238       !is_a_guest() and !is_admin() and (
    239         read_ec_conf('dup_allow') == '1' or (
    240           read_ec_conf('dup_allow') == '2' and (
    241             dup_allowed($user['id']) or (
    242               read_ec_conf('simple_mode_on') == '1' and
    243               is_generic()
    244             )
    245           )
    246         )
    247       )
    248     ) {
    249       // User access
    250       $result = pwg_query("
    251         SELECT `cat_id`
    252         FROM `".USER_ACCESS_TABLE."`
    253         WHERE `user_id` = ".$user['id'].";
    254       ");
    255       $insert = array();
    256       while ($row = pwg_db_fetch_assoc($result))
    257        $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
    258       if (!empty($insert)) pwg_query("
    259         INSERT INTO `".USER_ACCESS_TABLE."`
    260         VALUES ".implode(',', $insert).";
    261       ");
    262 
    263       // User groups
    264       $result = pwg_query("
    265         SELECT `group_id`
    266         FROM `".USER_GROUP_TABLE."`
    267         WHERE `user_id` = ".$user['id'].";
    268       ");
    269       $insert = array();
    270       while ($row = pwg_db_fetch_assoc($result))
    271        $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
    272       if (!empty($insert)) pwg_query("
    273         INSERT INTO `".USER_GROUP_TABLE."`
    274         VALUES ".implode(',', $insert).";
    275       ");
    276 
    277       // User infos
    278       $result = pwg_query("
    279         SELECT `level`
    280         FROM `".USER_INFOS_TABLE."`
    281         WHERE `user_id` = ".$user['id'].";
    282       ");
    283       $insert = array();
    284       while ($row = pwg_db_fetch_assoc($result))
    285        $insert[] = "(".$new_user['id'].",".$row['level'].")";
    286       if (!empty($insert)) pwg_query("
    287         UPDATE `".USER_INFOS_TABLE."`
    288         SET `level` = ".$user['level']."
    289         WHERE `user_id` = ".$new_user['id'].";
    290       ");
    291     }
     234  if (!is_a_guest() and !is_admin()) if (
     235    read_ec_conf('dup_allow') == '1' or (
     236      read_ec_conf('dup_allow') == '2' and
     237      dup_allowed($user['id'])
     238    )
     239  ) {
     240    // User access
     241    $result = pwg_query("
     242      SELECT `cat_id`
     243      FROM `".USER_ACCESS_TABLE."`
     244      WHERE `user_id` = ".$user['id'].";
     245    ");
     246    $insert = array();
     247    while ($row = mysql_fetch_assoc($result))
     248     $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
     249    if (!empty($insert)) pwg_query("
     250      INSERT INTO `".USER_ACCESS_TABLE."`
     251      VALUES ".implode(',', $insert).";
     252    ");
     253
     254    // User groups
     255    $result = pwg_query("
     256      SELECT `group_id`
     257      FROM `".USER_GROUP_TABLE."`
     258      WHERE `user_id` = ".$user['id'].";
     259    ");
     260    $insert = array();
     261    while ($row = mysql_fetch_assoc($result))
     262     $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
     263    if (!empty($insert)) pwg_query("
     264      INSERT INTO `".USER_GROUP_TABLE."`
     265      VALUES ".implode(',', $insert).";
     266    ");
     267
     268    // User infos
     269    $result = pwg_query("
     270      SELECT `level`
     271      FROM `".USER_INFOS_TABLE."`
     272      WHERE `user_id` = ".$user['id'].";
     273    ");
     274    $insert = array();
     275    while ($row = mysql_fetch_assoc($result))
     276     $insert[] = "(".$new_user['id'].",".$row['level'].")";
     277    if (!empty($insert)) pwg_query("
     278      UPDATE `".USER_INFOS_TABLE."`
     279      SET `level` = ".$user['level']."
     280      WHERE `user_id` = ".$new_user['id'].";
     281    ");
    292282  }
    293283}
     
    325315  global $lang, $template, $user;
    326316 
    327   if (read_ec_conf('activated') == '1') {
    328     if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
    329       // Makes the "quick connect" fieldset able to redirect to current page
    330       // after user identification, just as does the "connection" link.
    331       $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
    332       $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
    333     }
    334    
    335     // Add duplication link, if needed
     317  if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
     318    // Makes the "quick connect" fieldset able to redirect to current page
     319    // after user identification, just as does the "connection" link.
     320    $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
     321    $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
     322  }
     323 
     324  // Adds duplication link, if needed
     325  if (!is_admin() and !is_a_guest()) if (
     326    read_ec_conf('dup_allow') == '1' or (
     327      read_ec_conf('dup_allow') == '2' and
     328      dup_allowed($user['id'])
     329    )
     330  ) {
     331    $template->assign('U_REGISTER', get_root_url().'register.php');
    336332    if (
    337       !is_admin() and !is_a_guest() and (
    338         read_ec_conf('dup_allow') == '1' or (
    339           read_ec_conf('dup_allow') == '2' and (
    340             dup_allowed($user['id']) or (
    341               read_ec_conf('simple_mode_on') == '1' and
    342               is_generic()
    343             )
    344           )
    345         )
     333      read_ec_conf('duplic_display') == '1' or (
     334        read_ec_conf('duplic_display') == '2' and
     335        !is_generic()
    346336      )
    347337    ) {
    348       $template->assign('U_REGISTER', get_root_url().'register.php');
    349       if (
    350         read_ec_conf('duplic_display') == '1' or (
    351           read_ec_conf('duplic_display') == '2' and
    352           !is_generic()
    353         )
    354       ) {
    355         $lang['Register'] = $lang['Duplicate'];
    356         $lang['Create a new account'] =
    357          $lang['Create a new account with same properties'];
    358       }
    359     }
    360    
    361     // Adds connection link, if needed
    362     if (read_ec_conf('display_connection') == '1' and is_generic()) {
    363       // Adds connection link
    364       $template->assign(
    365         'U_LOGIN',
    366         get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
    367       );
    368     }
     338      $lang['Register'] = $lang['Duplicate'];
     339      $lang['Create a new account'] =
     340       $lang['Create a new account with same properties'];
     341    }
     342  }
     343 
     344  // Adds connection link, if needed
     345  if (read_ec_conf('display_connection') == '1' and is_generic()) {
     346    // Adds connection link
     347    $template->assign(
     348      'U_LOGIN',
     349      get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
     350    );
    369351  }
    370352}
Note: See TracChangeset for help on using the changeset viewer.