summaryrefslogtreecommitdiff
path: root/modules/comment/models
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-05-15 23:36:52 -0700
committerTim Almdal <tnalmdal@shaw.ca>2010-05-15 23:36:52 -0700
commit29a8ba959ec1ec1ebd14d12c2a102fd7d3fcd012 (patch)
treed1f75ca29e54e1df32d1d5589ec27b676ca092b4 /modules/comment/models
parent28aee011307e37cd80e9bef0f08cb9b0270d89b5 (diff)
parent1240878df0f4a2b0ad0cdb32814717038ff2773f (diff)
Merge branch 'master' into talmdal_dev
Diffstat (limited to 'modules/comment/models')
-rw-r--r--modules/comment/models/comment.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php
index 48084340..fb70c79a 100644
--- a/modules/comment/models/comment.php
+++ b/modules/comment/models/comment.php
@@ -61,7 +61,7 @@ class Comment_Model extends ORM {
if (!$array) {
$this->rules = array(
"guest_name" => array("callbacks" => array(array($this, "valid_author"))),
- "guest_email" => array("rules" => array("email")),
+ "guest_email" => array("callbacks" => array(array($this, "valid_email"))),
"guest_url" => array("rules" => array("url")),
"item_id" => array("callbacks" => array(array($this, "valid_item"))),
"state" => array("rules" => array("Comment_Model::valid_state")),
@@ -145,6 +145,19 @@ class Comment_Model extends ORM {
}
/**
+ * Make sure that the email address is legal.
+ */
+ public function valid_email(Validation $v, $field) {
+ if ($this->author_id == identity::guest()->id) {
+ if (empty($v->guest_email)) {
+ $v->add_error("guest_email", "required");
+ } else if (!valid::email($v->guest_email)) {
+ $v->add_error("guest_email", "invalid");
+ }
+ }
+ }
+
+ /**
* Make sure we have a valid associated item id.
*/
public function valid_item(Validation $v, $field) {