public function commit() { $url = $this->get('title'); if (strlen($url) && strpos($url, '://') == false) { $this->set('title', 'http://' . $url); } parent::commit(); }
public function commit() { parent::commit(); $email_record = get_record('artefact_internal_profile_email', 'owner', $this->owner, 'email', $this->title); if (!$email_record) { if (record_exists('artefact_internal_profile_email', 'owner', $this->owner, 'artefact', $this->id)) { update_record('artefact_internal_profile_email', (object) array('email' => $this->title, 'verified' => 1), (object) array('owner' => $this->owner, 'artefact' => $this->id)); if (get_field('artefact_internal_profile_email', 'principal', 'owner', $this->owner, 'artefact', $this->id)) { update_record('usr', (object) array('email' => $this->title, 'id' => $this->owner)); } } else { $principal = get_record('artefact_internal_profile_email', 'owner', $this->owner, 'principal', 1); insert_record('artefact_internal_profile_email', (object) array('owner' => $this->owner, 'email' => $this->title, 'verified' => 1, 'principal' => $principal ? 0 : 1, 'artefact' => $this->id)); update_record('usr', (object) array('email' => $this->title, 'id' => $this->owner)); } } }