• Online Demo
  • 30-day Free Trial
  #1  
Old 06-19-2012, 06:33 PM
rudders18 rudders18 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 9
Default Enhancing Plesk module

Hi
I am modifying the Plesk module to work better with Plesk 9.5 and now have it creating an account if one does not exist and then a domain which it did not before. I want to try and go a bit further if I can but my experience of how the modules are written is limited.

The question I have generally about module writing is how I can access other information about the account requesting a domain so that I can pass Plesk fuller account details such as name and address, are these fields easy to extract from the DB from within a module. If so, is there some sample code anywhere.

Thanks
Paul
Reply With Quote
  #2  
Old 06-21-2012, 03:49 PM
Tyson Tyson is offline
Administrator
 
Join Date: Jan 2008
Location: Anaheim, CA
Posts: 138
Default

Account information is not available to modules in v2.5. The Plesk module currently does not ask for first name, address, etc., which you would need to ask for with your updated module. I would suggest reviewing the documentation at http://blesta.com/manual/Modules and taking a look at other modules for reference.

For example, in the constructor, you could update the module to require name and address information be given from the customer:
PHP Code:
public function __construct() {
    ...
    
self::$module->addServiceHTMLField("text""First Name""detail[fname]""^.{2,}""You must provide a valid First Name.");
    
self::$module->addServiceHTMLField("text""Address 1""detail[address1]""^.{2,}""You must provide a valid Address.");
    ...
    
self::$module->addUserServiceHTMLField("text""First Name""detail[fname]""^.{2,}""You must provide a valid First Name.");
    
self::$module->addUserServiceHTMLField("text""Address 1""detail[address1]""^.{2,}""You must provide a valid Address.");
    ...

Then reference that information when creating the service:
PHP Code:
public function promodule($action$serviceInfo$packageinfo) {
    
$first_name $serviceInfo['detail']['fname'];
    
$address1 $serviceInfo['detail']['address1'];
    ...

__________________
Tyson
Developer

Blesta
Professional Billing
www.blesta.com
Reply With Quote
  #3  
Old 06-22-2012, 04:45 AM
Paul's Avatar
Paul Paul is offline
Blesta Developer
 
Join Date: Apr 2006
Location: Wherever I go, there I am.
Posts: 1,467
Send a message via AIM to Paul Send a message via MSN to Paul
Default

Rather than asking for those details, I think he just wants to pull them from the account. Since the details are not directly available to the module, you would need to do a direct query on the database from your module.

Maybe Tyson could post an example of this, if you think I'm on the right track.
__________________
Paul
Misc Stuff Guy

Blesta
Professional Billing
www.blesta.com
Reply With Quote
  #4  
Old 06-22-2012, 04:02 PM
Tyson Tyson is offline
Administrator
 
Join Date: Jan 2008
Location: Anaheim, CA
Posts: 138
Default

In that case you can fetch fields for the user by calling auserinfo(). The fields returned are numerically-indexed, so you'll want to take a look at what indices contain the fields you need.

PHP Code:
public function promodule($action$serviceInfo$packageInfo) {
    ...
    global 
$mysqldb;
    
$user auserinfo($mysqldb$serviceInfo['uid']);
    
print_r($user);
    die;
    ...

__________________
Tyson
Developer

Blesta
Professional Billing
www.blesta.com
Reply With Quote
  #5  
Old 06-22-2012, 08:45 PM
rudders18 rudders18 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 9
Default

Hi
That is just the information I needed, I will have a go at expanding the Plesk module in a week or so when I have some spare time

Thanks
Reply With Quote
Reply

Bookmarks

Tags
module, plesk

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Plesk module (client creation) error keeblerelfmatt General Discussion 2 06-24-2010 06:50 PM
Plesk module jacobb Pre-Sale Questions 8 05-19-2010 07:44 PM
Plesk Module Handling agerszt Feature Requests 2 07-04-2008 03:57 PM
Plesk Module Cody Modules & Gateways 4 03-15-2008 04:39 AM
Plesk Module Cody Development Status 0 10-17-2007 04:32 PM


All times are GMT. The time now is 08:35 AM.