mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-21 20:34:57 +09:00
Merge pull request #708 from evrifaessa/patch-1
Multiple changes, mostly based on removing references to the non-existing pro plan
This commit is contained in:
17 files changed
+7
-915
No files matched your search
@@ -6,7 +6,7 @@
|
||||
* to "bb-config.php" and fill in the values.
|
||||
* Import /install/structure.sql to your database
|
||||
* Import /install/content.sql to your database
|
||||
* Open browser http://www.youdomain.com/index.php?_url=/bb-admin to create new admin account.
|
||||
* Open browser http://www.yourdomain.com/index.php?_url=/bb-admin to create new admin account.
|
||||
* Remove /install directory
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ function handler_exception($e)
|
||||
<style>
|
||||
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;min-height:180px;padding:30px 0 15px}* > body{padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0} em{font-weight:bold}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}pre{ width: 100%; overflow:auto; }
|
||||
</style>
|
||||
<a href=//www.boxbilling.com/ target='_blank'><img src='https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png' alt='BoxBilling' style='height:60px'></a>
|
||||
<a href=//www.boxbilling.com/ target='_blank'><img src='/bb-themes/boxbilling/assets/images/logo.png' alt='BoxBilling' style='height:60px'></a>
|
||||
";
|
||||
$page = str_replace(PHP_EOL, "", $page);
|
||||
print $page;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
"id": "branding",
|
||||
"type": "mod",
|
||||
"name": "Branding",
|
||||
"description": "BoxBilling branding module. Can be deactivated by PRO license owners only.",
|
||||
"description": "Branding module of BoxBilling. This extension includes the footer reference to BoxBilling's official website.",
|
||||
"homepage_url": "http://github.com/boxbilling/",
|
||||
"author": "BoxBilling",
|
||||
"author_url": "http://extensions.boxbilling.com/",
|
||||
"license": "http://www.boxbilling.com/license.txt",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Serviceboxbillinglicense\Api;
|
||||
/**
|
||||
* BoxBilling license management
|
||||
*/
|
||||
class Admin extends \Api_Abstract
|
||||
{
|
||||
private function _getService($data)
|
||||
{
|
||||
if(!isset($data['order_id'])) {
|
||||
throw new \Box_Exception('Order id is required');
|
||||
}
|
||||
|
||||
$order = $this->di['db']->findOne('client_order',
|
||||
"id=:id
|
||||
AND service_type = 'boxbillinglicense'
|
||||
",
|
||||
array('id'=>$data['order_id']));
|
||||
|
||||
if(!$order) {
|
||||
throw new \Box_Exception('BoxBilling license order not found');
|
||||
}
|
||||
|
||||
$s = $this->di['db']->findOne('service_boxbillinglicense',
|
||||
'id=:id',
|
||||
array('id'=>$order->service_id));
|
||||
if(!$s) {
|
||||
throw new \Box_Exception('Order is not activated');
|
||||
}
|
||||
return array($order, $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update module configuration
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
* @return bool
|
||||
*/
|
||||
public function config_update($data)
|
||||
{
|
||||
$this->getService()->setModuleConfig($data);
|
||||
$this->di['logger']->info('Updated configuration information.');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module configuration
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
* @return bool
|
||||
*/
|
||||
public function config_get($data)
|
||||
{
|
||||
return $this->getService()->getModuleConfig($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detailed license order info
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function order_info($data)
|
||||
{
|
||||
list(, $service) = $this->_getService($data);
|
||||
return $this->getService()->licenseDetails($service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset license information. Usually used when moving BoxBilling to
|
||||
* new server.
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function order_reset($data)
|
||||
{
|
||||
list(, $service) = $this->_getService($data);
|
||||
$this->getService()->licenseReset($service);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to become partner. After you become BoxBilling
|
||||
* partner you are able to sell licenses.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function become_partner()
|
||||
{
|
||||
return $this->getService()->becomePartner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test connection to BoxBilling server. Used to test your configuration.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function test_connection()
|
||||
{
|
||||
$this->getService()->testApiConnection();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update existing order service
|
||||
* This method used to change service data if order setup fails
|
||||
* or have changed on remote server
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function update($data)
|
||||
{
|
||||
list(, $service) = $this->_getService($data);
|
||||
|
||||
$service->oid = $this->di['array_get']($data, 'oid', $service->oid);
|
||||
$service->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($service);
|
||||
|
||||
$this->di['logger']->info('Updated BoxBilling license %s details', $service->id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Serviceboxbillinglicense\Api;
|
||||
|
||||
/**
|
||||
* BoxBilling license management
|
||||
*/
|
||||
class Client extends \Api_Abstract
|
||||
{
|
||||
private function _getService($data)
|
||||
{
|
||||
if (!isset($data['order_id'])) {
|
||||
throw new \Box_Exception('Order id is required');
|
||||
}
|
||||
|
||||
$order = $this->di['db']->findOne('client_order',
|
||||
"id=:id
|
||||
AND client_id = :cid
|
||||
AND service_type = 'boxbillinglicense'
|
||||
",
|
||||
array(':id' => $data['order_id'], ':cid' => $this->getIdentity()->id));
|
||||
|
||||
if (!$order) {
|
||||
throw new \Box_Exception('BoxBilling license order not found');
|
||||
}
|
||||
|
||||
$s = $this->di['db']->findOne('service_boxbillinglicense',
|
||||
'id=:id AND client_id = :cid',
|
||||
array('id' => $order->service_id, 'cid' => $this->getIdentity()->id));
|
||||
if (!$s) {
|
||||
throw new \Box_Exception('Order is not activated');
|
||||
}
|
||||
|
||||
return array($order, $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset license information. Usually used when moving BoxBilling to
|
||||
* new server.
|
||||
*
|
||||
* @param int $order_id - order id
|
||||
* @return bool
|
||||
*/
|
||||
public function reset($data)
|
||||
{
|
||||
list($order, $service) = $this->_getService($data);
|
||||
$this->getService()->reset($order, $service, $data);
|
||||
$this->di['logger']->info('Reset license information. Order ID #%s', $order->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Serviceboxbillinglicense;
|
||||
|
||||
use Box\InjectionAwareInterface;
|
||||
|
||||
class Service implements InjectionAwareInterface
|
||||
{
|
||||
protected $di;
|
||||
|
||||
/**
|
||||
* @param mixed $di
|
||||
*/
|
||||
public function setDi($di)
|
||||
{
|
||||
$this->di = $di;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDi()
|
||||
{
|
||||
return $this->di;
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
$sql="
|
||||
CREATE TABLE IF NOT EXISTS `service_boxbillinglicense` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`oid` varchar(255) DEFAULT NULL,
|
||||
`created_at` varchar(35) DEFAULT NULL,
|
||||
`updated_at` varchar(35) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `oid` (`oid`),
|
||||
KEY `client_id_idx` (`client_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||
";
|
||||
|
||||
$this->di['db']->exec($sql);
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
|
||||
$this->di['db']->exec("DROP TABLE IF EXISTS `service_boxbillinglicense`");
|
||||
}
|
||||
|
||||
public function setModuleConfig($data)
|
||||
{
|
||||
$this->getModuleConfig();
|
||||
|
||||
$sql="
|
||||
UPDATE extension_meta
|
||||
SET meta_value = :config
|
||||
WHERE extension = 'mod_serviceboxbillinglicense'
|
||||
AND meta_key = 'config'
|
||||
";
|
||||
$params = array(
|
||||
'config' => json_encode($data),
|
||||
);
|
||||
$this->di['db']->exec($sql, $params);
|
||||
}
|
||||
|
||||
public function getModuleConfig()
|
||||
{
|
||||
$c = $this->di['db']->findOne('extension_meta', 'extension = :ext AND meta_key = :key', array('ext'=>'mod_serviceboxbillinglicense', 'key'=>'config'));
|
||||
if(is_null($c)) {
|
||||
$c = $this->di['db']->dispense('extension_meta');
|
||||
$c->extension = 'mod_serviceboxbillinglicense';
|
||||
$c->meta_key = 'config';
|
||||
$c->meta_value = null;
|
||||
$c->created_at = date('Y-m-d H:i:s');
|
||||
$c->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($c);
|
||||
}
|
||||
$config = json_decode($c->meta_value, 1);
|
||||
if(!isset($config['api_key'])) {
|
||||
$config['api_key'] = null;
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @return void
|
||||
*/
|
||||
public function create($order)
|
||||
{
|
||||
$model = $this->di['db']->dispense('service_boxbillinglicense');
|
||||
$model->client_id = $order->client_id;
|
||||
$model->created_at = date('Y-m-d H:i:s');
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($model);
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @return boolean
|
||||
*/
|
||||
public function activate($order, $model)
|
||||
{
|
||||
if(!is_object($model)) {
|
||||
throw new \Box_Exception('Could not activate order. Service was not created', null, 7456);
|
||||
}
|
||||
|
||||
$result = $this->_getApi()->partner_order_create();
|
||||
|
||||
$model->oid = $result;
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($model);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend VPS
|
||||
*
|
||||
* @param $order
|
||||
* @return boolean
|
||||
*/
|
||||
public function suspend($order, $model)
|
||||
{
|
||||
if(!is_object($model)) {
|
||||
throw new \Box_Exception('Could not activate order. Service was not created', null, 7456);
|
||||
}
|
||||
|
||||
$this->_getApi()->partner_order_suspend($model->vserverid);
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($model);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @return boolean
|
||||
*/
|
||||
public function unsuspend($order, $model)
|
||||
{
|
||||
if(!is_object($model)) {
|
||||
throw new \Box_Exception('Could not activate order. Service was not created', null, 7456);
|
||||
}
|
||||
|
||||
$this->_getApi()->partner_order_unsuspend($model->vserverid);
|
||||
$model->updated_at = date('Y-m-d H:i:s');
|
||||
$this->di['db']->store($model);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete($order, $model)
|
||||
{
|
||||
if(is_object($model)) {
|
||||
$this->_getApi()->partner_order_delete($model->vserverid);
|
||||
$this->di['db']->trash($model);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function reset($order, $model)
|
||||
{
|
||||
$this->_getApi()->partner_order_reset($model->f1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function becomePartner()
|
||||
{
|
||||
$data = array(
|
||||
'agree'=> true,
|
||||
);
|
||||
$this->_getApi()->partner_signup($data);
|
||||
}
|
||||
|
||||
public function licenseDetails($model)
|
||||
{
|
||||
$data = array(
|
||||
'order_id'=> $model->oid,
|
||||
);
|
||||
try {
|
||||
return $this->_getApi()->partner_order_get($data);
|
||||
} catch(\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function licenseReset($model)
|
||||
{
|
||||
$data = array(
|
||||
'order_id'=> $model->oid,
|
||||
);
|
||||
return $this->_getApi()->partner_order_reset($data);
|
||||
}
|
||||
|
||||
public function testApiConnection()
|
||||
{
|
||||
try {
|
||||
$this->_getApi()->client_get();
|
||||
} catch (\Exception $e) {
|
||||
error_log($e);
|
||||
throw new \Exception('Unable to connect to BoxBilling API. Make sure API key is valid.');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _getApi()
|
||||
{
|
||||
$config = $this->getModuleConfig();
|
||||
return $this->di['service_boxbilling']($config);
|
||||
}
|
||||
|
||||
public function toApiArray($model, $deep = false, $identity = null)
|
||||
{
|
||||
return array(
|
||||
'id' => $model->id,
|
||||
'oid' => $model->oid,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* BoxBilling
|
||||
*
|
||||
* @copyright BoxBilling, Inc (http://www.boxbilling.com)
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* Copyright BoxBilling, Inc
|
||||
* This source file is subject to the Apache-2.0 License that is bundled
|
||||
* with this source code in the file LICENSE
|
||||
*/
|
||||
|
||||
namespace Box\Mod\Serviceboxbillinglicense;
|
||||
|
||||
class ServiceBoxbilling implements \Box\InjectionAwareInterface
|
||||
{
|
||||
|
||||
protected $di;
|
||||
|
||||
public function setDi($di)
|
||||
{
|
||||
$this->di = $di;
|
||||
}
|
||||
|
||||
public function getDi()
|
||||
{
|
||||
return $this->di;
|
||||
}
|
||||
/**
|
||||
* Api URL
|
||||
*
|
||||
* @example https://www.boxbilling.com/api
|
||||
* @var string
|
||||
*/
|
||||
protected $_api_url = 'http://www.boxbilling.com/api';
|
||||
|
||||
/**
|
||||
* Api key is found in BoxBilling profile page
|
||||
*
|
||||
* @example e4yny7yjy5u3yhyhepumuqaquva3y4as
|
||||
* @var string
|
||||
*/
|
||||
protected $_api_key = NULL;
|
||||
|
||||
/**
|
||||
* Same service can be used to control BoxBilling as client and guest
|
||||
*
|
||||
* @example guest
|
||||
* @example admin
|
||||
* @example client
|
||||
* @var string
|
||||
*/
|
||||
protected $_api_role = 'client';
|
||||
|
||||
/**
|
||||
* Path to cookie to save session for requests.
|
||||
*
|
||||
* @var string - path to cookie. Must be writable
|
||||
*/
|
||||
protected $_cookie = NULL;
|
||||
|
||||
public function __construct($options)
|
||||
{
|
||||
if (!extension_loaded('curl')) {
|
||||
throw new \Exception('cURL extension is not enabled');
|
||||
}
|
||||
|
||||
if (isset($options['api_key'])) {
|
||||
$this->_api_key = $options['api_key'];
|
||||
}
|
||||
|
||||
if (isset($options['api_url'])) {
|
||||
$this->_api_url = $options['api_url'];
|
||||
}
|
||||
|
||||
if (isset($options['api_role'])) {
|
||||
$this->_api_role = $options['api_role'];
|
||||
}
|
||||
|
||||
$this->_cookie = sys_get_temp_dir() . '/bbcookie.txt';
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$data = array();
|
||||
if (isset($arguments[0]) && is_array($arguments[0])) {
|
||||
$data = $arguments[0];
|
||||
}
|
||||
|
||||
$module = substr($method, 0, strpos($method, '_'));
|
||||
$m = substr($method, strpos($method, '_') + 1);
|
||||
|
||||
$url = $this->_api_url . '/' . $this->_api_role . '/' . $module . '/' . $m;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->_api_role . ":" . $this->_api_key);
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_cookie);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_cookie);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if ($result === false) {
|
||||
$e = new \Exception(sprintf('Curl Error: "%s"', curl_error($ch)));
|
||||
curl_close($ch);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$json = json_decode($result, 1);
|
||||
|
||||
if (!is_array($json)) {
|
||||
throw new \Exception(sprintf('BoxBilling API: Invalid Response "%s"', $result));
|
||||
}
|
||||
|
||||
if (isset($json['error']) && !empty($json['error'])) {
|
||||
throw new \Exception($json['error']['message'], $json['error']['code']);
|
||||
}
|
||||
|
||||
if (!isset($json['result'])) {
|
||||
throw new \Exception(sprintf('BoxBilling API: Invalid Response "%s"', $result));
|
||||
}
|
||||
|
||||
return $json['result'];
|
||||
}
|
||||
|
||||
}
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
<div class="help">
|
||||
<h2>{% trans 'BoxBilling license management' %}</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ 'api/admin/serviceboxbillinglicense/update'|link }}" class="mainForm api-form save" data-api-reload="1">
|
||||
<fieldset>
|
||||
<div class="rowElem noborder">
|
||||
<label>{% trans 'License order ID' %}:</label>
|
||||
<div class="formRight">
|
||||
<input type="text" name="oid" value="{{service.oid}}" placeholder="License order ID on BoxBilling.com"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="order_id" value="{{ order.id }}" />
|
||||
<input type="submit" value="{% trans 'Update' %}" class="greyishBtn submitForm" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{% set info = admin.serviceboxbillinglicense_order_info({"order_id":order.id}) %}
|
||||
|
||||
{% if info %}
|
||||
|
||||
<div class="help">
|
||||
<h2>{% trans 'License details' %}</h2>
|
||||
</div>
|
||||
|
||||
<table class="tableStatic wide">
|
||||
<tbody>
|
||||
<tr class="noborder">
|
||||
<td style="width: 30%">{% trans 'Order status' %}:</td>
|
||||
<td>{{ info.status|title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'License key' %}:</td>
|
||||
<td>{{ info.license_key }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Created at' %}:</td>
|
||||
<td>{{ info.created_at|bb_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Updated at' %}:</td>
|
||||
<td>{{ info.updated_at|bb_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Expires at' %}:</td>
|
||||
<td>{{ info.expires_at|bb_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid IPs' %}:</td>
|
||||
<td>{% for v in info.ips %}{{ v }}{{constant("PHP_EOL")}}{%else%}All IPs{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid hostnames' %}:</td>
|
||||
<td>{% for v in info.hosts %}{{ v }}{{constant("PHP_EOL")}}{%else%}All hostnames{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid versions' %}:</td>
|
||||
<td>{% for v in info.versions %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any version{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid install paths' %}:</td>
|
||||
<td>{% for v in info.paths %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any install path{% endfor %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div class="aligncenter">
|
||||
<a href="{{ 'api/admin/serviceboxbillinglicense/order_reset'|link({'order_id' : order.id}) }}" data-api-confirm="Are you sure?" data-api-msg="License details was reset" class="btn55 mr10 api-link"><img src="images/icons/middlenav/refresh.png" alt=""><span>Reset</span></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="body">
|
||||
<div class="nNote nInformation hideit">
|
||||
<p><strong>{% trans 'INFORMATION' %}: </strong>{% trans 'Order is not activated or not found' %}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
|
||||
{% set active_menu = 'system' %}
|
||||
{% block meta_title %}{% trans 'BoxBilling license' %}{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<ul>
|
||||
<li class="firstB"><a href="{{ '/'|alink }}">{% trans 'Home' %}</a></li>
|
||||
<li><a href="{{ 'system'|alink }}">{% trans 'Settings' %}</a></li>
|
||||
<li class="lastB">{% trans 'BoxBilling license' %}</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="widget">
|
||||
<div class="head">
|
||||
<h5>{% trans 'BoxBilling license' %}</h5>
|
||||
</div>
|
||||
|
||||
<div class="body">
|
||||
<h2>{% trans '1. Configure API' %}</h2>
|
||||
</div>
|
||||
|
||||
{% set params = admin.serviceboxbillinglicense_config_get %}
|
||||
<form method="post" action="{{ 'api/admin/serviceboxbillinglicense/config_update'|link }}" class="mainForm api-form" data-api-msg="{% trans 'Configuration updated' %}">
|
||||
<fieldset>
|
||||
<div class="rowElem noborder">
|
||||
<label class="topLabel"><a href="http://www.boxbilling.com/login" target="_blank">Login to BoxBilling</a> and get your API key at <a href="http://www.boxbilling.com/me" target="_blank">profile page</a>.</label>
|
||||
<div class="formBottom">
|
||||
<input type="password" name="api_key" value="{{params.api_key}}" required="required" placeholder="Example: xsd4zzydzvndcwdkvviaqfyykjOardxi" style="width: 300px"/>
|
||||
<input type="button" value="2. {% trans 'Test connection' %}" class="greyishBtn submitForm" id="testconnection"/>
|
||||
<input type="submit" value="1. {% trans 'Update API key' %}" class="greyishBtn submitForm" />
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<div class="body">
|
||||
<h2>{% trans '2. Become partner' %}</h2>
|
||||
<p><a href="{{ 'api/admin/serviceboxbillinglicense/become_partner'|link }}" class="btnIconLeft mr10 mt10 api-link" data-api-jsonp="onAfterBecomePartner"><span>Click here to become partner</span></a></p>
|
||||
<p><a href="http://www.boxbilling.com/partner" target="_blank">Go to partnership program page</a> for more information.</p>
|
||||
</div>
|
||||
|
||||
<div class="body list arrowBlue">
|
||||
<h2>{% trans '3. Create license product' %}</h2>
|
||||
<p><a href="{{'product'|alink({'type' : 'boxbillinglicense', 'title' : 'BoxBilling License' })}}#tab-new" target="_blank">Create BoxBilling license product</a></p>
|
||||
<p>You can sell licenses for any price you want or even give it for free. All money collected from your clients stays for you.</p>
|
||||
<p>BoxBilling will start charging you only for active licenses after 14 days. This gives you ability to make revenue before you even spend money.</p>
|
||||
<p>Thats it. Remember the more you sell the lower the price you receive.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{% autoescape "js" %}
|
||||
<script type="text/javascript">
|
||||
|
||||
function onAfterBecomePartner() {
|
||||
bb.msg('You have successfully become BoxBilling partner.');
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('#testconnection').click(function(){
|
||||
bb.post('admin/serviceboxbillinglicense/test_connection', null, function(result){
|
||||
bb.msg('Successfully connected to BoxBilling API');
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endautoescape %}
|
||||
{% endblock %}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
{% if order.status == 'active' %}
|
||||
{% set info = admin.serviceboxbillinglicense_order_info({"order_id":order.id}) %}
|
||||
|
||||
<div class="row">
|
||||
<article class="span12 data-block">
|
||||
<div class="data-container">
|
||||
<header>
|
||||
<h2>{{ order.title }}</h2>
|
||||
</header>
|
||||
<section>
|
||||
<table >
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{% trans 'License key' %}:</td>
|
||||
<td>{{ info.license_key }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid IPs' %}:</td>
|
||||
<td>{% for v in info.ips %}{{ v }}{{constant("PHP_EOL")}}{%else%}All IPs{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid hostnames' %}:</td>
|
||||
<td>{% for v in info.hosts %}{{ v }}{{constant("PHP_EOL")}}{%else%}All hostnames{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid versions' %}:</td>
|
||||
<td>{% for v in info.versions %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any version{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{% trans 'Valid install paths' %}:</td>
|
||||
<td>{% for v in info.paths %}{{ v }}{{constant("PHP_EOL")}}{%else%}Any install path{% endfor %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a href="{{'api/client/serviceboxbillinglicense/reset' | link({'order_id' : order.id})}}" data-api-confirm="Are you sure?" data-api-msg="License details was reset" class="btn btn-primary api-link">{% trans 'Reset' %}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
{% endif %}
|
||||
-1
@@ -1 +0,0 @@
|
||||
{% include "mod_order_product.phtml" %}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"id": "serviceboxbillinglicense",
|
||||
"type": "mod",
|
||||
"name": "BoxBilling license product",
|
||||
"description": "Sell BoxBiling licenses and get paid. The more you sell - more profit you make",
|
||||
"icon_url": "icon.png",
|
||||
"homepage_url": "http://github.com/boxbilling/",
|
||||
"author": "BoxBilling",
|
||||
"author_url": "http://extensions.boxbilling.com/",
|
||||
"license": "http://www.boxbilling.com/license.txt",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -363,7 +363,7 @@ VALUES
|
||||
(2,'company_name','Company Name',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(3,'company_email','company@email.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(4,'company_signature','BoxBilling.com - Client Management, Invoice and Support Software',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(5,'company_logo','https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(5,'company_logo','/bb-themes/boxbilling/assets/images/logo.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(6,'company_address_1','Demo address line 1',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(7,'company_address_2','Demo address line 2',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(8,'company_address_3','Demo address line 3',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
|
||||
@@ -572,7 +572,7 @@ VALUES
|
||||
(2,'company_name','Demo BoxBilling.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(3,'company_email','my@mycompany.com',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(4,'company_signature','BoxBilling.com - Client Management, Invoice and Support Software',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(5,'company_logo','https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(5,'company_logo','/bb-themes/boxbilling/assets/images/logo.png',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(6,'company_address_1','Demo address line 1',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(7,'company_address_2','Demo address line 2',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
(8,'company_address_3','Demo address line 3',0,NULL,NULL,'2012-01-01 12:00:00','2012-01-01 12:00:00'),
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<body>
|
||||
<div id="header" class="wrapper">
|
||||
<div class="logo"><a href="{{ constant('BB_URL_INSTALL') }}" title="BoxBilling"><img src="https://sites.google.com/site/boxbilling/_/rsrc/1308483006796/home/logo_boxbilling.png" alt="" style="max-height: 50px"/></a></div>
|
||||
<div class="logo"><a href="{{ constant('BB_URL_INSTALL') }}" title="BoxBilling"><img src="/bb-themes/boxbilling/assets/images/logo.png" alt="" style="max-height: 50px"/></a></div>
|
||||
<div class="middleNav">
|
||||
<ul>
|
||||
<li class="iForum"><a href="http://www.boxbilling.com/forum" target="_blank" title="Invoicing, billing and client management software forum"><span>Forums</span></a></li>
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Box\Tests\Mod\Serviceboxbillinglicense;
|
||||
|
||||
use Box\Mod\Serviceboxbillinglicense\Service;
|
||||
|
||||
class ServiceTest extends \BBTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Box\Mod\Serviceboxbillinglicense\Service
|
||||
*/
|
||||
protected $service = null;
|
||||
|
||||
public function setup(): void
|
||||
{
|
||||
$this->service= new \Box\Mod\Serviceboxbillinglicense\Service();
|
||||
}
|
||||
|
||||
public function testDi()
|
||||
{
|
||||
$di = new \Box_Di();
|
||||
$this->service->setDi($di);
|
||||
$getDi = $this->service->getDi();
|
||||
$this->assertEquals($di, $getDi);
|
||||
}
|
||||
|
||||
public function testinstall()
|
||||
{
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('exec');
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$this->service->setDi($di);
|
||||
$this->service->install();
|
||||
}
|
||||
|
||||
public function testuninstall()
|
||||
{
|
||||
$uninstallSql = "DROP TABLE IF EXISTS `service_boxbillinglicense`";
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('exec')
|
||||
->with($uninstallSql);
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$this->service->setDi($di);
|
||||
$this->service->uninstall();
|
||||
}
|
||||
|
||||
public function testsetModuleConfig()
|
||||
{
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('exec');
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$serviceMock = $this->getMockBuilder('\Box\Mod\Serviceboxbillinglicense\Service')
|
||||
->setMethods(array('getModuleConfig'))
|
||||
->getMock();
|
||||
$serviceMock->expects($this->atLeastOnce())
|
||||
->method('getModuleConfig');
|
||||
|
||||
$serviceMock->setDi($di);
|
||||
$serviceMock->setModuleConfig(array());
|
||||
}
|
||||
|
||||
public function testgetModuleConfig()
|
||||
{
|
||||
$extensionMetaModel = new \Model_ExtensionMeta();
|
||||
$extensionMetaModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
$extensionMetaModel->meta_value = '{}';
|
||||
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('findOne')
|
||||
->with('extension_meta')
|
||||
->willReturn($extensionMetaModel);
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$this->service->setDi($di);
|
||||
$result = $this->service->getModuleConfig();
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('api_key', $result);
|
||||
}
|
||||
|
||||
public function testgetModuleConfig_CreateDatabaseRecord()
|
||||
{
|
||||
$extensionMetaModel = new \Model_ExtensionMeta();
|
||||
$extensionMetaModel->loadBean(new \RedBeanPHP\OODBBean());
|
||||
|
||||
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('findOne')
|
||||
->with('extension_meta');
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('dispense')
|
||||
->with('extension_meta')
|
||||
->willReturn($extensionMetaModel);
|
||||
$dbMock->expects($this->atLeastOnce())
|
||||
->method('store')
|
||||
->with($extensionMetaModel);
|
||||
|
||||
$di = new \Box_Di();
|
||||
$di['db'] = $dbMock;
|
||||
|
||||
$this->service->setDi($di);
|
||||
$result = $this->service->getModuleConfig();
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('api_key', $result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user