source: extensions/UserAdvManager/trunk/ConfirmMail.php @ 13123

Last change on this file since 13123 was 12271, checked in by Eric, 13 years ago
  • Bug 2447 fixed : Pre-filled text are localized for installation from scratch. If language is not supported by the plugin, the default language remains English.
  • maintain.inc.php refactory : Simplify installation from scratch and make code more readable.
  • Comments in all code are more readable.
  • Property svn:eol-style set to LF
File size: 4.5 KB
RevLine 
[3742]1<?php
2//----------------------------------------------------------- include
3define('PHPWG_ROOT_PATH','./../../');
[5633]4
[3742]5include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[7277]6include_once( PHPWG_ROOT_PATH.'include/functions_mail.inc.php' );
[5633]7
[5181]8include_once (UAM_PATH.'include/constants.php');
9include_once (UAM_PATH.'include/functions.inc.php');
[3742]10
[9177]11$title= l10n('UAM_confirm_mail_page_title');
[5633]12$page['body_id'] = 'theAboutPage';
13include(PHPWG_ROOT_PATH.'include/page_header.php');
14
15@include(PHPWG_ROOT_PATH.'template/'.$user['template'].
16  '/theme/'.$user['theme'].'/themeconf.inc.php');
17
[6354]18
[6785]19if (isset($_GET['key']) and isset($_GET['userid']))
[3742]20{
21
[6785]22  global $user, $lang, $conf, $errors;
[5181]23 
[6785]24  $key = $_GET['key'];
25  $userid = $_GET['userid'];
26  $redirect = false;
27 
[5181]28  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
[6785]29  $conf_UAM = unserialize($conf['UserAdvManager']);
[5181]30
[9160]31  $query = '
32SELECT '.USERS_TABLE.'.username
33FROM '.USERS_TABLE.'
34WHERE ('.USERS_TABLE.'.id ='.$userid.')
35;';
36  $result = pwg_db_fetch_assoc(pwg_query($query));
37
[6785]38  if (VerifyConfirmMail($key))
[5181]39  {
[5633]40    $status = true;
41   
[6785]42    log_user($userid, false);
43
[12271]44// We have to get the user's language in database
45// ----------------------------------------------
[6785]46    $query = '
[12227]47SELECT language
48FROM '.USER_INFOS_TABLE.'
49WHERE '.USER_INFOS_TABLE.'.user_id ='.$userid.'
[6785]50;';
51    $data = pwg_db_fetch_assoc(pwg_query($query));
52
[12271]53// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
54// -------------------------------------------------------------------------------------------------------------------------------
[6785]55    if (empty($data))
56    {
[12271]57// And switch gallery to this language before using personalized and multilangual contents
58// ---------------------------------------------------------------------------------------
[6785]59      $language = pwg_get_session_var('lang_switch', $user['language']);
60      switch_lang_to($language);
61    }
62    else
63    {
[12271]64// And switch gallery to this language before using personalized and multilangual contents
65// ---------------------------------------------------------------------------------------
[6785]66      switch_lang_to($data['language']);
67      load_language('plugin.lang', UAM_PATH);
68    }
69
[9160]70    if (isset($conf_UAM_ConfirmMail[5]) and $conf_UAM_ConfirmMail[5] <> '')
[6785]71    {
[9197]72      // Management of Extension flags ([username], [mygallery], [myurl])
[12271]73      // ----------------------------------------------------------------
[9160]74      $patterns[] = '#\[username\]#i';
[9253]75      $replacements[] = $result['username'];
[9160]76      $patterns[] = '#\[mygallery\]#i';
77      $replacements[] = $conf['gallery_title'];
[9197]78      $patterns[] = '#\[myurl\]#i';
79      $replacements[] = $conf['gallery_url'];
[9160]80   
81      if (function_exists('get_user_language_desc'))
82      {
83        $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
84      }
85      else $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
[6785]86    }
[9160]87   
[7277]88    $redirect = true;
[6785]89   
[3858]90    $template->assign(
91                        array(
[6785]92        'REDIRECT'             => $redirect,
[5633]93        'STATUS'               => $status,
[6785]94                                'CONFIRM_MAIL_MESSAGE' => $custom_text,
[3858]95                        )
96                );
[5181]97  } 
98  else
[5633]99  {
100    $status = false;
[7277]101    $redirect = false;
[9160]102   
103    if (isset($conf_UAM_ConfirmMail[6]) and $conf_UAM_ConfirmMail[6] <> '')
[6785]104    {
[9197]105      // Management of Extension flags ([username], [mygallery], [myurl])
[12271]106      // ----------------------------------------------------------------
[9160]107      $patterns[] = '#\[username\]#i';
[9253]108      $replacements[] = $result['username'];
[9160]109      $patterns[] = '#\[mygallery\]#i';
110      $replacements[] = $conf['gallery_title'];
[9197]111      $patterns[] = '#\[myurl\]#i';
112      $replacements[] = $conf['gallery_url'];
[9160]113   
114      if (function_exists('get_user_language_desc'))
115      {
116        $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
117      }
118      else $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
[6785]119    }
120   
[3858]121    $template->assign(
122                        array(
[6785]123        'REDIRECT'             => $redirect,
[7277]124        'GALLERY_URL'          => make_index_url(),
[5633]125        'STATUS'               => $status,
[6785]126                                'CONFIRM_MAIL_MESSAGE' => $custom_text,
[3858]127                        )
[5181]128                );
129  }
[3742]130}
131
[5056]132if (isset($lang['Theme: '.$user['theme']]))
[3742]133{
134  $template->assign(
[3858]135        'THEME_ABOUT',l10n('Theme: '.$user['theme'])
136  );
[3742]137}
138
[5633]139$template->set_filenames(
140  array(
141        'confirm_mail'=>dirname(__FILE__).'/template/ConfirmMail.tpl',
142        )
143);
[3742]144
145$template->pparse('confirm_mail');
146include(PHPWG_ROOT_PATH.'include/page_tail.php');
147?>
Note: See TracBrowser for help on using the repository browser.