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

Last change on this file since 17985 was 17985, checked in by flop25, 12 years ago

send a Confirmation Mail to the user if an admin validated by the link

  • 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);
[17985]43    if (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')
44    {
45      validation_mail($userid);
46    }
[12271]47// We have to get the user's language in database
48// ----------------------------------------------
[6785]49    $query = '
[12227]50SELECT language
51FROM '.USER_INFOS_TABLE.'
52WHERE '.USER_INFOS_TABLE.'.user_id ='.$userid.'
[6785]53;';
54    $data = pwg_db_fetch_assoc(pwg_query($query));
55
[12271]56// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
57// -------------------------------------------------------------------------------------------------------------------------------
[6785]58    if (empty($data))
59    {
[12271]60// And switch gallery to this language before using personalized and multilangual contents
61// ---------------------------------------------------------------------------------------
[6785]62      $language = pwg_get_session_var('lang_switch', $user['language']);
63      switch_lang_to($language);
64    }
65    else
66    {
[12271]67// And switch gallery to this language before using personalized and multilangual contents
68// ---------------------------------------------------------------------------------------
[6785]69      switch_lang_to($data['language']);
70      load_language('plugin.lang', UAM_PATH);
71    }
72
[9160]73    if (isset($conf_UAM_ConfirmMail[5]) and $conf_UAM_ConfirmMail[5] <> '')
[6785]74    {
[9197]75      // Management of Extension flags ([username], [mygallery], [myurl])
[12271]76      // ----------------------------------------------------------------
[9160]77      $patterns[] = '#\[username\]#i';
[9253]78      $replacements[] = $result['username'];
[9160]79      $patterns[] = '#\[mygallery\]#i';
80      $replacements[] = $conf['gallery_title'];
[9197]81      $patterns[] = '#\[myurl\]#i';
[14651]82      $replacements[] = get_gallery_home_url();
83
[9160]84      if (function_exists('get_user_language_desc'))
85      {
86        $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
87      }
88      else $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[5]));
[6785]89    }
[9160]90   
[7277]91    $redirect = true;
[5181]92  } 
93  else
[5633]94  {
95    $status = false;
[7277]96    $redirect = false;
[9160]97   
98    if (isset($conf_UAM_ConfirmMail[6]) and $conf_UAM_ConfirmMail[6] <> '')
[6785]99    {
[9197]100      // Management of Extension flags ([username], [mygallery], [myurl])
[12271]101      // ----------------------------------------------------------------
[9160]102      $patterns[] = '#\[username\]#i';
[9253]103      $replacements[] = $result['username'];
[9160]104      $patterns[] = '#\[mygallery\]#i';
105      $replacements[] = $conf['gallery_title'];
[9197]106      $patterns[] = '#\[myurl\]#i';
[14651]107      $replacements[] = get_gallery_home_url();
[9160]108   
109      if (function_exists('get_user_language_desc'))
110      {
111        $custom_text = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
112      }
113      else $custom_text = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[6]));
[6785]114    }
[5181]115  }
[14651]116
117  $Path_UAM = UAM_PATH; // Path to be used in template to reach the icons
118
119  $template->assign(
120    array(
121      'UAM_PATH'             => $Path_UAM,
122      'REDIRECT'             => $redirect,
123      'STATUS'               => $status,
[17946]124                                'CONFIRM_MAIL_MESSAGE' => $custom_text,
[14651]125    )
126  );
[3742]127}
128
[5056]129if (isset($lang['Theme: '.$user['theme']]))
[3742]130{
131  $template->assign(
[3858]132        'THEME_ABOUT',l10n('Theme: '.$user['theme'])
133  );
[3742]134}
135
[5633]136$template->set_filenames(
137  array(
138        'confirm_mail'=>dirname(__FILE__).'/template/ConfirmMail.tpl',
139        )
140);
[3742]141
142$template->pparse('confirm_mail');
143include(PHPWG_ROOT_PATH.'include/page_tail.php');
144?>
Note: See TracBrowser for help on using the repository browser.