My first plugin

2 posts / 0 new
Last post
#1 Tue, 09/04/2012 - 12:59
fspegni

My first plugin

Hello,

I'm trying to write my first Virtualmin plugin, following this:

http://www.virtualmin.com/documentation/developer/plugins#plugin_cgi_scr...

The problem I'm facing right now is that I cannot show a link to my cgi-scripts in the left-hand-side menu (using the Virtualmin theme).

I'm taking inspiration from the awstats plugin for virtualmin, so maybe i copy-and-pasted something wrong but i can't figure what. reading the API the only relevant functions (for this task) are feature_webmin and feature_links, that are as follows:

sub feature_webmin
{
    local ($d, $all) = @_;
    my @fdoms = grep { $_->{$module_name} } @$all;
if (@fdoms) {
  return ( [ $module_name, { 'doms' => join(" ", @fdoms) } ] );
  }
else {
  return ( );
  }
}

sub feature_links
{
local ($d) = @_;
return ( 
     { 'mod' => $module_name,
       'desc' => "Foo extension 1", 
       'page' => 'view.cgi', 
       'cat' => 'services',
     },
);
}

The file view.cgi has been created (in my virtualmin plugin directory). I've also removed modules and links cache, with:

rm /etc/webmin/virtual-server/links-cache/* rm /etc/webmin/module.infos.cache

Finally: I think the file structure and names are ok, because I can see my plugin when creating a new Virtual Server (or editing an existing one) and I can check it.

any suggestion on how to debug it?

UPDATE: thanks to andreychek on the irc channel, I found out that it was not enabled for my user (going to:

Webmin -> Webmin -> Webmin Users -> USERNAME -> Available Webmin modules

).

So my question becomes: is it possible to write the module in such a way that it is enabled for all existing users? Thanks :)

Tue, 09/04/2012 - 23:18
andreychek

Jamie and I have been going over what might cause that... his first thought was to make sure that you had the "feature_webmin" function added. But it looks like you do!

His other thought was that, depending on when exactly that function was added, you may want to try disabling, then re-enabling, the feature for your domain. Doing that should grant the privileges to the users within your domain.

-Eric

Topic locked