当前位置: 首页>>代码示例>>PHP>>正文


PHP User_Model::getFormFields方法代码示例

本文整理汇总了PHP中User_Model::getFormFields方法的典型用法代码示例。如果您正苦于以下问题:PHP User_Model::getFormFields方法的具体用法?PHP User_Model::getFormFields怎么用?PHP User_Model::getFormFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User_Model的用法示例。


在下文中一共展示了User_Model::getFormFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authorization

    public function authorization()
    {
        //-----------------------------------------------\\
        // This is the MIDDLE checkout page where the    \\
        // user info that was received is processed      \\
        // and inserted/updated in the DB before         \\
        // sending the user along to the payment segment \\
        //-----------------------------------------------\\
        // $db=new Database;
        // In Kohana, all views are loaded and treated as objects.
        $this->template->content = new View('authorization');
        // Meta Description and Meta Keywords for individual pages are, at this point, hard coded.
        $this->template->metaDescription = $this->description;
        $this->template->metaKeywords = $this->keywords;
        $this->template->metaTitle = $this->title;
        $this->template->title = $this->title;
        $formFields = User_Model::getFormFields();
        //USER
        if (User_Model::logged_in()) {
            $user = User_Model::logged_user();
        } else {
            $user = ORM::factory('user');
            $user->email = $_POST['userEmail'];
            $user->password = $_POST['userPassword'];
            foreach ($formFields['billing'] as $field) {
                $user->{$field->db_name} = $_POST[$field->formName];
            }
            $user->site_id = self::getCurrentSite()->id;
            $user->save();
            $user->forceLogin();
            Autoresponder::sendEmail('user.registration', $user->email, $user, array('new_pass' => $_POST['userPassword']));
        }
        $user->newsletter = isset($_POST["email-updates"]) ? 1 : 0;
        $user->save();
        $user_billing_info = ORM::factory('user_billing_info');
        $user_billing_info->user_id = $user->id;
        foreach ($formFields['billing'] as $field) {
            if (isset($_POST[$field->formName])) {
                $user_billing_info->{$field->db_name} = $_POST[$field->formName];
            }
        }
        $user_billing_info->save();
        $user_shipping_info = ORM::factory('user_shipping_info');
        $user_shipping_info->user_id = $user->id;
        foreach ($formFields['shipping'] as $field) {
            if (isset($_POST[$field->formName])) {
                $user_shipping_info->{$field->db_name} = $_POST[$field->formName];
            }
        }
        if (isset($_POST[$field->formName])) {
            $_SESSION["shipping" . "{$field->formName}"] = $_POST[$field->formName];
        }
        $user_shipping_info->save();
        //like the ->reload() function doesn't have into account the relations, this refresh the object and will load the new shipping and billing in case they are needed.
        $user = ORM::factory('user', $user->id);
        //ORDER
        $order = ORM::factory('order')->getCurrentOrder();
        $order->can_share = isset($_POST["share"]) ? 1 : 0;
        //shipping
        $shippingMethod = ORM::factory('shipping_method')->find($_POST['shippingMethod']);
        $shippingcost = $shippingMethod->getRateForPrice($order->subtotal)->price;
        if ($_POST['shippingCountry'] == "CA") {
            $shippingcost += 30;
        }
        $order->shipping_method_id = $shippingMethod->id;
        $order->shipping_total = $shippingcost;
        //user into order
        $order->user_id = $user->id;
        $order->shippingID = $user->user_shipping_info->id;
        $order->billingID = $user->user_billing_info->id;
        //last details and save
        $order->order_delivery_date = $_POST["requesteddate"];
        $order->date_modified = time();
        $order->save();
        //total and subtotal
        $order->refreshTotals();
        //like the ->reload() function doesn't have into account the relations, this refresh the object and will load the new shipping and billing in case they are needed.
        $order = ORM::factory('order', $order->id);
        //FOR NEXT FORM
        $this->template->content->user = $user;
        $this->template->content->order = $order;
        // Send final few pieces of data as variables to the template
        $this->template->content->requesteddate = $order->order_delivery_date;
        // After all the alterations and everything have been made, select the basket and pass on the this of items to the template
        $db = new Database();
        $resultall = $db->query('
							SELECT 
								orders_baskets.*, 
								orders_baskets.id as orders_basket_id, 
								products.name as productname, 
								products_descriptions.image as productimage, 
								products_descriptions.image_alt 
							FROM orders_baskets 
							LEFT JOIN products 
								ON orders_baskets.product_id = products.id 
							LEFT JOIN products_descriptions 
								ON products.products_description_id = products_descriptions.id 
							WHERE orders_baskets.order_id = ' . $order->id);
        $this->template->content->itemsresults = $resultall;
    }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:100,代码来源:shopping_cart.php

示例2: register

 public function register()
 {
     if (User_Model::logged_in()) {
         url::redirect('/customers/my_account');
     }
     $this->template->content = new View('customers/register');
     $this->template->metaDescription = $this->description;
     $this->template->metaKeywords = $this->keywords;
     $this->template->metaTitle = $this->title;
     $this->template->title = $this->title;
     $formFields = User_Model::getFormFields();
     if (User_Model::logged_in()) {
         $user = User_Model::logged_user();
         $this->template->content->user = $user;
         foreach ($formFields as $section => &$fields) {
             if ($section == 'user') {
                 continue;
             }
             foreach ($fields as &$field) {
                 switch ($field->form) {
                     case 'billing':
                         $field->value = $user->user_billing_info->{$field->db_name};
                         break;
                     case 'shipping':
                         $field->value = $user->user_shipping_info->{$field->db_name};
                         break;
                 }
             }
         }
     }
     $this->template->content->formFields = $formFields;
     $this->template->content->countries = ORM::factory('country')->find_all();
     $this->template->content->states = ORM::factory('state')->find_all();
     if (request::method() === 'post') {
         $post = new Validation($_POST);
         $post->add_rules('email', 'email');
         $post->add_rules('password', 'required');
         $post->add_rules('first_name', 'required');
         $post->add_rules('last_name', 'required');
         $post->add_rules('address_1', 'required');
         $post->add_rules('city', 'required');
         $post->add_rules('state', 'required');
         $post->add_rules('zip', 'required');
         $post->add_rules('country', 'required');
         $post->add_rules('phone', 'required');
         if ($post->validate()) {
             $db = new Database();
             //$auth = _Auth::factory();
             $user = ORM::factory('user');
             $user->email = $post->email;
             $user->password = $post->password;
             $user->firstname = $post->first_name;
             $user->lastname = $post->last_name;
             $user->company = $post->company;
             $user->address1 = $post->address_1;
             $user->address2 = $post->address_2;
             $user->city = $post->city;
             $user->state = $post->state;
             $user->zip = $post->zip;
             $user->country = $post->country;
             $user->phone1 = $post->phone;
             $user->phone2 = $post->second_phone;
             $user->save();
             unset($user);
             $id = $db->query("SELECT id\n\t\t\t\t\t\t\t\t  FROM users\n\t\t\t\t\t\t\t\t  WHERE email = '{$post->email}'");
             //print_r(mysql_fetch);
             foreach ($id as $keys => $value) {
                 //	echo 'Key: '. $keys."<br>";
                 if (is_object($value)) {
                     foreach ($value as $vkeys => $vvalue) {
                         //			echo 'VKeys: '.$vkeys."<br>";
                         //			echo 'VValue: '.$vvalue."<br>";
                         if ($vkeys == 'id') {
                             $id = $vvalue;
                         }
                     }
                 } else {
                     //	echo 'Value: '.$value."<br>";
                 }
             }
             //die();
             if (!$post->address_2) {
                 $post->address_2 = "none";
             }
             if (!$post->second_phone) {
                 $post->second_phone = "none";
             }
             $billing = $db->query("INSERT into user_billing_infos\n\t\t\t\t\t\t\tSET user_id = '{$id}', \n\t\t\t\t\t\t\tfirstname = '{$post->first_name}',\n\t\t\t\t\t\t\tlastname = '{$post->last_name}',\n\t\t\t\t\t\t\tcompany = '{$post->company}',\n\t\t\t\t\t\t\taddress1 = '{$post->address_1}',\n\t\t\t\t\t\t\taddress2 = '{$post->address_2}',\n\t\t\t\t\t\t\tcity = '{$post->city}',\n\t\t\t\t\t\t\tstate = '{$post->state}',\n\t\t\t\t\t\t\tzip = '{$post->zip}',\n\t\t\t\t\t\t\tcountry = '{$post->country}',\n\t\t\t\t\t\t\tphone1 = '{$post->phone}',\n\t\t\t\t\t\t\tphone2 = '{$post->second_phone}'\n\t\t\t\t\t\t\t");
             //$results = $db->excute();
             // $user = ORM::factory('user_billing_infos');
             // $user->email = $post->email;
             // $user->password = md5($post->password);
             // $user->firstname = $post->first_name;
             // $user->lastname = $post->last_name;
             // $user->company = $post->company;
             // $user->address1 = $post->address_1;
             // $user->address2 = $post->address_2;
             // $user->city = $post->city;
             // $user->state = $post->state;
             // $user->zip = $post->zip;
//.........这里部分代码省略.........
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:101,代码来源:customers.php


注:本文中的User_Model::getFormFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。