Hiding a field

From ISPWiki

Jump to: navigation, search

The article bellow describes the procedure that you need to follow to delete a button, line, column, etc. from the interface. You won't be able to undo this. Consider the example on how to hide a button that is used for switching to User panel.

Describe this button in xml and add the if attribute, which specifies that this button will be displayed, if the specified condition is met. As we want to hide this button, the condition must never be met. Create a /usr/local/ispmgr/etc/ispmgr_mod_myhide.xml file with the following content

<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
    <metadata name="user">
        <toolbar>
            <toolbtn name="su" if="myhide"/>
        </toolbar>
    </metadata>
</mgrdata>

and restart ISPmanager (killall ispmgr)

You can view the names of the modules and buttons in ispmgr.xml The if attribute can have any value that does not exist in ISPmanager.

The procedures described above can be applied to all the software products from our company. The prefixes in file names will differ, e.g. for BILLmanager you need to change ispmgr into billmgr.

Removing "unnecessary" functionality

Even though a button or field was hidden, the user still may continue using it and view the hidden fields via API.

Disable the functionality

To deny the user.su function, add the followings into the <mgrdata> tag

<handler name="hideaction.pl" type="cgi">
    <event before="yes">user.su</event>
</handler>

The event handler addon/hideaction.pl:

#!/usr/bin/perl
 
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<doc><skipaction/></doc>\n";

Hide a field from the table

The following example hides the owner field from the user list. Unlike the example mentioned above, the xml type is used here enabling to handle the result of the ISPmanager function:

<handler name="dropcol.pl" type="xml">
    <event after="yes">user</event>
</handler>

The event handler addon/dropcol.pl:

#!/usr/bin/perl
 
use XML::LibXML;
my $d = XML::LibXML->new->parse_string(join "", <STDIN>);
for my $dead ($d->findnodes(q{//elem/owner})) {
    $dead->unbindNode;
}
print $d->toString;
Was this helpful? Yes | No
Personal tools