MessagePreview.php
[Pman.Core] / MessagePreview.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Core_MessagePreview extends Pman
6 {
7     var $masterTemplate = 'mail/MessagePreview.html';
8     
9     function getAuth()
10     {
11         if (HTML_FlexyFramework::get()->cli) {
12             return true;
13         }
14         $this->authUser = $this->getAuthUser();
15         if (!$this->authUser) {
16             return false;
17         }
18         return true;
19     }
20     
21     function get()
22     {
23         if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){
24             $this->jerr('Missing Options');
25         }
26         
27         $mlq = DB_DataObject::factory($_REQUEST['_table']);
28         
29         $mlq->get($_REQUEST['_id']);
30         
31         $this->msg = $mlq;
32
33         $this->showHtml = isset($_REQUEST['_as_html']) ? true : false;
34         
35     }
36     
37     function post()
38     {
39         if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){
40             $this->jerr('Missing Options');
41         }
42         
43         if(!empty($_REQUEST['_send_test'])){
44             $this->sendTest();
45         }
46         
47         $mid = $_REQUEST['_id'];
48         
49         $mlq = DB_DataObject::factory($_REQUEST['_table']);
50         
51         $mlq->get($_REQUEST['_id']);
52         
53         $content = array(
54             'template' => $mlq->name,
55             'person' => $this->authUser
56         );
57         
58         $sent = DB_DataObject::factory($_REQUEST['_table'])->send($content);
59         
60         if(!is_object($sent)){
61             $this->jok('SUCCESS');
62         }
63         
64         $this->jerr('error!!:' . $sent->toString());
65         
66     }
67     
68     function sendTest()
69     {
70         $table = DB_DataObject::factory($_REQUEST['_table']);
71         
72         if($table->get($_REQUEST['_id'])){
73             $this->jerr('Invalid Message ID');
74         }
75         
76         
77     }
78 }