PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/email_log/email_log.inc.php

https://github.com/axxtel/agilebill
PHP | 118 lines | 87 code | 11 blank | 20 comment | 9 complexity | c2749974ed32ad5ae15ba7934c9f6d39 MD5 | raw file
  1. <?php
  2. /**
  3. * AgileBill - Open Billing Software
  4. *
  5. * This body of work is free software; you can redistribute it and/or
  6. * modify it under the terms of the Open AgileBill License
  7. * License as published at http://www.agileco.com/agilebill/license1-4.txt
  8. *
  9. * For questions, help, comments, discussion, etc., please join the
  10. * Agileco community forums at http://forum.agileco.com/
  11. *
  12. * @link http://www.agileco.com/
  13. * @copyright 2004-2008 Agileco, LLC.
  14. * @license http://www.agileco.com/agilebill/license1-4.txt
  15. * @author Tony Landis <tony@agileco.com>
  16. * @package AgileBill
  17. * @version 1.4.93
  18. */
  19. class email_log
  20. {
  21. var $user_view_count = 25; /* show last X email logs for user */
  22. function user_list($VAR) {
  23. if(!SESS_LOGGED) return false;
  24. $db=&DB();
  25. $email = $db->GetOne("select email from ".AGILE_DB_PREFIX."account where id = ".SESS_ACCOUNT);
  26. $rs=$db->Execute(sqlSelect($db,"email_log","id,email,date_orig,subject,urgent,userread",
  27. "email=::$email:: and account_id=".SESS_ACCOUNT,'date_orig',$this->user_view_count));
  28. if($rs && $rs->RecordCount()) {
  29. $smart=array();
  30. while(!$rs->EOF) {
  31. array_push($smart, $rs->fields);
  32. $rs->MoveNext();
  33. }
  34. global $smarty;
  35. $smarty->assign('email_log', $smart);
  36. }
  37. }
  38. function user_view($VAR) {
  39. /* validate, update to read, and view() */
  40. if(!SESS_LOGGED || empty($VAR['id'])) return false;
  41. /* select id for this user */
  42. $db=&DB();
  43. $rs = $db->Execute(sqlSelect($db,"email_log","*","id=::{$VAR['id']}:: and account_id=".SESS_ACCOUNT));
  44. if($rs && $rs->RecordCount()) {
  45. global $smarty;
  46. $smarty->assign('email_log', $rs->fields);
  47. if($rs->fields['userread'] != 1) {
  48. /* update to read */
  49. $fields=Array('userread'=>1);
  50. $db->Execute(sqlUpdate($db,"email_log",$fields,"id = {$rs->fields['id']}"));
  51. }
  52. }
  53. }
  54. function add($account_id, $subject, $message, $email, $html=0, $urgent=0) {
  55. $db=&DB();
  56. $fields=Array('date_orig'=>time(), 'account_id'=>$account_id, 'subject'=>$subject, 'message'=>$message, 'email'=>$email, 'html'=>$html, 'urgent'=>$urgent, 'userread'=>0);
  57. $id = & $db->Execute(sqlInsert($db,"email_log",$fields));
  58. }
  59. function view($VAR) {
  60. $this->construct();
  61. $type = "view";
  62. $this->method["$type"] = explode(",", $this->method["$type"]);
  63. $db = new CORE_database;
  64. $db->view($VAR, $this, $type);
  65. }
  66. function delete($VAR) {
  67. $this->construct();
  68. $db = new CORE_database;
  69. $db->mass_delete($VAR, $this, "");
  70. }
  71. function search_form($VAR) {
  72. $this->construct();
  73. $type = "search";
  74. $this->method["$type"] = explode(",", $this->method["$type"]);
  75. $db = new CORE_database;
  76. $db->search_form($VAR, $this, $type);
  77. }
  78. function search($VAR) {
  79. $this->construct();
  80. $type = "search";
  81. $this->method["$type"] = explode(",", $this->method["$type"]);
  82. $db = new CORE_database;
  83. $db->search($VAR, $this, $type);
  84. }
  85. function search_show($VAR) {
  86. $this->construct();
  87. $type = "search";
  88. $this->method["$type"] = explode(",", $this->method["$type"]);
  89. $db = new CORE_database;
  90. $db->search_show($VAR, $this, $type);
  91. }
  92. function construct() {
  93. $this->module = "email_log";
  94. $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml";
  95. $C_xml = new CORE_xml;
  96. $construct = $C_xml->xml_to_array($this->xml_construct);
  97. $this->method = $construct["construct"]["method"];
  98. $this->trigger = $construct["construct"]["trigger"];
  99. $this->field = $construct["construct"]["field"];
  100. $this->table = $construct["construct"]["table"];
  101. $this->module = $construct["construct"]["module"];
  102. $this->cache = $construct["construct"]["cache"];
  103. $this->order_by = $construct["construct"]["order_by"];
  104. $this->limit = $construct["construct"]["limit"];
  105. }
  106. }
  107. ?>