Example #1
0
 public function displayMain()
 {
     global $smarty, $link, $cookie;
     if (!$cookie->logged) {
         Tools::redirect($link->getPage('LoginView'));
     }
     $user = new User((int) $cookie->id_user);
     if (Tools::isSubmit('joinCommit')) {
         if (User::checkPassword($user->id, Tools::encrypt($_POST['old_passwd']))) {
             if (Tools::getRequest('confirmation') == Tools::getRequest('passwd')) {
                 if (!empty($_POST['passwd']) && Validate::isPasswd($_POST['passwd'])) {
                     $user->copyFromPost();
                     if ($user->update()) {
                         $cookie->passwd = $user->passwd;
                         $cookie->write();
                         $smarty->assign('success', 'Your personal information has been successfully updated.');
                     }
                 } else {
                     $user->_errors[] = 'Password is invalid.';
                 }
             } else {
                 $user->_errors[] = 'Password and confirmation do not match.';
             }
         } else {
             $user->_errors[] = 'Your password is incorrect.';
         }
     }
     $smarty->assign(array('errors' => $user->_errors, 'DISPLAY_LEFT' => Module::hookBlock(array('myaccount')), 'user' => $user));
     return $smarty->fetch('my-user.tpl');
 }
Example #2
0
 public function displayMain()
 {
     global $smarty, $link;
     $errors = array();
     if (Tools::isSubmit('CreateUser')) {
         if (!Validate::isEmail(Tools::getRequest('email')) || User::userExists(Tools::getRequest('email'))) {
             $errors[] = 'The email is invalid or an account is already registered with this e-mail!';
         } elseif (empty($_POST['passwd'])) {
             $errors[] = 'The password is empty!';
         } else {
             $user = new User();
             $user->copyFromPost();
             $user->active = 1;
             if ($user->add()) {
                 $address = new Address();
                 $address->copyFromPost();
                 $address->id_user = $user->id;
                 $address->is_default = 1;
                 if ($address->add()) {
                     $user->logined(array('id_address' => $address->id));
                     if (Tools::getRequest("step") == 2) {
                         Tools::redirect($link->getPage('CheckoutView'));
                     } else {
                         Tools::redirect($link->getPage('MyaccountView'));
                     }
                     return;
                 } else {
                     $errors = $address->_errors;
                 }
             } else {
                 $errors = $user->_errors;
             }
         }
     }
     $countrys = Country::loadData(1, 500, null, null, array('active' => 1));
     $smarty->assign(array('id_default_country' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'countrys' => $countrys, 'step' => Tools::getRequest("step"), 'errors' => $errors));
     return $smarty->fetch('join.tpl');
 }
Example #3
0
<?php

if (Tools::P('saveUser') == 'add') {
    $user = new User();
    if (User::userExists(Tools::P('email'))) {
        $user->_errors[] = '邮箱地址已存在!';
    } elseif (!Validate::isPasswd(Tools::P('passwd'))) {
        $user->_errors[] = '用户密码错误!';
    } else {
        $user->copyFromPost();
        if ($user->add()) {
            UIAdminAlerts::conf('用户已添加');
        }
    }
    if (is_array($user->_errors) and count($user->_errors) > 0) {
        $errors = $user->_errors;
    }
}
if (isset($_GET['id'])) {
    $id = (int) Tools::G('id');
    $obj = new User($id);
}
if (Tools::P('saveUser') == 'edit') {
    if (Tools::P('email') != $obj->email && User::userExists(Tools::P('email'))) {
        $obj->_errors[] = '邮箱地址已存在!';
    } elseif (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;