Пример #1
0
 /**
  * Mark existing addresses as not default if the new address is default
  *
  * @param Address $objAddress
  */
 protected function updateDefaultAddress(Address $objAddress)
 {
     $arrSet = array();
     if ($objAddress->isDefaultBilling) {
         $arrSet['isDefaultBilling'] = '';
     }
     if ($objAddress->isDefaultShipping) {
         $arrSet['isDefaultShipping'] = '';
     }
     if (!empty($arrSet)) {
         // @todo restore foratting when #6623 is fixed in Contao core
         \Database::getInstance()->prepare("UPDATE " . $objAddress->getTable() . " %s WHERE pid=? AND ptable=? AND store_id=? AND id!=?")->set($arrSet)->execute($this->member, \MemberModel::getTable(), $this->store_id, $objAddress->id);
     }
 }
Пример #2
0
 /**
  * Edit an address record. Based on the PersonalData core module
  * @param integer
  * @return void
  */
 protected function edit($intAddressId = 0)
 {
     $table = Address::getTable();
     \System::loadLanguageFile(\MemberModel::getTable());
     $this->Template = new \Isotope\Template($this->memberTpl);
     $this->Template->hasError = false;
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['saveData']);
     if ($intAddressId === 0) {
         $objAddress = Address::createForMember(\FrontendUser::getInstance()->id);
     } else {
         $objAddress = Address::findOneForMember($intAddressId, \FrontendUser::getInstance()->id);
     }
     if (null === $objAddress) {
         global $objPage;
         \Controller::redirect(\Controller::generateFrontendUrl($objPage->row()));
     }
     $objForm = new Form($table . '_' . $this->id, 'POST', function ($objForm) {
         return \Input::post('FORM_SUBMIT') === $objForm->getFormId();
     }, (bool) $this->tableless);
     $objForm->bindModel($objAddress);
     // Add form fields and modify for the address book
     $arrFields = $this->arrFields;
     $objForm->addFieldsFromDca($table, function ($strName, &$arrDca) use($arrFields) {
         if (!in_array($strName, $arrFields) || !$arrDca['eval']['feEditable']) {
             return false;
         }
         // Map checkboxWizard to regular checkbox widget
         if ($arrDca['inputType'] == 'checkboxWizard') {
             $arrDca['inputType'] = 'checkbox';
         }
         // Special field "country"
         if ($strName == 'country') {
             $arrCountries = array_merge(Isotope::getConfig()->getBillingCountries(), Isotope::getConfig()->getShippingCountries());
             $arrDca['reference'] = $arrDca['options'];
             $arrDca['options'] = array_values(array_intersect(array_keys($arrDca['options']), $arrCountries));
             $arrDca['default'] = Isotope::getConfig()->billing_country;
         }
         return true;
     });
     if ($objForm->isSubmitted()) {
         if ($objForm->validate()) {
             $objAddress->save();
             // Call onsubmit_callback
             if (is_array($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'])) {
                 foreach ($GLOBALS['TL_DCA'][$table]['config']['onsubmit_callback'] as $callback) {
                     $objCallback = \System::importStatic($callback[0]);
                     $objCallback->{$callback}[1]($objAddress);
                 }
             }
             global $objPage;
             \Controller::redirect(\Controller::generateFrontendUrl($objPage->row()));
         } else {
             $this->Template->hasError = true;
         }
     }
     $objForm->addToTemplate($this->Template);
     // Add groups
     $arrGroups = array();
     foreach ($objForm->getFormFields() as $strName => $arrConfig) {
         if ($arrConfig['feGroup'] != '') {
             $arrGroups[$arrConfig['feGroup']][$strName] = $objForm->getWidget($strName)->parse();
         }
     }
     foreach ($arrGroups as $k => $v) {
         $this->Template->{$k} = $v;
     }
     $this->Template->addressDetails = $GLOBALS['TL_LANG'][$table]['addressDetails'];
     $this->Template->contactDetails = $GLOBALS['TL_LANG'][$table]['contactDetails'];
     $this->Template->personalData = $GLOBALS['TL_LANG'][$table]['personalData'];
     $this->Template->loginDetails = $GLOBALS['TL_LANG'][$table]['loginDetails'];
 }
<?php

/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Table tl_iso_rule_usage
 */
$GLOBALS['TL_DCA']['tl_iso_rule_usage'] = array('config' => array('sql' => array('keys' => array('id' => 'primary', 'pid' => 'index'))), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('foreignKey' => \Isotope\Model\Rule::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'belongsTo', 'load' => 'lazy')), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'order_id' => array('foreignKey' => \Isotope\Model\ProductCollection::getTable() . '.document_number', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'config_id' => array('foreignKey' => \Isotope\Model\Config::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'member_id' => array('foreignKey' => \MemberModel::getTable() . '.username', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'))));