diff --git a/VERSION.txt b/VERSION.txt index 3486c52b6..b1d702d25 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -0.10.8.2176 \ No newline at end of file +0.10.8.2195 \ No newline at end of file diff --git a/app/webroot/index.php b/app/webroot/index.php index 0b315443f..43488974f 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -110,6 +110,6 @@ else if (DEBUG) { - echo ""; + echo ""; } ?> \ No newline at end of file diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 9fef4085f..6be01946f 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -135,6 +135,10 @@ class Dispatcher extends Object { $params['controller'] = Inflector::underscore($ctrlName); $ctrlClass = $ctrlName.'Controller'; + if (!is_null($params['action'])) + { + array_unshift($params['pass'], $params['action']); + } $params['action'] = $oldAction; } } diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index 9d5dfda5d..95e481ea0 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -102,6 +102,36 @@ class RequestHandlerComponent extends Object } } +/** + * Returns true if the current call a POST request + * + * @return bool True if call is a POST + */ + function isPost() + { + return (low(env('REQUEST_METHOD')) == 'post'); + } + +/** + * Returns true if the current call a PUT request + * + * @return bool True if call is a PUT + */ + function isPut() + { + return (low(env('REQUEST_METHOD')) == 'put'); + } + +/** + * Returns true if the current call a GET request + * + * @return bool True if call is a GET + */ + function isGet() + { + return (low(env('REQUEST_METHOD')) == 'get'); + } + /** * Gets Prototype version if call is Ajax, otherwise empty string. diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 4fdf24011..663f47a2a 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -90,7 +90,7 @@ class Controller extends Object * * @var unknown_type */ - var $viewPath; + var $viewPath = null; /** * Variables for the view @@ -208,7 +208,12 @@ class Controller extends Object } $this->name = $r[1]; } - $this->viewPath = Inflector::underscore($this->name); + + if ($this->viewPath == null) + { + $this->viewPath = Inflector::underscore($this->name); + } + $this->modelClass = Inflector::singularize($this->name); $this->modelKey = Inflector::underscore($this->modelClass); @@ -395,6 +400,8 @@ class Controller extends Object $this->action = $action; $args = func_get_args(); + unset($args[0]); + call_user_func_array(array(&$this, $action), $args); } @@ -461,6 +468,18 @@ class Controller extends Object $this->beforeRender(); + if (!isset($this->_viewVars['data'])) + { + if (isset($this->params['data'])) + { + $this->set('data', $this->params['data']); + } + else + { + $this->set('data', array()); + } + } + $this->_viewClass =& new $viewClass($this); if(!empty($this->modelNames)) { diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 5a53f9849..a39040427 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -445,12 +445,12 @@ class DataSource extends Object $keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}'); foreach($keys as $key) { + $val = null; if (strpos($query, $key) !== false) { switch($key) { case '{$__cakeID__$}': - $val = null; if (isset($data[$index][$model->name])) { if(isset($data[$index][$model->name][$model->primaryKey])) @@ -463,8 +463,9 @@ class DataSource extends Object } } break; - case '{$__cake_foreignKey__$}': - + case '{$__cakeForeignKey__$}': + $foreignKey = Inflector::underscore($linkModel->name).'_id'; + $val = $data[$index][$model->name][$foreignKey]; break; } $query = r($key, $this->value($val, $model->getColumnType($model->primaryKey)), $query); diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b2c96aff9..083a909fb 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -383,6 +383,7 @@ class DboSource extends DataSource $linkedModels = array(); $this->__bypass = false; $this->__assocJoins = null; + if(!is_null($recursive)) { $_recursive = $model->recursive; @@ -429,16 +430,15 @@ class DboSource extends DataSource { foreach($model->{$type} as $assoc => $assocData) { + $linkModel =& $model->{$assocData['className']}; if (!in_array($type.'/'.$assoc, $linkedModels)) { - $linkModel =& $model->{$assocData['className']}; $this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive); - } else { - // Fetch recursively on belongsTo and hasOne - if ($model->recursive > 1) - { -//$this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1); - } + } + elseif($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) + { + // Do recursive joins on belongsTo and hasOne relationships + $this->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1); } } } @@ -656,10 +656,11 @@ class DboSource extends DataSource $assocData['fields'] = ''; } $sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields'])); - $sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias; + $sql .= ' FROM '.$this->name($linkModel->table).' AS '.$alias.' '; $conditions = $queryData['conditions']; $condition = $model->escapeField($assocData['foreignKey']); $condition .= '={$__cakeForeignKey__$}'; + if (is_array($conditions)) { $conditions[] = $condition; @@ -722,7 +723,7 @@ class DboSource extends DataSource $conditions = $assocData['conditions']; $condition = $linkModel->escapeField($linkModel->primaryKey); - $condition .= '={$__cakeID__$}'; + $condition .= '={$__cakeForeignKey__$}'; if (is_array($conditions)) { @@ -1026,7 +1027,7 @@ class DboSource extends DataSource { if (!preg_match('/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i', $conditions, $match)) { - $clause = 'WHERE '; + $clause = ' WHERE '; } } if (is_string($conditions)) @@ -1066,7 +1067,7 @@ class DboSource extends DataSource } else { - $clause = 'WHERE '; + $clause = ' WHERE '; $out = $this->conditionKeysToString($conditions); return $clause . ' ('.join(') AND (', $out).')'; } diff --git a/cake/libs/model/dbo/dbo_mysql.php b/cake/libs/model/dbo/dbo_mysql.php index ee3e0ef7c..60efc3e28 100644 --- a/cake/libs/model/dbo/dbo_mysql.php +++ b/cake/libs/model/dbo/dbo_mysql.php @@ -88,9 +88,9 @@ class DboMysql extends DboSource 'text' => array('name' => 'text'), 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), 'float' => array('name' => 'float', 'formatter' => 'floatval'), - 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'), - 'time' => array('name' => 'time', 'format' => 'h:i:s', 'formatter' => 'date'), + 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), + 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), + 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'), 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'), 'binary' => array('name' => 'blob'), 'boolean' => array('name' => 'tinyint', 'limit' => '1')); diff --git a/cake/libs/model/dbo/dbo_postgres.php b/cake/libs/model/dbo/dbo_postgres.php index 8c7abbb76..94e0478fc 100644 --- a/cake/libs/model/dbo/dbo_postgres.php +++ b/cake/libs/model/dbo/dbo_postgres.php @@ -389,6 +389,54 @@ class DboPostgres extends DboSource return null; } +/** + * Converts database-layer column types to basic types + * + * @param string $real Real database-layer column type (i.e. "varchar(255)") + * @return string Abstract column type (i.e. "string") + */ + function column($real) + { + $col = r(')', '', $real); + $limit = null; + @list($col, $limit) = explode('(', $col); + + if (in_array($col, array('date', 'time', 'timestamp'))) + { + return $col; + } + if ($col == 'boolean') + { + return 'boolean'; + } + if (strpos($col, 'integer') !== false) + { + return 'integer'; + } + if (strpos($col, 'char') !== false) + { + return 'string'; + } + if (strpos($col, 'text') !== false) + { + return 'text'; + } + if (strpos($col, 'bytea') !== false) + { + return 'binary'; + } + if (in_array($col, array('float', 'double', 'decimal'))) + { + return 'float'; + } + return 'text'; + } + +/** + * Enter description here... + * + * @param unknown_type $results + */ function resultSet(&$results) { $this->results =& $results; diff --git a/cake/libs/model/model_php4.php b/cake/libs/model/model_php4.php index a307be7bf..8290a072a 100644 --- a/cake/libs/model/model_php4.php +++ b/cake/libs/model/model_php4.php @@ -417,7 +417,7 @@ class Model extends Object $this->__backAssociation[$assoc] = $this->{$assoc}; foreach($models as $model) { - $this->__backAssociation = array_merge_recursive($this->__backAssociation, $this->{$assoc}); + $this->__backAssociation = array_merge($this->__backAssociation, $this->{$assoc}); unset($this->{$assoc}[$model]); } } @@ -555,7 +555,7 @@ class Model extends Object { if($this->db->isInterfaceSupported('listSources')) { - if (!in_array(strtolower($tableName), $this->db->listSources())) + if (!in_array(low($tableName), $this->db->listSources()) && !in_array($tableName, $this->db->listSources())) { return $this->cakeError('missingTable',array(array('className' => $this->name, 'table' => $tableName))); @@ -847,6 +847,7 @@ class Model extends Object $weHaveMulti = false; } + $newID = null; foreach ($this->data as $n => $v) { if(isset($weHaveMulti) && $count > 0 && count($this->hasAndBelongsToMany) > 0) @@ -917,13 +918,16 @@ class Model extends Object if($this->db->create($this, $fields, $values)) { $this->__insertID = $this->db->lastInsertId($this->table, $this->primaryKey); - $this->id = $this->__insertID; - if(!$this->id > 0 && isset($newID)) + if (!$this->__insertID && $newID != null) { $this->__insertID = $newID; $this->id = $newID; } + else + { + $this->id = $this->__insertID; + } if(!empty($joined)) { @@ -1311,7 +1315,7 @@ class Model extends Object $sizeOf = sizeof($data); for ($ii=0; $ii < $sizeOf; $ii++) { - if ($data[$ii][$this->name]['parent_id'] == $root) + if (($data[$ii][$this->name]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->name]['parent_id'] == '0'))) { $tmp = $data[$ii]; if (isset($data[$ii][$this->name][$this->primaryKey])) diff --git a/cake/libs/model/model_php5.php b/cake/libs/model/model_php5.php index 4b14605ad..92605f56b 100644 --- a/cake/libs/model/model_php5.php +++ b/cake/libs/model/model_php5.php @@ -413,7 +413,7 @@ class Model extends Object $this->__backAssociation[$assoc] = $this->{$assoc}; foreach($models as $model) { - $this->__backAssociation = array_merge_recursive($this->__backAssociation, $this->{$assoc}); + $this->__backAssociation = array_merge($this->__backAssociation, $this->{$assoc}); unset($this->{$assoc}[$model]); } } @@ -551,7 +551,7 @@ class Model extends Object { if($this->db->isInterfaceSupported('listSources')) { - if (!in_array(strtolower($tableName), $this->db->listSources())) + if (!in_array(low($tableName), $this->db->listSources()) && !in_array($tableName, $this->db->listSources())) { return $this->cakeError('missingTable',array(array('className' => $this->name, 'table' => $tableName))); @@ -843,6 +843,7 @@ class Model extends Object $weHaveMulti = false; } + $newID = null; foreach ($this->data as $n => $v) { if(isset($weHaveMulti) && $count > 0 && count($this->hasAndBelongsToMany) > 0) @@ -913,13 +914,16 @@ class Model extends Object if($this->db->create($this, $fields, $values)) { $this->__insertID = $this->db->lastInsertId($this->table, $this->primaryKey); - $this->id = $this->__insertID; - if(!$this->id > 0 && isset($newID)) + if (!$this->__insertID && $newID != null) { $this->__insertID = $newID; $this->id = $newID; } + else + { + $this->id = $this->__insertID; + } if(!empty($joined)) { @@ -1307,7 +1311,7 @@ class Model extends Object $sizeOf = sizeof($data); for ($ii=0; $ii < $sizeOf; $ii++) { - if ($data[$ii][$this->name]['parent_id'] == $root) + if (($data[$ii][$this->name]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->name]['parent_id'] == '0'))) { $tmp = $data[$ii]; if (isset($data[$ii][$this->name][$this->primaryKey])) diff --git a/cake/libs/security.php b/cake/libs/security.php index f204d84e3..46fe69ea7 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -53,7 +53,7 @@ class Security extends Object function inactiveMins() { - $security =& Security::getInstance(); + //$security =& Security::getInstance(); switch (CAKE_SECURITY) { case 'high': @@ -71,8 +71,7 @@ class Security extends Object function generateAuthKey() { - - return $authKey; + return Security::hash(uniqid(rand(), true)); } function validateAuthKey($authKey) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 77334691e..a30e6acb1 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -189,7 +189,7 @@ class AjaxHelper extends Helper if (isset($options['id'])) { $htmlOptions['onclick'] = ' return false;'; - return $this->Html->link($title, $href, $htmlOptions) . $this->Javascript->event("$('{$options['id']}')", "click", $this->remoteFunction($options)); + return $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle) . $this->Javascript->event("$('{$options['id']}')", "click", $this->remoteFunction($options)); } else { @@ -648,11 +648,17 @@ class AjaxHelper extends Helper { foreach($this->ajaxOptions as $key) { - unset($options[$key]); + if (isset($options[$key])) + { + unset($options[$key]); + } } foreach($extra as $key) { - unset($options[$key]); + if (isset($extra[$key])) + { + unset($options[$key]); + } } return $options; } diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 13757c89b..38fff3e04 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -208,7 +208,7 @@ class HtmlHelper extends Helper $htmlAttributes['onclick'] = "return confirm('{$confirmMessage}');"; } - if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0))) + if (((strpos($url, '://')) || (strpos($url, 'javascript:') === 0) || (strpos($url, 'mailto:') === 0))) { $output = sprintf($this->tags['link'], $url, $this->_parseAttributes($htmlAttributes), $title); @@ -1126,7 +1126,13 @@ class HtmlHelper extends Helper $htmlAttributes['method'] = $type=='get'? 'get': 'post'; $type == 'file'? $htmlAttributes['enctype'] = 'multipart/form-data': null; - return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')); + $token = ''; + if (isset($this->params['_Token']) && !empty($this->params['_Token'])) + { + $token = $this->hidden('_Token/key', array('value' => $this->params['_Token']['key']), true); + } + + return sprintf($this->tags['form'], $this->parseHtmlOptions($htmlAttributes, null, '')) . $token; } /** diff --git a/cake/scripts/acl.php b/cake/scripts/acl.php index 6318ebb98..409036228 100644 --- a/cake/scripts/acl.php +++ b/cake/scripts/acl.php @@ -41,6 +41,7 @@ define ('DS', DIRECTORY_SEPARATOR); define ('ROOT', dirname(dirname(dirname(__FILE__))).DS); define ('APP_DIR', 'app'); define('CAKE_CORE_INCLUDE_PATH', ROOT); +define('CORE_PATH', CAKE_CORE_INCLUDE_PATH); define ('DEBUG', 1); ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS); @@ -53,6 +54,7 @@ uses ('neat_array'); uses ('object'); uses ('session'); uses ('security'); +uses ('inflector'); uses ('model'.DS.'connection_manager'); uses ('model'.DS.'datasources'.DS.'dbo_source'); uses ('model'.DS.'model');