public function onSubmit($data) { //Validation is already mostly done by the form class. Sweet. $this->project = $data['project-name']; $this->organization = $data['organization-name']; $this->group = $data['group-name']; $this->reason = $data['reason']; $this->old_project = ApprovedRevs::getProjectName($this->getTitle()); $this->old_organization = ApprovedRevs::getOrganizationName($this->getTitle()); $this->old_group = ApprovedRevs::getGroup($this->getTitle()); // no change? if ($this->project == $this->old_project && $this->organization == $this->old_organization && $this->group == $this->old_group) { return array('approvedrevs-form-error-nochange'); } if (empty($this->old_project)) { $action = 'assign'; } elseif (empty($this->project)) { // Already assigned to project $action = 'unassign'; } else { $action = 'reassign'; } ApprovedRevs::logProjectAssignment($this->getTitle(), $action, $this->getUser(), $this->project, $this->organization, $this->group, $this->reason); ApprovedRevs::saveProjectAssociationInDB($this->getTitle(), $action, $this->project, $this->organization, $this->group); return true; }