-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_controller.php
112 lines (97 loc) · 3.07 KB
/
app_controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Controller class containing application controller's actions
*
* @author Chauncey Thorn <[email protected]>
* @version 1.0
* @package Recovery
*/
class AppController extends Controller {
/**
* Property used to store view of controller
*
* @access public
* @var string View of controller
*/
var $view = 'Theme';
/**
* Property used to store list of components used by this controller's actions
*
* @access public
* @var string List of components used by this controller's actions
*/
var $components = array('Email');
/**
* Property used to store list of helpers used by application's all controller's actions' views
*
* @access public
* @var string List of helpers used by application's all controller's actions' views
*/
var $helpers = array('Html', 'Javascript');
/**
* Method called automatically before each action execution
*
* @access public
*/
function beforeFilter()
{
$this->theme = 'Modern';
}
/**
* Method called automatically before the view is rendered
*
* @access public
*/
function beforeRender()
{
$this->theme = 'Modern';
$viewPaths = Configure::read('viewPaths');
array_unshift($viewPaths, array_pop($viewPaths));
Configure::write('viewPaths', $viewPaths);
}
/**
* Method used to set given error message to use in view and then render error view
*
* @access public
* @param string $message Error message to be displayed
*/
function renderError($message)
{
// Set error message to use in view
$this->set('message', $message);
// Render error view
$this->render(null, null, VIEWS . 'errors' . DS . 'error.ctp');
}
/**
* Method used to send required e-mail to [email protected]
*
* @access public
* @param string $ofabbr Office Abbrev
* @param string $report_type Report type
*/
//initial nethod to send require email
// i.e.
// HUD, Major Communications
// HUD, Formula Block Grant Allocation
// HUD, Weekly Report #X
//templage: Templates for these files can be found at https://max.omb.gov/community/x/doC2Dw.
// need special accout for above url (problem)
public function sendEmail($ofabbr=null, $report_type=null)
{
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' =>'localhost');
$this->Email->sendAs = 'html';
$this->Email->delivery = 'smtp';
$this->Email->to = "[email protected]";
$this->Email->subject = $ofabbr.', '.$report_type;
$this->Email->from = $ofabbr. ' <[email protected]>';
//$msg = 'This is a test to see if e-mail works';
if ( $this->Email->send($msg) ) {
$this->Session->setFlash('Template email sent');
} else {
$this->Session->setFlash('Template email not sent');
}
}
}