/** * Autentica un usuario usando el adaptador * * @return boolean */ public function authenticate() { $where_condition = array(); foreach ($this->compare_attributes as $field => $value) { $value = addslashes($value); $where_condition[] = "{$field} = '{$value}'"; } $result = Load::model($this->class)->count(join(" AND ", $where_condition)); if ($result) { $model = KumbiaActiveRecord::get($this->class)->find_first(join(" AND ", $where_condition)); $identity = array(); foreach ($model->fields as $field) { /** * Trata de no incluir en la identidad el password del usuario */ if (!in_array($field, array('password', 'clave', 'contrasena', 'passwd', 'pass'))) { $identity[$field] = $model->{$field}; } } $this->identity = $identity; } return $result; }
/** * Deletes data from Relational Map Table * * @param mixed $what */ public function delete($what = '') { if (func_num_args() > 1) { $what = Util::getParams(func_get_args()); } if ($this->schema) { $table = $this->schema . "." . $this->source; } else { $table = $this->source; } $conditions = ''; if (is_array($what)) { if ($what["conditions"]) { $conditions = $what["conditions"]; } } else { if (is_numeric($what)) { KumbiaActiveRecord::sql_sanitize($this->primary_key[0]); $conditions = "{$this->primary_key[0]} = '{$what}'"; } else { if ($what) { $conditions = $what; } else { KumbiaActiveRecord::sql_sanitize($this->primary_key[0]); $conditions = "{$this->primary_key[0]} = '{$this->{$this->primary_key[0]}}'"; } } } if (method_exists($this, "before_delete")) { if ($this->{$this->primary_key[0]}) { $this->find($this->{$this->primary_key[0]}); } if ($this->before_delete() == 'cancel') { return false; } } else { if (isset($this->before_delete)) { if ($this->{$this->primary_key[0]}) { $this->find($this->{$this->primary_key[0]}); } $method = $this->before_delete; if ($this->{$method}() == 'cancel') { return false; } } } $val = $this->db->delete($table, $conditions); if ($val) { if (method_exists($this, "after_delete")) { if ($this->after_delete() == 'cancel') { return false; } } else { if (isset($this->after_delete)) { $method = $this->after_delete; if ($this->{$method}() == 'cancel') { return false; } } } } return $val; }