Changes

From SME Server
Jump to navigationJump to search
Created page with "== NAME == esmith::FormMagick::Panels::ibays - useful panel functions<br /> In a root terminal you can do the command below if you want to display the up-to-date content pe..."
== NAME ==
esmith::FormMagick::Panels::ibays - useful panel functions<br />

In a root terminal you can do the command below if you want to display the up-to-date content
perldoc esmith::FormMagick::Panels::ibays
== SYNOPSIS ==
use esmith::FormMagick::Panels::ibays;

my $panel = esmith::FormMagick::Panel::ibays->new();
$panel->display();

== DESCRIPTION ==
=== new(); ===
Exactly as for esmith::FormMagick

== HTML GENERATION ROUTINES ==
Routines for generating chunks of HTML needed by the panel.

== ROUTINES FOR FILLING IN FIELDS ==
=== print_ibay_table ===

Prints out the ibay table on the front page.

=== print_vhost_message() ===

Prints a warning message that vhosts whose content is this ibay will be modified to point to primary site.

=== group_list() ===

Returns a hash of groups for the Create/Modify screen’s group field’s drop down list.

=== userAccess_list ===

Returns the hash of user access settings for showing in the user access drop down list.

=== publicAccess_list ===

Returns the hash of public access settings for showing in the public access drop down list.

== VALIDATION ROUTINES ==
=== max_ibay_name_length() ===

Checks the length of a given i-bay name against the maximum set in the maxIbayNameLength record of the configuration database. Defaults to a maximum length of the maxIbayNameLength set in the config db.

=== conflict_check ===

Check the proposed name for clashes with existing pseudonyms or other accounts of any type.

== THE ROUTINES THAT ACTUALLY DO THE WORK ==
=== print_save_or_add_button() ===


sub print_save_or_add_button {
my ($self) = @_;

my $action = $self->cgi->param("action") ││ ’’;
if ($action eq "modify") {
$self->print_button("SAVE");
} else {
$self->print_button("ADD");
}

}

sub create_ibay {
my ($self) = @_;
my $name = $self->cgi->param(’name’);

my $msg = $self->validate_name($name);
unless ($msg eq "OK")
{
return $self->error($msg);
}

$msg = $self->max_ibay_name_length($name);
unless ($msg eq "OK")
{
return $self->error($msg);
}

$msg = $self->conflict_check($name);
unless ($msg eq "OK")
{
return $self->error($msg);
}

my $uid = $accountdb->get_next_uid();
if (my $acct = $accountdb->new_record($name, {
Name => $self->cgi->param(’description’),
CgiBin => $self->cgi->param(’CgiBin’),
Group => $self->cgi->param(’group’),
PublicAccess => $self->cgi->param(’publicAccess’),
UserAccess => $self->cgi->param(’userAccess’),
Uid => $uid,
Gid => $uid,
PasswordSet => ’no’,
type => ’ibay’,
}) )
{
# Untaint $name before use in system()
$name =~ /(.+)/; $name = $1;
if (system ("/sbin/e-smith/signal-event", "ibay-create", $name) == 0) {
$self->success("SUCCESSFULLY_CREATED_IBAY");
} else {
$self->error("ERROR_WHILE_CREATING_IBAY");
}
} else {
$self->error(’CANT_CREATE_IBAY’);
}
}

sub modify_ibay {
my ($self) = @_;
my $name = $self->cgi->param(’name’);
if (my $acct = $accountdb->get($name)) {
if ($acct->prop(’type’) eq ’ibay’) {
$acct->merge_props(
Name => $self->cgi->param(’description’),
CgiBin => $self->cgi->param(’CgiBin’),
Group => $self->cgi->param(’group’),
PublicAccess => $self->cgi->param(’publicAccess’),
UserAccess => $self->cgi->param(’userAccess’),
);

# Untaint $name before use in system()
$name =~ /(.+)/; $name = $1;
if (system ("/sbin/e-smith/signal-event", "ibay-modify",
$name) == 0)
{
$self->success("SUCCESSFULLY_MODIFIED_IBAY");
} else {
$self->error("ERROR_WHILE_MODIFYING_IBAY");
}
} else {
$self->error(’CANT_FIND_IBAY’);
}
} else {
$self->error(’CANT_FIND_IBAY’);
}
}

=== getExtraParams() ===

Sets variables used in the lexicon to their required values.

=== verifyPasswords() ===

Returns an error message if the two new passwords input don’t match.

=== validate_name ===

Checks that the name supplied does not contain any unacceptable chars.
Returns OK on success or a localised error message otherwise.

ting is($panel->validate_name(’foo’), ’OK’, ’validate_name’);
is($panel->validate_name(’cust3.prj12’),’OK’,’ .. name with dots and
nums’); is($panel->validate_name(’cust_bay’),’OK’,’ .. name with under-
score’); isnt($panel->validate_name(’3amigos’), ’OK’, ’ .. cannot start
with number’); isnt($panel->validate_name(’betty ford’), ’OK’, ’ ..
cannot contain space’);

=== check_password ===

Validates the password using the desired strength

[[Category:Developer]]
[[Category:SME Server Development Framework]]
[[Category:Development Tools]]

Navigation menu