[vhffs-dev] [954] Added vhffs_groups.realname field, which contain a string which is displayed in public part of the panel |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [954] Added vhffs_groups.realname field, which contain a string which is displayed in public part of the panel
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 30 Sep 2007 20:12:15 +0200
Revision: 954
Author: gradator
Date: 2007-09-30 18:12:15 +0000 (Sun, 30 Sep 2007)
Log Message:
-----------
Added vhffs_groups.realname field, which contain a string which is displayed in public part of the panel
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Group.pm
trunk/vhffs-api/src/Vhffs/Panel/Group.pm
trunk/vhffs-api/src/Vhffs/User.pm
trunk/vhffs-api/src/examples/create_group.pl
trunk/vhffs-backend/src/pgsql/initdb.sql.in
trunk/vhffs-compat/4.0.sql.in
trunk/vhffs-panel/group/create.pl
trunk/vhffs-panel/group/prefs.pl
trunk/vhffs-panel/templates/group/prefs.tmpl
trunk/vhffs-public/allgroups.pl
trunk/vhffs-public/group.pl
trunk/vhffs-public/lastgroups.pl
trunk/vhffs-public/rss/lastgroups.pl
trunk/vhffs-public/templates/group.tmpl
trunk/vhffs-public/templates/misc/lastgroups-part.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-api/src/Vhffs/Group.pm 2007-09-30 18:12:15 UTC (rev 954)
@@ -61,14 +61,14 @@
=head2 create
- my $group = Vhffs::Group::create($main, $groupname, $owner_uid, $gid, $description)
+ my $group = Vhffs::Group::create($main, $groupname, $realname, $owner_uid, $gid, $description)
Create in DB and return a fully functional group.
=cut
sub create {
- my ($main, $groupname, $owner_uid, $gid, $description) = @_;
+ my ($main, $groupname, $realname, $owner_uid, $gid, $description) = @_;
return undef unless check_groupname($groupname);
return undef unless defined($owner_uid);
@@ -83,6 +83,8 @@
}
}
+ $realname = $groupname unless defined $realname;
+
my $dbh = $main->get_db_object;
local $dbh->{RaiseError} = 1;
local $dbh->{PrintError} = 0;
@@ -111,9 +113,9 @@
my $quota = $groupconf->{default_quota} || 10;
- my $query = 'INSERT INTO vhffs_groups(gid, groupname, passwd, quota, quota_used, object_id) VALUES(?, ?, NULL, ?, 0, ?)';
+ my $query = 'INSERT INTO vhffs_groups(gid, groupname, realname, passwd, quota, quota_used, object_id) VALUES(?, ?, NULL, ?, 0, ?)';
my $sth = $dbh->prepare( $query );
- $sth->execute($gid, $groupname, $quota, $parent->get_oid);
+ $sth->execute($gid, $groupname, $realname, $quota, $parent->get_oid);
$dbh->commit if($transaction_started);
$group = get_by_gid($main, $gid);
@@ -155,9 +157,9 @@
{
my $self = shift;
- my $sql = 'UPDATE vhffs_groups SET quota = ?, quota_used = ? WHERE gid = ?';
+ my $sql = 'UPDATE vhffs_groups SET realname = ?, quota = ?, quota_used = ? WHERE gid = ?';
my $sth = $self->{db}->prepare($sql);
- $sth->execute( $self->{'quota'}, $self->{'quota_used'}, $self->{'gid'}) or return -1;
+ $sth->execute( $self->{'realname'}, $self->{'quota'}, $self->{'quota_used'}, $self->{'gid'}) or return -1;
#Exec the super method !
return -2 if( $self->SUPER::commit < 0 );
@@ -292,12 +294,11 @@
#modify a group
-#use it as modify_user, but with the fields of the vhfs_groups table
+#use it as modify_user, but with the fields of the vhffs_groups table
sub modify
{
my $request;
-
my ( $self , $field , $value ) = @_;
$self->{$field} = $value;
@@ -335,6 +336,14 @@
}
+sub set_realname
+{
+ my $self = shift;
+ my $value = shift;
+ $self->{'realname'} = $value;
+}
+
+
sub set_quota_used
{
my $self = shift;
@@ -351,6 +360,13 @@
}
+sub get_realname
+{
+ my $self = shift;
+ return $self->{'realname'};
+}
+
+
=head2 get_label
See C<Vhffs::Object::get_label>.
@@ -622,7 +638,7 @@
sub get_by_gid {
my ($vhffs, $gid) = @_;
- my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.gid = ?';
+ my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.groupname, g.realname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.gid = ?';
my $dbh = $vhffs->get_db_object;
my @params = $dbh->selectrow_array($query, undef, $gid);
@@ -644,7 +660,7 @@
sub get_by_groupname {
my ($vhffs, $groupname) = @_;
- my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.groupname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.groupname = ?';
+ my $query = 'SELECT g.gid, o.object_id, o.owner_uid, g.groupname, g.realname, g.passwd, g.quota, g.quota_used, o.date_creation, o.description, o.state FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE g.groupname = ?';
my $dbh = $vhffs->get_db_object;
my @params = $dbh->selectrow_array($query, undef, $groupname);
@@ -656,11 +672,11 @@
sub _new {
no strict 'refs';
- my ($class, $main, $gid, $oid, $owner_uid, $groupname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
+ my ($class, $main, $gid, $oid, $owner_uid, $groupname, $realname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
my $self = $class->SUPER::_new($main, $oid, $owner_uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GROUP);
return undef unless(defined $self);
- foreach (qw (gid groupname passwd quota quota_used) ) {
+ foreach (qw (gid groupname realname passwd quota quota_used) ) {
eval '$self->{$_} = $'.$_;
}
return $self;
Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2007-09-30 18:12:15 UTC (rev 954)
@@ -138,9 +138,9 @@
sub create_group
{
- my( $groupname , $user , $main, $description ) = @_;
+ my( $groupname , $realname, $user , $main, $description ) = @_;
- my $group = Vhffs::Group::create($main, $groupname, $user->get_uid, undef, $description);
+ my $group = Vhffs::Group::create($main, $groupname, $realname, $user->get_uid, undef, $description);
return undef unless( defined $group );
Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-api/src/Vhffs/User.pm 2007-09-30 18:12:15 UTC (rev 954)
@@ -216,7 +216,7 @@
my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, firstname, lastname, address, zipcode, city, country, mail, gpg_key, note, language, theme, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, NULL, ?)');
$sth->execute($uid, $gid, $username, $userconf->{'default_shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, Vhffs::Constants::DEFAULT_LANG, $parent->get_oid);
- my $group = Vhffs::Group::create($main, $username, $uid, $gid);
+ my $group = Vhffs::Group::create($main, $username, undef, $uid, $gid);
die('Error creating group') unless (defined $group);
$group->set_status(Vhffs::Constants::ACTIVATED);
$group->set_quota( $userconf->{'default_quota'} || 1 );
Modified: trunk/vhffs-api/src/examples/create_group.pl
===================================================================
--- trunk/vhffs-api/src/examples/create_group.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-api/src/examples/create_group.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -14,12 +14,12 @@
die("Usage: $0 groupname owner_username description\n") unless(@ARGV == 3);
-my ($groupname, $username, $description) = @ARGV;
+my ($groupname, $realname, $username, $description) = @ARGV;
my $user = Vhffs::User::get_by_username($princ, $username);
die("User not found\n") unless(defined $user);
-my $group = Vhffs::Group::create($princ, $groupname, $user->get_uid, undef, $description) ;
+my $group = Vhffs::Group::create($princ, $groupname, $realname, $user->get_uid, undef, $description) ;
if( !defined $group )
{
Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-09-30 18:12:15 UTC (rev 954)
@@ -55,7 +55,8 @@
CREATE TABLE vhffs_groups
(
gid serial,
- groupname varchar(50) NOT NULL DEFAULT ' ',
+ groupname varchar(50) NOT NULL,
+ realname varchar(50),
passwd varchar(20),
quota int4 NOT NULL,
quota_used int4 NOT NULL DEFAULT 0,
@@ -69,10 +70,10 @@
(
uid serial,
gid int4 NOT NULL,
- username varchar(50) NOT NULL DEFAULT ' ',
- shell varchar(20) NOT NULL DEFAULT ' ',
- passwd varchar(40) NOT NULL DEFAULT ' ',
- homedir varchar(40) NOT NULL DEFAULT ' ',
+ username varchar(50) NOT NULL,
+ shell varchar(20) NOT NULL,
+ passwd varchar(40) NOT NULL,
+ homedir varchar(40) NOT NULL,
admin int4 NOT NULL,
object_id int4 NOT NULL,
firstname varchar(250),
@@ -83,7 +84,7 @@
country varchar(250),
mail varchar(200),
gpg_key varchar(250),
- note int4 DEFAULT '0',
+ note int4 DEFAULT 0,
language varchar(16),
theme varchar(250),
CONSTRAINT vhffs_users_pkey PRIMARY KEY (uid)
Modified: trunk/vhffs-compat/4.0.sql.in
===================================================================
--- trunk/vhffs-compat/4.0.sql.in 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-compat/4.0.sql.in 2007-09-30 18:12:15 UTC (rev 954)
@@ -354,3 +354,7 @@
ALTER TABLE vhffs_history RENAME COLUMN date_new TO date;
ALTER TABLE vhffs_history ALTER COLUMN date SET NOT NULL;
COMMIT;
+
+-- add realname field to vhffs_groups
+ALTER TABLE vhffs_groups ADD COLUMN realname varchar(50);
+UPDATE vhffs_groups SET realname=groupname;
Modified: trunk/vhffs-panel/group/create.pl
===================================================================
--- trunk/vhffs-panel/group/create.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-panel/group/create.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -57,16 +57,18 @@
my $submitted = defined($cgi->param('project_submit'));
my $groupname;
my $description;
+my $realname;
if($submitted) {
# User posted the form, let's check it
$groupname = $cgi->param('project_name');
$description = $cgi->param('description');
+ $realname = $cgi->param('realname');
if( $groupname !~ /^[a-z0-9]{3,12}$/ ) {
$panel->add_error( gettext('Groupname must contain between 3 and 12 characters, only letters or numbers in lower case') );
} elsif( $description =~ /^\s*$/ ) {
$panel->add_error( gettext('You must enter a description') );
- } elsif( ! defined(my $group = Vhffs::Panel::Group::create_group( $groupname , $user , $vhffs, $description ) ) ) {
+ } elsif( ! defined(my $group = Vhffs::Panel::Group::create_group( $groupname , $realname, $user , $vhffs, $description ) ) ) {
$panel->add_error( gettext('Error creating group (maybe a group with the same name already exists)') );
} else {
my $url = '/group/index.pl?msg='.gettext('Project Successfully created !');
Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-panel/group/prefs.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -84,16 +84,21 @@
$panel->add_error( gettext( 'You\'re not allowed to do this (ACL rights)' ) );
} else {
my $description = $cgi->param( 'description' );
- if( ! defined ($description) ) {
+ my $realname = $cgi->param( 'realname' );
+
+ if( ! defined ($description) || ! defined ($realname) ) {
$panel->add_error( gettext('CGI error') );
} elsif( $description =~ /^\s*$/ ) {
$panel->add_error( gettext('You must enter a description') );
+ } elsif( $realname eq '' ) {
+ $panel->add_error( gettext('You must enter a real name') );
} else {
$group->set_description($description);
+ $group->set_realname($realname);
if($group->commit < 0) {
$panel->add_error( gettext('An error occured while updating the project') );
} else {
- $panel->add_info( gettext('Description updated') );
+ $panel->add_info( gettext('Group updated') );
}
}
}
@@ -203,6 +208,8 @@
$template->param( VALUE_OWNER => $group->get_owner_username );
$template->param( TEXT_DESCRIPTION => gettext("Project Description") );
$template->param( VALUE_DESCRIPTION => CGI::escapeHTML($group->get_description) );
+ $template->param( TEXT_REALNAME => gettext('Project full name') );
+ $template->param( VALUE_REALNAME => CGI::escapeHTML($group->get_realname) );
$template->param( TEXT_MODIFY => gettext("Modify") );
$template->param( TEXT_DELETE_PROJECT => gettext("Delete this project") );
$template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
Modified: trunk/vhffs-panel/templates/group/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/prefs.tmpl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-panel/templates/group/prefs.tmpl 2007-09-30 18:12:15 UTC (rev 954)
@@ -7,6 +7,7 @@
<label><tmpl_var name="TEXT_OWNER">:</label>
<tmpl_var name="VALUE_OWNER">
</p>
+ <p><label for="realname" class="realname"><tmpl_var name="TEXT_REALNAME">:</label><input type="text" value="<tmpl_var name="VALUE_REALNAME">" name="realname" id="realname"/></p>
<p><label for="description" class="description"><tmpl_var name="TEXT_DESCRIPTION">:</label></p>
<p><textarea name="description" id="description" class="description" cols="45" rows="7"><tmpl_var name="VALUE_DESCRIPTION"></textarea></p>
<p class="button" id="buttonModify">
Modified: trunk/vhffs-public/allgroups.pl
===================================================================
--- trunk/vhffs-public/allgroups.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/allgroups.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -75,10 +75,9 @@
{
$template = new HTML::Template( filename => $templatedir."/public/misc/lastgroups-part.tmpl" );
- $template->param( TEXT_TITLE => $group->get_groupname );
-
$template->param( TEXT_GROUPNAME => gettext("Groupname") );
$template->param( VALUE_GROUPNAME => $group->get_groupname );
+ $template->param( VALUE_REALNAME => CGI::escapeHTML($group->get_realname) );
$template->param( TEXT_USERS => gettext("Users") );
$template->param( TEXT_DESCRIPTION => gettext("Description") );
Modified: trunk/vhffs-public/group.pl
===================================================================
--- trunk/vhffs-public/group.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/group.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -86,8 +86,7 @@
{
$name = Vhffs::Functions::check_arg( $name );
$template = new HTML::Template( filename => $templatedir."/public/group.tmpl" );
- $template->param( TEXT_TITLE => $group->get_groupname );
-
+ $template->param( VALUE_REALNAME => $group->get_realname );
$template->param( TEXT_GROUPNAME => gettext("Groupname") );
$template->param( TEXT_DESCRIPTION => gettext("Description") );
$template->param( VALUE_GROUPNAME => $group->get_groupname );
Modified: trunk/vhffs-public/lastgroups.pl
===================================================================
--- trunk/vhffs-public/lastgroups.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/lastgroups.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -68,7 +68,7 @@
{
$template = new HTML::Template( filename => $templatedir."/public/misc/lastgroups-part.tmpl" );
- $template->param( TEXT_TITLE => $group->get_groupname );
+ $template->param( VALUE_REALNAME => $group->get_realname );
$template->param( TEXT_GROUPNAME => gettext("Groupname") );
$template->param( VALUE_GROUPNAME => $group->get_groupname );
Modified: trunk/vhffs-public/rss/lastgroups.pl
===================================================================
--- trunk/vhffs-public/rss/lastgroups.pl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/rss/lastgroups.pl 2007-09-30 18:12:15 UTC (rev 954)
@@ -87,8 +87,9 @@
for( my $i = 0 ; $i < $#{$groups} ; $i++ )
{
my $name = $groups->[$i]->get_groupname;
+ my $realname = $groups->[$i]->get_realname;
$rss->add_item(
- title => $name,
+ title => $realname,
link => "$url/group.pl?name=$name",
description => "Vhffs Group",
);
Modified: trunk/vhffs-public/templates/group.tmpl
===================================================================
--- trunk/vhffs-public/templates/group.tmpl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/templates/group.tmpl 2007-09-30 18:12:15 UTC (rev 954)
@@ -1,6 +1,6 @@
<tmpl_var name="BANNER">
- <h1><tmpl_var name="TEXT_TITLE"></h1>
+ <h1><tmpl_var name="VALUE_REALNAME"></h1>
<p>
Modified: trunk/vhffs-public/templates/misc/lastgroups-part.tmpl
===================================================================
--- trunk/vhffs-public/templates/misc/lastgroups-part.tmpl 2007-09-30 15:14:12 UTC (rev 953)
+++ trunk/vhffs-public/templates/misc/lastgroups-part.tmpl 2007-09-30 18:12:15 UTC (rev 954)
@@ -1,5 +1,5 @@
-<h2><a href="group.pl?name=<tmpl_var name="VALUE_GROUPNAME">"><tmpl_var name="TEXT_TITLE"></a></h2>
+<h2><a href="group.pl?name=<tmpl_var name="VALUE_GROUPNAME">"><tmpl_var name="VALUE_REALNAME"></a></h2>
<ul>
<li><tmpl_var name="TEXT_GROUPNAME">