mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merging fixes into the trunk.
Revision: [2641] Adding fix for file upload data Revision: [2640] Disabling Dispatcher access to controller callbacks Revision: [2639] Fixing output bug in AjaxHelper::link() Revision: [2638] Adding fix for Ticket #714 (The OC! [not the tv show]) Revision: [2637] Additional refactoring of DB_ACL git-svn-id: https://svn.cakephp.org/repo/trunk/cake/1.x.x.x@2642 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0c0dec8bc0
commit
e385b666dd
8 changed files with 82 additions and 22 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1.0.0.2630
|
||||
1.0.0.2642
|
|
@ -76,7 +76,7 @@ selectend = "</select>"
|
|||
password = "<input type="password" name="data[%s][%s]" %s/>"
|
||||
|
||||
; Tag template for a file input tag.
|
||||
file = "<input type="file" name="%s" %s/>"
|
||||
file = "<input type="file" name="data[%s][%s]" %s/>"
|
||||
|
||||
; Tag template for a submit button tag.
|
||||
submit = "<input type="submit" %s/>"
|
||||
|
|
|
@ -205,6 +205,11 @@ class Dispatcher extends Object
|
|||
$missingAction = true;
|
||||
}
|
||||
|
||||
if (in_array(strtolower($params['action']), array('beforefilter', 'beforerender', 'afterfilter')))
|
||||
{
|
||||
$missingAction = true;
|
||||
}
|
||||
|
||||
if(in_array('return', array_keys($params)) && $params['return'] == 1)
|
||||
{
|
||||
$controller->autoRender = false;
|
||||
|
@ -362,8 +367,25 @@ class Dispatcher extends Object
|
|||
|
||||
foreach ($_FILES as $name => $data)
|
||||
{
|
||||
$params['form'][$name] = $data;
|
||||
if ($name != 'data')
|
||||
{
|
||||
$params['form'][$name] = $data;
|
||||
}
|
||||
}
|
||||
if (isset($_FILES['data']))
|
||||
{
|
||||
foreach ($_FILES['data'] as $key => $data)
|
||||
{
|
||||
foreach ($data as $model => $fields)
|
||||
{
|
||||
foreach ($fields as $field => $value)
|
||||
{
|
||||
$params['data'][$model][$field][$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
|
||||
|
||||
$params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
|
||||
|
|
|
@ -266,7 +266,17 @@ class DB_ACL extends AclBase
|
|||
return null;
|
||||
}
|
||||
$obj = new $obj;
|
||||
$tmp = $obj->find(is_numeric($id) ? "Aco.user_id = {$id}" : "Aco.alias = '" . addslashes($id) . "'");
|
||||
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$conditions = array('Aco.user_id' => $id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$conditions = array('Aco.alias' => $id);
|
||||
}
|
||||
|
||||
$tmp = $obj->find($conditions);
|
||||
$aco->setId($tmp['Aco']['id']);
|
||||
return $aco;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class AclNode extends AppModel
|
|||
}
|
||||
|
||||
$parent = $parent[$class];
|
||||
$this->_syncTable($table_name, 1, $parent['lft'], $parent['lft']);
|
||||
$this->_syncTable(1, $parent['lft'], $parent['lft']);
|
||||
}
|
||||
|
||||
$return = $this->save(array($class => array(
|
||||
|
@ -157,7 +157,7 @@ class AclNode extends AppModel
|
|||
return false;
|
||||
}
|
||||
|
||||
$this->_syncTable($table_name, 0, $object['lft'], $object['lft']);
|
||||
$this->_syncTable(0, $object['lft'], $object['lft']);
|
||||
|
||||
if ($object['lft'] < $newParent['lft'])
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ class AclNode extends AppModel
|
|||
|
||||
if ($parent_id != null)
|
||||
{
|
||||
$this->_syncTable($table_name, 1, $newParent['lft'], $newParent['lft']);
|
||||
$this->_syncTable(1, $newParent['lft'], $newParent['lft']);
|
||||
}
|
||||
|
||||
$object['lft'] = $newParent['lft'] + 1;
|
||||
|
@ -176,7 +176,7 @@ class AclNode extends AppModel
|
|||
|
||||
if($newParent['lft'] == 0)
|
||||
{
|
||||
$this->_syncTable($table_name, 2, $newParent['lft'], $newParent['lft']);
|
||||
$this->_syncTable(2, $newParent['lft'], $newParent['lft']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -260,12 +260,11 @@ class AclNode extends AppModel
|
|||
* Shifts the left and right values of the aro/aco tables
|
||||
* when a node is added or removed
|
||||
*
|
||||
* @param unknown_type $table
|
||||
* @param unknown_type $dir
|
||||
* @param unknown_type $lft
|
||||
* @param unknown_type $rght
|
||||
*/
|
||||
function _syncTable($table, $dir, $lft, $rght)
|
||||
function _syncTable($dir, $lft, $rght)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
|
||||
|
@ -287,8 +286,8 @@ class AclNode extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
$db->query('UPDATE '.$table.' SET rght = rght '.$dir.' '.$shift.' WHERE rght > '.$rght);
|
||||
$db->query('UPDATE '.$table.' SET lft = lft '.$dir.' '.$shift.' WHERE lft > '.$lft);
|
||||
$db->query('UPDATE '.$this->table.' SET '.$db->name('rght').' = '.$db->name('rght').' '.$dir.' '.$shift.' WHERE '.$db->name('rght').' > '.$rght);
|
||||
$db->query('UPDATE '.$this->table.' SET '.$db->name('lft').' = '.$db->name('lft').' '.$dir.' '.$shift.' WHERE '.$db->name('lft').' > '.$lft);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,7 +307,6 @@ class AclNode extends AppModel
|
|||
{
|
||||
$vars['secondary_id'] = 'object_id';
|
||||
}
|
||||
$vars['table_name'] = $class . 's';
|
||||
$vars['class'] = ucwords($class);
|
||||
return $vars;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,13 @@ class Router extends Object {
|
|||
*/
|
||||
var $routes = array();
|
||||
|
||||
/**
|
||||
* CAKE_ADMIN route
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $__admin = null;
|
||||
|
||||
function __construct ()
|
||||
{
|
||||
if(defined('CAKE_ADMIN'))
|
||||
|
@ -59,7 +66,7 @@ class Router extends Object {
|
|||
$admin = CAKE_ADMIN;
|
||||
if(!empty($admin))
|
||||
{
|
||||
$this->routes[] = array (
|
||||
$this->__admin = array (
|
||||
'/:'.$admin.'/:controller/:action/* (default)',
|
||||
'/^(?:\/(?:('.$admin.')(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/',
|
||||
array($admin, 'controller', 'action'),
|
||||
|
@ -81,6 +88,15 @@ class Router extends Object {
|
|||
{
|
||||
$parsed = $names = array ();
|
||||
|
||||
if (defined('CAKE_ADMIN') && $default == null)
|
||||
{
|
||||
if ($route == CAKE_ADMIN)
|
||||
{
|
||||
$this->routes[] = $this->__admin;
|
||||
$this->__admin = null;
|
||||
}
|
||||
}
|
||||
|
||||
$r = null;
|
||||
if (($route == '') || ($route == '/'))
|
||||
{
|
||||
|
@ -151,16 +167,22 @@ class Router extends Object {
|
|||
array('controller', 'action'),
|
||||
array());
|
||||
|
||||
if (defined('CAKE_ADMIN') && $this->__admin != null)
|
||||
{
|
||||
$this->routes[] = $this->__admin;
|
||||
$this->__admin = null;
|
||||
}
|
||||
|
||||
$this->connect('/bare/:controller/:action/*', array('bare'=>'1'));
|
||||
$this->connect('/ajax/:controller/:action/*', array('bare'=>'1'));
|
||||
|
||||
if(defined('WEBSERVICES') && WEBSERVICES == 'on' )
|
||||
{
|
||||
$this->connect('/rest/:controller/:action/*', array('webservices'=>'Rest'));
|
||||
$this->connect('/rss/:controller/:action/*', array('webservices'=>'Rss'));
|
||||
$this->connect('/soap/:controller/:action/*', array('webservices'=>'Soap'));
|
||||
$this->connect('/xml/:controller/:action/*', array('webservices'=>'Xml'));
|
||||
$this->connect('/xmlrpc/:controller/:action/*', array('webservices'=>'XmlRpc'));
|
||||
$this->connect('/rest/:controller/:action/*', array('webservices' => 'Rest'));
|
||||
$this->connect('/rss/:controller/:action/*', array('webservices' => 'Rss'));
|
||||
$this->connect('/soap/:controller/:action/*', array('webservices' => 'Soap'));
|
||||
$this->connect('/xml/:controller/:action/*', array('webservices' => 'Xml'));
|
||||
$this->connect('/xmlrpc/:controller/:action/*', array('webservices' => 'XmlRpc'));
|
||||
}
|
||||
|
||||
$this->routes[] = $default_route;
|
||||
|
|
|
@ -189,13 +189,19 @@ class AjaxHelper extends Helper
|
|||
if (isset($options['id']))
|
||||
{
|
||||
$htmlOptions['onclick'] = ' return false;';
|
||||
return $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle) . $this->Javascript->event("'{$options['id']}'", "click", $this->remoteFunction($options));
|
||||
$return = $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle);
|
||||
$script = $this->Javascript->event("'{$options['id']}'", "click", $this->remoteFunction($options));
|
||||
if (is_string($script))
|
||||
{
|
||||
$return .= $script;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$htmlOptions['onclick'] = $this->remoteFunction($options) . '; return false;';
|
||||
return $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle);
|
||||
$return = $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function linkToRemote ($title, $options = array(), $html_options = array())
|
||||
|
|
|
@ -395,7 +395,9 @@ function url($url = null, $return = false)
|
|||
*/
|
||||
function file($fieldName, $htmlAttributes = null, $return = false)
|
||||
{
|
||||
return $this->output(sprintf($this->tags['file'], $fieldName,
|
||||
$this->setFormTag($fieldName);
|
||||
|
||||
return $this->output(sprintf($this->tags['file'], $this->model, $this->field,
|
||||
$this->_parseAttributes($htmlAttributes, null, '', ' ')), $return);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue