Changes to AgileBill
This commit is contained in:
@@ -1,118 +1,79 @@
|
||||
<?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/
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @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>
|
||||
* @author Tony Landis <tony@agileco.com>
|
||||
* @package AgileBill
|
||||
* @version 1.4.93
|
||||
* @subpackage Modules:EmailLog
|
||||
*/
|
||||
|
||||
class email_log
|
||||
{
|
||||
|
||||
/**
|
||||
* The main AgileBill Email Log Class
|
||||
*
|
||||
* @package AgileBill
|
||||
* @subpackage Modules:EmailLog
|
||||
*/
|
||||
class email_log extends OSB_module {
|
||||
var $user_view_count = 25; /* show last X email logs for user */
|
||||
|
||||
function user_list($VAR) {
|
||||
if(!SESS_LOGGED) return false;
|
||||
$db=&DB();
|
||||
$email = $db->GetOne("select email from ".AGILE_DB_PREFIX."account where id = ".SESS_ACCOUNT);
|
||||
$rs=$db->Execute(sqlSelect($db,"email_log","id,email,date_orig,subject,urgent,userread",
|
||||
"email=::$email:: and account_id=".SESS_ACCOUNT,'date_orig',$this->user_view_count));
|
||||
if($rs && $rs->RecordCount()) {
|
||||
$smart=array();
|
||||
while(!$rs->EOF) {
|
||||
array_push($smart, $rs->fields);
|
||||
$rs->MoveNext();
|
||||
|
||||
public function user_list($VAR) {
|
||||
if (! SESS_LOGGED)
|
||||
return false;
|
||||
|
||||
$db = &DB();
|
||||
|
||||
$email = $db->GetOne(sqlSelect($db,'account','email',array('id'=>SESS_ACCOUNT)));
|
||||
$rs = $db->Execute(
|
||||
sqlSelect($db,'email_log','id,email,date_orig,subject,urgent,userread',array('email'=>$email,'account_id'=>SESS_ACCOUNT),'date_orig',$this->user_view_count));
|
||||
|
||||
if ($rs && $rs->RecordCount()) {
|
||||
$smart = array();
|
||||
while (! $rs->EOF) {
|
||||
array_push($smart,$rs->fields);
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
global $smarty;
|
||||
$smarty->assign('email_log', $smart);
|
||||
}
|
||||
}
|
||||
|
||||
function user_view($VAR) {
|
||||
/* validate, update to read, and view() */
|
||||
if(!SESS_LOGGED || empty($VAR['id'])) return false;
|
||||
/* select id for this user */
|
||||
$db=&DB();
|
||||
$rs = $db->Execute(sqlSelect($db,"email_log","*","id=::{$VAR['id']}:: and account_id=".SESS_ACCOUNT));
|
||||
if($rs && $rs->RecordCount()) {
|
||||
global $smarty;
|
||||
$smarty->assign('email_log', $rs->fields);
|
||||
if($rs->fields['userread'] != 1) {
|
||||
/* update to read */
|
||||
$fields=Array('userread'=>1);
|
||||
$db->Execute(sqlUpdate($db,"email_log",$fields,"id = {$rs->fields['id']}"));
|
||||
}
|
||||
$smarty->assign('email_log',$smart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function user_view($VAR) {
|
||||
if (! SESS_LOGGED || empty($VAR['id']))
|
||||
return false;
|
||||
|
||||
$db = &DB();
|
||||
|
||||
$rs = $db->Execute(sqlSelect($db,'email_log','*',array('id'=>$VAR['id'],'account_id'=>SESS_ACCOUNT)));
|
||||
if ($rs && $rs->RecordCount()) {
|
||||
global $smarty;
|
||||
|
||||
$smarty->assign('email_log',$rs->fields);
|
||||
# Update to read
|
||||
if ($rs->fields['userread'] != 1)
|
||||
$db->Execute(sqlUpdate($db,'email_log',array('userread'=>1),array('id'=>$rs->fields['id'])));
|
||||
}
|
||||
}
|
||||
|
||||
function add($account_id, $subject, $message, $email, $html=0, $urgent=0) {
|
||||
$db=&DB();
|
||||
$fields=Array('date_orig'=>time(), 'account_id'=>$account_id, 'subject'=>$subject, 'message'=>$message, 'email'=>$email, 'html'=>$html, 'urgent'=>$urgent, 'userread'=>0);
|
||||
$id = & $db->Execute(sqlInsert($db,"email_log",$fields));
|
||||
}
|
||||
|
||||
function view($VAR) {
|
||||
$this->construct();
|
||||
$type = "view";
|
||||
$this->method["$type"] = explode(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->view($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function delete($VAR) {
|
||||
$this->construct();
|
||||
$db = new CORE_database;
|
||||
$db->mass_delete($VAR, $this, "");
|
||||
}
|
||||
|
||||
function search_form($VAR) {
|
||||
$this->construct();
|
||||
$type = "search";
|
||||
$this->method["$type"] = explode(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search_form($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function search($VAR) {
|
||||
$this->construct();
|
||||
$type = "search";
|
||||
$this->method["$type"] = explode(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function search_show($VAR) {
|
||||
$this->construct();
|
||||
$type = "search";
|
||||
$this->method["$type"] = explode(",", $this->method["$type"]);
|
||||
$db = new CORE_database;
|
||||
$db->search_show($VAR, $this, $type);
|
||||
}
|
||||
|
||||
function construct() {
|
||||
$this->module = "email_log";
|
||||
$this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml";
|
||||
$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"];
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@@ -1,55 +1,107 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<construct>
|
||||
<module>email_log</module>
|
||||
<table>email_log</table>
|
||||
<dependancy>setup</dependancy>
|
||||
<cache>0</cache>
|
||||
<order_by>date_orig</order_by>
|
||||
<limit>35</limit>
|
||||
<construct>
|
||||
<!-- Module name -->
|
||||
<module>email_log</module>
|
||||
<!-- Module supporting database table -->
|
||||
<table>email_log</table>
|
||||
<!-- Module dependancy(s) (module wont install if these modules are not yet installed) -->
|
||||
<dependancy>setup</dependancy>
|
||||
<!-- DB cache in seconds -->
|
||||
<cache>0</cache>
|
||||
<!-- Default order_by field for SQL queries -->
|
||||
<order_by>date_orig</order_by>
|
||||
<!-- Default SQL limit for SQL queries -->
|
||||
<limit>25</limit>
|
||||
<!-- Schema version (used to determine if the schema has change during upgrades) -->
|
||||
<version>1</version>
|
||||
|
||||
<!-- Database indexes -->
|
||||
<index>
|
||||
<ids>id,site_id,account_id</ids>
|
||||
<email>email</email>
|
||||
<status>html,urgent,userread</status>
|
||||
</index>
|
||||
<field>
|
||||
<id>
|
||||
<type>I8</type>
|
||||
<unique>1</unique>
|
||||
</id>
|
||||
<site_id>
|
||||
<type>I4</type>
|
||||
</site_id>
|
||||
<date_orig>
|
||||
<type>I8</type>
|
||||
<convert>date-now</convert>
|
||||
</date_orig>
|
||||
<account_id>
|
||||
<type>I4</type>
|
||||
<validate>any</validate>
|
||||
</account_id>
|
||||
<email>
|
||||
<type>C(128)</type>
|
||||
</email>
|
||||
<subject>
|
||||
<type>C(128)</type>
|
||||
</subject>
|
||||
<message>
|
||||
<type>X2</type>
|
||||
</message>
|
||||
<html>
|
||||
<type>L</type>
|
||||
</html>
|
||||
<urgent>
|
||||
<type>L</type>
|
||||
</urgent>
|
||||
<userread>
|
||||
<type>L</type>
|
||||
</userread>
|
||||
</field>
|
||||
<method>
|
||||
<delete>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</delete>
|
||||
<view>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</view>
|
||||
<search>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</search>
|
||||
</method>
|
||||
<trigger></trigger>
|
||||
</construct>
|
||||
|
||||
<!-- Database fields -->
|
||||
<field>
|
||||
<!-- Record ID -->
|
||||
<id>
|
||||
<index>1</index>
|
||||
<type>I8</type>
|
||||
<unique>1</unique>
|
||||
</id>
|
||||
<!-- Site ID -->
|
||||
<site_id>
|
||||
<index>1</index>
|
||||
<type>I4</type>
|
||||
</site_id>
|
||||
<!-- Date record created -->
|
||||
<date_orig>
|
||||
<convert>date-now</convert>
|
||||
<display>Date Created</display>
|
||||
<type>I8</type>
|
||||
</date_orig>
|
||||
<account_id>
|
||||
<type>I4</type>
|
||||
<validate>any</validate>
|
||||
</account_id>
|
||||
<email>
|
||||
<display>Email Address</display>
|
||||
<type>C(128)</type>
|
||||
</email>
|
||||
<subject>
|
||||
<display>Subject</display>
|
||||
<type>C(128)</type>
|
||||
</subject>
|
||||
<message>
|
||||
<display>Message</display>
|
||||
<type>X2</type>
|
||||
</message>
|
||||
<html>
|
||||
<type>L</type>
|
||||
</html>
|
||||
<urgent>
|
||||
<type>L</type>
|
||||
</urgent>
|
||||
<userread>
|
||||
<type>L</type>
|
||||
</userread>
|
||||
</field>
|
||||
|
||||
<!-- Methods for this class, and the fields they have access to, if applicable -->
|
||||
<method>
|
||||
<delete>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</delete>
|
||||
<search>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</search>
|
||||
<view>id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread</view>
|
||||
</method>
|
||||
|
||||
<!-- Method triggers -->
|
||||
<trigger></trigger>
|
||||
|
||||
<!-- Template page display titles -->
|
||||
<title>
|
||||
<user_list>Emails</user_list>
|
||||
<user_view>Email</user_view>
|
||||
</title>
|
||||
|
||||
<!-- Template helpers -->
|
||||
<tpl>
|
||||
<search_show>
|
||||
<checkbox>
|
||||
<field>id</field>
|
||||
<type>checkbox</type>
|
||||
<width>25px</width>
|
||||
</checkbox>
|
||||
<date_orig>
|
||||
<field>date_orig</field>
|
||||
<type>date</type>
|
||||
</date_orig>
|
||||
<email>
|
||||
<field>email</field>
|
||||
</email>
|
||||
<subject>
|
||||
<field>subject</field>
|
||||
</subject>
|
||||
</search_show>
|
||||
</tpl>
|
||||
</construct>
|
||||
|
@@ -1,34 +1,51 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<install>
|
||||
<install>
|
||||
<!-- Tree Menu Module Properties -->
|
||||
<module_properties>
|
||||
<name>email_log</name>
|
||||
<parent>setup</parent>
|
||||
<notes>Stores log of all e-mails sent out to accounts</notes>
|
||||
<menu_display>1</menu_display>
|
||||
<dependancy>setup</dependancy>
|
||||
<sub_modules></sub_modules>
|
||||
</module_properties>
|
||||
<sql_inserts>
|
||||
<module_method>
|
||||
<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>
|
||||
<!-- MODULE Dependancy, this module wont be installed if the dependant modules dont exist -->
|
||||
<dependancy>setup</dependancy>
|
||||
<!-- Translated display to use on the tree -->
|
||||
<display>Email Log</display>
|
||||
<!-- Display a module in the menu tree -->
|
||||
<menu_display>1</menu_display>
|
||||
<!-- MODULE Name -->
|
||||
<name>email_log</name>
|
||||
<!-- MODULE Notes, these notes show up in the modules table, as a description of the module -->
|
||||
<notes><![CDATA[Stores log of all e-mails sent out to accounts]]></notes>
|
||||
<!-- MODULE Parent, the parent node in the tree -->
|
||||
<parent>setup</parent>
|
||||
<!-- SUB Modules to install with this one -->
|
||||
<sub_modules></sub_modules>
|
||||
<!-- MODULE Type (core|base), core modules cannot be deleted, unrecognised types are ignored. -->
|
||||
<type></type>
|
||||
</module_properties>
|
||||
|
||||
<!-- Tree Menu & Module Methods to load, they will be assigned the group permissions on install time, as selected by the user. -->
|
||||
<module_method>
|
||||
<delete>
|
||||
<name>delete</name>
|
||||
<notes><![CDATA[Delete records]]></notes>
|
||||
</delete>
|
||||
<search>
|
||||
<display>List</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>search</name>
|
||||
<notes><![CDATA[List records]]></notes>
|
||||
<page><![CDATA[core:search&module=%%&_next_page_one=view]]></page>
|
||||
</search>
|
||||
<search_form>
|
||||
<display>Search</display>
|
||||
<menu_display>1</menu_display>
|
||||
<name>search_form</name>
|
||||
<notes><![CDATA[Search for records]]></notes>
|
||||
</search_form>
|
||||
<search_show>
|
||||
<name>search_show</name>
|
||||
<notes><![CDATA[Show the results of a search]]></notes>
|
||||
</search_show>
|
||||
<view>
|
||||
<name>view</name>
|
||||
<notes><![CDATA[View a record]]></notes>
|
||||
</view>
|
||||
</module_method>
|
||||
</install>
|
||||
|
Reference in New Issue
Block a user