Inheritance: extends Controller
コード例 #1
0
 /**
  * Checks with the view what the user wants to do and dispatches actions to model, view and controllers
  *
  * Should be called from index to start app
  *
  * @return  string or redirect to self// Is this relly good structure?
  */
 public function indexAction()
 {
     $message = null;
     $view = null;
     $dtv = new \view\DateTimeView();
     if ($this->navigationView->doesUserWantToSeeRegPage()) {
         $view = new \view\RegistrationView();
         $regController = new RegistrationController($this->userCollection, $view);
         $message = $regController->indexAction();
         if ($this->userCollection->getRegistrationSucceeded()) {
             $this->navigationView->redirectTo($message, '');
         }
     } else {
         if ($this->navigationView->doesUserWantToSeeLoginPage()) {
             $view = new \view\LoginView($this->loginModel);
             $loginController = new LoginController($this->loginModel, $view);
             $message = $loginController->indexAction();
             if ($this->loginModel->checkLoginStatus() && isset($message)) {
                 $this->navigationView->redirectTo($message);
             }
         }
     }
     if (!isset($message)) {
         $message = $this->navigationView->getSessionMessage();
     }
     return $this->layoutView->render($view, $dtv, $this->navigationView, $message);
 }
コード例 #2
0
ファイル: RouteController.php プロジェクト: audef1/myShop
 public function renderView()
 {
     if (!isset($_SESSION['cart'])) {
         $cart = new Cart();
         $_SESSION['cart'] = serialize($cart);
     }
     foreach ($this->model->getUris() as $key => $value) {
         if (preg_match("#^{$value}\$#", $this->uriView)) {
             if ($this->model->getView($key) === "PageView") {
                 $pagecontroller = new PageController($this->additionalParam);
                 $pagecontroller->renderView();
             } else {
                 if ($this->model->getView($key) === "ProductView") {
                     $productscontroller = new ProductsController();
                     $productscontroller->renderView();
                 } else {
                     if ($this->model->getView($key) === "SingleProductView") {
                         $singleproductcontroller = new SingleProductController($this->additionalParam);
                         $singleproductcontroller->renderView();
                     } else {
                         if ($this->model->getView($key) === "LoginView") {
                             $logincontroller = new LoginController($this->additionalParam);
                             $logincontroller->renderView();
                         } else {
                             if ($this->model->getView($key) === "CustomerView") {
                                 $customercontroller = new CustomerController();
                                 $customercontroller->renderView();
                             } else {
                                 if ($this->model->getView($key) === "CartView") {
                                     $cartcontroller = new CartController($this->additionalParam);
                                     $cartcontroller->renderView();
                                 } else {
                                     if ($this->model->getView($key) === "ContactView") {
                                         $contactcontroller = new ContactController($this->additionalParam);
                                         $contactcontroller->renderView();
                                     } else {
                                         if ($this->model->getView($key) === "RegisterView") {
                                             $registrationcontroller = new RegistrationController($this->additionalParam);
                                             $registrationcontroller->renderView();
                                         } else {
                                             if ($this->model->getView($key) === "CheckoutView") {
                                                 $checkoutcontroller = new CheckoutController($this->additionalParam);
                                                 $checkoutcontroller->renderView();
                                             } else {
                                                 $useView = $this->model->getView($key);
                                                 $view = new $useView();
                                                 $view->render();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: MasterController.php プロジェクト: ehamrin/1dv608
 public function handleInput()
 {
     if ($this->navigationView->inRegistration()) {
         $registration = new RegistrationController($this->navigationView, $this->registrationView, $this->registrationModel);
         if (!$registration->DoRegister()) {
             $this->view = $registration->GetView();
         }
     } else {
         $login = new LoginController($this->navigationView, $this->loginModel, $this->loginView);
         $login->DoLogin();
         $this->view = $login->GetView();
     }
 }
コード例 #4
0
 protected function afterRecordsCreated($event)
 {
     $this->personIdent->setScenario('insert');
     $this->personIdent->profile_id = $event->params['profile']->user_id;
     $this->personIdent->save();
     parent::afterRecordsCreated($event);
 }
コード例 #5
0
ファイル: routes.php プロジェクト: rostik404/TestProject
<?php

$app->get('/', function () use($app) {
    require 'controllers/MainController.php';
    $controller = new MainController();
    $controller->index($app);
});
$app->post('/registration', function () use($app) {
    require 'controllers/RegistrationController.php';
    require 'models/RegistrationModel.php';
    $controller = new RegistrationController();
    $controller->index($app);
});
$app->post('/auth', function () use($app) {
    require 'controllers/AuthController.php';
    require 'models/AuthModel.php';
    $controller = new AuthController();
    $controller->index($app);
});
コード例 #6
0
 public function actionCreate()
 {
     if (User::model()->isAuthor()) {
         $this->redirect('/');
     }
     if (isset($_GET['iframe']) and $_GET['iframe'] == 'yes') {
         $iframe = true;
     } else {
         $iframe = false;
     }
     $model = new Zakaz();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->isGuest) {
         Yii::app()->theme = 'client';
         $user = new RegistrationForm();
         if (isset($_POST['RegistrationForm'])) {
             Yii::import('user.controllers.RegistrationController');
             if (RegistrationController::register($user, $_POST['RegistrationForm'])) {
             }
         }
     }
     $isGuest = Yii::app()->user->isGuest;
     $new = true;
     $agreementNotAccepted = null;
     $messageForCustomer = null;
     if (!$isGuest && self::createProject($model, $_POST['Zakaz'])) {
         if (User::model()->isManager()) {
             $this->redirect(Yii::app()->createUrl('/project/zakaz/update', array('id' => $model->id)));
         } else {
             $new = false;
             $agreementNotAccepted = Templates::model()->getTemplate(Templates::TYPE_FOR_MANAGER_AGREEMENT_NOT_ACCEPTED);
             $messageForCustomer = Templates::model()->getTemplate(Templates::TYPE_FOR_CUSTOMER_AGREEMENT_NOT_ACCEPTED);
         }
     } else {
         $model->attributes = $_POST['Zakaz'];
     }
     if (!isset($model->unixtime) || $model->unixtime == '') {
         $model->unixtime = time();
     }
     if ($iframe) {
         $this->layout = '//layouts/iframe';
     }
     $this->render('create', array('model' => $model, 'isGuest' => $isGuest, 'user' => $user, 'new' => $new, 'agreementNotAccepted' => $agreementNotAccepted, 'messageForCustomer' => $messageForCustomer));
 }
コード例 #7
0
 public function changePasswordComplete($url_hash_email, $email)
 {
     $newPassword = Input::get('newInput');
     $encrypt_id = RegistrationController::encryptPassword($email);
     $encrypt_id = str_replace('/', '', $encrypt_id);
     if ($encrypt_id == $url_hash_email) {
         $resultSet = $this->GlobalModel->getModelRowListByColumnName('tbl_users', 'id', $email, null);
         $_userEmail = null;
         $input_fname = null;
         $input_lname = null;
         foreach ($resultSet as $var) {
             $_userEmail = $var->user_email;
             $input_fname = $var->user_fname;
             $input_lname = $var->user_lname;
         }
         /** peform password encryption*/
         $hash_password = RegistrationController::encryptPassword($newPassword);
         $updateArr = array('user_password' => $hash_password, 'user_changepass' => 'changed');
         $whereArr = array('id' => $email);
         $data = $this->GlobalModel->updateModel('tbl_users', $whereArr, $updateArr);
         //bokbok
         $theme = Theme::uses('homepage')->layout('default');
         return $theme->of('home.PasswordChangeSuccess')->render();
     }
 }
コード例 #8
0
ファイル: plugin.php プロジェクト: useada/freech-1
function registration_mail_send(&$api, &$user)
{
    $subject = _('Your registration at [SITE_TITLE]');
    $body = _("Hello [FIRSTNAME] [LASTNAME],\n" . "\n" . "Thank you for registering at" . " [SITE_TITLE]. Your account name" . " is \"[LOGIN]\".\n" . "\n" . "Please confirm your email address by" . " clicking the registration link below." . "\n" . "[URL]\n");
    $username = urlencode($user->get_name());
    $hash = urlencode($user->get_confirmation_hash());
    $url = cfg('site_url') . '?action=account_confirm' . "&username={$username}&hash={$hash}";
    $api->send_mail($user, $subject, $body, array('url' => $url));
    include_once dirname(__FILE__) . '/registration_controller.class.php';
    $controller = new RegistrationController($api);
    $controller->show_mail_sent($user);
}
コード例 #9
0
 public function processOrderPage()
 {
     $message = false;
     $login_ok = false;
     if (!Yii::app()->user->isGuest && User::model()->isCustomer()) {
         $login_ok = true;
     }
     if (!$login_ok && isset($_POST['Login'])) {
         if (Yii::app()->user->isGuest) {
             $model = new UserLogin();
             //$this->performAjaxValidation($model);
             // collect user input data
             $model->attributes = $_POST['Login'];
             // validate user input and redirect to previous page if valid
             if ($model->validate()) {
                 //$this->lastViset();
                 $login_ok = true;
             } else {
                 $message = 'Incorrect login or password';
                 //Yii::app()->end();
             }
         }
     }
     if (!$login_ok && isset($_POST['User'])) {
         $model = new User();
         $attributes = $_POST['User'];
         //$attributes['full_name'] =  $_POST['User']['first_name'].' '.$_POST['User']['last_name'];
         $pos = strpos($attributes['email'], '@');
         $attributes['username'] = str_replace(array('@', '.'), '_', $attributes['email']);
         // substr( $attributes['email'], 0, $pos);
         $attributes['full_name'] = $_POST['User']['first_name'] . ' ' . $_POST['User']['last_name'];
         unset($attributes['first_name']);
         unset($attributes['last_name']);
         $p = $_POST['Profile'];
         $country = $p['country'];
         $countryCodes = $this->getCountryCodes();
         $code = $countryCodes[$country];
         $attributes['phone_number'] = '+' . $code . $attributes['phone_number'];
         Yii::import('user.controllers.RegistrationController');
         if (RegistrationController::register($model, $attributes)) {
             $login_ok = true;
             $profile = new Profile();
             $profile->user_id = $model->id;
             $profile->country = $country;
             $profile->save();
         } else {
             if ($attributes['email'] != '') {
                 $message = 'Sorry, registration faild...<br>';
                 foreach ($model->errors as $err => $descr) {
                     $message .= $descr[0] . '<br>';
                 }
             }
         }
     }
     $model = new Zakaz();
     $model->attributes = $_POST['Zakaz'];
     // (unixtime)
     if ($login_ok) {
         Yii::import('project.controllers.ZakazController');
         if (ZakazController::createProject($model, $_POST['Project'])) {
             $cost = $this->calculateCost($model);
             $payment = new ProjectPayments();
             $payment->order_id = $model->id;
             $payment->project_price = $cost;
             $payment->received = 0;
             $payment->to_receive = $cost;
             $payment->work_price = 0;
             $payment->payed = 0;
             $payment->to_pay = 0;
             $payment->save();
             if (Campaign::getPayment2Chekout() != 0) {
                 $user = User::model()->with('profile')->findByPk($model->user_id);
                 $data = array('sid' => Campaign::getPayment2Chekout(), 'mode' => '2CO', 'li_0_type' => 'product', 'li_0_name' => 'order' . $model->id, 'li_0_price' => $cost, 'li_0_product_id' => $model->id, 'x_receipt_link_url' => 'http://' . $_SERVER["HTTP_HOST"] . '/project/payment/affiliatePayment', 'card_holder_name' => $user->full_name, 'country' => $user->profile->country, 'email' => $user->email, 'phone' => $user->phone_number);
                 $this->redirectWithPost('https://2checkout.com/checkout/purchase', $data);
             }
             echo 'Ok! Cost = ' . $cost;
             Yii::app()->end();
         } else {
             //echo 'Project is not valid!!<br>';
             //print_r($_POST['Project']);
             //Yii::app()->end();
             $message = 'Please complete all required fields.';
         }
     }
     if (!isset($model->unixtime) or $model->unixtime == '') {
         $model->unixtime = time();
     }
     Yii::app()->theme = explode('.', $_SERVER['SERVER_NAME'])[0];
     $this->render('page/order', array('logged' => $login_ok, 'message' => $message, 'project' => $model, 'countryCodes' => $this->getCountryCodes()));
     Yii::app()->end();
 }