public static function getRegistrationHhtml(&$obj, &$OPCloader)
 {
     // if (!empty($no_login_in_template)) return "";
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!empty($obj->cart)) {
         $cart =& $obj->cart;
     } else {
         $cart = VirtueMartCart::getCart();
     }
     $type = 'BT';
     // for unlogged
     $virtuemart_userinfo_id = 0;
     $new = 1;
     $fieldtype = $type . 'address';
     /*
     if (method_exists($cart, 'prepareAddressDataInCart'))
     $cart->prepareAddressDataInCart($type, $new);
     */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::populateCart($cart, $type, true);
     /*
     if (method_exists($cart, 'prepareAddressFieldsInCart'))
     $cart->prepareAddressFieldsInCart();
     */
     OPCloader::setRegType();
     if (!class_exists('VirtuemartModelUserfields')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php';
     }
     $corefields = VirtueMartModelUserfields::getCoreFields();
     $userFields = $cart->{$fieldtype};
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $layout = 'default';
     foreach ($userFields['fields'] as $key => $uf) {
         if (!in_array($key, $corefields) || $key == 'agreed') {
             unset($userFields['fields'][$key]);
             continue;
         }
         if (!empty($opc_email_in_bt) || $OPCloader->isNoLogin() || $OPCloader->isNoLogin()) {
             if ($userFields['fields'][$key]['name'] == 'email') {
                 unset($userFields['fields'][$key]);
                 continue;
             }
         }
         if ($key == 'email') {
             $user = JFactory::getUser();
             $uid = $user->get('id');
             // user is logged, but does not have a VM account
             if (!OPCloader::logged($cart) && !empty($uid)) {
                 // the user is logged in only in joomla, but does not have an account with virtuemart
                 $userFields['fields'][$key]['formcode'] = str_replace('/>', ' readonly="readonly" />', $userFields['fields'][$key]['formcode']);
             }
         }
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::getUserFields($userFields, $OPCloader, $cart);
     // lets move email to the top
     $copy = array();
     // we will reorder the fields, so the email is first when used as username
     $u = OPCLang::_('COM_VIRTUEMART_REGISTER_UNAME');
     //$e = OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL');
     // disable when used for logged in
     if (!empty($userFields['fields'])) {
         /*
              if (empty($opc_email_in_bt) && (!empty($double_email)))
         {
           // email is in BT, let's check for double mail
         		
         		$email2 = $userFields['fields']['email'];
         		$email2['name'] = 'email2'; 
         		$title = OPCLang::_('COM_ONEPAGE_EMAIL2'); 
         		if ($title != 'COM_ONEPAGE_EMAIL2')
         		$email2['title'] = $title;
         		$email2['formcode'] = str_replace('"email', '"email2', $email2['formcode']); 
         		$email2['formcode'] = str_replace('id=', ' onblur="javascript: doublemail_checkMail();" id=', $email2['formcode']);
         		
         		$h = '<span style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email2_info" class="email2_class">';
         		$emailerr = OPCLang::_('COM_ONEPAGE_EMAIL_DONT_MATCH');
         		if ($emailerr != 'COM_ONEPAGE_EMAIL_DONT_MATCH')
         		$h .= $emailerr;
         		else $h .= "Emails don't match!";
         		$h .= '</span>';
         		$email2['formcode'] .= $h;
         }
         */
         /*
         	 if (!empty($opc_check_username))
         	 if ((!OPCloader::logged($cart)) && (empty($uid)))
         	 if (!empty($userFields['fields']['username']))
         {
          
            $un = $userFields['fields']['username']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.username_check(this);" id=', $un);
         		 $un .=  '<span class="username_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="username_already_exists">';
         		 $un .= OPCLang::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', $u); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['username']['formcode'] = $un; 
         }
         */
         /*
         if (!empty($opc_check_email))
         if ((!OPCloader::logged($cart)) && (empty($uid)))
         if (!empty($userFields['fields']['email']))
         {
         
            $un = $userFields['fields']['email']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un);
         		 $un .=  '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">';
         		 $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL')); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['email']['formcode'] = $un; 
         }
         */
     }
     /*
     	$OPCloader->reorderFields($userFields); 
     */
     if (count($userFields['fields']) === 0) {
         // no fields found
         return '';
     }
     //if (empty($opc_email_in_bt) && (!empty($double_email)))
     //$OPCloader->insertAfter($userFields['fields'], 'email', $email2, 'email2');
     $vars = array('rowFields' => $userFields, 'cart' => $obj, 'is_registration' => true);
     $html = $OPCloader->fetch($OPCloader, 'list_user_fields.tpl', $vars);
     $html = str_replace("'password'", "'opc_password'", $html);
     $html = str_replace("password2", "opc_password2", $html);
     if (strpos($html, 'email_field') !== false) {
         $html .= '<input type="hidden" name="email_in_registration" value="1" id="email_in_registration" />';
     } else {
         $html .= '<input type="hidden" name="email_in_registration" value="0" id="email_in_registration" />';
     }
     return $html;
 }
