6.5. Adding functionality to the user interface

As we explained before, our goal is to centralize the configuration of those modules that are based on user and group accounts stored in LDAP in one place. This place is the configuration pages provided by the Users and Groups eBox module.

Let's go back to the samba module. When the user edits a group, and the samba service is activated, he will be able to configure the samba parameters for that group. In this case it will be possible to enable a shared resource for the group as well as its name. This options will show up along with the general configuration options for the group.

EBox::UsersAndGroups calls the _groupAddOns() method implementation given by the samba module, giving to it the name of the group that is about to be edited. The samba module will return the template and its arguments.

Example 6.1. _groupAddOns implementation

sub _groupAddOns($$) {
	my $self = shift;
	my $groupname = shift;

	my $samba = EBox::Global->modInstance('samba');
	unless ($samba->service){
		return undef;
	}

	my @args;
	my $args =  { 'groupname' => $groupname,
		'share'     => $self->_groupSharing($groupname)
		'sharename' => $self->sharingName($groupname)};

	return { path => '/samba/samba.mas', params => $args };

}  

In line 3, we get the group name as a parameter.

In line 6, we return undef if the samba service is disabled.

The next lines create a hash that contains the path to the mason template and its arguments. The arguments are the name of the shared resource and whether it is enabled.