Koozali.org: home of the SME Server

custom alphanumeric field into user account (server-manager > users)

Offline larieu

  • ****
  • 214
  • +0/-0
I wasn't able to find any info related to topic

I want to create a custom field (lets say 32 alphanumeric one) in user area
server-manager > user (add / modify)
which will be visible only in this screen (not visible in normal search of LDAP - for examnple in search of user in Thunderbird via LDAP )

It exist some way to achieve this?
if everybody's life around you is better, probably yours will be better
just try to improve their life

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #1 on: March 05, 2013, 05:35:13 PM »
first of all you should read the developer's manual to understand how things work behind the curtain

Offline larieu

  • ****
  • 214
  • +0/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #2 on: March 06, 2013, 09:29:04 AM »
Stefano

 :sad: disappointed - this kind of answer on forum set back all my wiliness to try

..... I hopped at least one guide line
I'm not a developer (unfortunately for me)
I know something about the internal things on SME server but ...
I hoped someone has already played around the topic and will be glad to give me at least some direct hints with pointing to wiki and/or other forum posts about how to do it
As I write I was not able to find relevant things

look what I found trying to access the developer (by searching it on wiki)

http://wiki.contribs.org/index.php?title=The_SME_Server_Developer%27s_Guide&action=edit&redlink=1

Quote
Warning: You are recreating a page that was previously deleted.

You should consider whether it is appropriate to continue editing this page. The deletion and move log for this page are provided here for convenience:

and on talk page is all about manual - ...

maybe I stress this out twice - Stefano you are a mood killer with that comment
2~5 links with where to read will be by far better
Thanks for your time anyway


« Last Edit: March 06, 2013, 12:37:43 PM by larieu »
if everybody's life around you is better, probably yours will be better
just try to improve their life

Offline Stefano

  • *
  • 10,839
  • +2/-0

Offline larieu

  • ****
  • 214
  • +0/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #4 on: March 06, 2013, 10:07:04 AM »
I think this is the exact link

http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual#Adding_new_account_properties

If someone will look for something like this again
if everybody's life around you is better, probably yours will be better
just try to improve their life

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #5 on: March 06, 2013, 06:10:52 PM »
I think this is the exact link

http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual#Adding_new_account_properties

That will work as a separate panel. Your other alternative is to modify the existing useraccounts panel code.

In either case, since you say you are not a developer, you should expect some challenges in getting this working. The httpd/admin-error_log will be useful to you if anything goes wrong.

Offline larieu

  • ****
  • 214
  • +0/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #6 on: March 08, 2013, 10:50:08 AM »
CharlieBrady

I've set up a virtual machine (proxmox) and I managed to have the separate panel
(with my custom name_of_panel, my custom NameEntry and my custom file names into /path )

but I have messed up the things when I want to put the same NameEntry into User ADD/Modify submenu
"luckily" it is a VM  which I can made snapshots on...
if everybody's life around you is better, probably yours will be better
just try to improve their life

Offline larieu

  • ****
  • 214
  • +0/-0
Re: custom alphanumeric field into user account (server-manager > users)
« Reply #7 on: March 14, 2013, 07:47:23 PM »
CharlieBrady

as usual you pointed me to the right direction

"how to" - maybe someone else is interested

Assume you need one field available to all users (except admin) named NewField which is kept int db Accouns as prop NewProp

First edit the useraccounts file into /etc/e-smith/web/functions

from

Code: [Select]
...
        <field type="text" id="ForwardAddress" validation="emailforward()"
            display="display_email_forwarding()"
            >
            <label>FORWARDING_ADDRESS</label>
        </field>
        <field type="select" id="VPNClientAccess" options="'yes' => 'YES',
            'no' => 'NO'" validation="nonblank" value="get_pptp_value()">
            <label>VPN_CLIENT_ACCESS</label>
        </field> 
...

will become

Code: [Select]
...
        <field type="text" id="ForwardAddress" validation="emailforward()"
            display="display_email_forwarding()"
            >
            <label>FORWARDING_ADDRESS</label>
        </field>
        <field type="text" id="NewProp"
            >
            <label>NewField</label>
        </field> 
        <field type="select" id="VPNClientAccess" options="'yes' => 'YES',
            'no' => 'NO'" validation="nonblank" value="get_pptp_value()">
            <label>VPN_CLIENT_ACCESS</label>
        </field> 
...

Note
As long as you don't need any restriction in this field should be ok
If you need to have restrictions you should implement an validation sub_procedure


second edit the useraccounts.pm from /usr/lib/perl5/site_perl/esmith/FormMagik/Panel/
(you need to edit in 3 places)

from

Code: [Select]
....
       my $fwd = $cgi->param('ForwardAddress') ?
            $cgi->param('ForwardAddress') :
            ($rec ? ($rec->prop('ForwardAddress')) : '');
        my $pptp = $cgi->param('VPNClientAccess') ?
            $cgi->param('VPNClientAccess') :
            ($rec ? ($rec->prop('VPNClientAccess')) : 'no');
        # now that we're down with the 411, let's set the values
...

...
        $cgi->param(-name=>'ForwardAddress', -value=>$fwd);
        $cgi->param(-name=>'VPNClientAccess', -value=>$pptp);
...

...
            'ForwardAddress' => $self->{cgi}->param('ForwardAddress'),
            'VPNClientAccess'=> $self->{cgi}->param('VPNClientAccess'),
...

will become


Code: [Select]
....
       my $fwd = $cgi->param('ForwardAddress') ?
            $cgi->param('ForwardAddress') :
            ($rec ? ($rec->prop('ForwardAddress')) : '');
        my $newvar = $cgi->param('NewProp') ?
        $cgi->param('NewProp') :
        ($rec ? ($rec->prop('NewProp')) : '');
        my $pptp = $cgi->param('VPNClientAccess') ?
            $cgi->param('VPNClientAccess') :
            ($rec ? ($rec->prop('VPNClientAccess')) : 'no');
        # now that we're down with the 411, let's set the values
...

...
        $cgi->param(-name=>'ForwardAddress', -value=>$fwd);
        $cgi->param(-name=>'NewProp', -value=>$newvar);
        $cgi->param(-name=>'VPNClientAccess', -value=>$pptp);
...

...
            'ForwardAddress' => $self->{cgi}->param('ForwardAddress'),
            'NewProp' => $self->{cgi}->param('NewProp'),
            'VPNClientAccess'=> $self->{cgi}->param('VPNClientAccess'),
...

Note
As long as you don't need to edit the field in this page (for example you'll have another panel for edit) you can omit the last edit
If you opt to omit the last bit you can put any value into the field but it will not be saved (next time you'll access this menu you'll have the initial value)


Question

Do you think this template is ok to be added as "next example" into developer section of wiki, after the CellNumber one ?
« Last Edit: March 14, 2013, 07:49:19 PM by larieu »
if everybody's life around you is better, probably yours will be better
just try to improve their life