Beispiel #1
0
 /**
  * @author Max Milbers
  * @param
  */
 function check()
 {
     if (!empty($this->product_price)) {
         $this->product_price = str_replace(array(',', ' '), array('.', ''), $this->product_price);
     } else {
         $this->product_price = null;
     }
     return parent::check();
 }
 /**
  * @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();
 }
Beispiel #3
0
 /**
  * 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('VmTableData')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtabledata.php';
         }
         $db = JFactory::getDBO();
         $dataTable = clone $this;
         $langTable = new VmTableData($this->_tbl_lang, $tblKey, $db);
         $langTable->setPrimaryKey($tblKey);
         $langData = array();
         $langObKeys = array();
         $langUniqueKeys = array();
         if (is_object($data)) {
             foreach ($this->_translatableFields as $name) {
                 if (isset($data->{$name})) {
                     //We directly store language stuff "escaped"
                     $langData[$name] = htmlentities($data->{$name}, ENT_QUOTES, "UTF-8");
                 } else {
                     //	$langData[$name] = '';
                 }
                 unset($dataTable->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_unique_name[$name]);
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data->$tblKey;
         } else {
             foreach ($this->_translatableFields as $name) {
                 if (isset($data[$name])) {
                     //$langData[$name] = $data[$name];
                     $langData[$name] = htmlentities($data[$name], ENT_QUOTES, "UTF-8");
                 } else {
                     //	$langData[$name] = '';
                 }
                 unset($dataTable->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_unique_name[$name]);
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = vmText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', vmText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($dataTable->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data[$tblKey];
         }
         $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);
                     if ($this->_lhash) {
                         self::$_cache['l'][$this->_lhash] = $this->loadFieldValues(false);
                     }
                 }
             }
         }
     } else {
         if (!$this->bindChecknStoreNoLang($data, $preload)) {
             $ok = false;
         }
     }
     return $ok;
 }
Beispiel #4
0
 /**
  * Validates the user info record fields.
  *
  * @author RickG, RolandD, Max Milbers
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 public function check()
 {
     if ($this->address_type == 'BT' or $this->address_type == 'ST') {
         if ($this->address_type == 'ST' and empty($this->address_type_name)) {
             vmError('Table userinfos check failed: address_type ' . $this->address_type . ' without name', 'check failed: ST has no name');
             return false;
         }
     } else {
         vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type ');
         vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name);
         return false;
     }
     if (!empty($this->virtuemart_userinfo_id)) {
         $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id;
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         if (!Permissions::getInstance()->check("admin")) {
             $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id;
             $this->_db->setQuery($q);
             $total = $this->_db->loadResultArray();
             if (count($total) > 0) {
                 $userId = JFactory::getUser()->id;
                 if ($total[0] != $userId) {
                     vmError('Hacking attempt uid check, you got logged');
                     echo 'Hacking attempt uid check, you got logged';
                     return false;
                 }
             }
         }
         return parent::check();
     }
     if (empty($this->address_type)) {
         $this->address_type = 'BT';
     }
     /* Check if a record exists */
     $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type);
     if ($this->address_type != 'BT') {
         $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name);
     }
     $this->_db->setQuery($q);
     $total = $this->_db->loadResultArray();
     if (count($total) > 0) {
         $this->virtuemart_userinfo_id = (int) $total[0];
     } else {
         $this->virtuemart_userinfo_id = 0;
         //md5(uniqid($this->virtuemart_user_id));
     }
     return parent::check();
 }
Beispiel #5
0
 /**
  * Validates the user info record fields.
  *
  * @author RickG, RolandD, Max Milbers
  * @return boolean True if the table buffer is contains valid data, false otherwise.
  */
 public function check()
 {
     if ($this->address_type == 'BT' or $this->address_type == 'ST') {
         if ($this->address_type == 'ST' and empty($this->address_type_name)) {
             $this->address_type_name = 'Delivery Address ' . rand(1, 9);
             vmWarn('Table userinfos check failed: address_type ' . $this->address_type . ' without name, autogenerated ' . $this->address_type_name, 'check failed: ST has no name, autogenerated ' . $this->address_type_name);
         }
     } else {
         vmError('Table userinfos check failed: Unknown address_type ' . $this->address_type, 'check failed: Unknown address_type ');
         vmdebug('Table userinfos check failed: Unknown address_type ' . $this->address_type . ' virtuemart_user_id ' . $this->virtuemart_user_id . ' name ' . $this->name);
         return false;
     }
     if (!empty($this->virtuemart_userinfo_id)) {
         $this->virtuemart_userinfo_id = (int) $this->virtuemart_userinfo_id;
         $user = JFactory::getUser();
         if (!$user->authorise('core.admin', 'com_virtuemart')) {
             $q = "SELECT virtuemart_user_id\n\t\t\t\t\t\t\t\t\t\tFROM #__virtuemart_userinfos\n\t\t\t\t\t\t\t\t\t\tWHERE virtuemart_userinfo_id = " . $this->virtuemart_userinfo_id;
             $this->_db->setQuery($q);
             $total = $this->_db->loadColumn();
             if (count($total) > 0) {
                 $userId = JFactory::getUser()->id;
                 if ($total[0] != $userId) {
                     vmError('Hacking attempt uid check, you got logged');
                     echo 'Hacking attempt uid check, you got logged';
                     return false;
                 }
             }
         }
         //return parent::check();
     } else {
         if (empty($this->address_type)) {
             $this->address_type = 'BT';
         }
         /* Check if a record exists */
         $q = "SELECT virtuemart_userinfo_id\n\t\t\tFROM #__virtuemart_userinfos\n\t\t\tWHERE virtuemart_user_id = " . $this->virtuemart_user_id . "\n\t\t\tAND address_type = " . $this->_db->Quote($this->address_type);
         if ($this->address_type != 'BT') {
             $q .= " AND address_type_name = " . $this->_db->Quote($this->address_type_name);
         }
         $this->_db->setQuery($q);
         $total = $this->_db->loadColumn();
         if (count($total) > 0) {
             $this->virtuemart_userinfo_id = (int) $total[0];
         } else {
             $this->virtuemart_userinfo_id = 0;
             //md5(uniqid($this->virtuemart_user_id));
         }
     }
     if (empty($this->virtuemart_user_id)) {
         $user = JFactory::getUser();
         if (!empty($user->id)) {
             $this->virtuemart_user_id = $user->id;
         }
     }
     return parent::check();
 }
 function check()
 {
     //$this->checkCurrencySymbol();
     return parent::check();
 }
