|
|
@@ -1,16 +1,14 @@
|
|
|
<?php
|
|
|
App::uses('ModelBehavior', 'Model');
|
|
|
/**
|
|
|
- * ConfirmableBehavior allows forms to easily require a checkbox toggled (confirmed)
|
|
|
- * example: terms of use on registration
|
|
|
+ * ConfirmableBehavior allows forms to easily require a checkbox toggled (confirmed).
|
|
|
+ * Example: Terms of use on registration forms or some "confirm delete checkbox"
|
|
|
*
|
|
|
* Copyright 2011, dereuromark (http://www.dereuromark.de)
|
|
|
*
|
|
|
- * @link http://github.com/dereuromark/
|
|
|
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
- */
|
|
|
-
|
|
|
-/**
|
|
|
+ * @link http://github.com/dereuromark/
|
|
|
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
+ * @link http://www.dereuromark.de/2011/07/05/introducing-two-cakephp-behaviors/
|
|
|
* 2011-07-05 ms
|
|
|
*/
|
|
|
class ConfirmableBehavior extends ModelBehavior {
|
|
|
@@ -32,7 +30,12 @@ class ConfirmableBehavior extends ModelBehavior {
|
|
|
$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], is_array($settings) ? $settings : array());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * ConfirmableBehavior::beforeValidate()
|
|
|
+ *
|
|
|
+ * @param mixed $Model
|
|
|
+ * @return bool $success
|
|
|
+ */
|
|
|
public function beforeValidate(Model $Model) {
|
|
|
$return = parent::beforeValidate($Model);
|
|
|
|
|
|
@@ -45,6 +48,12 @@ class ConfirmableBehavior extends ModelBehavior {
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * ConfirmableBehavior::beforeSave()
|
|
|
+ *
|
|
|
+ * @param mixed $Model
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
public function beforeSave(Model $Model) {
|
|
|
$return = parent::beforeSave($Model);
|
|
|
|
|
|
@@ -55,9 +64,8 @@ class ConfirmableBehavior extends ModelBehavior {
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * Run before a model is saved, used...
|
|
|
+ * The actual logic
|
|
|
*
|
|
|
* @param object $Model Model about to be saved.
|
|
|
* @return boolean true if save should proceed, false otherwise
|
|
|
@@ -75,6 +83,4 @@ class ConfirmableBehavior extends ModelBehavior {
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
+}
|