public function deletar(Model $Model, $id, $cascade = false) { if ($Model->hasAny(array($Model->primaryKey => $id))) { return $Model->delete($id, $cascade); } throw new NotFoundException($Model->useLogger("Erro: impossível fazer a operação")); }
public function isUniqueValue(Model $Model) { if (array_key_exists($this->valueVariable, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$this->valueVariable] != '') { $conditions = array('AND' => array(strtolower($this->roleModel) . '_custom_field_id' => $this->fieldId, $this->valueVariable => $Model->data[$Model->alias][$this->valueVariable], strtolower($this->roleModel) . '_id !=' => $Model->data[$Model->alias][strtolower($this->roleModel) . '_id'])); if ($Model->hasAny($conditions)) { return false; } } return true; }
/** * * @param Model $Model * @param unknown $check * @param unknown $scope * @return boolean */ public function fieldExists(Model $Model, $check, $scope = array()) { $value = array_values($check); $value = $value[0]; $field = key($check); if ($field == 'password') { $value = AuthComponent::password($value); } $conditions = array($Model->alias . '.' . $field => $value); if (!empty($scope)) { $conditions = Hash::merge($scope, $conditions); } if ($Model->hasAny($conditions)) { return true; } return false; }