Example #2
0
 function getBTfields(&$obj, $unlg = false, $no_wrapper = false)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $default_shipping_country = OPCloader::getDefaultCountry($cart);
     // $default_shipping_country
     $islogged = OPCloader::logged($obj->cart);
     if ($islogged && empty($unlg)) {
         return $this->getUserInfoBT($obj);
     } else {
         if (!class_exists('VirtueMartCart')) {
             require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
         }
         if (!empty($obj->cart)) {
             $cart =& $obj->cart;
         } else {
             $cart = VirtueMartCart::getCart();
         }
         $type = 'BT';
         $this->address_type = 'BT';
         // for unlogged
         $virtuemart_userinfo_id = 0;
         $this->virtuemart_userinfo_id = 0;
         $new = 1;
         if (!empty($unlg)) {
             $new = false;
         }
         $fieldtype = $type . 'address';
         if (empty($cart->BT)) {
             $cart->BT = array();
         }
         $user = JFactory::getUser();
         $uid = $user->get('id');
         // PPL Express address:
         $moveBT = false;
         $count = 0;
         if (!empty($cart->savedST)) {
             if (!$islogged) {
                 foreach ($cart->savedST as $key => $val) {
                     if ($key == 'virtuemart_country_id') {
                         continue;
                     }
                     if ($key == 'virtuemart_state_id') {
                         continue;
                     }
                     if (substr($key, 0, 7) === 'shipto_') {
                         continue;
                     }
                     if (empty($cart->BT[$key]) && !empty($val)) {
                         $count++;
                     } else {
                         if (!empty($cart->BT[$key]) && $val != $cart->BT[$key]) {
                             $count--;
                         }
                     }
                 }
                 if ($count > 0) {
                     if ($cart->savedST['virtuemart_country_id'] != $cart->BT['virtuemart_country_id']) {
                         $cart->BT['virtuemart_state_id'] = 0;
                     }
                     foreach ($cart->savedST as $key => $val) {
                         if (!empty($val)) {
                             $cart->BT[$key] = $val;
                         }
                     }
                 }
             }
         }
         if (empty($cart->BT['virtuemart_country_id'])) {
             if (!empty($default_shipping_country) && is_numeric($default_shipping_country)) {
                 $cart->BT['virtuemart_country_id'] = $default_shipping_country;
             } else {
                 // let's set a default country
                 $vendor = $this->getVendorInfo($cart);
                 $cart->BT['virtuemart_country_id'] = $vendor['virtuemart_country_id'];
             }
         }
         /*
         if (!empty($cart->BT) && (count($cart->BT)>2)) $new = false;    
         if (empty($cart->BT)) $new = true; 
         */
         $type = 'BT';
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
         OPCUserFields::populateCart($cart, $type, true);
         OPCloader::setRegType();
         $op_disable_shipto = OPCloader::getShiptoEnabled($cart);
         if (!class_exists('VirtuemartModelUserfields')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php';
         }
         $corefields = VirtueMartModelUserfields::getCoreFields();
         $userFields = $cart->{$fieldtype};
         if (isset($cart->BTaddress) && isset($cart->BTaddress['fields']) && isset($cart->BTaddress['fields']['virtuemart_country_id']) && !empty($cart->BTaddress['fields']['virtuemart_country_id']['value'])) {
             if (is_numeric($cart->BTaddress['fields']['virtuemart_country_id']['value'])) {
                 $cart->BT['virtuemart_country_id'] = $cart->BTaddress['fields']['virtuemart_country_id']['value'];
             }
         }
         // unset corefields
         $onlyf = array();
         if (empty($bt_fields_from)) {
             $q = 'select name from #__virtuemart_userfields where published=1 and registration = 1';
             $db = JFactory::getDBO();
             $db->setQuery($q);
             $onlyf2 = $db->loadAssocList();
             foreach ($onlyf2 as $k => $v) {
                 $onlyf[] = $v['name'];
             }
         }
         if (!empty($userFields['fields'])) {
             foreach ($userFields['fields'] as $key => $uf) {
                 // disable fields that are not marked for registration
                 if (!empty($onlyf)) {
                     if (!in_array($uf['name'], $onlyf)) {
                         unset($userFields['fields'][$key]);
                         continue;
                     }
                 }
                 $userFields['fields'][$key]['formcode'] = str_replace('vm-chzn-select', '', $userFields['fields'][$key]['formcode']);
                 OPCloader::$fields_names[$key] = $userFields['fields'][$key]['title'];
                 if ($userFields['fields'][$key]['type'] == 'delimiter') {
                     unset($userFields['fields'][$key]);
                     continue;
                 }
                 foreach ($corefields as $f) {
                     if ($f == $uf['name']) {
                         // will move the email to bt section
                         if (empty($no_login_in_template) || $unlg) {
                             if ($f == 'email') {
                                 if (empty($opc_email_in_bt)) {
                                     if (!$this->isNoLogin()) {
                                         unset($userFields['fields'][$key]);
                                     }
                                 }
                             } else {
                                 unset($userFields['fields'][$key]);
                             }
                             continue;
                         }
                     }
                 }
                 if (empty($custom_rendering_fields)) {
                     $custom_rendering_fields = array();
                 }
                 if (!empty($custom_rendering_fields)) {
                     if (in_array($uf['name'], $custom_rendering_fields)) {
                         unset($userFields['fields'][$key]);
                         continue;
                     }
                 }
                 if ($key == 'name') {
                     if (!empty($op_no_display_name)) {
                         if (!empty($userFields['fields']['name'])) {
                             unset($userFields['fields']['name']);
                         }
                     }
                 }
             }
         }
         // end of for each
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
         $skipreorder = array('email');
         OPCUserFields::getUserFields($userFields, $this, $cart, array(), array(), $skipreorder);
         // logic reversed, if email is not in BT, remove it
         if (!((!empty($opc_email_in_bt) || $this->isNoLogin()) && !empty($double_email))) {
             unset($userFields['fields']['email2']);
             // email is in BT, let's check for double mail
         }
         $skipreorder = array();
         if (!empty($opc_email_in_bt) || $this->isNoLogin()) {
             $skipreorder[] = 'email';
             if (!empty($opc_check_email)) {
                 if (!OPCloader::logged($cart) && empty($uid)) {
                     if (!empty($userFields['fields']['email'])) {
                         $un = $userFields['fields']['email']['formcode'];
                         if (stripos($un, 'id="email_already_exists"') === false) {
                             //if (!$double_email)
                             $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un);
                             $un .= '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">';
                             $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL'));
                             $un .= '</span>';
                             $userFields['fields']['email']['formcode'] = $un;
                         }
                     }
                 }
             }
         }
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
         OPCUserFields::reorderFields($userFields, $skipreorder);
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $this->_model = OPCmini::getModel('user');
         //new VirtuemartModelUser();
         $layout = 'default';
         $hidden = array();
         $hidden_html = '';
         if (!empty($userFields['fields'])) {
             foreach ($userFields['fields'] as $key => $val) {
                 if (!empty($val['hidden'])) {
                     $hidden[] = $val;
                     $hidden_html .= $val['formcode'];
                     unset($userFields['fields'][$key]);
                 }
             }
         }
         $vars = array('rowFields' => $userFields, 'cart' => $obj, 'is_logged' => $unlg);
         $html = $this->fetch($this, 'list_user_fields.tpl', $vars);
         $hidden_html = str_replace('"required"', '""', $hidden_html);
         $html .= $hidden_html;
         $html = $this->addListeners($html);
         if (empty($custom_rendering_fields)) {
             $custom_rendering_fields = array();
         }
         if (in_array('virtuemart_country_id', $custom_rendering_fields)) {
             $html .= '<input type="hidden" id="virtuemart_country_id" name="virtuemart_country_id" value="' . $default_shipping_country . '" />';
         }
         if (in_array('virtuemart_state_id', $custom_rendering_fields)) {
             $html .= '<input type="hidden" id="virtuemart_state_id" name="virtuemart_state_id" value="0" />';
         }
         return $html;
     }
 }
