Beispiel #1
0
 function check()
 {
     $result = true;
     $this->_validation_errors = array();
     if ($this->_category_field) {
         $db = $this->getDbo();
         $category = $this->{$this->_category_field};
         //Table has a category field, and we get all fields that are assigned to that category
         $db->setQuery("SELECT fid FROM #__" . APP_PREFIX . "_fields_categories WHERE cid = '{$category}'");
         $allowed_fields = $db->loadResultArray();
     }
     foreach ($this->_custom_fields as $field) {
         if ($this->_category_field && $field->categoryfilter && !in_array($field->id, $allowed_fields)) {
             continue;
         }
         $fieldvalue = $this->{$field->db_name};
         if ($field->compulsory && ($fieldvalue === NULL || $fieldvalue == '')) {
             //attention 0 can be a non empty value !
             $this->_validation_errors[] = JText::_("FACTORY_FIELD") . " " . $field->name . " " . JText::_("FACTORY_IS_REQUIRED");
         }
         if (!$field->validate_type) {
             continue;
         }
         $validator = CustomFieldsFactory::getFieldValidator($field->validate_type);
         if (!$validator->validateValue($fieldvalue, $field->params)) {
             $result = false;
             $this->_validation_errors = array_merge($this->_validation_errors, $validator->{$errormessages});
         }
     }
     $result = $result && parent::check();
     return $result;
 }
Beispiel #2
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_NUTRIENT_TITLE'));
         return false;
     }
     // check for valid symbol
     if (trim($this->symbol) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_NUTRIENT_SYMBOL'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_nutrients WHERE title = ' . $this->_db->Quote($this->title);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_NUTRIENT_DUPLICATE_TITLE'));
         return false;
     }
     // check for existing symbol
     $query = 'SELECT id FROM #__sibdiet_nutrients WHERE symbol = ' . $this->_db->Quote($this->symbol);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_NUTRIENT_DUPLICATE_SYMBOL'));
         return false;
     }
     return parent::check();
 }
Beispiel #3
0
 /**
  * Method to perform sanity checks on the JTable instance properties to ensure
  * they are safe to store in the database.  Child classes should override this
  * method to make sure the data they are storing in the database is safe and
  * as expected before storage.
  *
  * @return  boolean  True if the instance is sane and able to be stored in the database.
  *
  * @since   2.5
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     if (trim($this->alias) == '') {
         $this->alias = $this->title;
     }
     $this->alias = JApplicationHelper::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     $params = new Registry($this->params);
     $nullDate = $this->_db->getNullDate();
     $d1 = $params->get('d1', $nullDate);
     $d2 = $params->get('d2', $nullDate);
     // Check the end date is not earlier than the start date.
     if ($d2 > $nullDate && $d2 < $d1) {
         // Swap the dates.
         $params->set('d1', $d2);
         $params->set('d2', $d1);
         $this->params = (string) $params;
     }
     return true;
 }
Beispiel #4
0
 /**
  * Overloaded check function
  *
  * @return  boolean  True on success, false on failure
  *
  * @see     JTable::check()
  * @since   11.1
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     $this->menutype = JApplicationHelper::stringURLSafe($this->menutype);
     if (empty($this->menutype)) {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY'));
         return false;
     }
     // Sanitise data.
     if (trim($this->title) == '') {
         $this->title = $this->menutype;
     }
     // Check for unique menutype.
     $query = $this->_db->getQuery(true)->select('COUNT(id)')->from($this->_db->quoteName('#__menu_types'))->where($this->_db->quoteName('menutype') . ' = ' . $this->_db->quote($this->menutype))->where($this->_db->quoteName('id') . ' <> ' . (int) $this->id);
     $this->_db->setQuery($query);
     if ($this->_db->loadResult()) {
         $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype));
         return false;
     }
     return true;
 }
Beispiel #5
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid First name
     if (trim($this->fname) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_PROFILE_FNAME'));
         return false;
     }
     // check for valid Last name
     if (trim($this->lname) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_PROFILE_LNAME'));
         return false;
     }
     /** sanity check for user_id */
     if ($this->users_id) {
         // check for existing profile with selected user
         $query = 'SELECT id FROM #__sibdiet_profiles WHERE users_id = ' . (int) $this->users_id;
         $this->_db->setQuery($query);
         $xid = (int) $this->_db->loadResult();
         if ($xid && $xid != (int) $this->id) {
             $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_PROFILE_DUPLICATE_USERS_ID'));
             return false;
         }
     }
     return parent::check();
 }
