public function getUserInterface($params = null) { switch (@$_REQUEST['section']) { /* * * Publicly Accesscable Pages * */ case 'signup': $this->template = 'account_signup.tpl'; $this->addJS('/modules/User/js/profile.js'); if (!($form = $this->getUserAddEditForm('/user/signup'))) { break; } $form->setConstants(array('section' => 'signup')); if (isset($_POST['a_submit']) && $form->validate()) { $this->template = 'account_confirmed.tpl'; $_POST['username'] = $_POST['a_username']; $_POST['password'] = $_POST['a_password']; $_POST['doLogin'] = "******"; $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); $auth->checkAuth(); header('Location: /user/'); } $this->smarty->assign('form', $form); return $this->smarty->fetch($this->template); break; case 'logout': unset($_SESSION['authenticated_user']); $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->logout(); header('Location: /'); exit; break; default: if ($_SESSION['authenticated_user']) { header('Location: /'); exit; } return authInlineHTML(); } }
public function getUserInterface($params = null) { include 'include/CMSPage.php'; $this->smarty->assign('hasRestriction', $this->hasRestriction()); $page = new CMSPage($_REQUEST['page']); $rev = $page->getActiveRevisions($_SESSION['lang']); if ($page->getAccess() != 'public' && $this->hasRestriction()) { $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); if (!$auth->checkAuth()) { return authInlineHTML(); } else { if ($page->getAccess() != 'public' && $_SESSION['authenticated_user']->hasPerm('membersaccess')) { $this->smarty->assign('content_perms', true); } else { $this->smarty->assign('content_perms', false); } } } else { $this->smarty->assign('content_perms', true); } $metaData = $rev->getMetaData(); $this->smarty->assign('content', $rev); $this->setMetaDescription($metaData['description']); $this->setMetaTitle($metaData['title']); $this->setMetaKeywords($metaData['keywords']); $this->setPageTitle($rev->getPageTitle()); return $this->smarty->fetch('db:content.tpl'); }
public function getUserInterface($params = null) { switch (@$_REQUEST['section']) { /* * * Publicly Accesscable Pages * */ case 'signup': //$_REQUEST['id'] = @$_SESSION["authenticated_user"]->getId(); $usr = new User(); $form = $usr->getUserAddEditForm("/user/signup/", false, false); if (@$_REQUEST["user_created"]) { //The user has been added return "You have create a new user"; } return $form->display(); $this->template = 'account_signup.tpl'; $this->addJS('/modules/User/js/profile.js'); if (!($form = $this->getUserAddEditForm('/user/signup'))) { break; } $form->setConstants(array('section' => 'signup')); if (isset($_POST['a_submit']) && $form->validate()) { $this->template = 'account_confirmed.tpl'; $_POST['username'] = $_POST['a_username']; $_POST['password'] = $_POST['a_password']; $_POST['doLogin'] = "******"; $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); $auth->checkAuth(); header('Location: /user/'); } $this->smarty->assign('form', $form); return $this->smarty->fetch($this->template); break; case 'logout': unset($_SESSION['authenticated_user']); $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->logout(); header('Location: /'); exit; break; case 'forgotpass': $form = new Form('frm_forgotpass', 'POST', "/user/forgotpass"); $form->addElement('header', 'via_username', 'Retrieve your password via email'); $form->addElement('text', 'username', 'Username'); $form->addElement('submit', 'submit', 'GO >>'); if ($form->validate() && isset($_REQUEST['submit'])) { $usr = new User(@$_REQUEST["username"]); if (!$usr->getId()) { $form->addElement('static', 'error_msg', ' ', 'This username could not be found in our database'); return $form->display(); } srand(time()); $randomPass = rand(); $this->smarty->assign('randomPass', $randomPass); $body = $this->smarty->fetch('resetPasswordEmail.tpl'); $headers = "From: info@feedstore.ca"; $mailResult = mail($usr->getEmail(), "Your password has been reset", $body, $headers); if ($mailResult) { $usr->setPassword($randomPass); $usr->save(); return "Your password has been changed and sent to your email address: " . $usr->getEmail(); } else { return "Could not reset the password. Please contact the administrator of the site."; } } return $form->display(); break; case 'profile': if (!@isset($_SESSION["authenticated_user"]) || !@$_SESSION["authenticated_user"]->getId()) { header('location: /user/'); exit; } $_REQUEST['id'] = @$_SESSION["authenticated_user"]->getId(); $usr = new User(); $form = $usr->getUserAddEditForm("/user/profile", false, false); if (@$_REQUEST["user_created"]) { $_SESSION["authenticated_user"] = new User($_SESSION["authenticated_user"]->getId()); //Refresh the user in the session } return $form->display(); break; default: if (isset($_SESSION['authenticated_user']) && $_SESSION['authenticated_user']) { $this->smarty->assign('username', $_SESSION['authenticated_user']->getUserName()); return $this->smarty->fetch('my_account.tpl'); } return authInlineHTML(); } }
/** * Manage the accounts of the shoppers * * This function allows the shoppers to manage their account * They can change their profile (address, email, phone number, etc), or view all the orders that they made * * @return string */ public function handleMyAccount($action) { $auth_container = new User(); $auth = new Auth($auth_container, null, 'authInlineHTML'); $auth->start(); if (!$auth->checkAuth()) { return authInlineHTML(); } $userId = $_SESSION['authenticated_user']->getId(); switch ($action) { case 'MyProfile': //Display my profile //It is easier to re-generate the profile form rather than using the original one $form = new Form('user_profile', 'POST', '/Store/MyAccount/&action=MyProfile'); $form->addElement('static', 'a_username', 'Username'); $form->addElement('password', 'a_password', 'Password'); $form->addElement('password', 'a_password_confirm', 'Confirm Password'); $form->addElement('text', 'a_name', 'Full Name'); //$form->addElement( 'text', 'a_email', 'Email Address'); $form->addElement('checkbox', 'a_join_newsletter', 'Sign me up for your E-Newsletter'); $form->addElement('submit', 'a_submit', 'Save'); $user = new User($userId); $defaultValues['a_username'] = $user->getUsername(); $defaultValues['a_name'] = $user->getName(); //$defaultValues ['a_email'] = $user->getEmail(); $defaultValues['a_password'] = null; $defaultValues['a_password_confirm'] = null; $defaultValues['a_join_newsletter'] = $user->getJoinNewsletter(); $form->setDefaults($defaultValues); $form->addRule('a_name', 'Please enter the user\'s name', 'required', null); //$form->addRule( 'a_email', 'Please enter an email address', 'required', null ); //$form->addRule( 'a_email', 'Please enter a valid email address', 'email', null ); $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null); if (isset($_REQUEST['a_submit']) && $form->validate()) { if ($_REQUEST['a_password'] != '') { $user->setPassword($_REQUEST['a_password']); } $user->setName($_REQUEST['a_name']); if (!@$_REQUEST['a_join_newsletter']) { $_REQUEST['a_join_newsletter'] = 0; } $user->setJoinNewsletter($_REQUEST['a_join_newsletter']); //$user->setEmail($_REQUEST['a_email']); $user->save(); $this->smarty->assign('profileHasBeenChanged', 1); } $this->smarty->assign('form', $form); //After displaying the "standard" user profile, display all the extra fields such as shipping address, billing address, and phone number $userDetails = UserDetails::getUserDetailsBasedOnUserId($userId); $this->smarty->assign('userDetails', $userDetails); return $this->smarty->fetch("MyProfile.tpl"); break; case 'MyOrders': //Display all the orders that this user has made, and display the details of a particular order through an ajax call if (@$_REQUEST["order_id"]) { $order = new Order($_REQUEST["order_id"]); if ($order->getUser() != $userId) { //Make sure users cannot view orders that do not belong to them return 'Order does not belong to you'; } $orderItems = OrderDetail::getAll($_REQUEST["order_id"]); $orderComments = OrderComment::getAll($order->getId()); $this->smarty->assign('order', $order); $this->smarty->assign('orderItems', $orderItems); $this->smarty->assign('orderComments', $orderComments); return $this->smarty->fetch("admin/OrderDetail.tpl"); } $this->addJS('/js/facebox.js'); $this->addCSS('/css/facebox.css'); $results = Order::getAll(true, $userId); $this->smarty->assign('results', $results); return $this->smarty->fetch("MyOrders.tpl"); break; } return $this->smarty->fetch("MyAccount.tpl"); }