From: Chris W. <la...@us...> - 2004-10-25 02:29:41
|
Update of /cvsroot/openinteract/OpenInteract2/extra_packages/delicious_tags/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7857/OpenInteract2 Modified Files: DeliciousTaggableObject.pm DeliciousTag.pm Log Message: updates for 0.02 Index: DeliciousTaggableObject.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/extra_packages/delicious_tags/OpenInteract2/DeliciousTaggableObject.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeliciousTaggableObject.pm 24 Oct 2004 16:40:08 -0000 1.1 --- DeliciousTaggableObject.pm 25 Oct 2004 02:29:31 -0000 1.2 *************** *** 6,9 **** --- 6,15 ---- use OpenInteract2::DeliciousTag; + sub c_add_tags { + my ( $class, $object_type, $object_id, $url, $name, @tags ) = @_; + return OpenInteract2::DeliciousTag + ->add_tags( $object_type, $object_id, $url, $name, @tags ); + } + sub c_fetch_my_tags { my ( $class, $object_type, $id ) = @_; *************** *** 27,30 **** --- 33,43 ---- + sub add_tags { + my ( $object, @tags ) = @_; + my $info = $object->object_description; + return __PACKAGE__->c_add_tags( $info->{name}, $info->{object_id}, + $info->{url}, $info->{title}, @tags ); + } + sub fetch_my_tags { my ( $object ) = @_; Index: DeliciousTag.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/extra_packages/delicious_tags/OpenInteract2/DeliciousTag.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeliciousTag.pm 24 Oct 2004 16:40:08 -0000 1.1 --- DeliciousTag.pm 25 Oct 2004 02:29:31 -0000 1.2 *************** *** 4,10 **** --- 4,32 ---- use strict; + use DateTime; @OpenInteract2::DeliciousTag::ISA = qw( OpenInteract2::DeliciousTagPersist ); + # this should be wrapped in a transaction... + + sub add_tags { + my ( $class, $object_type, $object_id, $url, $name, @tags ) = @_; + $class->db_delete({ + table => $class->table_name, + where => 'object_type = ? AND object_id = ?', + value => [ $object_type, $object_id ], + }); + foreach my $tag ( @tags ) { + $class->new({ + tag => $tag, + object_type => $object_type, + object_id => $object_id, + url => $url, + name => $name, + created_on => DateTime->now(), + })->save(); + } + } + sub fetch_all_tags { my ( $class ) = @_; |