Beispiel #7
0
 /**
  * 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;
     if ($this->_translatable) {
         if (!class_exists('VmTableData')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmtabledata.php';
         }
         $db = JFactory::getDBO();
         $langTable = new VmTableData($this->_tbl_lang, $tblKey, $db);
         $langTable->setPrimaryKey($tblKey);
         $langData = array();
         $langObKeys = array();
         $langUniqueKeys = array();
         if (is_object($data)) {
             foreach ($this->_translatableFields as $name) {
                 if (!empty($data->{$name})) {
                     $langData[$name] = $data->{$name};
                 } else {
                     $langData[$name] = '';
                 }
                 unset($this->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_unique_name[$name]);
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data->$tblKey;
         } else {
             foreach ($this->_translatableFields as $name) {
                 if (!empty($data[$name])) {
                     $langData[$name] = $data[$name];
                 } else {
                     $langData[$name] = '';
                 }
                 unset($this->{$name});
                 if (!empty($this->_unique_name[$name])) {
                     $langUniqueKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_unique_name[$name]);
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
                 if (!empty($this->_obkeys[$name])) {
                     $langObKeys[$name] = JText::sprintf('COM_VIRTUEMART_STRING_ERROR_OBLIGATORY_KEY', JText::_('COM_VIRTUEMART_' . strtoupper($name)));
                     unset($this->_obkeys[$name]);
                 }
             }
             // 				$langTable->$tblKey = $data[$tblKey];
         }
         $langTable->_unique_name = $langUniqueKeys;
         $langTable->_obkeys = $langObKeys;
         $langTable->_slugAutoName = $this->_slugAutoName;
         unset($this->_slugAutoName);
         $langTable->_slugName = 'slug';
         unset($this->_slugName);
         $langTable->setProperties($langData);
         $langTable->_translatable = false;
         // 			$dataLang = $data;
         // 			vmdebug('my $dataLang',$langTable,$data);
         // 			vmdebug('my $table $this',$this);
         $this->bindChecknStoreNoLang($data, $preload);
         // 			vmdebug('bindchecknstore',$langData,$this);
         $langTable->{$tblKey} = !empty($this->{$tblKey}) ? $this->{$tblKey} : 0;
         $ok = true;
         if ($ok) {
             if (!$langTable->check()) {
                 $ok = false;
                 // $msg .= ' check';
                 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 ' . get_class($langTable) . ' ' . $langTable->_db->getErrorMsg());
             }
         }
         // 			if(is_object($data)){
         // 				$data->$tblKey = !empty($langTable->$tblKey) ? $langTable->$tblKey : 0;
         // 			}else {
         // 				$data[$tblKey] = !empty($langTable->$tblKey) ? $langTable->$tblKey : 0;
         // 			}
         // 			$langTable->bindChecknStoreNoLang($data,$preload);
     } else {
         $this->bindChecknStoreNoLang($data, $preload);
     }
     return true;
 }
Beispiel #8
0
 function check()
 {
     if (empty($this->order_number)) {
         if (!class_exists('VirtueMartModelOrders')) {
             require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
         }
         $this->order_number = VirtueMartModelOrders::generateOrderNumber((string) time());
     }
     if (empty($this->order_pass)) {
         $this->order_pass = '******' . substr(md5((string) time() . $this->order_number), 0, 5);
     }
     $adminID = JFactory::getSession()->get('vmAdminID', false);
     if ($adminID) {
         if (!class_exists('vmCrypt')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
         }
         $adminID = vmCrypt::decrypt($adminID);
         $this->created_by = $adminID;
     }
     return parent::check();
 }
Beispiel #9
0
 function check()
 {
     if (empty($this->order_number)) {
         if (!class_exists('VirtueMartModelOrders')) {
             VmModel::getModel('orders');
         }
         $this->order_number = VirtueMartModelOrders::genStdOrderNumber($this->virtuemart_vendor_id);
     }
     if (empty($this->order_pass)) {
         if (!class_exists('VirtueMartModelOrders')) {
             VmModel::getModel('orders');
         }
         $this->order_pass = VirtueMartModelOrders::genStdOrderPass();
     }
     if ($adminID = vmAccess::getBgManagerId()) {
         $this->created_by = $adminID;
     }
     return parent::check();
 }
Beispiel #10
0
 function check()
 {
     if (empty($this->order_number)) {
         if (!class_exists('VirtueMartModelOrders')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
         }
         $this->order_number = VirtueMartModelOrders::generateOrderNumber((string) time());
     }
     if (empty($this->order_pass)) {
         $this->order_pass = '******' . substr(md5((string) time() . $this->order_number), 0, 5);
     }
     $adminID = JFactory::getSession()->get('vmAdminID');
     if (isset($adminID)) {
         $this->created_by = $adminID;
     }
     return parent::check();
 }