Initial Commit of AgileBill Open Source
This commit is contained in:
12
modules/voip_blacklist/auth.inc.php
Normal file
12
modules/voip_blacklist/auth.inc.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$auth_methods = Array
|
||||
(
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_search'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_search_show'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_delete'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_view'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_add'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'user_update'),
|
||||
Array ('module' => 'voip_blacklist', 'method' => 'ajax_add')
|
||||
);
|
||||
?>
|
215
modules/voip_blacklist/voip_blacklist.inc.php
Normal file
215
modules/voip_blacklist/voip_blacklist.inc.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?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> and Thralling Penguin, LLC <http://www.thrallingpenguin.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
*/
|
||||
|
||||
class voip_blacklist
|
||||
{
|
||||
|
||||
# Open the constructor for this mod
|
||||
function voip_blacklist()
|
||||
{
|
||||
# name of this module:
|
||||
$this->module = "voip_blacklist";
|
||||
|
||||
if(!defined('AJAX')) {
|
||||
# location of the construct XML file:
|
||||
$this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml";
|
||||
|
||||
# open the construct file for parsing
|
||||
$C_xml = new CORE_xml;
|
||||
$construct = $C_xml->xml_to_array($this->xml_construct);
|
||||
|
||||
$this->method = $construct["construct"]["method"];
|
||||
$this->trigger = $construct["construct"]["trigger"];
|
||||
$this->field = $construct["construct"]["field"];
|
||||
$this->table = $construct["construct"]["table"];
|
||||
$this->module = $construct["construct"]["module"];
|
||||
$this->cache = $construct["construct"]["cache"];
|
||||
$this->order_by = $construct["construct"]["order_by"];
|
||||
$this->limit = $construct["construct"]["limit"];
|
||||
}
|
||||
}
|
||||
|
||||
function user_search($VAR) {
|
||||
if(SESS_LOGGED) {
|
||||
$VAR['voip_blacklist_account_id'] = SESS_ACCOUNT;
|
||||
$type = "search";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search($VAR, $this, $type);
|
||||
} else {
|
||||
define("FORCE_REDIRECT", "?_page=account:account");
|
||||
}
|
||||
}
|
||||
|
||||
function user_search_show($VAR) {
|
||||
$this->search_show($VAR,$this);
|
||||
}
|
||||
|
||||
function user_view($VAR) {
|
||||
if(SESS_LOGGED) {
|
||||
$this->did = @$VAR['id'];
|
||||
$db = &DB();
|
||||
$rs = & $db->Execute(sqlSelect($db,"voip_blacklist","account_id","id = ::$this->did::"));
|
||||
if($rs->fields['account_id'] == SESS_ACCOUNT) {
|
||||
$this->view($VAR,$this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
echo "Not logged in or authenticated!";
|
||||
}
|
||||
|
||||
function user_delete($VAR) {
|
||||
if(SESS_LOGGED) {
|
||||
$this->did = @$VAR['delete_id'];
|
||||
$db = &DB();
|
||||
$rs = & $db->Execute(sqlSelect($db,"voip_blacklist","account_id","id = ::$this->did::"));
|
||||
#echo $sql;exit;
|
||||
if($rs->fields['account_id'] == SESS_ACCOUNT) {
|
||||
$this->delete($VAR,$this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
echo "Not logged in or authenticated!";
|
||||
}
|
||||
|
||||
function user_update($VAR) {
|
||||
if(SESS_LOGGED) {
|
||||
$this->did = @$VAR['id'];
|
||||
$db = &DB();
|
||||
$rs = & $db->Execute(sqlSelect($db,"voip_blacklist","account_id","id = ::$this->did::"));
|
||||
if($rs->fields['account_id'] == SESS_ACCOUNT) {
|
||||
$this->update($VAR,$this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
echo "Not logged in or authenticated!";
|
||||
}
|
||||
|
||||
|
||||
function user_add($VAR) {
|
||||
# verify logged in:
|
||||
if(!SESS_LOGGED) {
|
||||
define("FORCE_REDIRECT", "?_page=account:account");
|
||||
return false;
|
||||
}
|
||||
|
||||
# Verify did_id is owned by user
|
||||
$did=@$VAR['voip_blacklist_voip_did_id'];
|
||||
$db=&DB();
|
||||
$rs = & $db->Execute(sqlSelect($db,"voip_did","account_id","id = ::$did::"));
|
||||
if($rs && $rs->RecordCount() > 0 && $rs->fields['account_id'] == SESS_ACCOUNT)
|
||||
{
|
||||
// insert the record
|
||||
// todo: validate the src no
|
||||
$VAR['voip_blacklist_account_id'] = SESS_ACCOUNT;
|
||||
$this->add($VAR,$this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function ajax_add($VAR)
|
||||
{
|
||||
$db =& DB();
|
||||
$rs = $db->Execute($sql=sqlSelect($db,"voip_cdr","src, dst","id=::".$VAR['voip_cdr_id'].":: and account_id=::".SESS_ACCOUNT."::"));
|
||||
if ($rs && $rs->RecordCount()) {
|
||||
if(strlen($rs->fields['src'])) {
|
||||
$did = $rs->fields['dst'];
|
||||
$rs1 = $db->Execute(sqlSelect($db,"voip_did","id, blacklist","account_id=::".SESS_ACCOUNT.":: and (did=::$did:: or did=::1$did::)"));
|
||||
if ($rs1 && $rs1->RecordCount()) {
|
||||
if ($rs1->fields['blacklist']) {
|
||||
$rs2 = $db->Execute(sqlSelect($db,"voip_blacklist","id","account_id=::".SESS_ACCOUNT.":: and src=::".$rs->fields['src']."::"));
|
||||
if ($rs2 && $rs2->RecordCount()) {
|
||||
echo "alert('Sorry, this number is already in your blacklist.');\n";
|
||||
} else {
|
||||
$f['account_id'] = SESS_ACCOUNT;
|
||||
$f['voip_did_id'] = $rs1->fields['id'];
|
||||
$f['src'] = $rs->fields['src'];
|
||||
$f['dst'] = 'Playback tt-monkeys';
|
||||
$db->Execute(sqlInsert($db,"voip_blacklist",$f));
|
||||
echo "alert('Added entry to your blacklist.');\n";
|
||||
}
|
||||
} else {
|
||||
echo "alert('Your account does not have the blacklist feature.');\n";
|
||||
}
|
||||
} else {
|
||||
echo "alert('Sorry, can not find the DID associated with this CDR.');\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "alert('Sorry, the CDR does not belong to your account.');\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function add($VAR)
|
||||
{
|
||||
$type = "add";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->add($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function view($VAR)
|
||||
{
|
||||
$type = "view";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->view($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function update($VAR)
|
||||
{
|
||||
$type = "update";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->update($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function delete($VAR)
|
||||
{
|
||||
$db = new CORE_database;
|
||||
$db->mass_delete($VAR, $this, "");
|
||||
}
|
||||
|
||||
function search_form($VAR)
|
||||
{
|
||||
$type = "search";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search_form($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function search($VAR)
|
||||
{
|
||||
$type = "search";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function search_show($VAR)
|
||||
{
|
||||
$type = "search";
|
||||
$this->method["$type"] = split(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search_show($VAR, $this, $type);
|
||||
}
|
||||
}
|
||||
?>
|
43
modules/voip_blacklist/voip_blacklist_construct.xml
Normal file
43
modules/voip_blacklist/voip_blacklist_construct.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<module>voip_blacklist</module>
|
||||
<table>voip_blacklist</table>
|
||||
<dependancy>voip</dependancy>
|
||||
<cache>0</cache>
|
||||
<order_by>id</order_by>
|
||||
<limit>35</limit>
|
||||
<index>
|
||||
<didsrc>voip_did_id,src</didsrc>
|
||||
</index>
|
||||
<field>
|
||||
<id>
|
||||
<type>I4</type>
|
||||
<unique>1</unique>
|
||||
</id>
|
||||
<site_id>
|
||||
<type>I4</type>
|
||||
</site_id>
|
||||
<voip_did_id>
|
||||
<type>I8</type>
|
||||
<asso_table>voip_did</asso_table>
|
||||
<asso_field>did</asso_field>
|
||||
</voip_did_id>
|
||||
<account_id>
|
||||
<type>I4</type>
|
||||
</account_id>
|
||||
<src>
|
||||
<type>C(32)</type>
|
||||
</src>
|
||||
<dst>
|
||||
<type>C(64)</type>
|
||||
</dst>
|
||||
</field>
|
||||
<method>
|
||||
<add>id,site_id,voip_did_id,account_id,src,dst</add>
|
||||
<update>id,site_id,voip_did_id,account_id,src,dst</update>
|
||||
<delete>id,site_id,voip_did_id,account_id,src,dst</delete>
|
||||
<view>id,site_id,voip_did_id,account_id,src,dst</view>
|
||||
<search>id,site_id,voip_did_id,account_id,src,dst</search>
|
||||
</method>
|
||||
<trigger>0</trigger>
|
||||
</construct>
|
42
modules/voip_blacklist/voip_blacklist_install.xml
Normal file
42
modules/voip_blacklist/voip_blacklist_install.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<install>
|
||||
<module_properties>
|
||||
<name>voip_blacklist</name>
|
||||
<parent>voip</parent>
|
||||
<notes>This module stores the VoIP blacklist records</notes>
|
||||
<menu_display>1</menu_display>
|
||||
<dependancy>voip</dependancy>
|
||||
<sub_modules></sub_modules>
|
||||
</module_properties>
|
||||
<sql_inserts>
|
||||
<module_method>
|
||||
<add>
|
||||
<name>add</name>
|
||||
<page>%%:add</page>
|
||||
<menu_display>1</menu_display>
|
||||
</add>
|
||||
<update>
|
||||
<name>update</name>
|
||||
</update>
|
||||
<delete>
|
||||
<name>delete</name>
|
||||
</delete>
|
||||
<view>
|
||||
<name>view</name>
|
||||
<page>core:search&module=%%&_escape=1</page>
|
||||
<menu_display>1</menu_display>
|
||||
</view>
|
||||
<search>
|
||||
<name>search</name>
|
||||
<page>%%:search_form</page>
|
||||
<menu_display>1</menu_display>
|
||||
</search>
|
||||
<search_form>
|
||||
<name>search_form</name>
|
||||
</search_form>
|
||||
<search_show>
|
||||
<name>search_show</name>
|
||||
</search_show>
|
||||
</module_method>
|
||||
</sql_inserts>
|
||||
</install>
|
Reference in New Issue
Block a user