Beispiel #6
0
 /**
  * Validation and filtering.
  *
  * @return  boolean
  *
  * @since   1.5
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Check the to and from users.
     $user = new JUser($this->user_id_from);
     if (empty($user->id)) {
         $this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_FROM_USER'));
         return false;
     }
     $user = new JUser($this->user_id_to);
     if (empty($user->id)) {
         $this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_TO_USER'));
         return false;
     }
     if (empty($this->subject)) {
         $this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_SUBJECT'));
         return false;
     }
     if (empty($this->message)) {
         $this->setError(JText::_('COM_MESSAGES_ERROR_INVALID_MESSAGE'));
         return false;
     }
     return true;
 }
Beispiel #7
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_AUDIO_TITLE'));
         return false;
     }
     // check for valid file
     if (trim($this->url) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_AUDIO_FILE'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_audios WHERE title = ' . $this->_db->Quote($this->title);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_AUDIO_DUPLICATE_TITLE'));
         return false;
     }
     // check for existing file
     $query = 'SELECT id FROM #__sibdiet_audios WHERE url = ' . $this->_db->Quote($this->url);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_AUDIO_DUPLICATE_FILE'));
         return false;
     }
     return parent::check();
 }
 public function check()
 {
     if (!$this->id) {
         return false;
     }
     return parent::check();
 }
Beispiel #9
0
 public function check()
 {
     if (empty($this->object_id)) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_OBJECT_ID'));
         return false;
     }
     if (empty($this->object_type)) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_OBJECT_TYPE'));
         return false;
     }
     if (empty($this->rating_group_id)) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_RATING_GROUP'));
         return false;
     }
     $this->_db->setQuery('SELECT COUNT(*) FROM #__djrevs_objects WHERE id=' . (int) $this->object_id);
     if (!$this->_db->loadResult()) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_OBJECT_ID'));
         return false;
     }
     $this->_db->setQuery('SELECT COUNT(*) FROM #__djrevs_objects WHERE object_type=' . $this->_db->quote($this->object_type));
     if (!$this->_db->loadResult()) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_OBJECT_TYPE'));
         return false;
     }
     $this->_db->setQuery('SELECT COUNT(*) FROM #__djrevs_rating_groups WHERE id=' . (int) $this->rating_group_id);
     if (!$this->_db->loadResult()) {
         $this->setError(JText::_('COM_DJREVIEWS_INTERNAL_ERROR_RATING_GROUP'));
         return false;
     }
     return parent::check();
 }
Beispiel #10
0
 function check()
 {
     if (empty($this->type)) {
         $this->setError(JText::_('Type not set'));
         return false;
     }
     return parent::check();
 }
Beispiel #11
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // If there is an ordering column and this is a new row then get the next ordering value
     if (property_exists($this, 'ordering') && $this->id == 0) {
         $this->ordering = self::getNextOrder();
     }
     return parent::check();
 }
Beispiel #12
0
 public function check()
 {
     if (trim($this->question) == '') {
         $this->setError(JText::_('COM_SMFAQ_QUESTION_ERROR_MSG'));
         return false;
     }
     return parent::check();
 }
Beispiel #13
0
 public function check()
 {
     if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) {
         $this->setError(JText::_('COM_JUDIRECTORY_START_PUBLISH_AFTER_FINISH'));
         return false;
     }
     return parent::check();
 }
Beispiel #14
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     //If there is an ordering column and this is a new row then get the next ordering value
     if (property_exists($this, 'ordering') && $this->id == 0) {
         $this->ordering = self::getNextOrder();
     }
     $this->virtuemart_category_id = implode(',', $this->virtuemart_category_id);
     return parent::check();
 }
Beispiel #15
0
 function check()
 {
     if (!is_numeric($this->tarif_1)) {
         $this->tarif_1 = NULL;
     }
     if (!is_numeric($this->tarif_2)) {
         $this->tarif_2 = NULL;
     }
     return parent::check();
 }
Beispiel #16
0
 /**
  * Overloaded check function
  *
  * @return  boolean  True on success, false on failure
  *
  * @see     JTable::check()
  * @since   3.1
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     if (trim($this->core_title) == '') {
         $this->setError(JText::_('JLIB_CMS_WARNING_PROVIDE_VALID_NAME'));
         return false;
     }
     if (trim($this->core_alias) == '') {
         $this->core_alias = $this->core_title;
     }
     $this->core_alias = JApplicationHelper::stringURLSafe($this->core_alias);
     if (trim(str_replace('-', '', $this->core_alias)) == '') {
         $this->core_alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     // Not Null sanity check
     if (empty($this->core_images)) {
         $this->core_images = '{}';
     }
     if (empty($this->core_urls)) {
         $this->core_urls = '{}';
     }
     // Check the publish down date is not earlier than publish up.
     if ($this->core_publish_down > $this->_db->getNullDate() && $this->core_publish_down < $this->core_publish_up) {
         // Swap the dates.
         $temp = $this->core_publish_up;
         $this->core_publish_up = $this->core_publish_down;
         $this->core_publish_down = $temp;
     }
     // Clean up keywords -- eliminate extra spaces between phrases
     // and cr (\r) and lf (\n) characters from string
     if (!empty($this->core_metakey)) {
         // Only process if not empty
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         // Remove bad characters
         $after_clean = JString::str_ireplace($bad_characters, "", $this->core_metakey);
         // Create array using commas as delimiter
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             if (trim($key)) {
                 // Ignore blank keywords
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->core_metakey = implode(", ", $clean_keys);
     }
     return true;
 }
Beispiel #17
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for existing diet with selected seasons
     $query = 'SELECT id FROM #__sibdiet_defaults WHERE season = ' . $this->_db->Quote($this->season) . ' AND diets_id = ' . $this->_db->Quote($this->diets_id);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_DEFAULT_DUPLICATE'));
         return false;
     }
     return parent::check();
 }
Beispiel #18
0
 /**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Check for valid name.
     if (trim($this->name) == '') {
         $this->setError(JText::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
         return false;
     }
     if (empty($this->alias)) {
         $this->alias = $this->name;
     }
     $this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
     }
     // Check the publish down date is not earlier than publish up.
     if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up) {
         $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
         return false;
     }
     // Clean up keywords -- eliminate extra spaces between phrases
     // and cr (\r) and lf (\n) characters from string if not empty
     if (!empty($this->metakey)) {
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         // Remove bad characters
         $after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
         // Create array using commas as delimiter
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             if (trim($key)) {
                 // Ignore blank keywords
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->metakey = implode(", ", $clean_keys);
     }
     // Clean up description -- eliminate quotes and <> brackets
     if (!empty($this->metadesc)) {
         // Only process if not empty
         $bad_characters = array("\"", "<", ">");
         $this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
     }
     return true;
 }
 /**
  * Overloaded check function
  */
 public function check()
 {
     //If there is an ordering column and this is a new row then get the next ordering value
     if (property_exists($this, 'ordering') && $this->id == 0) {
         $this->ordering = self::getNextOrder();
     }
     // URL
     jimport('joomla.filter.output');
     //		if(empty($this->alias)) {
     //			$this->alias = $this->title;
     //		}
     //		$this->alias = JFilterOutput::stringURLSafe($this->alias);
     return parent::check();
 }
