2008-11-26 22:50:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* AgileBill - Open Billing Software
|
|
|
|
*
|
|
|
|
* This body of work is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the Open AgileBill License
|
|
|
|
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
*
|
|
|
|
* Originally authored by Tony Landis, AgileBill LLC
|
|
|
|
*
|
|
|
|
* Recent modifications by Deon George
|
|
|
|
*
|
|
|
|
* @author Deon George <deonATleenooksDOTnet>
|
|
|
|
* @copyright 2009 Deon George
|
|
|
|
* @link http://osb.leenooks.net
|
2008-11-26 22:50:40 +00:00
|
|
|
*
|
|
|
|
* @link http://www.agileco.com/
|
|
|
|
* @copyright 2004-2008 Agileco, LLC.
|
|
|
|
* @license http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
* @author Tony Landis <tony@agileco.com>
|
2008-11-26 22:50:40 +00:00
|
|
|
* @package AgileBill
|
2009-08-03 04:10:16 +00:00
|
|
|
* @subpackage Modules:Product
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
/**
|
2009-08-03 04:10:16 +00:00
|
|
|
* The main AgileBill Base Product Plugin Class
|
|
|
|
*
|
|
|
|
* @package AgileBill
|
|
|
|
* @subpackage Modules:Product
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
abstract class base_product_plugin {
|
|
|
|
# Plugin Name
|
|
|
|
protected $name = '';
|
|
|
|
# If this plugin provisions remote services
|
|
|
|
public $remote_based = false;
|
|
|
|
# Account Using this Plugin
|
|
|
|
protected $account;
|
|
|
|
# Product this Plugin is Refering
|
|
|
|
protected $product;
|
|
|
|
# Product Actributes
|
|
|
|
protected $product_attr;
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
/**
|
|
|
|
* Provision new service
|
2009-08-03 04:10:16 +00:00
|
|
|
*
|
|
|
|
* Some available variables:
|
|
|
|
* * All the fields on the account table, eg: id,username,email,first_name,last_name
|
|
|
|
* $this->account['username'];
|
|
|
|
* * All the fields in the service table, eg: id,host_username,host_password
|
|
|
|
* $this->service['id'];
|
|
|
|
* * All the fields captured by the custom product plugin configuration template
|
|
|
|
* $this->plugin_data['my_field'];
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
protected function p_new() {
|
|
|
|
# Do some background logging of what is going on
|
|
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
|
|
|
|
|
|
|
|
return true;
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
/**
|
|
|
|
* Modify service
|
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
protected function p_edit() {
|
|
|
|
# Do some background logging of what is going on
|
|
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Suspend service
|
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
protected function p_inactive() {
|
|
|
|
# Do some background logging of what is going on
|
|
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activate service
|
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
protected function p_active() {
|
|
|
|
# Do some background logging of what is going on
|
|
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-03 04:10:16 +00:00
|
|
|
* Delete service
|
|
|
|
*/
|
|
|
|
protected function p_delete() {
|
|
|
|
# Do some background logging of what is going on
|
|
|
|
global $C_debug;
|
|
|
|
$C_debug->error(__FILE__,__METHOD__,print_r(array($this->plugin_data,$this->service),true));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete items from a cart
|
|
|
|
* Return is not used
|
|
|
|
*/
|
|
|
|
public function delete_cart($VAR,$cart) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate items added to cart
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
public function validate_cart($VAR,$cart) {
|
2008-11-26 22:50:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process a Service
|
|
|
|
*/
|
|
|
|
public function p_one($id) {
|
2008-11-26 22:50:40 +00:00
|
|
|
global $C_debug;
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
$db = &DB();
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
/* Get the service details */
|
|
|
|
$rs = $db->Execute(sqlSelect($db,'service','*',sprintf('id=::%s::',$id)));
|
|
|
|
if (! $rs || ! $rs->RecordCount())
|
|
|
|
return false;
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
$this->service = $rs->fields;
|
|
|
|
@$this->plugin_data = unserialize($this->service['prod_plugin_data']);
|
|
|
|
@$this->prod_attr_cart = unserialize($this->service['prod_attr_cart']);
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
# Get the account details
|
|
|
|
$acct = $db->Execute(sqlSelect($db,'account','*',sprintf('id=::%s::',$this->service['account_id'])));
|
|
|
|
if ($acct && $acct->RecordCount())
|
|
|
|
$this->account = $acct->fields;
|
|
|
|
|
|
|
|
# Get the product details
|
|
|
|
if (! empty($this->service['product_id'])) {
|
|
|
|
$product = $db->Execute(sqlSelect($db,'product','*',sprintf('id = ::%s::',$this->service['product_id'])));
|
|
|
|
$this->product = $product->fields;
|
|
|
|
@$this->product_attr = unserialize($product->fields['prod_plugin_data']);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Determine the correct action
|
|
|
|
switch ($this->service['queue']) {
|
2008-11-26 22:50:40 +00:00
|
|
|
case 'new':
|
2009-08-03 04:10:16 +00:00
|
|
|
$result = $this->p_new();
|
|
|
|
break;
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
case 'active':
|
2009-08-03 04:10:16 +00:00
|
|
|
$result = $this->p_active();
|
|
|
|
break;
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
case 'inactive':
|
|
|
|
$result = $this->p_inactive();
|
2009-08-03 04:10:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'edit':
|
2008-11-26 22:50:40 +00:00
|
|
|
if ($this->service['active'] == 1)
|
|
|
|
$this->p_active();
|
|
|
|
else
|
|
|
|
$this->p_inactive();
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
$result = $this->p_edit();
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
case 'delete':
|
|
|
|
$result = $this->p_delete();
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
break;
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
$result = false;
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
$sql = sprintf("UPDATE %sservice SET queue='none', date_last=%s WHERE id =%s AND site_id=%s",
|
|
|
|
AGILE_DB_PREFIX,$db->qstr(time()),$db->qstr($rs->fields['id']),$db->qstr(DEFAULT_SITE));
|
|
|
|
$db->Execute($sql);
|
|
|
|
|
|
|
|
} else {
|
2008-11-26 22:50:40 +00:00
|
|
|
$C_debug->error($this->name.'php', $this->service['queue'], @$result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
?>
|