XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
changemail.php
Go to the documentation of this file.
1 <?php
20 $xoopsOption['pagetype'] = "user";
21 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
23 $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
24 
25 if (!$GLOBALS['xoopsUser'] || $GLOBALS['xoopsConfigUser']['allow_chgmail'] != 1) {
26  redirect_header(XOOPS_URL . "/modules/" . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/", 2, _NOPERM);
27 }
28 
29 $xoopsOption['template_main'] = 'profile_email.html';
30 include $GLOBALS['xoops']->path('header.php');
31 
32 if (!isset($_POST['submit']) || !isset($_POST['passwd'])) {
33  //show change password form
34  include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
35  $form = new XoopsThemeForm(_PROFILE_MA_CHANGEMAIL, 'emailform', $_SERVER['REQUEST_URI'], 'post', true);
36  $form->addElement(new XoopsFormPassword(_US_PASSWORD, 'passwd', 15, 50), true);
37  $form->addElement(new XoopsFormText(_PROFILE_MA_NEWMAIL, 'newmail', 15, 50), true);
38  $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
39  $form->assign($GLOBALS['xoopsTpl']);
40 } else {
42  $pass = @$myts->stripSlashesGPC(trim($_POST['passwd']));
43  $email = @$myts->stripSlashesGPC(trim($_POST['newmail']));
44  $errors = array();
45  if (md5($pass) != $GLOBALS['xoopsUser']->getVar('pass', 'n')) {
47  }
48  if (!checkEmail($email)) {
50  }
51 
52  if ($errors) {
53  $msg = implode('<br />', $errros);
54  } else {
55  //update password
56  $GLOBALS['xoopsUser']->setVar('email', trim($_POST['newmail']));
57 
59  if ($member_handler->insertUser($GLOBALS['xoopsUser'])) {
61 
62  //send email to new email address
63  $xoopsMailer =& xoops_getMailer();
64  $xoopsMailer->useMail();
65  $xoopsMailer->setTemplateDir($GLOBALS['xoopsModule']->getVar('dirname', 'n'));
66  $xoopsMailer->setTemplate('emailchanged.tpl');
67  $xoopsMailer->assign("SITENAME", $GLOBALS['xoopsConfig']['sitename']);
68  $xoopsMailer->assign("ADMINMAIL", $GLOBALS['xoopsConfig']['adminmail']);
69  $xoopsMailer->assign("SITEURL", XOOPS_URL . "/");
70  $xoopsMailer->assign("NEWEMAIL", $email);
71  $xoopsMailer->setToEmails($email);
72  $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
73  $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
74  $xoopsMailer->setSubject(sprintf(_PROFILE_MA_NEWEMAIL, $GLOBALS['xoopsConfig']['sitename']));
75  $xoopsMailer->send();
76 
77  } else {
78  $msg = implode('<br />', $GLOBALS['xoopsUser']->getErrors() );
79  }
80  }
81  redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'), 2, $msg);
82 }
83 
84 $xoBreadcrumbs[] = array('title' => _PROFILE_MA_CHANGEMAIL);
85 
86 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
87 ?>