public function validate($deep = true) { // call parent parent::validate($deep); // save results return $this->finishValidation(); }
public function save($deep = true) { if (!$this->Demonstrated) { $this->Demonstrated = time(); } return parent::save($deep); }
public function save($deep = true) { // call parent parent::save($deep); if ($this->isFieldDirty('Content')) { Cache::delete($this->getHtmlCacheKey()); } }
public function save($deep = true) { // set handle if (!$this->Handle) { $this->Handle = HandleBehavior::generateRandomHandle(__CLASS__, 12); } parent::save(); }
public function save() { // set handle if (!$this->Handle) { $this->Handle = static::getUniqueHandle($this->Title); } // call parent parent::save(); }
public function save($deep = true) { // set author if (!$this->AuthorID && !empty($_SESSION) && !empty($_SESSION['User'])) { $this->Author = $_SESSION['User']; } // call parent parent::save($deep); }
public function destroy() { $success = parent::destroy(); if ($success && $this->Project->NextUpdate - 1 == $this->Number) { $this->Project->NextUpdate--; $this->Project->save(); } return $success; }
public function save($deep = true) { HandleBehavior::onSave($this); if (!$this->Maintainer) { $this->Maintainer = $GLOBALS['Session']->Person; } parent::save($deep); if (!$this->Members) { ProjectMember::create(['ProjectID' => $this->ID, 'MemberID' => $this->Maintainer->ID, 'Role' => 'Founder'], true); } }
public function validate($deep = true) { // call parent parent::validate($deep); // check handle uniqueness if ($this->isFieldDirty('Code') && !$this->_validator->hasErrors('Code') && $this->Code) { $ExistingRecord = static::getByHandle($this->Code); if ($ExistingRecord && $ExistingRecord->ID != $this->ID) { $this->_validator->addError('Code', 'Code already registered'); } } // save results return $this->finishValidation(); }
public function save($deep = true) { // set author if (!$this->AuthorID && !empty($_SESSION) && !empty($_SESSION['User'])) { $this->Author = $_SESSION['User']; } // set published if (!$this->Published && $this->Status == 'Published') { $this->Published = time(); } // implement handles HandleBehavior::onSave($this); // call parent parent::save($deep); }
public function save($deep = true) { $wasCompetencyDirty = $this->isFieldDirty('CompetencyID'); $wasDemonstrationsRequiredDirty = $this->isFieldDirty('DemonstrationsRequired'); parent::save($deep); if ($wasCompetencyDirty) { if ($this->Competency) { $this->Competency->getSkillIds(true); // true to force refresh of cached value } if ($oldCompetencyId = $this->getOriginalValue('CompetencyID')) { Competency::getByID($oldCompetencyId)->getSkillIds(true); // true to force refresh of cached value } } if ($wasDemonstrationsRequiredDirty) { $this->Competency->getTotalDemonstrationsRequired(true); // true to force refresh of cached value } }
public function getData() { return array_merge(parent::getData(), array('items' => array_values(JSON::translateObjects($this->Items)), 'tags' => array_values(JSON::translateObjects($this->Tags)), 'Author' => $this->Author ? $this->Author->getData() : null)); }
public function validate($deep = true) { // call parent parent::validate($deep); // strip any non-digit characters from phone before validation if ($this->Phone) { $this->Phone = preg_replace('/\\D/', '', $this->Phone); } $this->_validator->validate(array('field' => 'Class', 'validator' => 'selection', 'choices' => self::$subClasses, 'required' => false)); $this->_validator->validate(array('field' => 'FirstName', 'minlength' => 2, 'required' => true, 'errorMessage' => 'First name is required.')); $this->_validator->validate(array('field' => 'LastName', 'minlength' => 2, 'required' => true, 'errorMessage' => 'Last name is required.')); $this->_validator->validate(array('field' => 'Email', 'validator' => 'email', 'required' => static::$requireEmail)); // check handle uniqueness if ($this->isDirty && !$this->_validator->hasErrors('Email') && $this->Email) { $ExistingUser = User::getByField('Email', $this->Email); if ($ExistingUser && $ExistingUser->ID != $this->ID) { $this->_validator->addError('Email', static::$existingEmailError); } } $this->_validator->validate(array('field' => 'Phone', 'validator' => 'phone', 'required' => static::$requirePhone)); $this->_validator->validate(array('field' => 'BirthDate', 'validator' => 'date_ymd', 'required' => static::$requireBirthDate)); $this->_validator->validate(array('field' => 'Gender', 'validator' => 'selection', 'required' => static::$requireGender, 'choices' => self::$fields['Gender']['values'])); // save results return $this->finishValidation(); }