Beispiel #20
0
 /**
  * Overloaded check method to ensure data integrity
  *
  * @return  boolean  True on success
  *
  * @since   11.1
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     if (trim($this->title) == '') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE'));
         return false;
     }
     return true;
 }
Beispiel #21
0
 /**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     if (empty($this->title)) {
         $this->setError(JText::_('COM_TEMPLATES_ERROR_STYLE_REQUIRES_TITLE'));
         return false;
     }
     return true;
 }
Beispiel #22
0
 /**
  * Overloaded check function
  *
  * @return  boolean  True if the object is ok
  *
  * @see     JTable::check()
  * @since   3.4
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Check for valid name
     if (trim($this->name) == '' || trim($this->location) == '') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION'));
         return false;
     }
     return true;
 }
Beispiel #23
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_COMPOSITIONS_GROUP_TITLE'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_compositions_groups WHERE title = ' . $this->_db->Quote($this->title);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_COMPOSITIONS_GROUP_DUPLICATE_TITLE'));
         return false;
     }
     return parent::check();
 }
Beispiel #24
0
 /**
  * Overloaded check function
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     $this->old_url = trim(rawurldecode($this->old_url));
     $this->new_url = trim(rawurldecode($this->new_url));
     // Check for valid name.
     if (empty($this->old_url)) {
         $this->setError(JText::_('COM_REDIRECT_ERROR_SOURCE_URL_REQUIRED'));
         return false;
     }
     // Check for NOT NULL.
     if (empty($this->referer)) {
         $this->referer = '';
     }
     // Check for valid name if not in advanced mode.
     if (empty($this->new_url) && JComponentHelper::getParams('com_redirect')->get('mode', 0) == false) {
         $this->setError(JText::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));
         return false;
     } elseif (empty($this->new_url) && JComponentHelper::getParams('com_redirect')->get('mode', 0) == true) {
         // Else if an empty URL and in redirect mode only throw the same error if the code is a 3xx status code
         if ($this->header < 400 && $this->header >= 300) {
             $this->setError(JText::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED'));
             return false;
         }
     }
     // Check for duplicates
     if ($this->old_url == $this->new_url) {
         $this->setError(JText::_('COM_REDIRECT_ERROR_DUPLICATE_URLS'));
         return false;
     }
     $db = $this->getDbo();
     // Check for existing name
     $query = $db->getQuery(true)->select($db->quoteName('id'))->from('#__redirect_links')->where($db->quoteName('old_url') . ' = ' . $db->quote($this->old_url));
     $db->setQuery($query);
     $xid = (int) $db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_REDIRECT_ERROR_DUPLICATE_OLD_URL'));
         return false;
     }
     return true;
 }
Beispiel #25
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_DEFAULTS_MEALLY_TITLE'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_defaults_meallys WHERE title = ' . $this->_db->Quote($this->title) . ' AND defaults_id = ' . (int) $this->defaults_id . ' AND meal = ' . (int) $this->meal;
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_DEFAULTS_MEALLY_DUPLICATE_TITLE'));
         return false;
     }
     return parent::check();
 }
Beispiel #26
0
 /**
  * Overloaded check function
  *
  * @return  boolean
  *
  * @see     JTable::check
  * @since   1.5
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Set name
     $this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
     // Set alias
     if (trim($this->alias) == '') {
         $this->alias = $this->name;
     }
     $this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
     }
     // Check the publish down date is not earlier than publish up.
     if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) {
         $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
         return false;
     }
     // Set ordering
     if ($this->state < 0) {
         // Set ordering to 0 if state is archived or trashed
         $this->ordering = 0;
     } elseif (empty($this->ordering)) {
         // Set ordering to last if ordering was 0
         $this->ordering = self::getNextOrder($this->_db->quoteName('catid') . '=' . $this->_db->quote($this->catid) . ' AND state>=0');
     }
     if (empty($this->publish_up)) {
         $this->publish_up = $this->getDbo()->getNullDate();
     }
     if (empty($this->publish_down)) {
         $this->publish_down = $this->getDbo()->getNullDate();
     }
     if (empty($this->modified)) {
         $this->modified = $this->getDbo()->getNullDate();
     }
     return true;
 }
 /**
  * Overloaded check function
  *
  * @since    1.0.0
  */
 public function check()
 {
     //If there is an ordering column and this is a new row then get the next ordering value
     if ($this->id == 0) {
         $this->ordering = self::getNextOrder('field_id=' . (int) $this->field_id);
     }
     // Check for a field name.
     if (trim($this->value) == '') {
         $this->setError(JText::_('COM_FIELDSANDFILTERS_DATABASE_ERROR_VALID_FIELD_VALUE'));
         return false;
     }
     // Check for a field alias
     if (trim($this->alias) == '') {
         $this->alias = $this->value;
     }
     $this->alias = JApplication::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
     }
     return parent::check();
 }
