function check() { if (empty($this->shopper_group_name)) { vmError('com_tsmart_SHOPPERGROUP_RECORDS_MUST_HAVE_NAME'); return false; } else { if (function_exists('mb_strlen')) { $length = mb_strlen($this->shopper_group_name); } else { $length = strlen($this->shopper_group_name); } if ($length > 128) { vmError('com_tsmart_SHOPPERGROUP_NAME_128'); } } if ($this->tsmart_shoppergroup_id == 1) { $this->default = 2; $this->sgrp_additional = 0; } if ($this->tsmart_shoppergroup_id == 2) { $this->default = 1; $this->sgrp_additional = 0; } return parent::check(); }
function check() { if (empty($this->notify_email) || !filter_var($this->notify_email, FILTER_VALIDATE_EMAIL)) { vmError(tsmText::_('com_tsmart_ENTER_A_VALID_EMAIL_ADDRESS'), tsmText::_('com_tsmart_ENTER_A_VALID_EMAIL_ADDRESS')); return false; } return parent::check(); }
function check() { if (!empty($this->customfield_price)) { $this->customfield_price = str_replace(array(',', ' '), array('.', ''), $this->customfield_price); } else { $this->customfield_price = null; } return parent::check(); }
/** * Validates the userfields record fields. * * @return boolean True if the table buffer is contains valid data, false otherwise. */ function check() { if (preg_match('/[^a-z0-9\\._\\-]/i', $this->name) > 0) { vmError(tsmText::_('com_tsmart_NAME_OF_USERFIELD_CONTAINS_INVALID_CHARACTERS')); return false; } if ($this->name != 'tsmart_country_id' and $this->name != 'tsmart_state_id') { $reqValues = array('select', 'multiselect', 'radio', 'multicheckbox'); if (in_array($this->type, $reqValues) and $this->_nrOfValues == 0) { vmError(tsmText::_('com_tsmart_VALUES_ARE_REQUIRED_FOR_THIS_TYPE')); return false; } } return parent::check(); }
/** * Validates the order status record fields. * * @return boolean True if the table buffer is contains valid data, false otherwise. */ function check() { $db = JFactory::getDBO(); $q = 'SELECT count(*),tsmart_orderstate_id FROM `#__tsmart_orderstates` '; $q .= 'WHERE `order_status_code`="' . $this->order_status_code . '"'; $db->setQuery($q); $row = $db->loadRow(); if (is_array($row)) { if ($row[0] > 0) { if ($row[1] != $this->tsmart_orderstate_id) { vmError(tsmText::_('com_tsmart_ORDER_STATUS_CODE_EXISTS')); return false; } } } return parent::check(); }
function check() { $ok = TRUE; $notice = TRUE; if (empty($this->file_type) and empty($this->file_is_forSale)) { $ok = FALSE; vmError(tsmText::sprintf('com_tsmart_MEDIA_NO_TYPE'), $this->file_name); } if (!empty($this->file_url)) { if (function_exists('mb_strlen')) { $length = mb_strlen($this->file_url); } else { $length = strlen($this->file_url); } if ($length > 254) { vmError(JText::sprintf('com_tsmart_URL_TOO_LONG', $length)); } if (strpos($this->file_url, '..') !== FALSE) { $ok = FALSE; vmError(tsmText::sprintf('com_tsmart_URL_NOT_VALID', $this->file_url)); } if (empty($this->tsmart_media_id)) { $q = 'SELECT `tsmart_media_id`,`file_url` FROM `' . $this->_tbl . '` WHERE `file_url` = "' . $this->_db->escape($this->file_url) . '" '; $this->_db->setQuery($q); $unique_id = $this->_db->loadAssocList(); $count = count($unique_id); if ($count !== 0) { if ($count == 1) { if (empty($this->tsmart_media_id)) { $this->tsmart_media_id = $unique_id[0]['tsmart_media_id']; } else { vmError(tsmText::_('com_tsmart_MEDIA_IS_ALREADY_IN_DB')); $ok = FALSE; } } else { // vmError(vmText::_('com_tsmart_MEDIA_IS_DOUBLED_IN_DB')); vmError(tsmText::_('com_tsmart_MEDIA_IS_DOUBLED_IN_DB')); $ok = FALSE; } } } } else { vmError(tsmText::_('com_tsmart_MEDIA_MUST_HAVE_URL')); $ok = FALSE; } if (empty($this->file_title) && !empty($this->file_name)) { $this->file_title = $this->file_name; } if (!empty($this->file_title)) { if (strlen($this->file_title) > 126) { vmError(tsmText::sprintf('com_tsmart_TITLE_TOO_LONG', strlen($this->file_title))); } $q = 'SELECT * FROM `' . $this->_tbl . '` '; $q .= 'WHERE `file_title`="' . $this->_db->escape($this->file_title) . '" AND `file_type`="' . $this->_db->escape($this->file_type) . '"'; $this->_db->setQuery($q); $unique_id = $this->_db->loadAssocList(); $tblKey = 'tsmart_media_id'; if (!empty($unique_id)) { foreach ($unique_id as $item) { if ($item['tsmart_media_id'] != $this->tsmart_media_id) { $lastDir = substr($this->file_url, 0, strrpos($this->file_url, '/')); $lastDir = substr($lastDir, strrpos($lastDir, '/') + 1); if (!empty($lastDir)) { $this->file_title = $this->file_title . '_' . $lastDir; } else { $this->file_title = $this->file_title . '_' . rand(1, 9); } } } } } else { vmError(tsmText::_('com_tsmart_MEDIA_MUST_HAVE_TITLE')); $ok = FALSE; } if (!empty($this->file_description)) { if (strlen($this->file_description) > 254) { vmError(tsmText::sprintf('com_tsmart_DESCRIPTION_TOO_LONG', strlen($this->file_description))); } } // $app = JFactory::getApplication(); //vmError('Checking '.$this->file_url); if (empty($this->file_mimetype)) { $rel_path = str_replace('/', DS, $this->file_url); //The function mime_content_type is deprecated, we may use /*function _mime_content_type($filename) { $result = new finfo(); if (is_resource($result) === true) { return $result->file($filename, FILEINFO_MIME_TYPE); } return false; } if (function_exists ('mime_content_type')) { $ok = TRUE; $app = JFactory::getApplication (); if (!$this->file_is_forSale) { $this->file_mimetype = mime_content_type (JPATH_ROOT . DS . $rel_path); } else { $this->file_mimetype = mime_content_type ($rel_path); } if (!empty($this->file_mimetype)) { if ($this->file_mimetype == 'directory') { vmError ('cant store this media, is a directory ' . $rel_path); return FALSE; } else { if (strpos ($this->file_mimetype, 'corrupt') !== FALSE) { vmError ('cant store this media, Document corrupt: Cannot read summary info ' . $rel_path); return FALSE; } } } else { vmError ('Couldnt resolve mime ' . $rel_path); return FALSE; } } else {*/ if (!class_exists('JFile')) { require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php'; } if (!$this->file_is_forSale) { $lastIndexOfSlash = strrpos($this->file_url, '/'); $name = substr($this->file_url, $lastIndexOfSlash + 1); $file_extension = strtolower(JFile::getExt($name)); } else { $lastIndexOfSlash = strrpos($this->file_url, DS); $name = substr($this->file_url, $lastIndexOfSlash + 1); $file_extension = strtolower(JFile::getExt($name)); } if (empty($name)) { vmError(tsmText::_('com_tsmart_NO_MEDIA')); } elseif ($file_extension === 'jpg' or $file_extension === 'jpeg' or $file_extension === 'jpe') { $this->file_mimetype = 'image/jpeg'; } elseif ($file_extension === 'gif') { $this->file_mimetype = 'image/gif'; } elseif ($file_extension === 'png') { $this->file_mimetype = 'image/png'; } elseif ($file_extension === 'bmp') { vmInfo(tsmText::sprintf('com_tsmart_MEDIA_SHOULD_NOT_BMP', $name)); $notice = true; } elseif ($file_extension === 'mp3') { $this->file_mimetype = 'audio/mpeg'; } elseif ($file_extension === 'ogg') { $this->file_mimetype = 'audio/ogg'; } elseif ($file_extension === 'oga') { $this->file_mimetype = 'audio/vorbis'; } elseif ($file_extension === 'wma') { $this->file_mimetype = 'audio-/x-ms-wma'; } elseif ($file_extension === 'mp4' or $file_extension === 'mpe' or $file_extension === 'mpeg' or $file_extension === 'mpg' or $file_extension === 'mpga' or $file_extension === 'm2v') { $this->file_mimetype = 'video/mpeg'; } elseif ($file_extension === 'avi') { $this->file_mimetype = 'video/x-msvideo'; } elseif ($file_extension === 'qt' or $file_extension === 'mov') { $this->file_mimetype = 'video/quicktime'; } elseif ($file_extension === 'wmv') { $this->file_mimetype = 'video/x-ms-wmv'; } elseif ($file_extension === '3gp') { $this->file_mimetype = 'video/3gpp'; } elseif ($file_extension === 'ogv') { $this->file_mimetype = 'video/ogg'; } elseif ($file_extension === 'flv') { $this->file_mimetype = 'video/x-flv'; } elseif ($file_extension === 'f4v') { $this->file_mimetype = 'video/x-f4v'; } elseif ($file_extension === 'm4v') { $this->file_mimetype = 'video/x-m4v'; } elseif ($file_extension === 'webm') { $this->file_mimetype = 'video/webm'; } elseif ($file_extension === 'zip') { $this->file_mimetype = 'application/zip'; } elseif ($file_extension === 'pdf') { $this->file_mimetype = 'application/pdf'; } elseif ($file_extension === 'gz') { $this->file_mimetype = 'application/x-gzip'; } elseif ($file_extension === 'exe') { $this->file_mimetype = 'application/octet-stream'; } elseif ($file_extension === 'swf') { $this->file_mimetype = 'application/x-shockwave-flash'; } elseif ($file_extension === 'doc') { $this->file_mimetype = 'application/msword'; } elseif ($file_extension === 'docx') { $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; } elseif ($file_extension === 'xls') { $this->file_mimetype = 'application/vnd.ms-excel'; } elseif ($file_extension === 'xlsx') { $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; } elseif ($file_extension === 'ppt') { $this->file_mimetype = 'application/vnd.ms-powerpoint'; } elseif ($file_extension === 'pptx') { $this->file_mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; } elseif ($file_extension === 'txt') { $this->file_mimetype = 'text/plain'; } elseif ($file_extension === 'rar') { $this->file_mimetype = 'application/x-rar-compressed'; } else { vmInfo(tsmText::sprintf('com_tsmart_MEDIA_SHOULD_HAVE_MIMETYPE', $name)); $notice = TRUE; } //} } //Nasty small hack, should work as long the word for default is in the language longer than 3 words and the first //letter should be always / or something like this //It prevents storing of the default path $a = trim(substr($this->file_url_thumb, 0, 4)); $b = trim(substr(tsmText::_('com_tsmart_DEFAULT_URL'), 0, 4)); if (strpos($a, $b) !== FALSE) { $this->file_url_thumb = null; } if ($ok) { return parent::check(); } else { return FALSE; } }
public function check() { $csValue = $this->limit_list_step; if (!empty($csValue)) { $sequenceArray = explode(',', $csValue); foreach ($sequenceArray as &$csV) { $csV = (int) trim($csV); } $this->limit_list_step = implode(',', $sequenceArray); } return parent::check(); }