Ignore:
Timestamp:
Sep 24, 2012, 3:48:46 PM (12 years ago)
Author:
flop25
Message:

no more need of confirmMail.php / tpl
better handle on init
bug pending :
-no login on key validation (like previously)
-no confirmation msg on key validation : $pageinfos[] doesn't seems to work on identification page

Location:
extensions/UserAdvManager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r18158 r18205  
    887887    }
    888888  }
     889  if( isset($_GET['UAM_msg']))
     890  {
     891    UAM_DisplayMsg();
     892  }
     893  elseif (isset($_GET['key']) and isset($_GET['userid']))
     894  {
     895    UAM_ConfirmMail();
     896  }
     897
    889898}
    890899
     
    919928  }
    920929}
    921 
     930/**
     931 * Triggered on init
     932 *
     933 * Check the key and display a message
     934 */
     935function UAM_ConfirmMail()
     936{
     937
     938  if (isset($_GET['key']) and isset($_GET['userid']))
     939  {
     940 
     941    global $user, $lang, $conf, $page;
     942   
     943    $key = $_GET['key'];
     944    $userid = $_GET['userid'];
     945   
     946    $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
     947    $conf_UAM = unserialize($conf['UserAdvManager']);
     948 
     949    $query = '
     950  SELECT '.USERS_TABLE.'.username
     951  FROM '.USERS_TABLE.'
     952  WHERE ('.USERS_TABLE.'.id ='.$userid.')
     953  ;';
     954    $result = pwg_db_fetch_assoc(pwg_query($query));
     955 
     956    if (VerifyConfirmMail($key))
     957    {
     958      if (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')
     959      {
     960        validation_mail($userid);
     961      }
     962  // We have to get the user's language in database
     963  // ----------------------------------------------
     964      $query = '
     965  SELECT language
     966  FROM '.USER_INFOS_TABLE.'
     967  WHERE '.USER_INFOS_TABLE.'.user_id ='.$userid.'
     968  ;';
     969      $data = pwg_db_fetch_assoc(pwg_query($query));
     970 
     971  // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
     972  // -------------------------------------------------------------------------------------------------------------------------------
     973      if (empty($data))
     974      {
     975  // And switch gallery to this language before using personalized and multilangual contents
     976  // ---------------------------------------------------------------------------------------
     977        $language = pwg_get_session_var('lang_switch', $user['language']);
     978        switch_lang_to($language);
     979      }
     980      else
     981      {
     982  // And switch gallery to this language before using personalized and multilangual contents
     983  // ---------------------------------------------------------------------------------------
     984        switch_lang_to($data['language']);
     985        load_language('plugin.lang', UAM_PATH);
     986      }
     987 
     988      if (isset($conf_UAM_ConfirmMail[5]) and $conf_UAM_ConfirmMail[5] <> '')
     989      {
     990        // Management of Extension flags ([username], [mygallery], [myurl])
     991        // ----------------------------------------------------------------
     992        $patterns[] = '#\[username\]#i';
     993        $replacements[] = $result['username'];
     994        $patterns[] = '#\[mygallery\]#i';
     995        $replacements[] = $conf['gallery_title'];
     996        $patterns[] = '#\[myurl\]#i';
     997        $replacements[] = get_gallery_home_url();
     998 
     999        if (function_exists('get_user_language_desc'))
     1000        {
     1001          $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
     1002        }
     1003        else
     1004        {
     1005          $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
     1006        }
     1007        $page['infos'][]=$custom_text;
     1008        //print_r($custom_text);
     1009      }
     1010      //log_user($userid, true);
     1011    } 
     1012    else
     1013    {
     1014      if (isset($conf_UAM_ConfirmMail[6]) and $conf_UAM_ConfirmMail[6] <> '')
     1015      {
     1016        // Management of Extension flags ([username], [mygallery], [myurl])
     1017        // ----------------------------------------------------------------
     1018        $patterns[] = '#\[username\]#i';
     1019        $replacements[] = $result['username'];
     1020        $patterns[] = '#\[mygallery\]#i';
     1021        $replacements[] = $conf['gallery_title'];
     1022        $patterns[] = '#\[myurl\]#i';
     1023        $replacements[] = get_gallery_home_url();
     1024     
     1025        if (function_exists('get_user_language_desc'))
     1026        {
     1027          $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
     1028        }
     1029        else
     1030        {
     1031          $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
     1032        }
     1033       
     1034        $page['errors'][]=$custom_text;
     1035      }
     1036    }
     1037  }
     1038}
    9221039/**
    9231040 * Triggered on render_lost_password_mail_content
     
    18361953    SetUnvalidated($user_id);
    18371954   
    1838     return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id;
     1955    if ( $conf['guest_access'] )
     1956    {
     1957      return( get_absolute_root_url().'?key='.$Confirm_Mail_ID.'&userid='.$user_id);
     1958    }
     1959    else
     1960    {
     1961      return( get_absolute_root_url().'identification.php?key='.$Confirm_Mail_ID.'&userid='.$user_id);
     1962    }
    18391963  }
    18401964}
     
    19262050    pwg_query($query);
    19272051
    1928                                 $query = '
     2052    $query = '
    19292053UPDATE '.USER_INFOS_TABLE.'
    19302054SET registration_date = "'.$dbnow.'"
    19312055WHERE user_id = '.$user_id.'
    19322056;';
    1933                                 pwg_query($query);
     2057    pwg_query($query);
    19342058   
    1935     return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id;
     2059    if ( $conf['guest_access'] )
     2060    {
     2061      return( get_absolute_root_url().'?key='.$Confirm_Mail_ID.'&userid='.$user_id);
     2062    }
     2063    else
     2064    {
     2065      return( get_absolute_root_url().'identification.php?key='.$Confirm_Mail_ID.'&userid='.$user_id);
     2066    }
    19362067  }
    19372068}
  • extensions/UserAdvManager/trunk/main.inc.php

    r17972 r18205  
    6666add_event_handler('init', 'UAM_InitPage');
    6767
    68 // Display messages about Login rejected, etc
    69 // ---------------------------
    70 add_event_handler('init','UAM_DisplayMsg');
    71 add_event_handler('identification','UAM_DisplayMsg');
    7268
    7369// PWG_Stuffs module
Note: See TracChangeset for help on using the changeset viewer.