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

Last change on this file since 17969 was 17946, checked in by Eric, 12 years ago

New feature : Send the validation key by email to webmaster (not admins !) to allow it to validate manually a user registration whithout having to connect the gallery. This is when manual validation by admins is set in UAM options.

By the way, I fixed a bug in VerifyConfirmMail($key) function. I'm wondering it worked before...

I don't remember why I used $conf_UAM[4] <> -1 or isset($datastatus) in VerifyConfirmMail($key) function. Now only $conf_UAM[4] <> -1 is used and all works fine.

Next step : Extending the send of validation key to all admins in addition of webmaster.

  • Property svn:eol-style set to LF
File size: 4.4 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';
[14651]79      $replacements[] = get_gallery_home_url();
80
[9160]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;
[5181]89  } 
90  else
[5633]91  {
92    $status = false;
[7277]93    $redirect = false;
[9160]94   
95    if (isset($conf_UAM_ConfirmMail[6]) and $conf_UAM_ConfirmMail[6] <> '')
[6785]96    {
[9197]97      // Management of Extension flags ([username], [mygallery], [myurl])
[12271]98      // ----------------------------------------------------------------
[9160]99      $patterns[] = '#\[username\]#i';
[9253]100      $replacements[] = $result['username'];
[9160]101      $patterns[] = '#\[mygallery\]#i';
102      $replacements[] = $conf['gallery_title'];
[9197]103      $patterns[] = '#\[myurl\]#i';
[14651]104      $replacements[] = get_gallery_home_url();
[9160]105   
106      if (function_exists('get_user_language_desc'))
107      {
108        $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
109      }
110      else $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
[6785]111    }
[5181]112  }
[14651]113
114  $Path_UAM = UAM_PATH; // Path to be used in template to reach the icons
115
116  $template->assign(
117    array(
118      'UAM_PATH'             => $Path_UAM,
119      'REDIRECT'             => $redirect,
120      'STATUS'               => $status,
[17946]121                                'CONFIRM_MAIL_MESSAGE' => $custom_text,
[14651]122    )
123  );
[3742]124}
125
[5056]126if (isset($lang['Theme: '.$user['theme']]))
[3742]127{
128  $template->assign(
[3858]129        'THEME_ABOUT',l10n('Theme: '.$user['theme'])
130  );
[3742]131}
132
[5633]133$template->set_filenames(
134  array(
135        'confirm_mail'=>dirname(__FILE__).'/template/ConfirmMail.tpl',
136        )
137);
[3742]138
139$template->pparse('confirm_mail');
140include(PHPWG_ROOT_PATH.'include/page_tail.php');
141?>
Note: See TracBrowser for help on using the repository browser.