Example #3
0
 function opcregister()
 {
     if (!class_exists('OPCLang')) {
         require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     }
     OPCLang::loadLang();
     $this->checkVM2Captcha('index.php?option=com_virtuemart&view=user');
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $msg = '';
     //$this->saveData(false,true);
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     $data = JRequest::get('post');
     $userinfo_id = (int) JRequest::getInt('virtuemart_userinfo_id', 0);
     $data['address_type'] = JRequest::getWord('addrtype', JRequest::getWord('address_type', 'BT'));
     if ($data['address_type'] == 'BT') {
         $prefix = '';
         $data['shipto_virtuemart_userinfo_id'] = null;
     } else {
         $prefix = 'shipto_';
         $data['shipto_virtuemart_userinfo_id'] = $userinfo_id;
     }
     $data['quite'] = false;
     $adminmode = false;
     // logged in users
     if (!empty($userinfo_id)) {
         $q = 'select * from #__virtuemart_userinfos where virtuemart_userinfo_id = ' . $userinfo_id . ' limit 0,1';
         $db = JFactory::getDBO();
         $db->setQuery($q);
         $res = $db->loadAssoc();
         // if user is already registered:
         $user = JFactory::getUser();
         $uidc = (int) $user->get('id');
         $data['virtuemart_user_id'] = $uidc;
         if (!empty($res)) {
             $address_type = $res['address_type'];
             $uid = (int) $res['virtuemart_user_id'];
             if (!empty($uid)) {
                 // 1st security, user ids must match
                 if ($uid != $uidc) {
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
                     if (!OPCmini::isSuperVendor()) {
                         $msg = 'OPC: Access Denied';
                         return $this->returnTerminate($msg);
                     } else {
                         $adminmode = true;
                     }
                 }
                 JRequest::setVar('virtuemart_user_id', $uid);
                 $data['virtuemart_user_id'] = $uid;
             }
         }
         if (!$adminmode) {
             if (empty($data['user_id'])) {
                 $data['user_id'] = $uidc;
                 $data['virtuemart_user_id'] = $uidc;
                 $data[$prefix . 'user_id'] = $uidc;
                 $data[$prefix . 'virtuemart_user_id'] = $uidc;
             }
             $username = $user->get('username');
             $email = $user->get('email');
             if (empty($data['username']) && !empty($username)) {
                 $data['username'] = $username;
                 $data[$prefix . 'username'] = $username;
             } else {
                 if (empty($data['username']) && !empty($email)) {
                     $data['username'] = $email;
                     $data[$prefix . 'username'] = $email;
                 }
             }
             if (empty($data[$prefix . 'email'])) {
                 $data[$prefix . 'email'] = $email;
             }
             $doUpdate = true;
         }
         // address name override:
         if (empty($data[$prefix . 'name'])) {
             if (!empty($res)) {
                 $data[$prefix . 'name'] = $res['address_type_name'];
             } else {
                 $data[$prefix . 'name'] = '';
             }
             if (!empty($data[$prefix . 'first_name'])) {
                 $data['name'] .= $data[$prefix . 'first_name'];
             }
             if (!empty($data[$prefix . 'last_name'])) {
                 $data[$prefix . 'name'] .= $data[$prefix . 'last_name'];
             }
         }
         // end of logged in user
         OPCloader::setRegType();
         //NO_REGISTRATION, NORMAL_REGISTRATION, SILENT_REGISTRATION, OPTIONAL_REGISTRATION
         if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION') {
             $register = false;
         } else {
             if (VM_REGISTRATION_TYPE == 'NORMAL_REGISTRATION') {
                 $register = true;
             } else {
                 if (VM_REGISTRATION_TYPE == 'SILENT_REGISTRATION') {
                     $register = true;
                 } else {
                     if (VM_REGISTRATION_TYPE == 'OPTIONAL_REGISTRATION') {
                         $register = JRequest::getVar('register_account', false);
                     }
                 }
             }
         }
         $mainframe = JFactory::getApplication();
         $msg = '';
         $userModel = OPCmini::getModel('user');
         if ($user->guest != 1 || $register) {
             self::getVendorDataStored($data);
         }
         // update address of already registered user
         /*
         if (!empty($doUpdate))
         {
          $this->userStoreAddress($userModel, $data); 
          return $this->returnTerminate(''); 
         }
         */
     }
     $cart = VirtuemartCart::getCart();
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     OPCShopperGroups::setShopperGroupsController($cart);
     if (method_exists($cart, 'prepareCartData')) {
         $cart->prepareCartData(false);
     }
     $this->prepareFields();
     $this->setCartAddress($cart);
     $this->setExtAddress($cart, false);
     // k2 mod with recaptcha enabled
     $session = JFactory::getSession();
     $orig = $session->get('socialConnectData');
     $session->set('socialConnectData', true);
     // end p1 k2 mod with recaptcha enabled
     $data = JRequest::get('post');
     $reg = JRequest::getVar('register_account');
     if (empty($reg)) {
         $reg = false;
     } else {
         $reg = true;
     }
     if (!isset($data['address_type'])) {
         $data['address_type'] = 'BT';
     }
     if ($data['address_type'] == 'ST') {
         if (!isset($data['ship_to_info_id'])) {
             $data['ship_to_info_id'] = 'new';
         }
         // opc hack:
         $data['sa'] = 'adresaina';
         $suid = JRequest::getVar('shipto_virtuemart_userinfo_id', JRequest::getVar('virtuemart_userinfo_id'));
         if (empty($suid)) {
             $data['opc_st_changed_new'] = true;
         }
         JRequest::setVar('opc_st_changed_new', true);
         JRequest::setVar('sa', 'adresaina');
     }
     $this->saveData($cart, $reg, false, $data);
     if (!empty($allow_sg_update)) {
         $this->storeShopperGroup($data, true);
     }
     $userModel = OPCmini::getModel('user');
     if (method_exists($userModel, 'getCurrentUser')) {
         $user = $userModel->getCurrentUser();
         self::$shopper_groups = $user->shopper_groups;
     }
     // k2 mod with recaptcha enabled
     if (empty($orig)) {
         $session->clear('socialConnectData');
     } else {
         $session->set('socialConnectData', $orig);
     }
     // end p2 k2 mod with recaptcha enabled
     return $this->returnTerminate($msg);
 }
