euromark 13 年 前
コミット
ecb58bca57

+ 6 - 2
Lib/MyModel.php

@@ -408,12 +408,13 @@ class MyModel extends Model {
 	 * @param string $type The type o the query ('count'/'all'/'first' - first only works with some mysql versions)
 	 * @param array $options The options array
 	 * @param string $alias You can use this intead of $options['alias'] if you want
+	 * @param bool $parenthesise Add parenthesis before and after
 	 * @return string $result sql snippet of the query to run
 	 * @modified Mark Scherer (cake2.x ready and improvements)
 	 * @link http://bakery.cakephp.org/articles/lucaswxp/2011/02/11/easy_and_simple_subquery_cakephp
 	 * 2011-07-05 ms
 	 */
-	public function subquery($type, $options = array(), $alias = null) {
+	public function subquery($type, $options = array(), $alias = null, $parenthesise = true) {
 		if ($alias === null) {
 			$alias = 'Sub' . $this->alias . '';
 		}
@@ -443,7 +444,10 @@ class MyModel extends Model {
 			'group' => null
 		);
 		$params = array_merge($default, $options);
-		$subQuery = '(' . trim($dbo->buildStatement($params, $this)) . ')';
+		$subQuery = trim($dbo->buildStatement($params, $this));
+		if ($parenthesise) {
+			$subQuery = '(' . $subQuery . ')';
+		}
 		return $subQuery;
 	}
 

+ 2 - 1
Model/Behavior/ChangePasswordBehavior.php

@@ -31,7 +31,7 @@ if (!defined('PWD_MAX_LENGTH')) {
  * TODO: allowEmpty and nonEmptyToEmpty - maybe with checkbox "set_new_pwd"
  * feel free to help me out
  *
- * @version 1.5
+ * @deprecated Use PasswordableBehavior instead!
  * @author Mark Scherer
  * @link http://www.dereuromark.de/2011/08/25/working-with-passwords-in-cakephp
  * @license MIT
@@ -168,6 +168,7 @@ class ChangePasswordBehavior extends ModelBehavior {
 	 * 2011-08-24 ms
 	 */
 	public function setup(Model $Model, $config = array()) {
+		trigger_error('Deprecated - use PasswordableBehavior instead');
 		$defaults = $this->_defaultSettings;
 		if ($configureDefaults = Configure::read('ChangePassword')) {
 			$defaults = Set::merge($defaults, $configureDefaults);

+ 1 - 1
Model/Behavior/PasswordableBehavior.php

@@ -169,7 +169,7 @@ class PasswordableBehavior extends ModelBehavior {
 	 */
 	public function setup(Model $Model, $config = array()) {
 		$defaults = $this->_defaultSettings;
-		if ($configureDefaults = Configure::read('ChangePassword')) {
+		if ($configureDefaults = Configure::read('Passwordable')) {
 			$defaults = Set::merge($defaults, $configureDefaults);
 		}
 		$this->settings[$Model->alias] = Set::merge($defaults, $config);