/** * isValid Checks if group exists in db using Groups model's function * * @param $value string group name * @return boolean */ public function isValid($value) { $value = Oibs_Controller_CustomController::replaceWhitespace($value); $this->_setValue($value); $groupModel = new Default_Model_Groups(); if (is_array($this->_options) && array_key_exists('oldname', $this->_options)) { // Edit mode - name can be the same as 'oldname'. //die('edit mode, oldname = ' . $options['oldname']); if ($value == $this->_options['oldname']) { // Name hasn't changed, so it's still valid. return true; } else { // Name has changed - check if it exists. if ($groupModel->groupExists($value)) { $this->_error(self::NOT_MATCH); return false; // if the group exists, the form is not valid } else { return true; // if the group doesn't exist, the form is valid } } } else { // Create mode - check normally. if ($groupModel->groupExists($value)) { $this->_error(self::NOT_MATCH); return false; // if the group exists, the form is not valid } else { return true; // if the group doesn't exist, the form is valid } } }
/** * isValid Checks if group exists in db using Groups model's function * * @param $value string group name * @return boolean */ public function isValid($value) { $value = (string) $value; $this->_setValue($value); $groupModel = new Default_Model_Groups(); if ($groupModel->groupExists($value)) { $this->_error(self::NOT_MATCH); return false; // if the group exists, the form is not valid } else { return true; // if the group doesn't exist, the form is valid } }