Initial Commit of AgileBill Open Source
This commit is contained in:
1335
modules/account/account.inc.php
Normal file
1335
modules/account/account.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
193
modules/account/account_construct.xml
Normal file
193
modules/account/account_construct.xml
Normal file
@@ -0,0 +1,193 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<!-- define the module name -->
|
||||
<module>account</module>
|
||||
<!-- define the module table name -->
|
||||
<table>account</table>
|
||||
<!-- define the module dependancy(s) -->
|
||||
<dependancy/>
|
||||
<!-- define the DB cache in seconds -->
|
||||
<cache>0</cache>
|
||||
<!-- define the default order_by field for SQL queries -->
|
||||
<order_by>last_name</order_by>
|
||||
<!-- define the methods -->
|
||||
<limit>30</limit>
|
||||
<!-- define the fields -->
|
||||
<field>
|
||||
<id>
|
||||
<type>I8</type>
|
||||
<unique>1</unique>
|
||||
</id>
|
||||
<site_id>
|
||||
<type>I4</type>
|
||||
</site_id>
|
||||
<date_orig>
|
||||
<type>I8</type>
|
||||
</date_orig>
|
||||
<date_last>
|
||||
<type>I8</type>
|
||||
<convert>date-now</convert>
|
||||
</date_last>
|
||||
<date_expire>
|
||||
<type>I8</type>
|
||||
<convert>date</convert>
|
||||
</date_expire>
|
||||
<parent_id>
|
||||
<type>I4</type>
|
||||
</parent_id>
|
||||
<language_id>
|
||||
<type>C(32)</type>
|
||||
</language_id>
|
||||
<country_id>
|
||||
<type>I4</type>
|
||||
</country_id>
|
||||
<affiliate_id>
|
||||
<type>C(32)</type>
|
||||
</affiliate_id>
|
||||
<campaign_id>
|
||||
<type>I4</type>
|
||||
</campaign_id>
|
||||
<reseller_id>
|
||||
<type>I4</type>
|
||||
</reseller_id>
|
||||
<currency_id>
|
||||
<type>I4</type>
|
||||
</currency_id>
|
||||
<theme_id>
|
||||
<type>C(32)</type>
|
||||
</theme_id>
|
||||
<username>
|
||||
<type>C(128)</type>
|
||||
<min_len>4</min_len>
|
||||
<max_len>12</max_len>
|
||||
<validate>any</validate>
|
||||
<unique>1</unique>
|
||||
<index>1</index>
|
||||
</username>
|
||||
<password>
|
||||
<type>C(128)</type>
|
||||
<min_len>6</min_len>
|
||||
<max_len>12</max_len>
|
||||
<validate>password</validate>
|
||||
<convert>md5</convert>
|
||||
</password>
|
||||
<inherit_group>
|
||||
<type>L</type>
|
||||
</inherit_group>
|
||||
<misc>
|
||||
<type>C2(128)</type>
|
||||
</misc>
|
||||
<status>
|
||||
<type>I4</type>
|
||||
</status>
|
||||
<first_name>
|
||||
<type>C(128)</type>
|
||||
<min_len>1</min_len>
|
||||
<max_len>128</max_len>
|
||||
<validate>any</validate>
|
||||
<index>1</index>
|
||||
</first_name>
|
||||
<middle_name>
|
||||
<type>C(128)</type>
|
||||
</middle_name>
|
||||
<last_name>
|
||||
<type>C(128)</type>
|
||||
<min_len>1</min_len>
|
||||
<max_len>128</max_len>
|
||||
<validate>any</validate>
|
||||
<index>1</index>
|
||||
</last_name>
|
||||
<title>
|
||||
<type>C(128)</type>
|
||||
</title>
|
||||
<email>
|
||||
<type>C(255)</type>
|
||||
<min_len>4</min_len>
|
||||
<max_len>128</max_len>
|
||||
<validate>email</validate>
|
||||
<unique>1</unique>
|
||||
<index>1</index>
|
||||
</email>
|
||||
<company>
|
||||
<type>C(255)</type>
|
||||
</company>
|
||||
<address1>
|
||||
<type>C(128)</type>
|
||||
<min_len>3</min_len>
|
||||
<max_len>128</max_len>
|
||||
<validate>any</validate>
|
||||
</address1>
|
||||
<address2>
|
||||
<type>C(128)</type>
|
||||
<max_len>128</max_len>
|
||||
</address2>
|
||||
<city>
|
||||
<type>C(32)</type>
|
||||
<min_len>2</min_len>
|
||||
<max_len>32</max_len>
|
||||
<validate>any</validate>
|
||||
</city>
|
||||
<state>
|
||||
<type>C(32)</type>
|
||||
<min_len>2</min_len>
|
||||
<max_len>32</max_len>
|
||||
<validate>any</validate>
|
||||
</state>
|
||||
<zip>
|
||||
<type>C(16)</type>
|
||||
<min_len>4</min_len>
|
||||
<max_len>16</max_len>
|
||||
<validate>any</validate>
|
||||
</zip>
|
||||
<email_type>
|
||||
<type>L</type>
|
||||
</email_type>
|
||||
<invoice_delivery>
|
||||
<type>I4</type>
|
||||
</invoice_delivery>
|
||||
<invoice_show_itemized>
|
||||
<type>L</type>
|
||||
<default>1</default>
|
||||
</invoice_show_itemized>
|
||||
<invoice_grace>
|
||||
<type>I4</type>
|
||||
</invoice_grace>
|
||||
<invoice_advance_gen>
|
||||
<type>I4</type>
|
||||
</invoice_advance_gen>
|
||||
<tax_id>
|
||||
<type>C(64)</type>
|
||||
</tax_id>
|
||||
<max_child>
|
||||
<type>I4</type>
|
||||
</max_child>
|
||||
</field>
|
||||
<!-- define indexes -->
|
||||
<index>
|
||||
<login>username,password</login>
|
||||
<search>first_name,middle_name,last_name</search>
|
||||
<company>company</company>
|
||||
<email>email</email>
|
||||
<affiliate>affiliate_id</affiliate>
|
||||
<campaign_id>campaign_id</campaign_id>
|
||||
<country>country_id</country>
|
||||
<region>city,state</region>
|
||||
<city>city</city>
|
||||
<state>state</state>
|
||||
<postal>zip</postal>
|
||||
<idmain>id,site_id</idmain>
|
||||
<fulltext_user>first_name,last_name,email,company</fulltext_user>
|
||||
</index>
|
||||
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
|
||||
<method>
|
||||
<add>id,date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id</add>
|
||||
<update>id,date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id</update>
|
||||
<view>id,parent_id,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id,max_child</view>
|
||||
</method>
|
||||
<!-- define the method triggers -->
|
||||
<trigger>
|
||||
<add>
|
||||
<success>account_admin:add_account_groups</success>
|
||||
</add>
|
||||
</trigger>
|
||||
</construct>
|
14
modules/account/account_install.xml
Normal file
14
modules/account/account_install.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<install>
|
||||
<module_properties>
|
||||
<name>account</name>
|
||||
<parent>account</parent>
|
||||
<notes><![CDATA[This is the account module for all accounts...]]></notes>
|
||||
</module_properties>
|
||||
<sql_inserts>
|
||||
<module_method>
|
||||
<install>
|
||||
<name>install</name>
|
||||
</install>
|
||||
</module_method>
|
||||
</sql_inserts>
|
||||
</install>
|
33
modules/account/account_install_data.xml
Normal file
33
modules/account/account_install_data.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<install>
|
||||
<account>
|
||||
<id>1</id>
|
||||
<site_id>1</site_id>
|
||||
<date_orig>1075175744</date_orig>
|
||||
<date_last>1112335769</date_last>
|
||||
<date_expire>0</date_expire>
|
||||
<parent_id>0</parent_id>
|
||||
<language_id>english</language_id>
|
||||
<country_id>840</country_id>
|
||||
<reseller_id>0</reseller_id>
|
||||
<currency_id>1</currency_id>
|
||||
<theme_id>default</theme_id>
|
||||
<username>admin</username>
|
||||
<password>21232f297a57a5a743894a0e4a801fc3</password>
|
||||
<misc>Notes</misc>
|
||||
<status>1</status>
|
||||
<first_name>Admin</first_name>
|
||||
<last_name>Admin</last_name>
|
||||
<title>Mrs</title>
|
||||
<email>email@company.com</email>
|
||||
<address1><![CDATA[100 Street's]]></address1>
|
||||
<city>City</city>
|
||||
<state>State</state>
|
||||
<zip>12345</zip>
|
||||
<email_type>0</email_type>
|
||||
<campaign_id>0</campaign_id>
|
||||
</account>
|
||||
<account_id>
|
||||
<id>33</id>
|
||||
</account_id>
|
||||
</install>
|
155
modules/account/account_xmlrpc.php
Normal file
155
modules/account/account_xmlrpc.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
ob_start();
|
||||
|
||||
include_once('../../config.inc.php');
|
||||
require_once(PATH_ADODB . 'adodb.inc.php');
|
||||
require_once(PATH_CORE . 'database.inc.php');
|
||||
require_once(PATH_CORE . 'setup.inc.php');
|
||||
require_once(PATH_CORE . 'vars.inc.php');
|
||||
require_once(PATH_CORE . 'translate.inc.php');
|
||||
require_once(PATH_CORE . 'xml.inc.php');
|
||||
include_once(PATH_INCLUDES . "xml-rpc/xml-rpc.php");
|
||||
$C_debug = new CORE_debugger;
|
||||
$C_setup = new CORE_setup;
|
||||
$C_translate= new CORE_translate;
|
||||
|
||||
class AccountServer extends IXR_Server {
|
||||
|
||||
var $account_id;
|
||||
var $account_parent_id=false;
|
||||
var $username;
|
||||
var $password;
|
||||
var $login_error;
|
||||
|
||||
function AccountServer() {
|
||||
$this->IXR_Server(array(
|
||||
'account.details' => 'this:getAccountDetails'
|
||||
));
|
||||
}
|
||||
|
||||
function getAccountDetails($args) {
|
||||
$this->username = $args[0];
|
||||
$this->password = $args[1];
|
||||
if(!$this->getAccountAuth()) return array('auth'=> false, 'reason'=>$this->login_error);
|
||||
$return = array(
|
||||
'auth' => true,
|
||||
'acct' => $this->account_id,
|
||||
'info' => $this->getAccountInfo(),
|
||||
'skus' => $this->getAccountSKUs(),
|
||||
'grps' => $this->getAccountGroups()
|
||||
);
|
||||
return $return;
|
||||
}
|
||||
|
||||
function getAccountAuth() {
|
||||
// select from account where username = $this_username and password = $this->password
|
||||
include_once(PATH_CORE.'login.inc.php');
|
||||
$login = new CORE_login_handler();
|
||||
if(!$login->login(array("_username"=> $this->username, "_password"=> $this->password), true)) {
|
||||
$this->login_error = $login->error;
|
||||
return false;
|
||||
} else {
|
||||
$db=&DB();
|
||||
$rs = $db->Execute(sqlSelect($db,"account","id","username = ::$this->username::"));
|
||||
$this->account_id = $rs->fields['id'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function getAccountInfo() {
|
||||
$db=&DB();
|
||||
$rs = $db->Execute(sqlSelect($db,"account","*","id = ::$this->account_id::"));
|
||||
if(!empty($rs->fields['parent_id'])) $this->account_parent_id = $rs->fields['parent_id'];
|
||||
$ret = Array(
|
||||
'company' => $rs->fields['company'],
|
||||
'first_name' => $rs->fields['first_name'],
|
||||
'last_name' => $rs->fields['last_name'],
|
||||
'address1' => $rs->fields['address1'],
|
||||
'address2' => $rs->fields['address2'],
|
||||
'city' => $rs->fields['city'],
|
||||
'state' => $rs->fields['state'],
|
||||
'zip' => $rs->fields['zip'],
|
||||
'email' => $rs->fields['email'],
|
||||
'acct_parent_id' => $rs->fields['parent_id']
|
||||
);
|
||||
$rs = $db->Execute(sqlSelect($db,"module","id","name=::account::"));
|
||||
$account_module=$rs->fields['id'];
|
||||
/* get custom fields*/
|
||||
$sql = "SELECT DISTINCT A.value, B.name FROM ".AGILE_DB_PREFIX."static_var as B
|
||||
LEFT JOIN ".AGILE_DB_PREFIX."static_var_record as A on (B.id=A.static_var_id AND A.record_id = ".$db->qstr($this->account_id).")
|
||||
WHERE A.module_id=$account_module ";
|
||||
$rs=$db->Execute($sql);
|
||||
if($rs &&$rs->RecordCount()) {
|
||||
while(!$rs->EOF) {
|
||||
$fld = substr(strtolower(ereg_replace(" ",'_', $rs->fields['name'])),0,32);
|
||||
@$ret["$fld"]=$rs->fields['value'];
|
||||
$rs->MoveNext();
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getAccountSKUs() {
|
||||
// select from invoice_item where id = $this->account_id
|
||||
$db=&DB();
|
||||
$p=AGILE_DB_PREFIX;
|
||||
$s=DEFAULT_SITE;
|
||||
$arr=false;
|
||||
$q = "SELECT DISTINCT A.sku FROM {$p}invoice_item A
|
||||
JOIN {$p}invoice B on ((B.account_id={$this->account_id} ";
|
||||
if($this->account_parent_id)
|
||||
$q.= " OR B.account_id = {$this->account_parent_id} ";
|
||||
$q.= ") AND B.id=A.invoice_id AND B.site_id={$s} AND billing_status=1 AND process_status=1)
|
||||
WHERE A.site_id = {$s}";
|
||||
$rs = $db->Execute($q);
|
||||
if($rs && $rs->RecordCount()) {
|
||||
while(!$rs->EOF) {
|
||||
$arr[] = $rs->fields['sku'];
|
||||
$rs->MoveNext();
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getAccountGroups() {
|
||||
// select from account_group where account_id = $this->account_id
|
||||
$db=&DB();
|
||||
$p=AGILE_DB_PREFIX;
|
||||
$s=DEFAULT_SITE;
|
||||
$arr=false;
|
||||
$q = "SELECT DISTINCT group_id FROM {$p}account_group WHERE account_id={$this->account_id} AND site_id={$s} AND (active=1 OR active!='' or active!=0 or active is not null)";
|
||||
$rs = $db->Execute($q);
|
||||
if($rs && $rs->RecordCount()) {
|
||||
while(!$rs->EOF) {
|
||||
$arr[] = $rs->fields['group_id'];
|
||||
$rs->MoveNext();
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
$server = new AccountServer();
|
||||
|
||||
ob_end_flush();
|
||||
|
||||
?>
|
38
modules/account/auth.inc.php
Normal file
38
modules/account/auth.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Agileco community forums at http://forum.agileco.com/
|
||||
*
|
||||
* @link http://www.agileco.com/
|
||||
* @copyright 2004-2008 Agileco, LLC.
|
||||
* @license http://www.agileco.com/agilebill/license1-4.txt
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
$auth_methods = Array
|
||||
(
|
||||
Array ('module' => 'account', 'method' => 'add'),
|
||||
Array ('module' => 'account', 'method' => 'user_add'),
|
||||
Array ('module' => 'account', 'method' => 'user_view'),
|
||||
Array ('module' => 'account', 'method' => 'add'),
|
||||
Array ('module' => 'account', 'method' => 'view'),
|
||||
Array ('module' => 'account', 'method' => 'update'),
|
||||
Array ('module' => 'account', 'method' => 'password'),
|
||||
Array ('module' => 'account', 'method' => 'password_reset'),
|
||||
Array ('module' => 'account', 'method' => 'static_var'),
|
||||
Array ('module' => 'account', 'method' => 'verify'),
|
||||
Array ('module' => 'account', 'method' => 'verify_resend'),
|
||||
Array ('module' => 'account', 'method' => 'sub_account_add'),
|
||||
Array ('module' => 'account', 'method' => 'sub_delete')
|
||||
);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user