mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merging fixes and enhancements into trunk
Revision: [1843] Added param $allowed to Sanitize::paranoid() this array will allow passing characters that you do not want removed in the string. Modified Sanitize::paranoid() to check an array. Modified Model::findNeighbours() setting param $conditions to null by default. Added fix for Ticket #294 Added fix to scripts/acl.php changed DboSource::fields() to use the count() one time instead of using it in the for loop also git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1844 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
73830ec0dc
commit
48c9bb3bbd
6 changed files with 64 additions and 33 deletions
|
@ -6,4 +6,4 @@
|
||||||
// +---------------------------------------------------------------------------------------------------+ //
|
// +---------------------------------------------------------------------------------------------------+ //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
0.10.7.1842 RC 2
|
0.10.7.1844 RC 2
|
|
@ -902,9 +902,10 @@ class DboSource extends DataSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($fields) >= 1 && $fields[0] != '*')
|
$count = count($fields);
|
||||||
|
if ($count > 1 && $fields[0] != '*')
|
||||||
{
|
{
|
||||||
for ($i = 0; $i < count($fields); $i++)
|
for ($i = 0; $i < $count; $i++)
|
||||||
{
|
{
|
||||||
$fields[$i] = $this->name($alias).'.'.$this->name($fields[$i]);
|
$fields[$i] = $this->name($alias).'.'.$this->name($fields[$i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -959,7 +959,7 @@ class Model extends Object
|
||||||
*/
|
*/
|
||||||
function hasAny ($conditions = null)
|
function hasAny ($conditions = null)
|
||||||
{
|
{
|
||||||
return ($this->findCount($conditions) !== false);
|
return ($this->findCount($conditions) != false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1120,10 +1120,14 @@ class Model extends Object
|
||||||
* @param unknown_type $value
|
* @param unknown_type $value
|
||||||
* @return array Array with keys "prev" and "next" that holds the id's
|
* @return array Array with keys "prev" and "next" that holds the id's
|
||||||
*/
|
*/
|
||||||
function findNeighbours ($conditions, $field, $value)
|
function findNeighbours ($conditions = null, $field, $value)
|
||||||
{
|
{
|
||||||
@list($prev) = Model::findAll($conditions . ' AND ' . $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
if(!is_null($conditions))
|
||||||
@list($next) = Model::findAll($conditions . ' AND ' . $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
{
|
||||||
|
$conditions = $conditions.' AND ';
|
||||||
|
}
|
||||||
|
@list($prev) = Model::findAll($conditions. $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
||||||
|
@list($next) = Model::findAll($conditions. $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
||||||
|
|
||||||
if (!isset($prev))
|
if (!isset($prev))
|
||||||
{
|
{
|
||||||
|
|
|
@ -953,7 +953,7 @@ class Model extends Object
|
||||||
*/
|
*/
|
||||||
function hasAny ($conditions = null)
|
function hasAny ($conditions = null)
|
||||||
{
|
{
|
||||||
return ($this->findCount($conditions) !== false);
|
return ($this->findCount($conditions) != false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1114,10 +1114,14 @@ class Model extends Object
|
||||||
* @param unknown_type $value
|
* @param unknown_type $value
|
||||||
* @return array Array with keys "prev" and "next" that holds the id's
|
* @return array Array with keys "prev" and "next" that holds the id's
|
||||||
*/
|
*/
|
||||||
function findNeighbours ($conditions, $field, $value)
|
function findNeighbours ($conditions = null, $field, $value)
|
||||||
{
|
{
|
||||||
@list($prev) = Model::findAll($conditions . ' AND ' . $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
if(!is_null($conditions))
|
||||||
@list($next) = Model::findAll($conditions . ' AND ' . $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
{
|
||||||
|
$conditions = $conditions.' AND ';
|
||||||
|
}
|
||||||
|
@list($prev) = Model::findAll($conditions. $field . ' < ' . $this->db->value($value), $field, $field . ' DESC', 1);
|
||||||
|
@list($next) = Model::findAll($conditions. $field . ' > ' . $this->db->value($value), $field, $field . ' ASC', 1);
|
||||||
|
|
||||||
if (!isset($prev))
|
if (!isset($prev))
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,9 +48,30 @@ class Sanitize
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function paranoid($string)
|
function paranoid($string, $allowed = array())
|
||||||
{
|
{
|
||||||
return preg_replace( "/[^a-zA-Z0-9]/", "", $string );
|
$allow = null;
|
||||||
|
|
||||||
|
if(!empty($allowed))
|
||||||
|
{
|
||||||
|
foreach ($allowed as $value)
|
||||||
|
{
|
||||||
|
$allow .= "\\$value";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_array($string))
|
||||||
|
{
|
||||||
|
foreach ($string as $key => $clean)
|
||||||
|
{
|
||||||
|
$cleaned[$key] = preg_replace( "/[^{$allow}a-zA-Z0-9]/", "", $clean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cleaned = preg_replace( "/[^{$allow}a-zA-Z0-9]/", "", $string );
|
||||||
|
}
|
||||||
|
return $cleaned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,7 @@ uses ('security');
|
||||||
uses ('model'.DS.'connection_manager');
|
uses ('model'.DS.'connection_manager');
|
||||||
uses ('model'.DS.'datasources'.DS.'dbo_source');
|
uses ('model'.DS.'datasources'.DS.'dbo_source');
|
||||||
uses ('model'.DS.'model');
|
uses ('model'.DS.'model');
|
||||||
|
require_once(CAKE.'app_model.php');
|
||||||
uses ('controller'.DS.'components'.DS.'acl');
|
uses ('controller'.DS.'components'.DS.'acl');
|
||||||
uses ('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode');
|
uses ('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode');
|
||||||
uses ('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco');
|
uses ('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco');
|
||||||
|
|
Loading…
Add table
Reference in a new issue