[otrs-cvs] Artefact/Kernel/System Artefact.pm,1.11,1.12
cvs-log at otrs.org
cvs-log at otrs.org
Mon Mar 17 12:43:41 GMT 2008
Comments:
Update of /home/cvs/Artefact/Kernel/System
In directory lancelot:/tmp/cvs-serv1952/Kernel/System
Modified Files:
Artefact.pm
Log Message:
Fixed syntax error.
Author: tr
Index: Artefact.pm
===================================================================
RCS file: /home/cvs/Artefact/Kernel/System/Artefact.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Artefact.pm 10 Feb 2008 08:20:00 -0000 1.11
--- Artefact.pm 17 Mar 2008 12:43:36 -0000 1.12
***************
*** 99,105 ****
my ( $Self, %Param ) = @_;
- my $MD5 = '';
- my $SQL = '';
-
# check needed stuff
for (qw(Title Description Content Filename ContentType TypeID)) {
--- 99,102 ----
***************
*** 111,115 ****
# get MD5
! $MD5 = Digest::MD5->new;
$Self->{EncodeObject}->EncodeOutput( \$Param{Content} );
$MD5->add( $Param{Content} );
--- 108,112 ----
# get MD5
! my $MD5 = Digest::MD5->new;
$Self->{EncodeObject}->EncodeOutput( \$Param{Content} );
$MD5->add( $Param{Content} );
***************
*** 139,143 ****
# build sql
! $SQL
= "INSERT INTO artefact (number, title, description, file, "
. " file_name, file_size, file_type, file_md5, type_id, "
--- 136,140 ----
# build sql
! my $SQL
= "INSERT INTO artefact (number, title, description, file, "
. " file_name, file_size, file_type, file_md5, type_id, "
***************
*** 151,175 ****
# db insert
! if ( $Self->{DBObject}->Do( SQL => $SQL, Bind => [ \$Param{Content} ] ) ) {
! my $ArtefactID;
! # get artefac id
! my $SQL = "SELECT artefact_id FROM artefact WHERE file_md5='$Param{FileMD5}'";
! $Self->{DBObject}->Prepare( SQL => $SQL );
! # fetch data
! while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! $ArtefactID = $Row[0];
! }
! # CreateArtefactNumber
! my $ArtefactNumber = $Self->{ConfigObject}->Get('SystemID') . ( $ArtefactID + 10000 );
! $SQL = "UPDATE artefact SET number = '$ArtefactNumber' WHERE artefact_id = $ArtefactID";
! $Self->{DBObject}->Do( SQL => $SQL );
! return $ArtefactID;
! }
! else {
! return;
}
}
--- 148,169 ----
# db insert
! return if !$Self->{DBObject}->Do( SQL => $SQL, Bind => [ \$Param{Content} ] );
! my $ArtefactID;
! # get artefac id
! $SQL = "SELECT artefact_id FROM artefact WHERE file_md5='$Param{FileMD5}'";
! $Self->{DBObject}->Prepare( SQL => $SQL );
! # fetch data
! while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! $ArtefactID = $Row[0];
}
+
+ # CreateArtefactNumber
+ my $ArtefactNumber = $Self->{ConfigObject}->Get('SystemID') . ( $ArtefactID + 10000 );
+ $SQL = "UPDATE artefact SET number = '$ArtefactNumber' WHERE artefact_id = $ArtefactID";
+ $Self->{DBObject}->Do( SQL => $SQL );
+ return $ArtefactID;
}
***************
*** 193,198 ****
my ( $Self, %Param ) = @_;
- my $SQL = '';
-
# check needed stuff
for (qw(ArtefactID Title Description Filename TypeID)) {
--- 187,190 ----
***************
*** 209,213 ****
# build sql
! $SQL
= "UPDATE artefact SET "
. " title ='$Param{Title}', "
--- 201,205 ----
# build sql
! my $SQL
= "UPDATE artefact SET "
. " title ='$Param{Title}', "
***************
*** 224,274 ****
# Update file
! if ( $Param{Content} ) {
! # get MD5
! my $ctx = Digest::MD5->new;
! $ctx->add( $Param{Content} );
! $Param{FileMD5} = $ctx->hexdigest;
! # get attachment size
! use bytes;
! $Param{FileSize} = length( $Param{Content} );
! no bytes;
! # db select if md5 is still exists
! $Self->{DBObject}->Prepare(
! SQL => "SELECT artefact_id FROM artefact WHERE file_md5='$Param{FileMD5}'", );
! if ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "The MD5 value of the File $Param{Filename} is still exists!",
! );
! return;
! }
! # build sql
! $SQL
! = "UPDATE artefact SET "
! . " file=?, "
! . " file_name = '$Param{Filename}', "
! . " file_size = $Param{FileSize}, "
! . " file_md5 = '$Param{FileMD5}', "
! . " file_type = '$Param{ContentType}' "
! . " WHERE "
! . " artefact_id = $Param{ArtefactID}";
- # db update
- if ( $Self->{DBObject}->Do( SQL => $SQL, Bind => [ \$Param{Content} ] ) ) {
- return 1;
- }
- else {
- return;
- }
- }
return 1;
}
! else {
! return;
! }
}
--- 216,259 ----
# Update file
! return 1 if !$Param{Content};
! # get MD5
! my $ctx = Digest::MD5->new;
! $ctx->add( $Param{Content} );
! $Param{FileMD5} = $ctx->hexdigest;
! # get attachment size
! use bytes;
! $Param{FileSize} = length( $Param{Content} );
! no bytes;
! # db select if md5 is still exists
! $Self->{DBObject}->Prepare(
! SQL => "SELECT artefact_id FROM artefact WHERE file_md5='$Param{FileMD5}'", );
! if ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "The MD5 value of the File $Param{Filename} is still exists!",
! );
! return;
! }
! # build sql
! $SQL
! = "UPDATE artefact SET "
! . " file=?, "
! . " file_name = '$Param{Filename}', "
! . " file_size = $Param{FileSize}, "
! . " file_md5 = '$Param{FileMD5}', "
! . " file_type = '$Param{ContentType}' "
! . " WHERE "
! . " artefact_id = $Param{ArtefactID}";
!
! # db update
! return if !$Self->{DBObject}->Do( SQL => $SQL, Bind => [ \$Param{Content} ] );
return 1;
}
! return;
}
***************
*** 286,314 ****
my ( $Self, %Param ) = @_;
- my $SQL = '';
-
# check needed stuff
! for (qw(ArtefactID)) {
! if ( !$Param{$_} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
! return;
! }
}
# db quote
! for ( keys %Param ) {
! $Param{$_} = $Self->{DBObject}->Quote( $Param{$_} ) || '';
! }
# build sql
! $SQL = "DELETE FROM artefact WHERE artefact_id = $Param{ArtefactID}";
# db delete
! if ( $Self->{DBObject}->Do( SQL => $SQL ) ) {
! return 1;
! }
! else {
! return;
! }
}
--- 271,289 ----
my ( $Self, %Param ) = @_;
# check needed stuff
! if ( !$Param{ArtefactID} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => 'Need ArtefactID!' );
! return;
}
# db quote
! $Param{ArtefactID} = $Self->{DBObject}->Quote( $Param{ArtefactID} ) || '';
# build sql
! my $SQL = "DELETE FROM artefact WHERE artefact_id = $Param{ArtefactID}";
# db delete
! return if !$Self->{DBObject}->Do( SQL => $SQL );
! return 1;
}
***************
*** 329,343 ****
# check needed stuff
! for (qw(ArtefactID)) {
! if ( !$Param{$_} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
! return;
! }
}
# db quote
! for ( keys %Param ) {
! $Param{$_} = $Self->{DBObject}->Quote( $Param{$_} ) || '';
! }
# db select
--- 304,314 ----
# check needed stuff
! if ( !$Param{ArtefactID} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => 'Need ArtefactID!' );
! return;
}
# db quote
! $Param{ArtefactID} = $Self->{DBObject}->Quote( $Param{ArtefactID} ) || '';
# db select
***************
*** 369,382 ****
$Data{ChangedBy} = $Row[13];
}
! if (%Data) {
! return %Data;
! }
! else {
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "No such artefact ($Param{ArtefactID})",
! );
! return ();
! }
}
--- 340,352 ----
$Data{ChangedBy} = $Row[13];
}
!
! return %Data if %Data;
!
! $Self->{LogObject}->Log(
! Priority => 'error',
! Message => "No such artefact ($Param{ArtefactID})",
! );
! return ();
!
}
***************
*** 457,470 ****
my ( $Self, %Param ) = @_;
- my $SQL = '';
my @Data = ();
# check needed stuff
! for (qw()) {
! if ( !$Param{$_} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
! return;
! }
! }
if ( !$Param{Order} ) {
$Param{Order} = " number DESC";
--- 427,435 ----
my ( $Self, %Param ) = @_;
my @Data = ();
# check needed stuff
! # info, there is no needed staff all params are optional
!
if ( !$Param{Order} ) {
$Param{Order} = " number DESC";
***************
*** 513,517 ****
}
! $SQL = "SELECT distinct(artefact_id) FROM artefact "
. "WHERE artefact_id > 0 $Where ORDER BY $Param{Order}";
--- 478,482 ----
}
! my $SQL = "SELECT distinct(artefact_id) FROM artefact "
. "WHERE artefact_id > 0 $Where ORDER BY $Param{Order}";
***************
*** 542,556 ****
# check needed stuff
! for (qw(TypeID)) {
! if ( !$Param{$_} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
! return;
! }
}
# db quote
! for ( keys %Param ) {
! $Param{$_} = $Self->{DBObject}->Quote( $Param{$_} ) || '';
! }
# db select
--- 507,517 ----
# check needed stuff
! if ( !$Param{TypeID} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => 'Need TypeID!' );
! return;
}
# db quote
! $Param{TypeID} = $Self->{DBObject}->Quote( $Param{TypeID} ) || '';
# db select
***************
*** 579,607 ****
my ( $Self, %Param ) = @_;
- my $SQL = '';
-
# check needed stuff
! for (qw(Description)) {
! if ( !$Param{$_} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
! return;
! }
}
# db quote
! for ( keys %Param ) {
! $Param{$_} = $Self->{DBObject}->Quote( $Param{$_} ) || '';
! }
# build sql
! $SQL = "INSERT INTO artefact_type (description)" . " VALUES " . " ('$Param{Description}')";
# db insert
! if ( $Self->{DBObject}->Do( SQL => $SQL ) ) {
! return 1;
! }
! else {
! return;
! }
}
--- 540,558 ----
my ( $Self, %Param ) = @_;
# check needed stuff
! if ( !$Param{Description} ) {
! $Self->{LogObject}->Log( Priority => 'error', Message => "Need Description!" );
! return;
}
# db quote
! $Param{Description} = $Self->{DBObject}->Quote( $Param{Description} ) || '';
# build sql
! my $SQL = "INSERT INTO artefact_type (description)" . " VALUES " . " ('$Param{Description}')";
# db insert
! return if !$Self->{DBObject}->Do( SQL => $SQL );
! return 1;
}
***************
*** 620,625 ****
my ( $Self, %Param ) = @_;
- my $SQL = '';
-
# check needed stuff
for (qw(Description TypeID UserID)) {
--- 571,574 ----
***************
*** 636,640 ****
# build sql
! $SQL
= "UPDATE artefact_type SET "
. " description = '$Param{Description}', "
--- 585,589 ----
# build sql
! my $SQL
= "UPDATE artefact_type SET "
. " description = '$Param{Description}', "
***************
*** 643,652 ****
# db update
! if ( $Self->{DBObject}->Do( SQL => $SQL ) ) {
! return 1;
! }
! else {
! return;
! }
}
--- 592,597 ----
# db update
! return if !$Self->{DBObject}->Do( SQL => $SQL );
! return 1;
}
***************
*** 664,680 ****
my %Data = ();
- # check needed stuff
- for (qw()) {
- if ( !$Param{$_} ) {
- $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
- return;
- }
- }
-
- # db quote
- for ( keys %Param ) {
- $Param{$_} = $Self->{DBObject}->Quote( $Param{$_} ) || '';
- }
-
# db select
$Self->{DBObject}->Prepare( SQL => "SELECT id, description FROM artefact_type", );
--- 609,612 ----
More information about the cvs-log
mailing list