From a4eedbad532a8f0e01eeb00948a761dea80bde77 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 13 Jun 2013 11:07:37 +0200 Subject: [PATCH] =?utf8?q?AuthClient:=20dbconnect(),=20get=5Fdbconnect=5Fa?= =?utf8?q?rgs()=20und=20Dokumentation=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/AuthClient.pm | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/SL/DB/AuthClient.pm b/SL/DB/AuthClient.pm index e83bb16bf..849fc30be 100644 --- a/SL/DB/AuthClient.pm +++ b/SL/DB/AuthClient.pm @@ -5,6 +5,7 @@ use strict; use Carp; use File::Path (); +use SL::DBConnect; use SL::DB::MetaSetup::AuthClient; use SL::DB::Manager::AuthClient; use SL::DB::Helper::Util; @@ -108,4 +109,87 @@ sub ensure_webdav_symlink_correctness { symlink '../' . $self->id, "${base_path}/${new_symlink}"; } +sub get_dbconnect_args { + my ($self, %params) = @_; + + return ( + 'dbi:Pg:dbname=' . $self->dbname . ';host=' . ($self->dbhost || 'localhost') . ';port=' . ($self->dbport || 5432), + $self->dbuser, + $self->dbpasswd, + SL::DBConnect->get_options(%params), + ); +} + +sub dbconnect { + my ($self, %params) = @_; + return SL::DBConnect->connect($self->get_dbconnect_args(%params)); +} + 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::AuthClient - RDBO model for the auth.clients table + +=head1 FUNCTIONS + +=over 4 + +=item C + +Establishes a new database connection to the database configured for +C<$self>. Returns a database handle as returned by +L (which is either a normal L handle or +one handled by L). + +C<%params> are optional parameters passed as the fourth argument to +L. They're first filtered through +L so the UTF-8 flag will be set properly. + +=item C + +Handles the symlink creation/deletion for the WebDAV folder. Does +nothing if WebDAV is not enabled in the configuration. + +For each existing client a symbolic link should exist in the directory +C pointing to the actual WebDAV directory which is the +client's database ID. + +The symbolic link's name is the client's name sanitized a bit. It's +calculated by L. + +=item C + +Returns an array of database connection parameters suitable for +passing to L. + +C<%params> are optional parameters passed as the fourth argument to +L. They're first filtered through +L so the UTF-8 flag will be set properly. + +=item C + +Returns an array of human-readable error message if the object must +not be saved and an empty list if nothing's wrong. + +=item C + +Returns the base name of the symbolic link for the WebDAV C +sub-folder. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut -- 2.20.1