Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

12
modules/faq/auth.inc.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
### public methods for this module:
$auth_methods = Array
(
Array ('module' => 'faq', 'method' => 'faq_categories'),
Array ('module' => 'faq', 'method' => 'faq_show'),
Array ('module' => 'faq', 'method' => 'autofill'),
Array ('module' => 'faq', 'method' => 'faq_search')
);
?>

318
modules/faq/faq.inc.php Normal file
View File

@@ -0,0 +1,318 @@
<?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
*/
class faq
{
# Open the constructor for this mod
function faq()
{
# name of this module:
$this->module = "faq";
$this->version = "1.0.0a";
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"];
}
}
### autofill for admin 'canned messages' in ticket reply
function autofill($VAR)
{
$db = &DB();
if(!empty($VAR['faq_autofill']) && strlen($VAR['faq_autofill']) > 3) {
$dbm = new CORE_database();
$result = $db->Execute(
$sql = $dbm->sql_select(
Array( 'faq_translate', 'faq' ),
Array( 'A.*', 'B.name' ),
" A.faq_id = B.id AND MATCH(A.question, A.answer) AGAINST(".$db->qstr($VAR['faq_autofill'].'*')." IN BOOLEAN MODE)",
"",
&$db
)
);
}
echo '<ul>';
# Create the alert for no records found
if (@$result != false && $result->RecordCount() > 0) {
$i=0;
while(!$result->EOF && $i < 10) {
echo '<li><div class="name"><b>' . stripcslashes( substr( ereg_replace("\r\n", " ", $result->fields['question']), 0, 65 ) ). '</b></div>'.
'<div class="email"><span class="informal">' . stripcslashes( substr( ereg_replace("\r\n", " ", $result->fields['answer']),0, 75 ) ) . '</span></div>'.
'<div class="index" style="display:none">'. stripcslashes( $result->fields['answer'].'</div></li>'). "\r\n";
$result->MoveNext();
$i++;
}
} else {
include_once(PATH_CORE.'translate.inc.php');
include_once(PATH_CORE.'xml.inc.php');
$C_translate = new CORE_translate;
echo '<li><div class="name"><b>'. $C_translate->translate('admin_no_match','faq') .'</b></div>' .
'<div class="email"><span class="informal">'. $C_translate->translate('admin_no_match_help','faq') .'</span></div>'.
'<div class="index" style="display:none">null</div></li>' . "\r\n";
}
echo "</ul>";
}
### Get the faq details:
function faq_show($VAR)
{
if (!empty($VAR['id'])) {
$db = &DB();
$dbm = new CORE_database();
$rs = $db->Execute(
$sql = $dbm->sql_select(
Array( 'faq_translate', 'faq', 'faq_category' ),
Array( 'A.*', 'B.name', 'C.group_avail' ),
" B.id = ::".$VAR['id'].":: AND B.id = A.faq_id AND A.language_id = '".SESS_LANGUAGE."' AND B.status = 1 AND C.status = 1 ",
"",
&$db
)
);
}
global $C_auth;
if( !$rs || $rs->RecordCount() == 0 || !$C_auth->auth_group_by_id( unserialize( $rs->fields['group_avail'] ))) {
include_once(PATH_CORE.'translate.inc.php');
include_once(PATH_CORE.'xml.inc.php');
$C_translate = new CORE_translate;
echo $C_translate->translate('no_faqs','faq');
} else {
echo '<p><u>' . ereg_replace("\r\n", "<BR>", stripcslashes( htmlentities( $rs->fields['question']) ) ). '</u></p>' .
'<p>' . ereg_replace("\r\n", "<BR>", $this->linkalize(stripcslashes( htmlentities( $rs->fields['answer']) ) ) ). '</p>';
}
}
### Get the faq translation:
function faq_search($VAR)
{
$db = &DB();
if(!empty($VAR['search']) && strlen($VAR['search']) > 3) {
$dbm = new CORE_database();
$result = $db->Execute(
$sql = $dbm->sql_select(
Array( 'faq_translate', 'faq', 'faq_category' ),
Array( 'A.*', 'B.name', 'C.group_avail' ),
" A.faq_id = B.id AND B.faq_category_id = C.id AND MATCH(A.question, A.answer) AGAINST(".$db->qstr($VAR['search'].'*')." IN BOOLEAN MODE) AND B.status = 1 AND C.status=1",
"",
&$db
)
);
} elseif (!empty($VAR['category_id'])) {
$dbm = new CORE_database();
$result = $db->Execute(
$sql = $dbm->sql_select(
Array( 'faq_translate', 'faq', 'faq_category' ),
Array( 'A.*', 'B.name', 'C.group_avail' ),
" B.faq_category_id = ::".$VAR['category_id'].":: AND B.id = A.faq_id AND B.faq_category_id = C.id AND A.language_id = '".SESS_LANGUAGE."' AND B.status = 1 AND C.status=1",
"",
&$db
)
);
}
echo '<ul>';
if (@$result != false && $result->RecordCount() > 0) {
$i=0;
while(!$result->EOF) {
global $C_auth;
if( $C_auth->auth_group_by_id( unserialize($result->fields['group_avail'] ))) {
echo '<li><div><a href="?_page=faq:faq&id='.$result->fields['faq_id'].'">' . stripcslashes( htmlentities( ereg_replace("\r\n", " ", $result->fields['question']) ) ). '</a></div> </li>'. "\r\n";
$i++;
}
$result->MoveNext();
}
} else {
include_once(PATH_CORE.'translate.inc.php');
include_once(PATH_CORE.'xml.inc.php');
$C_translate = new CORE_translate;
echo '<li><div class="name"><b>'. $C_translate->translate('admin_no_match','faq') .'</b></div> </div></li>' . "\r\n";
}
echo "</ul>";
}
### Get the authorized/active categories
function faq_categories($VAR)
{
$db = &DB();
$dbm = new CORE_database();
$rs = $db->Execute( $sql=
$sql = $dbm->sql_select(
'faq_category',
'*' ,
" status=1 ",
"sort_order,name,date_orig",
&$db
)
);
if(!$rs || $rs->RecordCount() == 0) {
//
} else {
while(!$rs->EOF) {
// validate groups
global $C_auth;
if( $C_auth->auth_group_by_id( unserialize($rs->fields['group_avail']) )) {
$smart[] = $rs->fields;
}
$rs->MoveNext();
}
}
global $smarty;
$smarty->assign('faq_category_list', @$smart);
}
##############################
## ADD ##
##############################
function add($VAR)
{
$type = "add";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$id = $db->add($VAR, $this, $type);
if($id && !empty($VAR['faq_question']))
{
# Insert translation
$db = &DB();
$idx = $db->GenID(AGILE_DB_PREFIX. 'faq_translate_id');
$sql = "INSERT INTO ".AGILE_DB_PREFIX."faq_translate
SET
site_id = ".DEFAULT_SITE.",
id = $idx,
faq_id = $id,
date_orig = ".time().",
date_last = ".time().",
language_id = '".DEFAULT_LANGUAGE."',
answer = ".$db->qstr( @$VAR['faq_answer'] ).",
question = ".$db->qstr( @$VAR['faq_question']);
$db->Execute($sql);
}
}
##############################
## VIEW ##
##############################
function view($VAR)
{
$type = "view";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->view($VAR, $this, $type);
}
##############################
## UPDATE ##
##############################
function update($VAR)
{
$type = "update";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->update($VAR, $this, $type);
}
##############################
## DELETE ##
##############################
function delete($VAR)
{
$this->associated_DELETE[] =
Array(
'table' => 'faq_translate',
'field' => 'faq_id'
);
$db = new CORE_database;
$db->mass_delete($VAR, $this, "");
}
##############################
## SEARCH FORM ##
##############################
function search_form($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_form($VAR, $this, $type);
}
##############################
## SEARCH ##
##############################
function search($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->search($VAR, $this, $type);
}
##############################
## SEARCH SHOW ##
##############################
function search_show($VAR)
{
$type = "search";
$this->method["$type"] = split(",", $this->method["$type"]);
$db = new CORE_database;
$db->search_show($VAR, $this, $type);
}
function linkalize($text)
{
$text = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $text);
$text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<A TARGET=\"_blank\" HREF=\"$1\">$1</A>", $text); //make all URLs links
$text = preg_replace("/[\w-\.]+@(\w+[\w-]+\.){0,3}\w+[\w-]+\.[a-zA-Z]{2,4}\b/i","<ahref=\"mailto:$0\">$0</a>",$text);
return $text;
}
}
?>

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<!-- define the module name -->
<module>faq</module>
<!-- define the module table name -->
<table>faq</table>
<!-- define the module dependancy(s) -->
<dependancy></dependancy>
<!-- define the DB cache in seconds -->
<cache>0</cache>
<!-- define the default order_by field for SQL queries -->
<order_by>sort_order,date_orig,name</order_by>
<!-- define the methods -->
<limit>35</limit>
<!-- define the fields -->
<field>
<id>
<type>I4</type>
<unique>1</unique>
</id>
<site_id>
<type>I4</type>
</site_id>
<faq_category_id>
<type>I4</type>
<asso_table>faq_category</asso_table>
<asso_field>name</asso_field>
</faq_category_id>
<date_orig>
<type>I8</type>
<convert>date-now</convert>
</date_orig>
<date_last>
<type>I8</type>
<convert>date-now</convert>
</date_last>
<date_start>
<type>I8</type>
<convert>date</convert>
</date_start>
<date_expire>
<type>I8</type>
<convert>date</convert>
</date_expire>
<sort_order>
<type>I4</type>
</sort_order>
<status>
<type>L</type>
</status>
<name>
<type>C(255)</type>
<min_len>1</min_len>
<max_len>255</max_len>
<validate>any</validate>
<unique>1</unique>
</name>
</field>
<!-- define all the methods for this class, and the fields they have access to, if applicable. -->
<method>
<add>id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name</add>
<update>id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name</update>
<delete>id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name</delete>
<view>id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name</view>
<search>id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name</search>
</method>
<!-- define the method triggers -->
<trigger>0</trigger>
</construct>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<!-- Define the main module properties -->
<module_properties>
<name>faq</name>
<parent>faq</parent>
<notes>This module controls the FAQs</notes>
<menu_display>1</menu_display>
<sub_modules>faq_category,faq_translate</sub_modules>
</module_properties>
<!-- Define any methods for this module -->
<sql_inserts>
<module_method>
<search>
<name>search</name>
<notes>Allow users to view the search form</notes>
<page>%%:search_form</page>
<menu_display>1</menu_display>
</search>
<view>
<name>view</name>
<notes>Allow users to view records</notes>
<page><![CDATA[core:search&module=%%&_escape=1&_next_page_one=view]]></page>
<menu_display>1</menu_display>
</view>
<add>
<name>add</name>
<notes>Allow users to add records</notes>
<menu_display>1</menu_display>
</add>
<delete>
<name>delete</name>
</delete>
<update>
<name>update</name>
</update>
<search_form>
<name>search_form</name>
</search_form>
<search_show>
<name>search_show</name>
<notes>Allow users to view the search results</notes>
</search_show>
</module_method>
</sql_inserts>
</install>