public static function createLog($accionId, $actor, $objeto, $tipoObj = null) { $log = new Userlog(); $log->accion_id = $accionId; if (is_numeric($actor)) { $log->actor_id = $actor; } else { $log->actor()->associate($actor); } if (is_null($tipoObj)) { $log->objeto()->associate($objeto); } else { $log->objeto_id = $objeto; $log->objeto_type = $tipoObj; } $log->save(); return $log; }
public static function authenticate($username = "", $password = "") { global $database; $username = $database->escape_value($username); $password = $database->escape_value($password); $sql = "SELECT * FROM Utilizator WHERE User='******' "; $sql .= "AND Parola='" . md5($password) . "' LIMIT 1"; $result_array = self::find_by_sql($sql); //return !empty($result_array) ? array_shift($result_array) : false; if (!empty($result_array)) { $user = array_shift($result_array); $userlog = new Userlog(); date_default_timezone_set('Europe/Berlin'); $userlog->DataLogare = date("Y-m-d"); $userlog->idUtilizator = $user->id; $userlog->save(); return $user; } else { return false; } }