/** * Validate the form */ protected function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validation $fields = $this->frm->getFields(); $fields['name']->isFilled(BL::err('FieldIsRequired')); $fields['email']->isFilled(BL::err('FieldIsRequired')); $fields['email']->isEmail(BL::err('EmailIsInvalid')); if ($this->frm->isCorrect()) { $item['name'] = $fields['name']->getValue(); $item['email'] = $fields['email']->getValue(); $item['active'] = $fields['active']->getValue(); BackendMailengineModel::updateUser($this->id, $item); $item['id'] = $this->id; //--Delete users from the group BackendMailengineModel::deleteGroupFromUser($this->id); //--Check if there are groups if (isset($fields['groups'])) { //--Get all the groups $groups = $fields["groups"]->getValue(); foreach ($groups as $key => $value) { $groupUser = array(); $groupUser["user_id"] = $this->id; $groupUser["group_id"] = $value; //--Add user to the group BackendMailengineModel::insertUserToGroup($groupUser); } } BackendModel::triggerEvent($this->getModule(), 'after_edit_user', $item); $this->redirect(BackendModel::createURLForAction('users') . '&report=edited&highlight=row-' . $item['id']); } } }