本文整理汇总了PHP中JTable::check方法的典型用法代码示例。如果您正苦于以下问题:PHP JTable::check方法的具体用法?PHP JTable::check怎么用?PHP JTable::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JTable
的用法示例。
在下文中一共展示了JTable::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
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;
}
示例2: check
/**
* 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();
}
示例3: check
/**
* 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;
}
示例4: check
/**
* 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;
}
示例5: check
/**
* 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();
}
示例6: check
/**
* 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;
}
示例7: check
/**
* 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();
}
示例8: check
public function check()
{
if (!$this->id) {
return false;
}
return parent::check();
}
示例9: check
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();
}
示例10: check
function check()
{
if (empty($this->type)) {
$this->setError(JText::_('Type not set'));
return false;
}
return parent::check();
}
示例11: check
/**
* 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();
}
示例12: check
public function check()
{
if (trim($this->question) == '') {
$this->setError(JText::_('COM_SMFAQ_QUESTION_ERROR_MSG'));
return false;
}
return parent::check();
}
示例13: check
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();
}
示例14: check
/**
* 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();
}
示例15: check
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();
}