protected function beforeSave() { if (is_object($this->image)) { $newImageData = (string) $this->image; } else { $newImageData = ''; } if ($newImageData != $this->imageData) { $this->imageData = $newImageData; } if (empty($this->date)) { $this->date = time(); } return parent::beforeSave(); }
/** * * @return boolean */ protected function beforeSave() { # automatically approve comments from good users if (!empty($this->email) and !$this->stored()) { $previousComment = $this->getTable()->fetchOne(array('email' => $this->email)); if (!empty($previousComment) and $previousComment->status == self::STATUS_APPROVED) { # previous comment is approved so user is good $this->status = self::STATUS_APPROVED; } } $this->comment = strip_tags($this->comment); if (empty($this->time)) { $this->time = time(); } return parent::beforeSave(); }