Pman.php
[Pman.Base] / Pman.php
1 <?php 
2 /**
3  * Pman Base class
4  * 
5  * Provides:
6  *  - base application setup (variables etc to javascript)
7  * 
8  *  - authentication and permission info about user / application
9  *  - json output methods.
10  *  - file upload error checking - checkFileUploadError
11  *  - logging to event table
12  *  - sendTemplate code (normally use the Person version for sending to specific people..)
13  * 
14  *  - doc managment code?? - remarks and tracking??? - MOVEME
15  *  - authentication link checking?? MOVEME?
16  *  - authentication reset password ?? MOVEME?
17  *  ?? arrayClean.. what's it doing here?!? ;)
18  * 
19  * Usefull implemetors
20  * DB_DataObject*:*toEventString (for logging - this is generically prefixed to all database operations.)
21  *   - any data object where this method exists, the result will get prefixed to the log remarks
22  */
23
24 class Pman extends HTML_FlexyFramework_Page 
25 {
26     var $appName= "";
27     var $appShortName= "";
28     var $appVersion = "1.8";
29     var $version = 'dev';
30     var $onloadTrack = 0;
31     var $linkFail = "";
32     var $showNewPass = 0;
33     var $logoPrefix = '';
34     var $appModules = '';
35     var $appDisabled = array(); // array of disabled modules..
36                     // (based on config option disable)
37     
38     var $authUser; // always contains the authenticated user..
39     
40    
41     
42     /**
43      * ------------- Standard getAuth/get/post methods of framework.
44      * 
45      * 
46      */
47     
48     function getAuth() // everyone allowed in!!!!!
49     {
50         $this->loadOwnerCompany();
51         
52         return true;
53         
54     }
55     
56     function init() 
57     {
58         if (isset($this->_hasInit)) {
59             return;
60         }
61         $this->_hasInit = true;
62           
63         $boot = HTML_FlexyFramework::get();
64         // echo'<PRE>';print_R($boot);exit;
65         $this->appName= $boot->appName;
66         $this->appNameShort= $boot->appNameShort;
67         $this->appModules= $boot->enable;
68         $this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
69         $this->appDisable = $boot->disable;
70         $this->appDisabled = explode(',', $boot->disable);
71         $this->version = $boot->version;
72         
73         if (!empty($ff->Pman['local_autoauth']) && 
74             ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
75             ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') 
76         ) {
77             $this->isDev = true;
78         }
79         
80     }
81     
82     function get($base) 
83     {
84         $this->init();
85             //$this->allowSignup= empty($opts['allowSignup']) ? 0 : 1;
86         $bits = explode('/', $base);
87         //print_R($bits);
88         if ($bits[0] == 'Link') {
89             $this->linkFail = $this->linkAuth(@$bits[1],@$bits[2]);
90             header('Content-type: text/html; charset=utf-8');
91             return;
92         } 
93         if ($bits[0] == 'PasswordReset') {
94             $this->linkFail = $this->resetPassword(@$bits[1],@$bits[2],@$bits[3]);
95             header('Content-type: text/html; charset=utf-8');
96             return;
97         } 
98         
99         
100         if ($this->getAuthUser()) {
101             $this->addEvent("RELOAD");
102         }
103         
104         
105         if (strlen($base)) {
106             $this->addEvent("BADURL", false, $base);
107             $this->jerr("invalid url");
108         }
109         // deliver template
110         if (isset($_GET['onloadTrack'])) {
111             $this->onloadTrack = (int)$_GET['onloadTrack'];
112         }
113         // getting this to work with xhtml is a nightmare
114         // = nbsp / <img> issues screw everyting up.
115          //var_dump($this->isDev);
116         // force regeneration on load for development enviroments..
117         
118         HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev);
119         
120         //header('Content-type: application/xhtml+xml; charset=utf-8');
121         header('Content-type: text/html; charset=utf-8');
122          
123     }
124     function post($base) {
125         return $this->get($base);
126     }
127     
128     
129     // --------------- AUTHENTICATION or  system information
130     /**
131      * loadOwnerCompany:
132      * finds the compay with comptype=='OWNER'
133      *
134      * @return {Pman_Core_DataObjects_Companies} the owner company
135      */
136     function loadOwnerCompany()
137     {
138          
139         $this->company = DB_DataObject::Factory('Companies');
140         if ($this->company) { // non-core pman projects
141             return; 
142         }
143         $this->company->get('comptype', 'OWNER');
144         
145     }
146     
147     
148     
149     /**
150      * getAuthUser: - get the authenticated user..
151      *
152      * @return {DB_DataObject} of type Pman[authTable] if authenticated.
153      */
154     
155     function getAuthUser()
156     {
157         if (!empty($this->authUser)) {
158             return $this->authUser;
159         }
160         $ff = HTML_FlexyFramework::get();
161         $tbl = empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable'];
162         
163         $u = DB_DataObject::factory( $tbl );
164         if (!$u->isAuth()) {
165             return false;
166         }
167         $this->authUser =$u->getAuthUser();
168         return $this->authUser ;
169     }
170     /**
171      * hasPerm:
172      * wrapper arround authuser->hasPerm
173      * @see Pman_Core_DataObjects_User::hasPerm
174      *
175      * @param {String} $name  The permission name (eg. Projects.List)
176      * @param {String} $lvl   eg. (C)reate (E)dit (D)elete ... etc.
177      * 
178      */
179     function hasPerm($name, $lvl)  // do we have a permission
180     {
181         static $pcache = array();
182         $au = $this->getAuthUser();
183         return $au && $au->hasPerm($name,$lvl);
184         
185     }
186    
187     /**
188      * modulesList:  List the modules in the application
189      *
190      * @return {Array} list of modules
191      */
192     function modulesList()
193     {
194         $this->init();
195         
196         $mods = explode(',', $this->appModules);
197         if (in_array('Core',$mods)) { // core has to be the first  modules loaded as it contains Pman.js
198             array_unshift($mods,   'Core');
199         }
200         
201         $mods = array_unique($mods);
202          
203         $disabled =  explode(',', $this->appDisable ? $this->appDisable: '');
204         $ret = array();
205         foreach($mods as $mod) {
206             // add the css file..
207             if (in_array($mod, $disabled)) {
208                 continue;
209             }
210             $ret[] = $mod;
211         }
212         return $ret;
213     }
214     
215      
216     
217     
218     function hasModule($name) 
219     {
220         $this->init();
221         if (!strpos( $name,'.') ) {
222             // use enable / disable..
223             return in_array($name, $this->modules()); 
224         }
225         
226         $x = DB_DataObject::factory('Group_Rights');
227         $ar = $x->defaultPermData();
228         if (empty($ar[$name]) || empty($ar[$name][0])) {
229             return false;
230         }
231         return true;
232     }
233     
234      
235     
236     
237     
238     /**
239      * ---------------- Global Tools ---------------   
240      */
241     
242     
243     
244     /**
245      * send a template to the user
246      * rcpts are read from the resulting template.
247      * 
248      * @arg $templateFile  - the file in mail/XXXXXX.txt
249      * @arg $args  - variables available to the form as {t.*} over and above 'this'
250      * 
251      * 
252      */
253     
254     function sendTemplate($templateFile, $args)
255     {
256         
257         
258         
259         $content  = clone($this);
260         
261         foreach((array)$args as $k=>$v) {
262             $content->$k = $v;
263         }
264         $content->msgid = md5(time() . rand());
265         
266         $content->HTTP_HOST = $_SERVER["HTTP_HOST"];
267         /* use the regex compiler, as it doesnt parse <tags */
268         require_once 'HTML/Template/Flexy.php';
269         $template = new HTML_Template_Flexy( array(
270                  'compiler'    => 'Regex',
271                  'filters' => array('SimpleTags','Mail'),
272             //     'debug'=>1,
273             ));
274         
275         // this should be done by having multiple template sources...!!!
276          
277         $template->compile('mail/'. $templateFile.'.txt');
278         
279         /* use variables from this object to ouput data. */
280         $mailtext = $template->bufferedOutputObject($content);
281         //echo "<PRE>";print_R($mailtext);
282         
283         /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
284         require_once 'Mail/mimeDecode.php';
285         require_once 'Mail.php';
286         
287         $decoder = new Mail_mimeDecode($mailtext);
288         $parts = $decoder->getSendArray();
289         if (PEAR::isError($parts)) {
290             return $parts;
291             //echo "PROBLEM: {$parts->message}";
292             //exit;
293         } 
294         list($recipents,$headers,$body) = $parts;
295         ///$recipents = array($this->email);
296         $mailOptions = PEAR::getStaticProperty('Mail','options');
297         $mail = Mail::factory("SMTP",$mailOptions);
298         $headers['Date'] = date('r');
299         if (PEAR::isError($mail)) {
300             return $mail;
301         } 
302         $oe = error_reporting(E_ALL ^ E_NOTICE);
303         $ret = $mail->send($recipents,$headers,$body);
304         error_reporting($oe);
305        
306         return $ret;
307     
308     }
309     
310     function checkFileUploadError()  // check for file upload errors.
311     {    
312         if (
313             empty($_FILES['File']) 
314             || empty($_FILES['File']['name']) 
315             || empty($_FILES['File']['tmp_name']) 
316             || empty($_FILES['File']['type']) 
317             || !empty($_FILES['File']['error']) 
318             || empty($_FILES['File']['size']) 
319         ) {
320             $this->jerr("File upload error: <PRE>" . print_r($_FILES,true) . print_r($_POST,true) . "</PRE>");
321         }
322     }
323     
324     
325     /**
326      * generate a tempory file with an extension (dont forget to delete it)
327      */
328     
329     function tempName($ext)
330     {
331         $x = tempnam(ini_get('session.save_path'), HTML_FlexyFramework::get()->appNameShort.'TMP');
332         unlink($x);
333         return $x .'.'. $ext;
334     }
335     /**
336      * ------------- Authentication testing ------ ??? MOVEME?
337      * 
338      * 
339      */
340     function linkAuth($trid, $trkey) 
341     {
342         $tr = DB_DataObject::factory('Documents_Tracking');
343         if (!$tr->get($trid)) {
344             return "Invalid URL";
345         }
346         if (strtolower($tr->authkey) != strtolower($trkey)) {
347             $this->AddEvent("ERROR-L", false, "Invalid Key");
348             return "Invalid KEY";
349         }
350         // check date..
351         $this->onloadTrack = (int) $tr->doc_id;
352         if (strtotime($tr->date_sent) < strtotime("NOW - 14 DAYS")) {
353             $this->AddEvent("ERROR-L", false, "Key Expired");
354             return "Key Expired";
355         }
356         // user logged in and not
357         $au = $this->getAuthUser();
358         if ($au && $au->id && $au->id != $tr->person_id) {
359             $au->logout();
360             
361             return "Logged Out existing Session\n - reload to log in with correct key";
362         }
363         if ($au) { // logged in anyway..
364             $this->AddEvent("LOGIN", false, "With Key (ALREADY)");
365             header('Location: ' . $this->baseURL.'?onloadTrack='.$this->onloadTrack);
366             exit;
367             return false;
368         }
369         
370         // authenticate the user...
371         // slightly risky...
372         $u = DB_DataObject::factory('Person');
373          
374         $u->get($tr->person_id);
375         $u->login();
376         $this->AddEvent("LOGIN", false, "With Key");
377         
378         // we need to redirect out - otherwise refererer url will include key!
379         header('Location: ' . $this->baseURL.'?onloadTrack='.$this->onloadTrack);
380         exit;
381         
382         return false;
383         
384         
385         
386         
387     }
388     
389     
390     /**
391      * ------------- Authentication password reset ------ ??? MOVEME?
392      * 
393      * 
394      */
395     
396     
397     function resetPassword($id,$t, $key)
398     {
399         
400         $au = $this->getAuthUser();
401         if ($au) {
402             return "Already Logged in - no need to use Password Reset";
403         }
404         
405         $u = DB_DataObject::factory('Person');
406         //$u->company_id = $this->company->id;
407         $u->active = 1;
408         if (!$u->get($id) || !strlen($u->passwd)) {
409             return "invalid id";
410         }
411         
412         // validate key.. 
413         if ($key != $u->genPassKey($t)) {
414             return "invalid key";
415         }
416         $uu = clone($u);
417         $u->no_reset_sent = 0;
418         $u->update($uu);
419         
420         if ($t < strtotime("NOW - 1 DAY")) {
421             return "expired";
422         }
423         $this->showNewPass = implode("/", array($id,$t,$key));
424         return false;
425     }
426     
427     /**
428      * jerrAuth: standard auth failure - with data that let's the UI know..
429      */
430     function jerrAuth()
431     {
432         $this->jerr("Not authenticated", array('authFailure' => true));
433     }
434      
435      
436      
437     /**
438      * ---------------- Standard JSON outputers. - used everywhere
439      */
440     
441     function jerr($str, $errors=array()) // standard error reporting..
442     {
443         
444         $cli = HTML_FlexyFramework::get()->cli;
445         if ($cli) {
446             echo "ERROR:\n" .$str . "\n";
447             exit;
448         }
449         
450         require_once 'Services/JSON.php';
451         $json = new Services_JSON();
452         
453         // log all errors!!!
454         $this->addEvent("ERROR", false, $str);
455         
456         if (!empty($_REQUEST['returnHTML']) || 
457             (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
458         ) {
459             header('Content-type: text/html');
460             echo "<HTML><HEAD></HEAD><BODY>";
461             echo  $json->encodeUnsafe(array(
462                     'success'=> false, 
463                     'errorMsg' => $str,
464                     'message' => $str, // compate with exeption / loadexception.
465
466                     'errors' => $errors ? $errors : true, // used by forms to flag errors.
467                     'authFailure' => !empty($errors['authFailure']),
468                 ));
469             echo "</BODY></HTML>";
470             exit;
471         }
472         
473         echo $json->encode(array(
474             'success'=> false, 
475             'data'=> array(), 
476             'errorMsg' => $str,
477             'message' => $str, // compate with exeption / loadexception.
478             'errors' => $errors ? $errors : true, // used by forms to flag errors.
479             'authFailure' => !empty($errors['authFailure']),
480         ));
481         exit;
482         
483     }
484     function jok($str)
485     {
486         
487         require_once 'Services/JSON.php';
488         $json = new Services_JSON();
489         
490         if (!empty($_REQUEST['returnHTML']) || 
491             (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
492         
493         ) {
494             header('Content-type: text/html');
495             echo "<HTML><HEAD></HEAD><BODY>";
496             // encode html characters so they can be read..
497             echo  str_replace(array('<','>'), array('\u003c','\u003e'),
498                         $json->encodeUnsafe(array('success'=> true, 'data' => $str)));
499             echo "</BODY></HTML>";
500             exit;
501         }
502          
503         
504         echo  $json->encode(array('success'=> true, 'data' => $str));
505         exit;
506         
507     }
508     /**
509      * output data for grids or tree
510      * @ar {Array} ar Array of data
511      * @total {Number|false} total number of records (or false to return count(ar)
512      * @extra {Array} extra key value list of data to pass as extra data.
513      * 
514      */
515     function jdata($ar,$total=false, $extra=array())
516     {
517         // should do mobile checking???
518         if ($total == false) {
519             $total = count($ar);
520         }
521         $extra=  $extra ? $extra : array();
522         require_once 'Services/JSON.php';
523         $json = new Services_JSON();
524         if (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE'])) {
525             
526             header('Content-type: text/html');
527             echo "<HTML><HEAD></HEAD><BODY>";
528             // encode html characters so they can be read..
529             echo  str_replace(array('<','>'), array('\u003c','\u003e'),
530                         $json->encodeUnsafe(array('success' =>  true, 'total'=> $total, 'data' => $ar) + $extra));
531             echo "</BODY></HTML>";
532             exit;
533         }
534         
535       
536         
537         
538         
539         
540        
541         echo $json->encode(array('success' =>  true, 'total'=> $total, 'data' => $ar) + $extra);    
542         exit;
543         
544         
545     }
546     
547     
548    
549     
550     /**
551      * ---------------- OUTPUT
552      */
553     function hasBg($fn) // used on front page to check if logos exist..
554     {
555         return file_exists($this->rootDir.'/Pman/'.$this->appNameShort.'/templates/images/'.  $fn);
556     }
557      /**
558      * outputJavascriptIncludes:
559      *
560      * output <script....> for all the modules in the applcaiton
561      *
562      */
563     function outputJavascriptIncludes() // includes on devel version..
564     {
565         
566         $mods = $this->modulesList();
567         
568         foreach($mods as $mod) {
569             // add the css file..
570         
571             
572             $files = $this->moduleJavascriptList($mod.'/widgets');
573              foreach($files as $f) {
574                 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
575             }
576             
577             $files = $this->moduleJavascriptList($mod);
578             foreach($files as $f) {
579                 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
580             }
581             
582         }
583          
584     }
585      /**
586      * outputCSSIncludes:
587      *
588      * output <link rel=stylesheet......> for all the modules in the applcaiton
589      *
590      */
591     function outputCSSIncludes() // includes on CSS links.
592     {
593         
594         $mods = $this->modulesList();
595         
596         
597         foreach($mods as $mod) {
598             // add the css file..
599             $css = $this->rootDir.'/Pman/'.$mod.'/'.strtolower($mod).'.css';
600             if (file_exists( $css)){
601                 $css = $this->rootURL .'/Pman/'.$mod.'/'.strtolower($mod).'.css';
602                 echo '<link rel="stylesheet" type="text/css" href="'.$css.'" />'."\n";
603             }
604              
605             
606         }
607          
608     }
609       
610     /**
611      * Gather infor for javascript files..
612      *
613      * @param {String} $mod the module to get info about.
614      * @return {StdClass}  details about module.
615      */
616     function moduleJavascriptFilesInfo($mod)
617     {
618         $ff = HTML_FlexyFramework::get();
619         
620         $base = dirname($_SERVER['SCRIPT_FILENAME']);
621         $dir =   $this->rootDir.'/Pman/'. $mod;
622         $path = $this->rootURL ."/Pman/$mod/";
623         
624         $ar = glob($dir . '/*.js');
625         
626         $files = array();
627         $arfiles = array();
628         $maxtime = 0;
629         $mtime = 0;
630         foreach($ar as $fn) {
631             $f = basename($fn);
632             // got the 'module file..'
633             $mtime = filemtime($dir . '/'. $f);
634             $maxtime = max($mtime, $maxtime);
635             $arfiles[$fn] = $mtime;
636             $files[] = $path . $f . '?ts='.$mtime;
637         }
638         
639         ksort($arfiles); // just sort by name so it's consistant for serialize..
640         
641         $compile  = empty($ff->Pman['public_cache_dir']) ? 0 : 1;
642         $basedir = $ff->Pman['public_cache_dir'];
643         $baseurl = $ff->Pman['public_cache_url'];
644         
645         $lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
646         usort($files, $lsort);
647         
648         $smod = str_replace('/','.',$mod);
649         
650         $output = date('Y-m-d-H-i-s-', $maxtime). $smod .'-'.md5(serialize($arfiles)) .'.js';
651         
652         $tmtime = file_exists($this->rootDir.'/_translations_/'. $smod.'.js')
653             ? filemtime($this->rootDir.'/_translations_/'. $smod.'.js') : 0;
654         
655         return (object) array(
656             'smod' => $smod,
657             'files' => $files,
658             'filesmtime' => $arfiles,
659             'maxtime' => $maxtime,
660             'compile' => $compile,
661             'translation_file' =>   $base .'/_translations_/' . $smod .  '.js',
662             'translation_mtime' =>   $tmtime,
663             'output' => $output,
664             'translation_data' => preg_replace('/\.js$/', '.__translation__.js', $output),
665             'translation_base' => dirname($dir) . '/',
666             'basedir' => $basedir,
667             'baseurl' => $baseurl,
668         );
669     }
670     
671     
672     
673     
674     /**
675      *  moduleJavascriptList: list the javascript files in a module
676      *
677      *  The original version of this.. still needs more thought...
678      *
679      *  Compiled is in Pman/_compiled_/{$mod}/{LATEST...}.js
680      *  Translations are in Pman/_translations_/{$mod}.js
681      *  
682      *  if that stuff does not exist just list files in  Pman/{$mod}/*.js
683      *
684      *  Compiled could be done on the fly..
685      * 
686      *
687      *
688      *  @param {String} $mod  the module to look at - eg. Pman/{$mod}/*.js
689      *  @return {Array} list of include paths (either compiled or raw)
690      *
691      */
692
693     
694     
695     function moduleJavascriptList($mod)
696     {
697         
698         
699         $dir =   $this->rootDir.'/Pman/'. $mod;
700         
701         
702         if (!file_exists($dir)) {
703             echo '<!-- missing directory '. htmlspecialchars($dir) .' -->';
704             return array();
705         }
706         
707         $info = $this->moduleJavascriptFilesInfo($mod);
708         print_R($info);
709         
710           
711         if (empty($info->files)) {
712             return array();
713         }
714         // finally sort the files, so they are in the right order..
715         
716         // only compile this stuff if public_cache is set..
717         
718          
719         // suggestions...
720         //  public_cache_dir =   /var/www/myproject_cache
721         //  public_cache_url =   /myproject_cache    (with Alias apache /myproject_cache/ /var/www/myproject_cache/)
722        
723           
724         // where are we going to write all of this..
725         // This has to be done via a 
726         if ( $info->compile && !file_exists($info->basedir.'/'.$info->output)) {
727             require_once 'Pman/Core/JsCompile.php';
728             $x = new Pman_Core_JsCompile();
729             
730             $x->pack($info->filesmtime,$info->basedir.'/'.$info->output, $info->translation_base);
731         }
732         
733         if ($info->compile && file_exists($info->basedir.'/'.$info->output) && filesize($info->basedir.'/'.$info->output)) {
734             $ret =array(
735                 $info->baseurl.'/'. $info->output,
736               
737             );
738             if ($info->translation_mtime) {
739                 $ret[] = $this->rootURL."/_translations_/". $info->smod.".js?ts=".$info->translation_mtime;
740             }
741             return $ret;
742         }
743         
744         
745         
746         // give up and output original files...
747         
748          
749         return $files;
750
751         
752     }
753     
754     
755     
756     /**
757      * ---------------- Logging ---------------   
758      */
759     
760     /**
761      * addEventOnce:
762      * Log an action (only if it has not been logged already.
763      * 
764      * @param {String} action  - group/name of event
765      * @param {DataObject|false} obj - dataobject action occured on.
766      * @param {String} any remarks 
767      */
768     
769     function addEventOnce($act, $obj = false, $remarks = '') 
770     {
771         $au = $this->getAuthUser();
772         $e = DB_DataObject::factory('Events');
773         $e->init($act,$obj,$remarks); 
774         if ($e->find(true)) {
775             return;
776         }
777         return $this->addEvent($act, $obj, $remarks);
778     }
779     /**
780      * addEvent:
781      * Log an action.
782      * 
783      * @param {String} action  - group/name of event
784      * @param {DataObject|false} obj - dataobject action occured on.
785      * @param {String} any remarks
786      * @return {Number} Event id.,
787      */
788     
789     function addEvent($act, $obj = false, $remarks = '') 
790     {
791         $au = $this->getAuthUser();
792         $e = DB_DataObject::factory('Events');
793         $e->init($act,$obj,$remarks); 
794          
795         $e->event_when = date('Y-m-d H:i:s');
796         
797         $eid = $e->insert();
798         $ff  = HTML_FlexyFramework::get();
799         if (empty($ff->Pman['event_log_dir'])) {
800             return $eid;
801         }
802         $file = $ff->Pman['event_log_dir']. date('/Y/m/d/'). $eid . ".php";
803         if (!file_exists(dirname($file))) {
804             mkdir(dirname($file),0700,true);
805         }
806         file_put_contents($file, var_export(array(
807             'REQUEST_URI' => empty($_SERVER['REQUEST_URI']) ? 'cli' : $_SERVER['REQUEST_URI'],
808             'GET' => empty($_GET) ? array() : $_GET,
809             'POST' => empty($_POST) ? array() : $_POST,
810         ), true));
811         
812         return $eid;
813         
814     }
815     // ------------------ DEPERCIATED ---
816      
817     function modules() // DEPRECITAED
818     {
819         return $this->modulesList(); 
820     }
821     function staticGetAuthUser() // DEPRECIATED..
822     {
823         
824         $x = new Pman();
825         return $x->getAuthUser();
826         
827     }
828      
829     
830 }