Merging fixes to trunk

Revision: [1805]
Adding fix for Ticket #238

Revision: [1804]
Fixing associations queries.
Adding fix from Ticket #275

Revision: [1803]
Removing the auto generating of a new session id when CAKE_SECURITY set to high.
Adding renew() to the session component, this can be used to regenerate a new session id.

Revision: [1802]
Adding fix for Ticket #280.
Need to decide if we should set the 2 vars mentioned in the ticket automatically,
I changed the 2 method to call the dbo. 

Revision: [1801]
Fixing errors in AclCLI class

Revision: [1800]
Made change to fields name setting, * will no longer be used, query will be built using the tables meta data

Revision: [1799]

Revision: [1798]
Adding fix for Ticket #269

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1806 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-01-15 12:18:57 +00:00
parent fb96b06394
commit 44cd92d739
10 changed files with 89 additions and 76 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.5.1797 RC 1
0.10.5.1806 RC 1

View file

@ -150,6 +150,20 @@ class SessionComponent extends Object
}
/**
* Enter description here...
*
* Use like this. $this->Session->valid();
* This will return true if session is valid
* false if session is invalid
*
* @return boolean
*/
function renew()
{
$this->CakeSession->renew();
}
/**
* Enter description here...
*

View file

@ -112,7 +112,7 @@ class DboSource extends DataSource
function execute($sql)
{
$t = getMicrotime();
$this->_result = $this->__execute($sql);
$this->_result = $this->_execute($sql);
$this->affected = $this->lastAffected();
$this->took = round((getMicrotime() - $t) * 1000, 0);
@ -407,7 +407,7 @@ class DboSource extends DataSource
if ($linkModel == null)
{
// Generates primary query
$sql = 'SELECT ' . join(', ', $this->fields($queryData['fields'])) . ' FROM ';
$sql = 'SELECT ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])) . ' FROM ';
$sql .= $this->name($model->table).' AS ';
$sql .= $this->name($model->name).' ' . join(' ', $queryData['joins']).' ';
$sql .= $this->conditions($queryData['conditions']).' '.$this->order($queryData['order']);
@ -418,7 +418,7 @@ class DboSource extends DataSource
$alias = $association;
if($model->name == $linkModel->name)
{
$alias = Inflector::pluralize($association);
// $alias = Inflector::pluralize($association);
}
switch ($type)
@ -430,7 +430,8 @@ class DboSource extends DataSource
{
return $assocData['finderQuery'];
}
$sql = 'SELECT * FROM '.$this->name($linkModel->table).' AS '.$alias;
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias;
$conditions = $queryData['conditions'];
$condition = $model->escapeField($assocData['foreignKey']);
$condition .= '={$__cake_foreignKey__$}';
@ -510,8 +511,8 @@ class DboSource extends DataSource
else
{
$conditions = $assocData['conditions'];
$sql = 'SELECT * FROM '.$this->name($linkModel->table).' AS ';
$sql .= $this->name($alias);
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
$sql .= ' FROM '.$this->name($linkModel->table).' AS '. $this->name($alias);
$cond = $this->name($alias).'.'.$this->name($assocData['foreignKey']);
$cond .= '={$__cake_id__$}';
@ -541,14 +542,13 @@ class DboSource extends DataSource
else
{
$joinTbl = $this->name($assocData['joinTable']);
$alias = $this->name($alias);
$sql = 'SELECT '.join(', ', $this->fields($assocData['fields']));
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias;
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias);
$sql .= ' JOIN '.$joinTbl.' ON '.$joinTbl;
$sql .= '.'.$this->name($assocData['foreignKey']).'={$__cake_id__$}';
$sql .= ' AND '.$joinTbl.'.'.$this->name($assocData['associationForeignKey']);
$sql .= ' = '.$alias.'.'.$this->name($linkModel->primaryKey);
$sql .= ' = '.$this->name($alias).'.'.$this->name($linkModel->primaryKey);
$sql .= $this->conditions($assocData['conditions']);
$sql .= $this->order($assocData['order']);
@ -621,10 +621,10 @@ class DboSource extends DataSource
{
$data['conditions'] = ' 1 ';
}
if (!isset($data['fields']))
{
$data['fields'] = '*';
}
// if (!isset($data['fields']))
// {
// $data['fields'] = '*';
// }
if (!isset($data['joins']))
{
$data['joins'] = array();
@ -639,11 +639,11 @@ class DboSource extends DataSource
}
}
function fields ($fields)
function fields (&$model, $alias, $fields)
{
if (is_array($fields))
{
$f = $fields;
$fields = $fields;
}
else
{
@ -661,7 +661,12 @@ class DboSource extends DataSource
}
else
{
$fields = array('*');
//$fields = array('*');
foreach ($model->_tableInfo->value as $field)
{
$fields[]= $field['name'];
}
}
}
@ -669,7 +674,7 @@ class DboSource extends DataSource
{
for ($i = 0; $i < count($fields); $i++)
{
$fields[$i] = $this->name($fields[$i]);
$fields[$i] = $this->name($alias).'.'.$this->name($fields[$i]);
}
}
return $fields;

View file

@ -125,8 +125,9 @@ class DboMysql extends DboSource
*
* @param string $sql SQL statement
* @return resource Result resource identifier
* @access protected
*/
function __execute ($sql)
function _execute ($sql)
{
return mysql_query($sql, $this->connection);
}
@ -168,10 +169,16 @@ class DboMysql extends DboSource
*/
function fetchRow ($assoc = false)
{
//return mysql_fetch_array($this->_result, $assoc? MYSQL_ASSOC: MYSQL_BOTH);
$this->resultSet($this->_result);
$resultRow = $this->fetchResult();
return $resultRow;
if(is_resource($this->_result))
{
$this->resultSet($this->_result);
$resultRow = $this->fetchResult();
return $resultRow;
}
else
{
return null;
}
}
/**
@ -244,7 +251,7 @@ class DboMysql extends DboSource
{
return '*';
}
return '`'.$data.'`';
return '`'. ereg_replace('\.', '`.`', $data) .'`';
}
/**

View file

@ -453,7 +453,7 @@ class Model extends Object
switch($key)
{
case 'fields':
$data = '*';
$data = '';
break;
case 'foreignKey':
$data = Inflector::singularize($this->table).'_id';
@ -1346,7 +1346,8 @@ class Model extends Object
*/
function getNumRows ()
{
return $this->__numRows;
//return $this->__numRows;
return $this->db->lastNumRows();
}
/**
@ -1356,7 +1357,8 @@ class Model extends Object
*/
function getAffectedRows ()
{
return $this->__affectedRows;
//return $this->__affectedRows;
return $this->db->lastAffected();
}
/**

View file

@ -450,7 +450,7 @@ class Model extends Object
switch($key)
{
case 'fields':
$data = '*';
$data = '';
break;
case 'foreignKey':
$data = Inflector::singularize($this->table).'_id';
@ -1343,7 +1343,8 @@ class Model extends Object
*/
function getNumRows ()
{
return $this->__numRows;
//return $this->__numRows;
return $this->db->lastNumRows();
}
/**
@ -1353,7 +1354,8 @@ class Model extends Object
*/
function getAffectedRows ()
{
return $this->__affectedRows;
//return $this->__affectedRows;
return $this->db->lastAffected();
}
/**

View file

@ -314,6 +314,7 @@ class CakeSession extends Object
setcookie(CAKE_SESSION_COOKIE, '', time()-42000, $this->path);
}
$file = $sessionpath.DS."sess_".session_id();
session_destroy();
@unlink($file);
$this->__construct($this->path);
}
@ -427,8 +428,8 @@ class CakeSession extends Object
{
if($this->readSessionVar("Config"))
{
if($this->userAgent == $this->readSessionVar("Config.userAgent") &&
$this->time <= $this->readSessionVar("Config.time"))
if($this->userAgent == $this->readSessionVar("Config.userAgent")
&& $this->time <= $this->readSessionVar("Config.time"))
{
$this->writeSessionVar("Config.time", $this->sessionTime);
$this->valid = true;
@ -449,11 +450,6 @@ class CakeSession extends Object
$this->valid = true;
$this->_setError(1, "Session is valid");
}
if($this->security == 'high')
{
$this->_regenerateId();
}
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
}
@ -519,7 +515,7 @@ class CakeSession extends Object
* @access private
*
*/
function _renew()
function renew()
{
$this->_regenerateId();
}

