/** * Fetch billing, delivery and payment from session * * @return void */ protected function fetchSessionDataIntoSessionAttribute() { $feUser = $this->getFrontendController()->fe_user; $this->sessionData['billing'] = Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($feUser->getKey('ses', Tx_Commerce_Utility_GeneralUtility::generateSessionKey('billing'))); $this->sessionData['delivery'] = Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($feUser->getKey('ses', Tx_Commerce_Utility_GeneralUtility::generateSessionKey('delivery'))); $this->sessionData['payment'] = Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($feUser->getKey('ses', Tx_Commerce_Utility_GeneralUtility::generateSessionKey('payment'))); $this->sessionData['mails'] = $feUser->getKey('ses', Tx_Commerce_Utility_GeneralUtility::generateSessionKey('mails')); if ($this->piVars['check'] == 'billing' && $this->piVars['step'] == 'payment') { // Remove reference to delivery address $this->sessionData['delivery'] = FALSE; $feUser->setKey('ses', Tx_Commerce_Utility_GeneralUtility::generateSessionKey('delivery'), FALSE); } }
/** * Returns the HTML code for the header row * * @param int $colCount The number of columns we have * @param array $acBefore The additional columns before the attribute columns * @param array $acAfter The additional columns after the attribute columns * @param bool $addTr Add table row * * @return string The HTML header code */ protected function getHeadRow(&$colCount, array $acBefore = NULL, array $acAfter = NULL, $addTr = TRUE) { $result = ''; if ($addTr) { $result .= '<tr>'; } if ($acBefore != NULL) { $result .= '<th>' . implode('</th><th>', Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($acBefore)) . '</th>'; } if (is_array($this->attributes['ct1'])) { foreach ($this->attributes['ct1'] as $attribute) { $result .= '<th>' . htmlspecialchars(strip_tags($attribute['attributeData']['title'])) . '</th>'; $colCount++; } } if ($acAfter != NULL) { $result .= '<th>' . implode('</th><th>', Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($acAfter)) . '</th>'; } if ($addTr) { $result .= '</tr>'; } $colCount += count($acBefore) + count($acAfter); return $result; }
/** * Get all addresses from the database that are assigned to the current user. * * @param int $userId UID of the user * @param int $addressType Type of addresses to retrieve * * @return array Keys with UIDs and values with complete addresses data */ public function getAddresses($userId, $addressType = 0) { $select = 'tx_commerce_fe_user_id = ' . (int) $userId . \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_address'); if ($addressType > 0) { $select .= ' AND tx_commerce_address_type_id=' . (int) $addressType; } elseif (isset($this->conf['selectAddressTypes'])) { $select .= ' AND tx_commerce_address_type_id IN (' . $this->conf['selectAddressTypes'] . ')'; } else { $this->addresses = array(); return array(); } $select .= ' AND deleted=0 AND pid=' . $this->conf['addressPid']; /** * Hook for adding select statement */ if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi4/class.tx_commerce_pi4.php']['getAddresses'])) { \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(' hook $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi4/class.tx_commerce_pi4.php\'][\'getAddresses\'] is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/AddressesController.php\'][\'getAddresses\'] '); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi4/class.tx_commerce_pi4.php']['getAddresses'] as $classRef) { $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); if (method_exists($hookObj, 'editSelectStatement')) { $select = $hookObj->editSelectStatement($select, $userId, $addressType, $this); } } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/AddressesController.php']['getAddresses'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/AddressesController.php']['getAddresses'] as $classRef) { $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); if (method_exists($hookObj, 'editSelectStatement')) { $select = $hookObj->editSelectStatement($select, $userId, $addressType, $this); } } } $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'tt_address', $select, '', 'tx_commerce_is_main_address desc'); $result = array(); foreach ($rows as $address) { $result[$address['uid']] = Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($address); } return $result; }
/** * This fetches the value for an attribute. It fetches the "default_value" * from the table if the attribute has no valuelist, otherwise it fetches * the title from the attribute_values table. * You can submit only an attribute uid, then the mehod fetches the data * from the databse itself, or you submit the data from the relation table * and the data from the attribute table if this data is already present. * * @param int $pUid Product UID * @param int $aUid Attribute UID * @param string $relationTable Table where the relations between * prodcts and attributes are stored * @param array $relationData Relation dataset between the product * and the attribute (default NULL) * @param array $attributeData Meta data (has_valuelist, unit) for * the attribute you want to get the value from (default NULL) * * @return string The value of the attribute. It's maybe appended with the * unit of the attribute */ public function getAttributeValue($pUid, $aUid, $relationTable, array $relationData = NULL, array $attributeData = NULL) { $database = self::getDatabaseConnection(); if ($relationData == NULL || $attributeData == NULL) { // data from database if one of the arguments is NULL. This nesccessary // to keep the data consistant $relRes = $database->exec_SELECTquery('uid_valuelist,default_value,value_char', $relationTable, 'uid_local = ' . (int) $pUid . ' AND uid_foreign = ' . (int) $aUid); $relationData = $database->sql_fetch_assoc($relRes); $attributeData = $this->getAttributeData($aUid, 'has_valuelist,unit'); } if ($attributeData['has_valuelist'] == '1') { if ($attributeData['multiple'] == 1) { $result = array(); if (is_array($relationData)) { foreach ($relationData as $relation) { $valueRes = $database->exec_SELECTquery('value', 'tx_commerce_attribute_values', 'uid = ' . (int) $relation['uid_valuelist'] . $this->enableFields('tx_commerce_attribute_values')); $value = $database->sql_fetch_assoc($valueRes); $result[] = $value['value']; } } return '<ul><li>' . implode('</li><li>', Tx_Commerce_Utility_GeneralUtility::removeXSSStripTagsArray($result)) . '</li></ul>'; } else { // fetch data from attribute values table $valueRes = $database->exec_SELECTquery('value', 'tx_commerce_attribute_values', 'uid = ' . (int) $relationData['uid_valuelist'] . $this->enableFields('tx_commerce_attribute_values')); $value = $database->sql_fetch_assoc($valueRes); return $value['value']; } } elseif (!empty($relationData['value_char'])) { // the value is in field default_value return $relationData['value_char'] . ' ' . $attributeData['unit']; } return $relationData['default_value'] . ' ' . $attributeData['unit']; }