Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
@@ -400,17 +400,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
$customValidationCode = function( $val ) use ( $database, $row, $record )
|
||||
{
|
||||
$where = array( array( 'field_' . $row->id . '=?', $val ) );
|
||||
|
||||
if ( $record !== NULL )
|
||||
{
|
||||
$where[] = array( 'primary_id_field != ?', $record->_id );
|
||||
}
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $database->id, $where )->first() )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack( "field_unique_entry_not_unique", FALSE, array( 'sprintf' => array( $database->recordWord( 1 ) ) ) ) );
|
||||
}
|
||||
call_user_func_array( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateUnique', array( $val, $row, $record ) );
|
||||
};
|
||||
}
|
||||
|
||||
@@ -996,6 +986,32 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this value is unique
|
||||
* Used in custom validation for fomr helpers
|
||||
*
|
||||
* @param string $val The value to check
|
||||
* @param \IPS\cms\Fields $field The field
|
||||
* @param \IPS\cms\Records $record The record (if any)
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public static function validateUnique( $val, $field, $record )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( static::$customDatabaseId );
|
||||
|
||||
$where = array( array( 'field_' . $field->id . '=?', $val ) );
|
||||
|
||||
if ( $record !== NULL )
|
||||
{
|
||||
$where[] = array( 'primary_id_field != ?', $record->_id );
|
||||
}
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $database->id, $where )->first() )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack( "field_unique_entry_not_unique", FALSE, array( 'sprintf' => array( $database->recordWord( 1 ) ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Duplicate
|
||||
*
|
||||
@@ -2737,7 +2753,10 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->$key );
|
||||
}
|
||||
|
||||
|
||||
/* Remove reciprocal map data */
|
||||
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array( 'map_origin_database_id=? AND map_field_id=? ', static::$customDatabaseId, $this->id ) );
|
||||
|
||||
/* Best remove the stored data */
|
||||
unset( \IPS\Data\Store::i()->database_reciprocal_links );
|
||||
|
||||
@@ -2996,7 +3015,20 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
{
|
||||
case 'Text':
|
||||
case 'TextArea':
|
||||
$customValidationCode = 'IPS\cms\Fields' . static::$customDatabaseId . '::validateInput_' . $this->id;
|
||||
if ( $this->unique )
|
||||
{
|
||||
$field = $this;
|
||||
$customValidationCode = function( $val ) use ( $field, $record )
|
||||
{
|
||||
call_user_func_array( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateUnique', array( $val, $field, $record ) );
|
||||
|
||||
return call_user_func( 'IPS\cms\Fields' . static::$customDatabaseId . '::validateInput_' . $field->id, $val );
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
$customValidationCode = 'IPS\cms\Fields' . static::$customDatabaseId . '::validateInput_' . $this->id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user