6 * - base application setup (variables etc to javascript)
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..)
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?!? ;)
21 * Pman['local_autoauth'] // who to login as when using localhost
22 * Pman['isDev'] // can the site show develpment info.?
23 * Pman['uiConfig'] // extra variable to export to front end..
24 * Pman['auth_comptype'] // -- if set to 'OWNER' then only users with company=OWNER can log in
25 * Pman['authTable'] // the authentication table (default 'person')
29 * DB_DataObject*:*toEventString (for logging - this is generically prefixed to all database operations.)
30 * - any data object where this method exists, the result will get prefixed to the log remarks
36 require_once 'Pman/Core/AssetTrait.php';
38 class Pman extends HTML_FlexyFramework_Page
40 use Pman_Core_AssetTrait;
41 //outputJavascriptDir()
46 var $appShortName= "";
47 var $appVersion = "1.8";
54 var $appDisabled = array(); // array of disabled modules..
55 // (based on config option disable)
57 var $authUser; // always contains the authenticated user..
59 var $disable_jstemplate = false; /// disable inclusion of jstemplate code..
62 var $css_path = ''; // can inject a specific path into the base HTML page.
65 var $transObj = false; // used to rollback or commit in JOK/JERR
67 // these are used somewhere -
68 var $builderJs = false;//
69 var $serverName = false;
71 var $allowSignup = false;
78 * ------------- Standard getAuth/get/post methods of framework.
83 function getAuth() // everyone allowed in!!!!!
85 $this->loadOwnerCompany();
90 function init($base = false)
93 if (isset($this->_hasInit)) {
96 $this->_hasInit = true;
97 // move away from doing this ... you can access bootLoader.XXXXXX in the master template..
98 $boot = HTML_FlexyFramework::get();
99 // echo'<PRE>';print_R($boot);exit;
100 $this->appName = $boot->appName;
102 $this->appNameShort = $boot->appNameShort;
104 $this->appModules = $boot->enable;
106 // echo $this->arrayToJsInclude($files);
107 $this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
109 $this->css_path = empty($boot->Pman['css_path']) ? '' : $boot->Pman['css_path'];
111 $this->appDisable = $boot->disable;
112 $this->appDisabled = explode(',', $boot->disable);
113 $this->version = $boot->version;
114 $this->uiConfig = empty($boot->Pman['uiConfig']) ? false : $boot->Pman['uiConfig'];
116 if (!empty($boot->Pman['local_autoauth']) &&
117 !empty($_SERVER['SERVER_ADDR']) &&
118 !empty($_SERVER['REMOTE_ADDR']) &&
119 ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
120 ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
126 !empty($_REQUEST['isDev'])
130 !empty($_SERVER['SERVER_ADDR']) &&
132 (($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['REMOTE_ADDR'] == '127.0.0.1'))
134 (($_SERVER['SERVER_ADDR'] == '::1') && ($_SERVER['REMOTE_ADDR'] == '::1'))
136 (preg_match('/^192\.168/', $_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] == $_SERVER['HTTP_HOST'])
140 !empty($boot->Pman['enable_isdev_url'])
144 $boot->Pman['isDev'] = true;
148 // if a file Pman_{module}_Pman exists.. and it has an init function... - call that..
150 //var_dump($this->appModules);
156 * call a method on {module}/Pman.php
157 * * initially used on the main page load to call init();
158 * * also used for ccsIncludes??
160 * // usage: $this->callModules('init', $base)
164 function callModules($fn)
166 $args = func_get_args();
168 foreach(explode(',',$this->appModules) as $m) {
169 $cls = 'Pman_'. $m . '_Pman';
170 if (!file_exists($this->rootDir . '/'.str_replace('_','/', $cls). '.php')) {
173 require_once str_replace('_','/', $cls). '.php';
175 if (method_exists($c, $fn)) {
176 call_user_func_array(array($c,$fn),$args);
182 function get($base, $opts=array())
186 $this->callModules('init', $this, $base);
189 //$this->allowSignup= empty($opts['allowSignup']) ? 0 : 1;
190 $bits = explode('/', $base);
193 // should really be moved to Login...
195 if ($bits[0] == 'PasswordReset') {
196 $this->linkFail = $this->resetPassword(@$bits[1],@$bits[2],@$bits[3]);
197 header('Content-type: text/html; charset=utf-8');
202 $au = $this->getAuthUser();
204 $ff= HTML_FlexyFramework::get();
206 if (!empty($ff->Pman['auth_comptype']) && $au->id > 0 &&
207 ( !$au->company_id || ($ff->Pman['auth_comptype'] != $au->company()->comptype))) {
211 $this->jerr("Login not permited to outside companies - please reload");
213 $this->addEvent("RELOAD");
217 if (strlen($base) && $bits[0] != 'PasswordReset') {
218 $this->jerror("BADURL","invalid url: $base");
221 if (isset($_GET['onloadTrack'])) {
222 $this->onloadTrack = (int)$_GET['onloadTrack'];
224 // getting this to work with xhtml is a nightmare
225 // = nbsp / <img> issues screw everyting up.
226 //var_dump($this->isDev);
227 // force regeneration on load for development enviroments..
229 HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
231 //header('Content-type: application/xhtml+xml; charset=utf-8');
235 if ($this->company && $this->company->logo_id) {
236 $im = DB_DataObject::Factory('Images');
237 $im->get($this->company->logo_id);
238 $this->appLogo = $this->baseURL . '/Images/Thumb/x100/'. $this->company->logo_id .'/' . $im->filename;
241 header('Content-type: text/html; charset=utf-8');
244 function post($base) {
245 return $this->get($base);
249 // --------------- AUTHENTICATION or system information
252 * finds the compay with comptype=='OWNER'
253 * ?? what about comptype_id-name ?????
255 * @return {Pman_Core_DataObjects_Companies} the owner company
257 function loadOwnerCompany()
259 // only applies if authtable is person..
260 $ff = HTML_FlexyFramework::get();
261 if (!empty($ff->Pman['authTable']) && !in_array($ff->Pman['authTable'] , [ 'core_person', 'Person' ])) {
265 $this->company = DB_DataObject::Factory('core_company');
266 if (!is_a($this->company, 'DB_DataObject')) { // non-core pman projects
269 $e = DB_DataObject::Factory('core_enum')->lookupObject('COMPTYPE', 'OWNER');
271 $this->company->get('comptype_id', $e->id);
272 return $this->company;
276 static function staticGetAuthUser($t) {
277 if (!empty($t->authUser)) {
280 $ff = HTML_FlexyFramework::get();
281 $tbl = empty($ff->Pman['authTable']) ? 'core_person' : $ff->Pman['authTable'];
283 $u = DB_DataObject::factory( $tbl );
285 if (is_a($u,'PEAR_Error') || !$u->isAuth()) {
288 $t->authUser =$u->getAuthUser();
289 return $t->authUser ;
294 * getAuthUser: - get the authenticated user..
296 * @return {DB_DataObject} of type Pman[authTable] if authenticated.
299 function getAuthUser()
301 return self::staticGetAuthUser($this);
305 * wrapper arround authuser->hasPerm
306 * @see Pman_Core_DataObject_Core_person::hasPerm
308 * @param {String} $name The permission name (eg. Projects.List)
309 * @param {String} $lvl eg. (C)reate (E)dit (D)elete ... etc.
312 function hasPerm($name, $lvl) // do we have a permission
314 static $pcache = array();
315 $au = $this->getAuthUser();
316 return $au && $au->hasPerm($name,$lvl);
320 * modulesList: List the modules in the application
322 * @return {Array} list of modules
324 function modulesList()
326 $boot = HTML_FlexyFramework::get();
327 // echo'<PRE>';print_R($boot);exit;
330 $mods = explode(',', $boot->enable);
331 if (in_array('Core',$mods)) { // core has to be the first modules loaded as it contains Pman.js
332 array_unshift($mods, 'Core');
335 if (in_array($boot->appNameShort,$mods)) { // Project has to be the last modules loaded as it contains Pman.js
336 unset($mods[array_search($boot->appNameShort, $mods)]);
337 $mods[] = $boot->appNameShort;
340 $mods = array_unique($mods);
342 $disabled = explode(',', $boot->disable ? $boot->disable : '');
344 foreach($mods as $mod) {
345 // add the css file..
346 if (in_array($mod, $disabled)) {
357 function hasModule($name)
360 if (!strpos( $name,'.') ) {
361 // use enable / disable..
362 return in_array($name, $this->modules());
365 $x = DB_DataObject::factory('core_group_right');
366 $ar = $x->defaultPermData();
367 if (empty($ar[$name]) || empty($ar[$name][0])) {
375 function jsencode($v, $header = false)
378 header("Content-type: text/javascript");
380 if (function_exists("json_encode")) {
381 $ret= json_encode($v);
382 if ($ret !== false) {
386 require_once 'Services/JSON.php';
387 $js = new Services_JSON();
388 return $js->encodeUnsafe($v);
397 * ---------------- Global Tools ---------------
399 function checkFileUploadError() // check for file upload errors.
402 empty($_FILES['File'])
403 || empty($_FILES['File']['name'])
404 || empty($_FILES['File']['tmp_name'])
405 || empty($_FILES['File']['type'])
406 || !empty($_FILES['File']['error'])
407 || empty($_FILES['File']['size'])
409 $this->jerr("File upload error: <PRE>" . print_r($_FILES,true) . print_r($_POST,true) . "</PRE>");
413 static $deleteOnExit = false;
415 * generate a tempory file with an extension (dont forget to delete it)
418 function deleteOnExitAdd($name)
420 if (self::$deleteOnExit === false) {
421 register_shutdown_function(array('Pman','deleteOnExit'));
422 self::$deleteOnExit = array();
424 self::$deleteOnExit[] = $name;
427 function tempName($ext, $deleteOnExit=false)
430 $x = tempnam(ini_get('session.save_path'), HTML_FlexyFramework::get()->appNameShort.'TMP');
432 $ret = $x .'.'. $ext;
434 $this->deleteOnExitAdd($ret);
440 static function deleteOnExit()
443 foreach(self::$deleteOnExit as $fn) {
444 if (file_exists($fn)) {
451 * ------------- Authentication password reset ------ ??? MOVEME?
459 * jerrAuth: standard auth failure - with data that let's the UI know..
463 $au = $this->authUser;
465 // is it an authfailure?
466 $this->jerr("Permission denied to view this resource", array('authFailure' => true));
468 $this->jerr("Not authenticated", array('authFailure' => true));
474 * ---------------- Standard JSON outputers. - used everywhere
477 * ---------------- Standard JSON outputers. - used everywhere
478 * JSON error - simple error with logging.
482 function jerr($str, $errors=array(), $content_type = false) // standard error reporting..
484 return $this->jerror('ERROR', $str,$errors,$content_type);
487 * Recomended JSON error indicator
490 * @param string $type - normally 'ERROR' - you can use this to track error types.
491 * @param string $message - error message displayed to user.
492 * @param array $errors - optioanl data to pass to front end.
493 * @param string $content_type - use text/plain to return plan text - ?? not sure why...
497 function jerror($type, $str, $errors=array(), $content_type = false) // standard error reporting..
499 if ($this->transObj) {
500 $this->transObj->query('ROLLBACK');
503 $cli = HTML_FlexyFramework::get()->cli;
505 echo "ERROR: " .$str . "\n"; // print the error first, as DB might fail..
508 if ($type !== false) {
511 DB_DataObject::factory('Events')->writeEventLogExtra($errors);
514 $this->addEvent($type, false, $str);
518 $cli = HTML_FlexyFramework::get()->cli;
520 exit(1); // cli --- exit code to stop shell execution if necessary.
524 if ($content_type == 'text/plain') {
525 header('Content-Disposition: attachment; filename="error.txt"');
526 header('Content-type: '. $content_type);
527 echo "ERROR: " .$str . "\n";
533 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
534 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
537 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
541 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
546 header('Content-type: text/html');
547 echo "<HTML><HEAD></HEAD><BODY>";
548 echo $this->jsencode(array(
551 'message' => $str, // compate with exeption / loadexception.
553 'errors' => $errors ? $errors : true, // used by forms to flag errors.
554 'authFailure' => !empty($errors['authFailure']),
556 echo "</BODY></HTML>";
560 if (isset($_REQUEST['_debug'])) {
561 echo '<PRE>'.htmlspecialchars(print_r(array(
565 'message' => $str, // compate with exeption / loadexception.
566 'errors' => $errors ? $errors : true, // used by forms to flag errors.
567 'authFailure' => !empty($errors['authFailure']),
573 echo $this->jsencode(array(
578 'message' => $str, // compate with exeption / loadexception.
579 'errors' => $errors ? $errors : true, // used by forms to flag errors.
580 'authFailure' => !empty($errors['authFailure']),
589 if ($this->transObj ) {
590 $this->transObj->query( connection_aborted() ? 'ROLLBACK' : 'COMMIT');
593 $cli = HTML_FlexyFramework::get()->cli;
595 echo "OK: " .$str . "\n";
599 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
600 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
603 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
607 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
611 header('Content-type: text/html');
612 echo "<HTML><HEAD></HEAD><BODY>";
613 // encode html characters so they can be read..
614 echo str_replace(array('<','>'), array('\u003c','\u003e'),
615 $this->jsencode(array('success'=> true, 'data' => $str), false));
616 echo "</BODY></HTML>";
621 echo $this->jsencode(array('success'=> true, 'data' => $str),true);
627 * output data for grids or tree
628 * @ar {Array} ar Array of data
629 * @total {Number|false} total number of records (or false to return count(ar)
630 * @extra {Array} extra key value list of data to pass as extra data.
633 function jdata($ar,$total=false, $extra=array(), $cachekey = false)
635 // should do mobile checking???
636 if ($total == false) {
639 $extra= $extra ? $extra : array();
642 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
643 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
646 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
650 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
655 header('Content-type: text/html');
656 echo "<HTML><HEAD></HEAD><BODY><![CDATA[";
657 // encode html characters so they can be read..
658 echo str_replace(array('<','>'), array('\u003c','\u003e'),
659 $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra, false));
660 echo "]]></BODY></HTML>";
665 // see if trimming will help...
666 if (!empty($_REQUEST['_pman_short'])) {
669 foreach($ar as $as) {
671 foreach($as as $k=>$v) {
672 if (is_string($v) && !strlen(trim($v))) {
684 $ret = $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra,true);
686 if (!empty($cachekey)) {
688 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
689 if (!file_exists(dirname($fn))) {
690 mkdir(dirname($fn), 0777,true);
692 file_put_contents($fn, $ret);
701 /** a daily cache **/
702 function jdataCache($cachekey)
704 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
705 if (file_exists($fn)) {
706 header('Content-type: application/json');
707 echo file_get_contents($fn);
717 * ---------------- OUTPUT
719 function hasBg($fn) // used on front page to check if logos exist..
721 return file_exists($this->rootDir.'/Pman/'.$this->appNameShort.'/templates/images/'. $fn);
724 * outputJavascriptIncludes:
726 * output <script....> for all the modules in the applcaiton
729 function outputJavascriptIncludes()
731 // BC support - currently 1 project still relies on this.. (MO portal)
732 $ff = HTML_FlexyFramework::get();
733 $o = isset($ff->Pman_Core) ? $ff->Pman_Core : array();
734 if (isset($o['packseed'])) {
735 return $this->outputJavascriptIncludesBC();
739 $mods = $this->modulesList();
741 $is_bootstrap = in_array('BAdmin', $mods);
743 foreach($mods as $mod) {
744 // add the css file..
747 if (!file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
748 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
754 $this->outputJavascriptDir("Pman/$mod/widgets", "*.js");
755 $this->outputJavascriptDir("Pman/$mod", "*.js");
759 if (empty($this->disable_jstemplate)) {
760 // and finally the JsTemplate...
761 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
764 $this->callModules('outputJavascriptIncludes', $this);
767 var $css_includes = array();
771 * output <link rel=stylesheet......> for all the modules in the applcaiton
774 * This could css minify as well.
776 function outputCSSIncludes() // includes on CSS links.
780 $mods = $this->modulesList();
781 $is_bootstrap = in_array('BAdmin', $mods);
783 $this->callModules('applyCSSIncludes', $this);
784 foreach($this->css_includes as $module => $ar) {
787 $this->assetArrayToHtml( $ar , 'css');
791 // old style... - probably remove this...
792 $this->callModules('outputCSSIncludes', $this);
794 foreach($mods as $mod) {
795 // add the css file..
796 if ($is_bootstrap && !file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
797 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
800 $this->outputCSSDir("Pman/$mod","*.css");
802 $this->outputSCSS($mod);
806 return ''; // needs to return something as we output it..
819 // --- OLD CODE - in for BC on MO project.... - needs removing...
821 // used on old versions.....
822 function outputJavascriptIncludesBC()
825 $mods = $this->modulesList();
827 foreach($mods as $mod) {
828 // add the css file..
831 $files = $this->moduleJavascriptList($mod.'/widgets');
832 foreach($files as $f) {
833 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
836 $files = $this->moduleJavascriptList($mod);
837 foreach($files as $f) {
838 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
842 if (empty($this->disable_jstemplate)) {
843 // and finally the JsTemplate...
844 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
849 * Gather infor for javascript files..
851 * @param {String} $mod the module to get info about.
852 * @return {StdClass} details about module.
854 function moduleJavascriptFilesInfo($mod)
857 static $cache = array();
859 if (isset($cache[$mod])) {
864 $ff = HTML_FlexyFramework::get();
866 $base = dirname($_SERVER['SCRIPT_FILENAME']);
867 $dir = $this->rootDir.'/Pman/'. $mod;
868 $path = $this->rootURL ."/Pman/$mod/";
870 $ar = glob($dir . '/*.js');
876 foreach($ar as $fn) {
878 // got the 'module file..'
879 $mtime = filemtime($dir . '/'. $f);
880 $maxtime = max($mtime, $maxtime);
881 $arfiles[$fn] = $mtime;
882 $files[] = $path . $f . '?ts='.$mtime;
885 ksort($arfiles); // just sort by name so it's consistant for serialize..
887 // The original idea of this was to serve the files direct from a publicly available 'cache' directory.
888 // but that doesnt really make sense - as we can just serve it from the session directory where we stick
889 // cached data anyway.
892 $compile = empty($ff->Pman['public_cache_dir']) ? 0 : 1;
893 $basedir = $compile ? $ff->Pman['public_cache_dir'] : false;
894 $baseurl = $compile ? $ff->Pman['public_cache_url'] : false;
898 $basedir = session_save_path(). '/translate-cache/';
899 if (!file_exists($basedir)) {
900 mkdir($basedir,0755);
902 $baseurl = $this->baseURL . '/Admin/Translations';
904 if (PHP_VERSION_ID < 70000 ) {
905 $lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
906 usort($files, $lsort);
908 usort($files, function($a,$b) { return strlen($a) > strlen($b) ? 1 : -1; });
911 $smod = str_replace('/','.',$mod);
913 $output = date('Y-m-d-H-i-s-', $maxtime). $smod .'-'.md5(serialize($arfiles)) .'.js';
916 // why are translations done like this - we just build them on the fly frmo the database..
917 $tmtime = file_exists($this->rootDir.'/_translations_/'. $smod.'.js')
918 ? filemtime($this->rootDir.'/_translations_/'. $smod.'.js') : 0;
920 $cache[$mod] = (object) array(
921 'smod' => $smod, // module name without '/'
922 'files' => $files, // list of all files.
923 'filesmtime' => $arfiles, // map of mtime=>file
924 'maxtime' => $maxtime, // max mtime
925 'compile' => $this->isDev ? false : $compile,
926 'translation_file' => $base .'/_translations_/' . $smod . '.js',
927 'translation_mtime' => $tmtime,
929 'translation_data' => preg_replace('/\.js$/', '.__translation__.js', $output),
930 'translation_base' => $dir .'/', //prefix of filename (without moudle name))
931 'basedir' => $basedir,
932 'baseurl' => $baseurl,
933 'module_dir' => $dir,
940 * moduleJavascriptList: list the javascript files in a module
942 * The original version of this.. still needs more thought...
944 * Compiled is in Pman/_compiled_/{$mod}/{LATEST...}.js
945 * Translations are in Pman/_translations_/{$mod}.js
947 * if that stuff does not exist just list files in Pman/{$mod}/*.js
949 * Compiled could be done on the fly..
953 * @param {String} $mod the module to look at - eg. Pman/{$mod}/*.js
954 * @return {Array} list of include paths (either compiled or raw)
960 function moduleJavascriptList($mod)
964 $dir = $this->rootDir.'/Pman/'. $mod;
967 if (!file_exists($dir)) {
968 echo '<!-- missing directory '. htmlspecialchars($dir) .' -->';
972 $info = $this->moduleJavascriptFilesInfo($mod);
976 if (empty($info->files)) {
979 // finally sort the files, so they are in the right order..
981 // only compile this stuff if public_cache is set..
985 // public_cache_dir = /var/www/myproject_cache
986 // public_cache_url = /myproject_cache (with Alias apache /myproject_cache/ /var/www/myproject_cache/)
989 if (!$info->compile) {
990 echo "<!-- Javascript compile turned off (isDev on, or public_cache_dir not set) -->\n";
994 // where are we going to write all of this..
995 // This has to be done via a
996 if (!file_exists($info->basedir.'/'.$info->output) || !filesize($info->basedir.'/'.$info->output)) {
997 require_once 'Pman/Core/JsCompile.php';
998 $x = new Pman_Core_JsCompile();
1000 $x->pack($info->filesmtime,$info->basedir.'/'.$info->output, $info->translation_base);
1002 echo "<!-- file exists not exist: {$info->basedir}/{$info->output} -->\n";
1005 if (file_exists($info->basedir.'/'.$info->output) &&
1006 filesize($info->basedir.'/'.$info->output)) {
1009 $info->baseurl.'/'. $info->output,
1012 // output all the ava
1013 // fixme - this needs the max datetime for the translation file..
1014 $ret[] = $this->baseURL."/Admin/InterfaceTranslations/".$mod.".js"; //?ts=".$info->translation_mtime;
1016 //if ($info->translation_mtime) {
1017 // $ret[] = $this->rootURL."/_translations_/". $info->smod.".js?ts=".$info->translation_mtime;
1024 // give up and output original files...
1027 return $info->files;
1034 * PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1036 function initErrorHandling()
1038 if (!class_exists('HTML_FlexyFramework2')) {
1039 // what about older code that still users PEAR?
1040 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1042 set_exception_handler(array($this,'onException'));
1047 static $permitError = false; // static why?
1049 var $showErrorToUser = true;
1051 function onPearError($err)
1053 return $this->onException($err);
1058 function onException($ex)
1060 static $reported = false;
1065 if (Pman::$permitError) {
1072 $out = is_a($ex,'Exception') || is_a($ex, 'Error') ? $ex->getMessage() : $ex->toString();
1075 //print_R($bt); exit;
1078 $bt = is_a($ex,'Exception')|| is_a($ex, 'Error') ? $ex->getTrace() : $ex->backtrace;
1079 if (is_a($ex,'Exception')|| is_a($ex, 'Error') ) {
1080 $ret[] = $ex->getFile() . '('. $ex->getLine() . ')';
1082 foreach( $bt as $b) {
1083 $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
1089 //convert the huge backtrace into something that is readable..
1090 $out .= "\n" . implode("\n", $ret);
1092 $this->addEvent("EXCEPTION", false, $out);
1094 if ($this->showErrorToUser) {
1097 // not sure why this is here... - perhaps doing a jerr() was actually caught by the UI, and hidden from the user..?
1098 $this->jerror(false,"An error Occured, please contact the website owner");
1100 //$this->jerr($out);
1107 * ---------------- Logging ---------------
1112 * Log an action (only if it has not been logged already.
1114 * @param {String} action - group/name of event
1115 * @param {DataObject|false} obj - dataobject action occured on.
1116 * @param {String} any remarks
1117 * @return {false|DB_DataObject} Event object.,
1120 function addEventOnce($act, $obj = false, $remarks = '')
1122 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1125 $e = DB_DataObject::factory('Events');
1126 $e->init($act,$obj,$remarks);
1127 if ($e->find(true)) {
1130 return $this->addEvent($act, $obj, $remarks);
1136 * @param {String} action - group/name of event
1137 * @param {DataObject|false} obj - dataobject action occured on.
1138 * @param {String} any remarks
1139 * @return {DB_DataObject} Event object.,
1142 function addEvent($act, $obj = false, $remarks = '')
1145 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1148 $au = $this->getAuthUser();
1150 $e = DB_DataObject::factory('Events');
1151 $e->init($act,$obj,$remarks);
1153 $e->event_when = $e->sqlValue('NOW()');
1155 $eid = $e->insert();
1157 // fixme - this should be in onInsert..
1158 $wa = DB_DataObject::factory('core_watch');
1159 if (method_exists($wa,'notifyEvent')) {
1160 $wa->notifyEvent($e); // trigger any actions..
1164 $e->onInsert(isset($_REQUEST) ? $_REQUEST : array() , $this);
1171 function addEventNotifyOnly($act, $obj = false, $remarks = '')
1173 $au = $this->getAuthUser();
1175 $e = DB_DataObject::factory('Events');
1176 $e->init($act,$obj,$remarks);
1178 $e->event_when = $e->sqlValue('NOW()');
1179 $wa = DB_DataObject::factory('core_watch');
1180 if (method_exists($wa,'notifyEvent')) {
1181 $wa->notifyEvent($e); // trigger any actions..
1186 // ------------------ DEPERCIATED ----------------------------
1188 // DEPRECITAED - use moduleslist
1189 function modules() { return $this->modulesList(); }
1192 // DEPRICATED USE Pman_Core_Mailer
1194 function emailTemplate($templateFile, $args)
1197 require_once 'Pman/Core/Mailer.php';
1198 $r = new Pman_Core_Mailer(array(
1199 'template'=>$templateFile,
1200 'contents' => $args,
1203 return $r->toData();
1206 // DEPRICATED - USE Pman_Core_Mailer
1207 // WHAT Part about DEPRICATED Does no one understand??
1208 function sendTemplate($templateFile, $args)
1210 require_once 'Pman/Core/Mailer.php';
1211 $r = new Pman_Core_Mailer(array(
1212 'template'=>$templateFile,
1213 'contents' => array(),