View file

@ -61,7 +61,7 @@ class AjaxHelper extends Helper
*
* @var array
*/
var $ajaxOptions = array('method','position','form','parameters','evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive');
var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive');
/**
* Options for draggable.
@ -84,8 +84,6 @@ class AjaxHelper extends Helper
*/
var $sortOptions = array('tag', 'only', 'overlap', 'constraint', 'containment', 'handle', 'hoverClass', 'ghosting', 'dropOnEmpty', 'onUpdate', 'onChange');
var $__ajaxKeys = array('url', 'with', 'update', 'loading', 'loaded', 'interactive', 'complete', 'type', 'confirm', 'condition', 'before', 'after', 'fallback');
/**
* Returns link to remote action
*
@ -377,22 +375,10 @@ class AjaxHelper extends Helper
$options['id'] = r("/", "_", $field);
}
$htmlOptions = $options;
$ajaxOptions = array('with', 'asynchronous', 'synchronous', 'method', 'position', 'form');
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['autocomplete'] = "off";
foreach($ajaxOptions as $key)
{
if(isset($options[$key]))
{
$ajaxOptions[$key] = $options[$key];
}
else
{
unset($ajaxOptions[$key]);
}
}
if(!isset($options['class']))
{
$options['class'] = "auto_complete";
@ -537,9 +523,13 @@ class AjaxHelper extends Helper
}
function __getHtmlOptions($options)
function __getHtmlOptions($options, $extra = array())
{
foreach($this->__ajaxKeys as $key)
foreach($this->ajaxOptions as $key)
{
unset($options[$key]);
}
foreach($extra as $key)
{
unset($options[$key]);
}

View file

@ -1377,7 +1377,7 @@ class HtmlHelper extends Helper
{
$value = isset($value)? $value : $this->tagValue($tagName."_min");
$minValue = empty($selected) ? date('i') : $selected ;
for( $minCount=0; $minCount<61; $minCount++)
for( $minCount=0; $minCount<60; $minCount++)
{
$mins[$minCount] = sprintf('%02d', $minCount);
}

View file

@ -51,19 +51,17 @@ define ('APP_DIR', 'app');
*
*/
define ('DEBUG', 1);
require_once (ROOT.'cake'.DS.'basics.php');
require_once (ROOT.'cake'.DS.'config'.DS.'paths.php');
require_once (CAKE.'basics.php');
require_once (CONFIGS.'core.php');
require_once (CONFIGS.'database.php');
uses ('neat_array');
uses ('object');
uses ('session');
uses ('security');
uses ('model'.DS.'connection_manager');
uses ('model'.DS.'datasources'.DS.'dbo_source');
uses ('model'.DS.'model');
uses ('model'.DS.'dbo'.DS.'dbo_factory');
uses ('controller'.DS.'controller');
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.'aco');
@ -105,12 +103,6 @@ class AclCLI {
* @var unknown_type
*/
var $acl;
/**
* Enter description here...
*
* @var unknown_type
*/
var $controller;
/**
* Enter description here...
@ -119,6 +111,13 @@ class AclCLI {
*/
var $args;
/**
* Enter description here...
*
* @var unknown_type
*/
var $dataSource = 'default';
/**
* Enter description here...
*
@ -143,9 +142,7 @@ class AclCLI {
$this->acl = $acl->getACL();
$this->args = $args;
$this->controller =& new Controller();
$this->controller->constructClasses();
$this->db =& ConnectionManager::getDataSource($this->dataSource);
$this->stdin = fopen('php://stdin', 'r');
$this->stdout = fopen('php://stdout', 'w');
@ -382,7 +379,7 @@ class AclCLI {
`rght` int(11) default NULL,
PRIMARY KEY (`id`)
);";
$this->controller->db->query($sql);
$this->db->query($sql);
fwrite($this->stdout, "Creating access request objects table (acos)...\n");
$sql2 = "CREATE TABLE `aros` (
@ -393,7 +390,7 @@ class AclCLI {
`rght` int(11) default NULL,
PRIMARY KEY (`id`)
);";
$this->controller->db->query($sql2);
$this->db->query($sql2);
fwrite($this->stdout, "Creating relationships table (aros_acos)...\n");
$sql3 = "CREATE TABLE `aros_acos` (
@ -406,7 +403,7 @@ class AclCLI {
`_delete` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
);";
$this->controller->db->query($sql3);
$this->db->query($sql3);
fwrite($this->stdout, "\nDone.\n");
}
@ -574,7 +571,7 @@ class AclCLI {
$class = ucwords($type);
$vars['secondary_id'] = ($class == 'aro' ? 'user_id' : 'object_id');
$vars['data_name'] = $type;
$vars['table_name'] = $class . 's';
$vars['table_name'] = $type . 's';
$vars['class'] = $class;
return $vars;
}