MailTemplateList.php
[Pman.Core] / MailTemplateList.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Core_MailTemplateList extends Pman
6 {
7     function getAuth()
8     {
9         $au = $this->getAuthUser();
10         if (!$au) {
11             die("NOT authenticated");
12         }
13         $this->authUser = $au;
14         return true;
15     }
16
17     function get()
18     {
19         $fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy;
20         
21         $templateDir = explode(PATH_SEPARATOR, $fopts['templateDir']);
22         
23         $ret = array();
24         
25         foreach ($templateDir as $dir){
26             
27             if(!file_exists($dir . '/mail')){
28                 continue;
29             }
30             
31             if ($handle = opendir($dir . '/mail')) {
32                 while (false !== ($entry = readdir($handle))) {
33                     if ($entry == "." || $entry == ".." || !preg_match('/\.html$/', $entry)) {
34                         continue;
35                     }
36                     
37                     $ret[] = array(
38                         'file' => $entry,
39                         'content' => file_get_contents("$dir/mail/$entry")
40                     );
41                 }
42                 
43                 closedir($handle);
44             }
45             
46         }
47         
48         $this->jdata($ret);
49         
50     }
51      
52 }