Beispiel #28
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_TEXT_TITLE'));
         return false;
     }
     // check for valid description
     if (trim($this->description) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_TEXT_DESCRIPTION'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_texts WHERE title = ' . $this->_db->Quote($this->title);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_TEXT_DUPLICATE_TITLE'));
         return false;
     }
     return parent::check();
 }
Beispiel #29
0
 /**
  * Overloaded check function
  */
 public function check()
 {
     // check for valid title
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_ACTIVITY_TITLE'));
         return false;
     }
     // check for valid Calorie
     if ((int) $this->calorie == 0) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_ACTIVITY_CALORIE'));
         return false;
     }
     // check for existing title
     $query = 'SELECT id FROM #__sibdiet_activities WHERE title = ' . $this->_db->Quote($this->title);
     $this->_db->setQuery($query);
     $xid = (int) $this->_db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_SIBDIET_ERR_TABLES_ACTIVITY_DUPLICATE_TITLE'));
         return false;
     }
     return parent::check();
 }
Beispiel #30
0
 /**
  * Method to check the current record to save
  *
  * @return  boolean  True on success
  *
  * @since   11.1
  */
 public function check()
 {
     try {
         parent::check();
     } catch (\Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Validate the title.
     if (trim($this->title) == '') {
         $this->setError(JText::_('JLIB_DATABASE_ERROR_VIEWLEVEL'));
         return false;
     }
     // Check for a duplicate title.
     $db = $this->_db;
     $query = $db->getQuery(true)->select('COUNT(title)')->from($db->quoteName('#__viewlevels'))->where($db->quoteName('title') . ' = ' . $db->quote($this->title))->where($db->quoteName('id') . ' != ' . (int) $this->id);
     $db->setQuery($query);
     if ($db->loadResult() > 0) {
         $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_USERLEVEL_NAME_EXISTS', $this->title));
         return false;
     }
     return true;
 }