[vhffs-dev] [1993] more core cleaning in Vhffs::Object() |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1993
Author: gradator
Date: 2012-02-02 23:43:35 +0100 (Thu, 02 Feb 2012)
Log Message:
-----------
more core cleaning in Vhffs::Object()
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Object.pm
trunk/vhffs-api/src/Vhffs/Panel/Object.pm
trunk/vhffs-panel/templates/admin/object/edit.tt
Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm 2012-02-02 22:12:24 UTC (rev 1992)
+++ trunk/vhffs-api/src/Vhffs/Object.pm 2012-02-02 22:43:35 UTC (rev 1993)
@@ -139,16 +139,7 @@
return 1;
}
-sub toString
-{
- my ($self) = @_;
- foreach ( keys %$self )
- {
- print "$_: $self->{$_} ";
- }
-}
-
=head2 create
my $object = Vhffs::Object::create($main, [$owner_uid, $owner_gid, $description, $state, $type])
@@ -194,53 +185,18 @@
return $self->{'owner_uid'};
}
-sub get_owner_name
-{
- my ($self) = @_;
-
- $self->{_owner_name} = scalar($self->{db}->selectrow_array('SELECT username FROM vhffs_users WHERE uid = ?', undef, $self->{owner_uid}))
- unless(exists($self->{_owner_name}));
-
- return $self->{_owner_name};
-}
-
sub get_owner_gid
{
my $self = shift;
return $self->{'owner_gid'};
}
-sub get_owner_group {
- my ($self) = @_;
-
- $self->{_owner_group} = scalar($self->{db}->selectrow_array('SELECT groupname FROM vhffs_groups WHERE gid = ?', undef, $self->{owner_gid}))
- unless(exists($self->{_owner_group}));
-
- return $self->{_owner_group};
-}
-
sub get_type
{
my $self = shift;
return $self->{type};
}
-#The modify method for Vhffs::Object only tells if the API can modify some values
-#It protects some importants fields such as object_id
-sub modify
-{
- my $self;
- my $field;
- my $value;
-
- ($self , $field , $value ) = @_;
-
- return -1 if( $field eq "object_id" );
-
- return 0;
-}
-
-
sub commit
{
my $self = shift;
@@ -632,44 +588,38 @@
return $result;
}
+=pod
-sub get_group
-{
- my $self = shift;
- if( defined $self->{'group'} )
- {
- return( $self->{'group'} );
- }
- else
- {
- if( defined $self->{'owner_gid'} )
- {
- use Vhffs::Group;
- $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
- return( $self->{'group'} ) if( defined( $self->{'group'} ) );
- }
- }
- return undef;
+=head2 get_group
+
+ my $group = $object->get_group;
+
+Returns a Vhffs::Group object of the group of the Vhffs::Object object.
+
+=cut
+sub get_group {
+ my $self = shift;
+ return $self->{'group'} if defined $self->{'group'};
+ require Vhffs::Group;
+ $self->{'group'} = Vhffs::Group::get_by_gid( $self->{'main'} , $self->{'owner_gid'} );
+ return $self->{'group'};
}
+=pod
-sub get_owner
-{
- my $self = shift;
- if( defined $self->{'user'} )
- {
- return( $self->{'user'} );
- }
- else
- {
- if( defined $self->{'owner_uid'} )
- {
- use Vhffs::User;
- $self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
- return( $self->{'user'} ) if( defined ( $self->{'user'} ) );
- }
- }
- return undef;
+=head2 get_owner
+
+ my $owner = $object->get_owner;
+
+Returns a Vhffs::User object of the owner of the Vhffs::Object object.
+
+=cut
+sub get_owner {
+ my $self = shift;
+ return $self->{'user'} if defined $self->{'user'};
+ require Vhffs::User;
+ $self->{'user'} = Vhffs::User::get_by_uid( $self->{'main'} , $self->{'owner_uid'} );
+ return $self->{'user'};
}
=pod
Modified: trunk/vhffs-api/src/Vhffs/Panel/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Object.pm 2012-02-02 22:12:24 UTC (rev 1992)
+++ trunk/vhffs-api/src/Vhffs/Panel/Object.pm 2012-02-02 22:43:35 UTC (rev 1993)
@@ -232,7 +232,7 @@
if( $object->get_type == Vhffs::Constants::TYPE_GROUP ) {
$vars->{refresh_url} = '?do=groupindex';
} else {
- $vars->{refresh_url} = '?do=groupview;group='.$object->get_owner_group;
+ $vars->{refresh_url} = '?do=groupview;group='.$object->get_group->get_groupname;
}
$panel->render('misc/message.tt', $vars );
Modified: trunk/vhffs-panel/templates/admin/object/edit.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/object/edit.tt 2012-02-02 22:12:24 UTC (rev 1992)
+++ trunk/vhffs-panel/templates/admin/object/edit.tt 2012-02-02 22:43:35 UTC (rev 1993)
@@ -8,7 +8,7 @@
</p>
<p>
<label>[% 'Owner UID:' | i18n | html %]</label>
- [% object.get_owner_uid %] ([% object.get_owner_name | html %])
+ [% object.get_owner_uid %] ([% object.get_owner.get_username | html %])
</p>
<p>
<label>[% 'Date of creation' | i18n | html %]</label>