Example #4
0
 function fetch(&$ref, $template, $vars, $new = '')
 {
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     if (defined('OPC_DETECTED_DEVICE') && OPC_DETECTED_DEVICE != 'DESKTOP') {
         if (!empty($mobile_template)) {
             $selected_template = $mobile_template;
         }
     }
     OPCloader::setRegType();
     if (VM_REGISTRATION_TYPE != 'OPTIONAL_REGISTRATION') {
         $op_create_account_unchecked = false;
     }
     if (!empty($ref->cart)) {
         $cart = $ref->cart;
     } else {
         $cart = VirtueMartCart::getCart(false);
     }
     $op_disable_shipping = OPCloader::getShippingEnabled();
     $no_shipping = $op_disable_shipping;
     if (OPCloader::checkOPCSecret()) {
         $selected_template .= '_preview';
     }
     $f = JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'overrides' . DS . $template . '.php';
     //var_dump($f); die();
     if (file_exists($f)) {
         ob_start();
         extract($vars);
         include $f;
         $ret = ob_get_clean();
         return $ret;
     } else {
         if (!empty($new)) {
             $ly = $ref->layoutName;
             if (empty($ly)) {
                 $ly = 'default';
             }
             if (empty($new)) {
                 $new = 'prices';
             }
             if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'cart' . DS . 'tmpl' . DS . $ly . '_' . $new . '.php')) {
                 ob_start();
                 include JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'cart' . DS . 'tmpl' . DS . $ly . '_' . $new . '.php';
                 $ret = ob_get_clean();
                 return $ret;
             }
         }
     }
 }
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Oscar van Eijk
  * @author Max Milbers
  *
  *  Original code from: \components\com_virtuemart\views\user\view.html.php
  *
  */
 function display($tpl = null)
 {
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if (!defined('OPC_IN_REGISTRATION_MODE')) {
         define('OPC_IN_REGISTRATION_MODE', 1);
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     OPCLang::loadLang();
     $this->loadOPC();
     // 	vmdebug('layout by view '.$layoutName);
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = JRequest::getWord('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     if (empty($this->fTask)) {
         $ftask = 'saveUser';
         $this->assignRef('fTask', $ftask);
     }
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     // 	vmdebug('my layoutname',$layoutName);
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (!class_exists('VirtuemartModelUser')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
     }
     $this->_model = new VirtuemartModelUser();
     //		$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     //the cuid is the id of the current user
     $this->_currentUser = JFactory::getUser();
     $this->_cuid = $this->_lists['current_id'] = $this->_currentUser->get('id');
     $this->assignRef('userId', $this->_cuid);
     $this->_userDetails = $this->_model->getUser();
     $this->assignRef('userDetails', $this->_userDetails);
     $address_type = JRequest::getWord('addrtype', 'BT');
     $this->assignRef('address_type', $address_type);
     //New Address is filled here with the data of the cart (we are in the cart)
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $new = false;
     if (JRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', '');
         if (empty($virtuemart_userinfo_id)) {
             require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
             $umodel = OPCmini::getModel('user');
             //new VirtuemartModelUser();
             $uid = JFactory::getUser()->id;
             $userDetails = $umodel->getUser();
             $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
         }
     }
     $this->assignRef('virtuemart_userinfo_id', $virtuemart_userinfo_id);
     $userFields = null;
     if ((strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) && empty($virtuemart_userinfo_id)) {
         $fieldtype = $address_type . 'address';
         if (method_exists($cart, 'prepareAddressDataInCart')) {
             $cart->prepareAddressDataInCart($address_type, $new);
         }
         if (method_exists($cart, 'prepareAddressFieldsInCart')) {
             $cart->prepareAddressFieldsInCart();
         }
         $userFields = $cart->{$fieldtype};
         $task = JRequest::getWord('task', '');
     } else {
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             // 			vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
         $task = 'editaddressST';
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'loader.php';
     /*
     if (!class_exists('VirtueMartCart'))
     	require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
     $this->cart = VirtueMartCart::getCart(); 
     */
     $OPCloader = new OPCloader();
     OPCloader::setRegType();
     $action_url = JURI::root(true) . '/index.php?option=com_onepage&amp;view=opc&amp;controller=opc&amp;task=opcregister&amp;nosef=1';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'javascript.php';
     OPCJavascript::getJavascript($this, $OPCloader, false, $action_url, 'com_onepage', 'opcregister');
     $OPCloader->customizeFieldsPerOPCConfig($userFields);
     OPCloader::loadJavascriptFiles($this);
     $op_formvars = OPCloader::getFormVars($this);
     /*
     	foreach ($userFields['fields'] as $key=>$val)
     {
        if (isset($val['formcode']))
     		{
     		
     		  $val['formcode'] .= $html; 
     		  break; 
     		  
     		}
     }
     */
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = JText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = JText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         if (JVM_VERSION <= 2) {
             $this->shopper($userFields);
         } else {
             $this->shopper3($userFields);
         }
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $this->_lists['shipTo'] = $this->generateStAddressList($this, $this->_model, $task, $cart);
     if ($this->_openTab < 0) {
         $_paneOffset = array();
     } else {
         if (defined('__VM_USER_USE_SLIDERS')) {
             $_paneOffset = array('startOffset' => $this->_openTab, 'startTransition' => 1, 'allowAllClose' => true);
         } else {
             $_paneOffset = array('startOffset' => $this->_openTab);
         }
     }
     // Implement the Joomla panels. If we need a ShipTo tab, make it the active one.
     // In tmpl/edit.php, this is the 4th tab (0-based, so set to 3 above)
     jimport('joomla.html.pane');
     $pane = OPCPane::getInstance(defined('__VM_USER_USE_SLIDERS') ? 'Sliders' : 'Tabs', $_paneOffset);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     $this->assignRef('pane', $pane);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = VmModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = JText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = JText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($address_type == 'BT') {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     $add_product_link = "";
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
     if (OPCmini::isSuperVendor()) {
         $add_product_link = JRoute::_('/index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0');
         $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $this->assignRef('add_product_link', $add_product_link);
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     //   if ($onlyindex) return JURI::root(true).'/index.php';
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $jsvalidator = $OPCloader->getJSValidatorScript($this);
     $op_userfields = $OPCloader->getBTfields($this);
     $registration_html = $OPCloader->getRegistrationHhtml($this);
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'commonhtml.php';
     $reg_html = OPCCommonHtml::getFormVarsRegistration($OPCloader);
     $op_formvars = $reg_html . $jsvalidator;
     $op_userfields .= $op_formvars;
     $onsubmit = $op_onclick = $OPCloader->getJSValidator($this);
     $op_onclick = ' onclick="' . $op_onclick . '" ';
     ob_start();
     //parent::display($tpl);
     include_once JPATH_OPC . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'registration_templates.php';
     $html = ob_get_clean();
     //$html = str_replace('"com_virtuemart"', '"com_onepage"', $html);
     //$html = str_replace('=com_virtuemart', '=com_onepage', $html);
     $this->getActions($html);
     $html = $OPCloader->addListeners($html);
     echo $html;
     $extras = $OPCloader->getExtras($this);
     echo $extras;
 }