/** * @author Max Milbers * @param JDatabase $db connector object */ function __construct(&$db) { parent::__construct('#__tsmart_category_categories', 'id', $db); $this->setPrimaryKey('category_child_id'); $this->setOrderable(); $this->setTableShortCut('cx'); }
function __construct(&$db) { parent::__construct('#__tsmart_vmusers', 'tsmart_user_id', $db); $this->setPrimaryKey('tsmart_user_id'); $this->setLoggable(); $this->setTableShortCut('vmu'); }
/** * @author Max Milbers * @param */ function check() { if (isset($this->product_price)) { $this->product_price = str_replace(array(',', ' '), array('.', ''), $this->product_price); } if (isset($this->product_override_price)) { $this->product_override_price = str_replace(array(',', ' '), array('.', ''), $this->product_override_price); } return parent::check(); }
function __construct(&$db) { parent::__construct('#__tsmart_vendors', 'tsmart_vendor_id', $db); $this->setPrimaryKey('tsmart_vendor_id'); $this->setUniqueName('vendor_name'); $this->setSlug('vendor_store_name'); //Attention the slug autoname MUST be also in the translatable, if existing $this->setLoggable(); $this->setTranslatable(array('vendor_store_name', 'vendor_phone', 'vendor_store_desc', 'vendor_terms_of_service', 'vendor_legal_info', 'vendor_url', 'metadesc', 'metakey', 'customtitle', 'vendor_letter_css', 'vendor_letter_header_html', 'vendor_letter_footer_html', 'vendor_invoice_free1', 'vendor_invoice_free2', 'vendor_mail_free1', 'vendor_mail_free2', 'vendor_mail_css')); $varsToPushParam = array('vendor_min_pov' => array(0.0, 'float'), 'vendor_min_poq' => array(1, 'int'), 'vendor_freeshipment' => array(0.0, 'float'), 'vendor_address_format' => array('', 'string'), 'vendor_date_format' => array('', 'string'), 'vendor_letter_format' => array('A4', 'string'), 'vendor_letter_orientation' => array('P', 'string'), 'vendor_letter_margin_top' => array(55, 'int'), 'vendor_letter_margin_left' => array(25, 'int'), 'vendor_letter_margin_right' => array(25, 'int'), 'vendor_letter_margin_bottom' => array(25, 'int'), 'vendor_letter_margin_header' => array(20, 'int'), 'vendor_letter_margin_footer' => array(20, 'int'), 'vendor_letter_font' => array('helvetica', 'string'), 'vendor_letter_font_size' => array(8, 'int'), 'vendor_letter_header_font_size' => array(7, 'int'), 'vendor_letter_footer_font_size' => array(6, 'int'), 'vendor_letter_header' => array(1, 'int'), 'vendor_letter_header_line' => array(1, 'int'), 'vendor_letter_header_line_color' => array("#000000", 'string'), 'vendor_letter_header_image' => array(1, 'int'), 'vendor_letter_header_imagesize' => array(60, 'int'), 'vendor_letter_header_cell_height_ratio' => array(1, 'float'), 'vendor_letter_footer' => array(1, 'int'), 'vendor_letter_footer_line' => array(1, 'int'), 'vendor_letter_footer_line_color' => array("#000000", 'string'), 'vendor_letter_footer_cell_height_ratio' => array(1, 'float'), 'vendor_letter_add_tos' => array(0, 'int'), 'vendor_letter_add_tos_newpage' => array(1, 'int'), 'vendor_mail_width' => array(640, 'int'), 'vendor_mail_header' => array(1, 'int'), 'vendor_mail_tos' => array(1, 'int'), 'vendor_mail_logo' => array(1, 'int'), 'vendor_mail_logo_width' => array(200, 'int'), 'vendor_mail_font' => array('helvetica', 'string'), 'vendor_mail_header_font_size' => array(11, 'int'), 'vendor_mail_font_size' => array(12, 'int'), 'vendor_mail_footer_font_size' => array(10, 'int')); $this->setParameterable('vendor_params', $varsToPushParam); $this->setTableShortCut('v'); }
public function bindChecknStore(&$data, $preload = false) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('itinerary.tsmart_itinerary_id')->from('#__tsmart_itinerary AS itinerary')->where('itinerary.tsmart_itinerary_id!=' . (int) $data['tsmart_itinerary_id'])->where('itinerary.tsmart_product_id=' . (int) $data['tsmart_product_id'])->where('itinerary.title = ' . $query->q("{$data['title']}")); $db->setQuery($query); $list_itinerary = $db->loadObjectList(); if (count($list_itinerary) > 0) { vmError('itinerary title exists, please select other itinerary title'); return false; } return parent::bindChecknStore($data, $preload); // TODO: Change the autogenerated stub }
function check() { //$this->checkCurrencySymbol(); return parent::check(); }
/** * @param $tableName * @param $tableFields * @param $primaryKey * @param $tableId * @param bool $loggable * @return tsmTableData */ protected function createPluginTableObject($tableName, $tableFields, $primaryKey, $tableId, $loggable = FALSE) { if (!class_exists('tsmTableData')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'tsmtabledata.php'; } $db = JFactory::getDBO(); $table = new tsmTableData($tableName, $tableId, $db); foreach ($tableFields as $field) { $table->{$field} = 0; } if ($primaryKey !== 0) { $table->setPrimaryKey($primaryKey); } if ($loggable) { $table->setLoggable(); } if ($this->_cryptedFields) { $this->_vmpCtable->setCryptedFields($this->_cryptedFields); } /*if (!$this->_tableChecked) { $this->onStoreInstallPluginTable ($this->_psType); $this->_tableChecked = TRUE; }*/ return $table; }
/** * Overloaded delete() to delete a list of tsmart_userinfo_id's based on the user id * @var mixed id * @return boolean True on success * @author Oscar van Eijk */ function delete($id = null, $where = 0) { // TODO If $id is not numeric, assume it's a tsmart_userinfo_id. Validate if this is safe enough if (!is_numeric($id)) { return parent::delete($id); } // Implicit else $this->_db->setQuery('DELETE from `#__tsmart_userinfos` WHERE `tsmart_user_id` = ' . $id); if ($this->_db->execute() === false) { vmError($this->_db->getError()); return false; } return true; }
/** * As shortcat, Important the & MUST be there, even in php5.3 * * @author Max Milbers * @param array/obj $data input data as assoc array or obj * @param boolean $preload You can preload the data here too preserve not updated data * @return array/obj $data the updated data */ public function bindChecknStore(&$data, $preload = false) { $tblKey = $this->_tbl_key; $ok = true; if ($this->_translatable) { if (!class_exists('tsmTableData')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'tsmtabledata.php'; } $db = JFactory::getDBO(); $dataTable = clone $this; $langTable = new tsmTableData($this->_tbl_lang, $tblKey, $db); $langTable->setLanguage($this->_langTag); $langTable->setPrimaryKey($tblKey); $langData = array(); $langObKeys = array(); $langUniqueKeys = array(); if (is_object($data)) { foreach ($this->_translatableFields as $name) { $langTable->{$name} = $this->{$name}; if (isset($data->{$name})) { //We directly store language stuff "escaped" $langData[$name] = htmlspecialchars(html_entity_decode($data->{$name}, ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8"); } unset($dataTable->{$name}); if (!empty($this->_unique_name[$name])) { $langUniqueKeys[$name] = 1; unset($dataTable->_unique_name[$name]); $langObKeys[$name] = 1; unset($dataTable->_obkeys[$name]); } if (!empty($this->_obkeys[$name])) { $langObKeys[$name] = 1; unset($dataTable->_obkeys[$name]); } } } else { foreach ($this->_translatableFields as $name) { $langTable->{$name} = $this->{$name}; if (isset($data[$name])) { $langData[$name] = htmlspecialchars(html_entity_decode($data[$name], ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8"); } unset($dataTable->{$name}); if (!empty($this->_unique_name[$name])) { $langUniqueKeys[$name] = 1; unset($dataTable->_unique_name[$name]); $langObKeys[$name] = 1; unset($dataTable->_obkeys[$name]); } if (!empty($this->_obkeys[$name])) { $langObKeys[$name] = 1; unset($dataTable->_obkeys[$name]); } } } $langTable->_unique_name = $langUniqueKeys; $langTable->_obkeys = $langObKeys; $langTable->_slugAutoName = $this->_slugAutoName; unset($dataTable->_slugAutoName); $langTable->_slugName = 'slug'; unset($dataTable->_slugName); $langTable->setProperties($langData); $langTable->_translatable = false; //We must check the langtable BEFORE we store the normal table, cause the langtable is often defining if there are enough data to store it (for exmple the name) if ($ok) { //vmdebug('my langtable before bind',$langTable->id); if (!$langTable->bind($data)) { $ok = false; $msg = 'bind'; // vmdebug('Problem in bind '.get_class($this).' '.$this->_db->getErrorMsg()); vmdebug('Problem in bind ' . get_class($this) . ' '); } } if ($ok) { if (!$langTable->check()) { $ok = false; vmdebug('Check returned false ' . get_class($langTable) . ' ' . $this->_tbl . ' ' . $langTable->_db->getErrorMsg()); } } if ($ok) { $dataTable->bindChecknStoreNoLang($data, $preload); $this->bind($dataTable); $langTable->{$tblKey} = !empty($this->{$tblKey}) ? $this->{$tblKey} : 0; //vmdebug('bindChecknStoreNoLang my $tblKey '.$tblKey.' '.$langTable->$tblKey); if ($ok and $preload) { if (!empty($langTable->{$tblKey})) { $id = $langTable->{$tblKey}; if (!$langTable->load($id)) { $ok = false; vmdebug('Preloading of language table failed, no id given, cannot store ' . $this->_tbl); } } else { if ($ok) { if (!$langTable->bind($data)) { $ok = false; vmdebug('Problem in bind ' . get_class($this) . ' '); } } if ($ok) { if (!$langTable->check()) { $ok = false; vmdebug('Check returned false ' . get_class($langTable) . ' ' . $this->_tbl . ' ' . $langTable->_db->getErrorMsg()); } } } } if ($ok) { if (!$langTable->store()) { $ok = false; // $msg .= ' store'; vmdebug('Problem in store with langtable ' . get_class($langTable) . ' with ' . $tblKey . ' = ' . $this->{$tblKey} . ' ' . $langTable->_db->getErrorMsg()); } else { $this->bind($langTable); } } } } else { if (!$this->bindChecknStoreNoLang($data, $preload)) { $ok = false; } } if ($ok) { if ($this->_lhash) { self::$_cache['l'][$this->_lhash] = $this->loadFieldValues(false); } } return $ok; }
/** * Overloaded delete() to delete records from order_userinfo and order payment as well, * and write a record to the order history (TODO Or should the hist table be cleaned as well?) * * @var integer Order id * @return boolean True on success * @auhtor Max Milbers * @author Kohl Patrick */ function delete($id = null, $where = 0) { $k = $this->_tbl_key; if ($id === null) { $id = $this->{$k}; } $this->_db->setQuery('DELETE from `#__tsmart_order_userinfos` WHERE `tsmart_order_id` = ' . (int) $id); if ($this->_db->execute() === false) { vmError($this->_db->getError()); return false; } /*vm_order_payment NOT EXIST have to find the table name*/ $this->_db->setQuery('SELECT `payment_element` FROM `#__tsmart_paymentmethods` , `#__tsmart_orders` WHERE `#__tsmart_paymentmethods`.`tsmart_paymentmethod_id` = `#__tsmart_orders`.`tsmart_paymentmethod_id` AND `tsmart_order_id` = ' . $id); $payment_element = $this->_db->loadResult(); if (!empty($payment_element)) { $paymentTable = '#__tsmart_payment_plg_' . $payment_element; $this->_db->setQuery('DELETE from `' . $paymentTable . '` WHERE `tsmart_order_id` = ' . $id); if ($this->_db->execute() === false) { vmError($this->_db->getError()); return false; } } /*vm_order_shipment NOT EXIST have to find the table name*/ $this->_db->setQuery('SELECT `shipment_element` FROM `#__tsmart_shipmentmethods` , `#__tsmart_orders` WHERE `#__tsmart_shipmentmethods`.`tsmart_shipmentmethod_id` = `#__tsmart_orders`.`tsmart_shipmentmethod_id` AND `tsmart_order_id` = ' . $id); $shipmentName = $this->_db->loadResult(); if (!empty($shipmentName)) { $shipmentTable = '#__tsmart_shipment_plg_' . $shipmentName; $this->_db->setQuery('DELETE from `' . $shipmentTable . '` WHERE `tsmart_order_id` = ' . $id); if ($this->_db->execute() === false) { vmError('TableOrders delete Order shipmentTable = ' . $shipmentTable . ' `tsmart_order_id` = ' . $id . ' dbErrorMsg ' . $this->_db->getError()); return false; } } $_q = 'INSERT INTO `#__tsmart_order_histories` (' . ' tsmart_order_history_id' . ',tsmart_order_id' . ',order_status_code' . ',created_on' . ',customer_notified' . ',comments' . ') VALUES (' . ' NULL' . ',' . $id . ",'-'" . ',NOW()' . ',0' . ",'Order deleted'" . ')'; $this->_db->setQuery($_q); $this->_db->execute(); // Ignore error here return parent::delete($id); }
/** * @author RickG * @param JDataBase $db */ function __construct(&$db) { parent::__construct('#__tsmart_configs', 'tsmart_config_id', $db); $this->setLoggable(); }
public function bindChecknStore(&$data, $preload = false) { return parent::bindChecknStore($data, $preload); // TODO: Change the autogenerated stub }
/** * @author Max Milbers * @param string $_db */ function __construct(&$_db) { parent::__construct('#__tsmart_order_userinfos', 'tsmart_order_userinfo_id', $_db); parent::showFullColumns(); $this->setLoggable(); }