DatabaseColumns.php
[Pman.Core] / DatabaseColumns.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Core_DatabaseColumns extends Pman {
6     
7     
8     function getAuth()
9     {
10         parent::getAuth(); // load company!
11         $au = $this->getAuthUser();
12        
13         if (!$au) {  
14             $this->jerr("Not authenticated", array('authFailure' => true));
15         }
16         if (!$au->pid()   ) { // not set up yet..
17             $this->jerr("Not authenticated", array('authFailure' => true));
18         }
19         
20         
21         $this->authUser = $au;
22         return true;
23     }
24     
25     function get($table) {
26         $d = DB_DAtaObject::Factory($table);
27         $re = $d->autoJoin();
28         //echo '<PRE>';print_r($re);
29         $ret = array ();
30         
31         foreach($re['join_names'] as $c=>$f) {
32             $re['cols'][$c] = $f;
33         }
34         foreach($re['cols'] as $c=>$f) {
35             $ret[]  = array(
36                 'name' => $c,
37                 'val' => $f
38             );
39             
40         }
41         $this->jdata($ret);
42         
43         
44     }
45 }