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;
74 * ------------- Standard getAuth/get/post methods of framework.
79 function getAuth() // everyone allowed in!!!!!
81 $this->loadOwnerCompany();
86 function init($base = false)
89 if (isset($this->_hasInit)) {
92 $this->_hasInit = true;
93 // move away from doing this ... you can access bootLoader.XXXXXX in the master template..
94 $boot = HTML_FlexyFramework::get();
95 // echo'<PRE>';print_R($boot);exit;
96 $this->appName = $boot->appName;
98 $this->appNameShort = $boot->appNameShort;
100 $this->appModules = $boot->enable;
102 // echo $this->arrayToJsInclude($files);
103 $this->isDev = empty($boot->Pman['isDev']) ? false : $boot->Pman['isDev'];
105 $this->css_path = empty($boot->Pman['css_path']) ? '' : $boot->Pman['css_path'];
107 $this->appDisable = $boot->disable;
108 $this->appDisabled = explode(',', $boot->disable);
109 $this->version = $boot->version;
110 $this->uiConfig = empty($boot->Pman['uiConfig']) ? false : $boot->Pman['uiConfig'];
112 if (!empty($boot->Pman['local_autoauth']) &&
113 !empty($_SERVER['SERVER_ADDR']) &&
114 !empty($_SERVER['REMOTE_ADDR']) &&
115 ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
116 ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')
122 !empty($_REQUEST['isDev'])
126 !empty($_SERVER['SERVER_ADDR']) &&
128 (($_SERVER['SERVER_ADDR'] == '127.0.0.1') && ($_SERVER['REMOTE_ADDR'] == '127.0.0.1'))
130 (($_SERVER['SERVER_ADDR'] == '::1') && ($_SERVER['REMOTE_ADDR'] == '::1'))
134 !empty($boot->Pman['enable_isdev_url'])
138 $boot->Pman['isDev'] = true;
142 // if a file Pman_{module}_Pman exists.. and it has an init function... - call that..
144 //var_dump($this->appModules);
150 * call a method on {module}/Pman.php
151 * * initially used on the main page load to call init();
152 * * also used for ccsIncludes??
154 * // usage: $this->callModules('init', $base)
158 function callModules($fn)
160 $args = func_get_args();
162 foreach(explode(',',$this->appModules) as $m) {
163 $cls = 'Pman_'. $m . '_Pman';
164 if (!file_exists($this->rootDir . '/'.str_replace('_','/', $cls). '.php')) {
167 require_once str_replace('_','/', $cls). '.php';
169 if (method_exists($c, $fn)) {
170 call_user_func_array(array($c,$fn),$args);
176 function get($base, $opts=array())
180 $this->callModules('init', $this, $base);
183 //$this->allowSignup= empty($opts['allowSignup']) ? 0 : 1;
184 $bits = explode('/', $base);
187 // should really be moved to Login...
189 if ($bits[0] == 'PasswordReset') {
190 $this->linkFail = $this->resetPassword(@$bits[1],@$bits[2],@$bits[3]);
191 header('Content-type: text/html; charset=utf-8');
196 $au = $this->getAuthUser();
198 $ff= HTML_FlexyFramework::get();
200 if (!empty($ff->Pman['auth_comptype']) && $au->id > 0 &&
201 ( !$au->company_id || ($ff->Pman['auth_comptype'] != $au->company()->comptype))) {
205 $this->jerr("Login not permited to outside companies - please reload");
207 $this->addEvent("RELOAD");
211 if (strlen($base) && $bits[0] != 'PasswordReset') {
212 $this->jerror("BADURL","invalid url: $base");
215 if (isset($_GET['onloadTrack'])) {
216 $this->onloadTrack = (int)$_GET['onloadTrack'];
218 // getting this to work with xhtml is a nightmare
219 // = nbsp / <img> issues screw everyting up.
220 //var_dump($this->isDev);
221 // force regeneration on load for development enviroments..
223 HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
225 //header('Content-type: application/xhtml+xml; charset=utf-8');
229 if ($this->company && $this->company->logo_id) {
230 $im = DB_DataObject::Factory('Images');
231 $im->get($this->company->logo_id);
232 $this->appLogo = $this->baseURL . '/Images/Thumb/x100/'. $this->company->logo_id .'/' . $im->filename;
235 header('Content-type: text/html; charset=utf-8');
238 function post($base) {
239 return $this->get($base);
243 // --------------- AUTHENTICATION or system information
246 * finds the compay with comptype=='OWNER'
247 * ?? what about comptype_id-name ?????
249 * @return {Pman_Core_DataObjects_Companies} the owner company
251 function loadOwnerCompany()
253 // only applies if authtable is person..
254 $ff = HTML_FlexyFramework::get();
255 if (!empty($ff->Pman['authTable']) && !in_array($ff->Pman['authTable'] , [ 'core_person', 'Person' ])) {
259 $this->company = DB_DataObject::Factory('core_company');
260 if (!is_a($this->company, 'DB_DataObject')) { // non-core pman projects
263 $e = DB_DataObject::Factory('core_enum')->lookupObject('COMPTYPE', 'OWNER');
265 $this->company->get('comptype_id', $e->id);
266 return $this->company;
270 static function staticGetAuthUser($t) {
271 if (!empty($t->authUser)) {
274 $ff = HTML_FlexyFramework::get();
275 $tbl = empty($ff->Pman['authTable']) ? 'core_person' : $ff->Pman['authTable'];
277 $u = DB_DataObject::factory( $tbl );
279 if (is_a($u,'PEAR_Error') || !$u->isAuth()) {
282 $t->authUser =$u->getAuthUser();
283 return $t->authUser ;
288 * getAuthUser: - get the authenticated user..
290 * @return {DB_DataObject} of type Pman[authTable] if authenticated.
293 function getAuthUser()
295 return self::staticGetAuthUser($this);
299 * wrapper arround authuser->hasPerm
300 * @see Pman_Core_DataObject_Core_person::hasPerm
302 * @param {String} $name The permission name (eg. Projects.List)
303 * @param {String} $lvl eg. (C)reate (E)dit (D)elete ... etc.
306 function hasPerm($name, $lvl) // do we have a permission
308 static $pcache = array();
309 $au = $this->getAuthUser();
310 return $au && $au->hasPerm($name,$lvl);
314 * modulesList: List the modules in the application
316 * @return {Array} list of modules
318 function modulesList()
320 $boot = HTML_FlexyFramework::get();
321 // echo'<PRE>';print_R($boot);exit;
324 $mods = explode(',', $boot->enable);
325 if (in_array('Core',$mods)) { // core has to be the first modules loaded as it contains Pman.js
326 array_unshift($mods, 'Core');
329 if (in_array($boot->appNameShort,$mods)) { // Project has to be the last modules loaded as it contains Pman.js
330 unset($mods[array_search($boot->appNameShort, $mods)]);
331 $mods[] = $boot->appNameShort;
334 $mods = array_unique($mods);
336 $disabled = explode(',', $boot->disable ? $boot->disable : '');
338 foreach($mods as $mod) {
339 // add the css file..
340 if (in_array($mod, $disabled)) {
351 function hasModule($name)
354 if (!strpos( $name,'.') ) {
355 // use enable / disable..
356 return in_array($name, $this->modules());
359 $x = DB_DataObject::factory('core_group_right');
360 $ar = $x->defaultPermData();
361 if (empty($ar[$name]) || empty($ar[$name][0])) {
369 function jsencode($v, $header = false)
372 header("Content-type: text/javascript");
374 if (function_exists("json_encode")) {
375 $ret= json_encode($v);
376 if ($ret !== false) {
380 require_once 'Services/JSON.php';
381 $js = new Services_JSON();
382 return $js->encodeUnsafe($v);
391 * ---------------- Global Tools ---------------
393 function checkFileUploadError() // check for file upload errors.
396 empty($_FILES['File'])
397 || empty($_FILES['File']['name'])
398 || empty($_FILES['File']['tmp_name'])
399 || empty($_FILES['File']['type'])
400 || !empty($_FILES['File']['error'])
401 || empty($_FILES['File']['size'])
403 $this->jerr("File upload error: <PRE>" . print_r($_FILES,true) . print_r($_POST,true) . "</PRE>");
407 static $deleteOnExit = false;
409 * generate a tempory file with an extension (dont forget to delete it)
412 function deleteOnExitAdd($name)
414 if (self::$deleteOnExit === false) {
415 register_shutdown_function(array('Pman','deleteOnExit'));
416 self::$deleteOnExit = array();
418 self::$deleteOnExit[] = $name;
421 function tempName($ext, $deleteOnExit=false)
424 $x = tempnam(ini_get('session.save_path'), HTML_FlexyFramework::get()->appNameShort.'TMP');
426 $ret = $x .'.'. $ext;
428 $this->deleteOnExitAdd($ret);
434 static function deleteOnExit()
437 foreach(self::$deleteOnExit as $fn) {
438 if (file_exists($fn)) {
445 * ------------- Authentication password reset ------ ??? MOVEME?
453 * jerrAuth: standard auth failure - with data that let's the UI know..
457 $au = $this->authUser();
459 // is it an authfailure?
460 $this->jerr("Permission denied to view this resource", array('authFailure' => true));
462 $this->jerr("Not authenticated", array('authFailure' => true));
468 * ---------------- Standard JSON outputers. - used everywhere
471 * ---------------- Standard JSON outputers. - used everywhere
472 * JSON error - simple error with logging.
476 function jerr($str, $errors=array(), $content_type = false) // standard error reporting..
478 return $this->jerror('ERROR', $str,$errors,$content_type);
481 * Recomended JSON error indicator
484 * @param string $type - normally 'ERROR' - you can use this to track error types.
485 * @param string $message - error message displayed to user.
486 * @param array $errors - optioanl data to pass to front end.
487 * @param string $content_type - use text/plain to return plan text - ?? not sure why...
491 function jerror($type, $str, $errors=array(), $content_type = false) // standard error reporting..
493 if ($this->transObj) {
494 $this->transObj->query('ROLLBACK');
497 $cli = HTML_FlexyFramework::get()->cli;
499 echo "ERROR: " .$str . "\n"; // print the error first, as DB might fail..
502 if ($type !== false) {
505 DB_DataObject::factory('Events')->writeEventLogExtra($errors);
508 $this->addEvent($type, false, $str);
512 $cli = HTML_FlexyFramework::get()->cli;
514 exit(1); // cli --- exit code to stop shell execution if necessary.
518 if ($content_type == 'text/plain') {
519 header('Content-Disposition: attachment; filename="error.txt"');
520 header('Content-type: '. $content_type);
521 echo "ERROR: " .$str . "\n";
527 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
528 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
531 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
535 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
540 header('Content-type: text/html');
541 echo "<HTML><HEAD></HEAD><BODY>";
542 echo $this->jsencode(array(
545 'message' => $str, // compate with exeption / loadexception.
547 'errors' => $errors ? $errors : true, // used by forms to flag errors.
548 'authFailure' => !empty($errors['authFailure']),
550 echo "</BODY></HTML>";
554 if (isset($_REQUEST['_debug'])) {
555 echo '<PRE>'.htmlspecialchars(print_r(array(
559 'message' => $str, // compate with exeption / loadexception.
560 'errors' => $errors ? $errors : true, // used by forms to flag errors.
561 'authFailure' => !empty($errors['authFailure']),
567 echo $this->jsencode(array(
572 'message' => $str, // compate with exeption / loadexception.
573 'errors' => $errors ? $errors : true, // used by forms to flag errors.
574 'authFailure' => !empty($errors['authFailure']),
583 if ($this->transObj ) {
584 $this->transObj->query( connection_aborted() ? 'ROLLBACK' : 'COMMIT');
587 $cli = HTML_FlexyFramework::get()->cli;
589 echo "OK: " .$str . "\n";
593 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
594 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
597 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
601 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
605 header('Content-type: text/html');
606 echo "<HTML><HEAD></HEAD><BODY>";
607 // encode html characters so they can be read..
608 echo str_replace(array('<','>'), array('\u003c','\u003e'),
609 $this->jsencode(array('success'=> true, 'data' => $str), false));
610 echo "</BODY></HTML>";
615 echo $this->jsencode(array('success'=> true, 'data' => $str),true);
621 * output data for grids or tree
622 * @ar {Array} ar Array of data
623 * @total {Number|false} total number of records (or false to return count(ar)
624 * @extra {Array} extra key value list of data to pass as extra data.
627 function jdata($ar,$total=false, $extra=array(), $cachekey = false)
629 // should do mobile checking???
630 if ($total == false) {
633 $extra= $extra ? $extra : array();
636 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
637 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
640 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
644 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
649 header('Content-type: text/html');
650 echo "<HTML><HEAD></HEAD><BODY>";
651 // encode html characters so they can be read..
652 echo str_replace(array('<','>'), array('\u003c','\u003e'),
653 $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra, false));
654 echo "</BODY></HTML>";
659 // see if trimming will help...
660 if (!empty($_REQUEST['_pman_short'])) {
663 foreach($ar as $as) {
665 foreach($as as $k=>$v) {
666 if (is_string($v) && !strlen(trim($v))) {
678 $ret = $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra,true);
680 if (!empty($cachekey)) {
682 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
683 if (!file_exists(dirname($fn))) {
684 mkdir(dirname($fn), 0777,true);
686 file_put_contents($fn, $ret);
695 /** a daily cache **/
696 function jdataCache($cachekey)
698 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
699 if (file_exists($fn)) {
700 header('Content-type: application/json');
701 echo file_get_contents($fn);
711 * ---------------- OUTPUT
713 function hasBg($fn) // used on front page to check if logos exist..
715 return file_exists($this->rootDir.'/Pman/'.$this->appNameShort.'/templates/images/'. $fn);
718 * outputJavascriptIncludes:
720 * output <script....> for all the modules in the applcaiton
723 function outputJavascriptIncludes()
725 // BC support - currently 1 project still relies on this.. (MO portal)
726 $ff = HTML_FlexyFramework::get();
727 $o = isset($ff->Pman_Core) ? $ff->Pman_Core : array();
728 if (isset($o['packseed'])) {
729 return $this->outputJavascriptIncludesBC();
733 $mods = $this->modulesList();
735 $is_bootstrap = in_array('BAdmin', $mods);
737 foreach($mods as $mod) {
738 // add the css file..
741 if (!file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
742 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
748 $this->outputJavascriptDir("Pman/$mod/widgets", "*.js");
749 $this->outputJavascriptDir("Pman/$mod", "*.js");
753 if (empty($this->disable_jstemplate)) {
754 // and finally the JsTemplate...
755 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
758 $this->callModules('outputJavascriptIncludes', $this);
761 var $css_includes = array();
765 * output <link rel=stylesheet......> for all the modules in the applcaiton
768 * This could css minify as well.
770 function outputCSSIncludes() // includes on CSS links.
774 $mods = $this->modulesList();
775 $is_bootstrap = in_array('BAdmin', $mods);
777 $this->callModules('applyCSSIncludes', $this);
778 foreach($this->css_includes as $module => $ar) {
781 $this->assetArrayToHtml( $ar , 'css');
785 // old style... - probably remove this...
786 $this->callModules('outputCSSIncludes', $this);
788 foreach($mods as $mod) {
789 // add the css file..
790 if ($is_bootstrap && !file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
791 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
794 $this->outputCSSDir("Pman/$mod","*.css");
795 $this->outputSCSS($mod);
818 // --- OLD CODE - in for BC on MO project.... - needs removing...
820 // used on old versions.....
821 function outputJavascriptIncludesBC()
824 $mods = $this->modulesList();
826 foreach($mods as $mod) {
827 // add the css file..
830 $files = $this->moduleJavascriptList($mod.'/widgets');
831 foreach($files as $f) {
832 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
835 $files = $this->moduleJavascriptList($mod);
836 foreach($files as $f) {
837 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
841 if (empty($this->disable_jstemplate)) {
842 // and finally the JsTemplate...
843 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
848 * Gather infor for javascript files..
850 * @param {String} $mod the module to get info about.
851 * @return {StdClass} details about module.
853 function moduleJavascriptFilesInfo($mod)
856 static $cache = array();
858 if (isset($cache[$mod])) {
863 $ff = HTML_FlexyFramework::get();
865 $base = dirname($_SERVER['SCRIPT_FILENAME']);
866 $dir = $this->rootDir.'/Pman/'. $mod;
867 $path = $this->rootURL ."/Pman/$mod/";
869 $ar = glob($dir . '/*.js');
875 foreach($ar as $fn) {
877 // got the 'module file..'
878 $mtime = filemtime($dir . '/'. $f);
879 $maxtime = max($mtime, $maxtime);
880 $arfiles[$fn] = $mtime;
881 $files[] = $path . $f . '?ts='.$mtime;
884 ksort($arfiles); // just sort by name so it's consistant for serialize..
886 // The original idea of this was to serve the files direct from a publicly available 'cache' directory.
887 // but that doesnt really make sense - as we can just serve it from the session directory where we stick
888 // cached data anyway.
891 $compile = empty($ff->Pman['public_cache_dir']) ? 0 : 1;
892 $basedir = $compile ? $ff->Pman['public_cache_dir'] : false;
893 $baseurl = $compile ? $ff->Pman['public_cache_url'] : false;
897 $basedir = session_save_path(). '/translate-cache/';
898 if (!file_exists($basedir)) {
899 mkdir($basedir,0755);
901 $baseurl = $this->baseURL . '/Admin/Translations';
903 if (PHP_VERSION_ID < 70000 ) {
904 $lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
905 usort($files, $lsort);
907 usort($files, function($a,$b) { return strlen($a) > strlen($b) ? 1 : -1; });
910 $smod = str_replace('/','.',$mod);
912 $output = date('Y-m-d-H-i-s-', $maxtime). $smod .'-'.md5(serialize($arfiles)) .'.js';
915 // why are translations done like this - we just build them on the fly frmo the database..
916 $tmtime = file_exists($this->rootDir.'/_translations_/'. $smod.'.js')
917 ? filemtime($this->rootDir.'/_translations_/'. $smod.'.js') : 0;
919 $cache[$mod] = (object) array(
920 'smod' => $smod, // module name without '/'
921 'files' => $files, // list of all files.
922 'filesmtime' => $arfiles, // map of mtime=>file
923 'maxtime' => $maxtime, // max mtime
924 'compile' => $this->isDev ? false : $compile,
925 'translation_file' => $base .'/_translations_/' . $smod . '.js',
926 'translation_mtime' => $tmtime,
928 'translation_data' => preg_replace('/\.js$/', '.__translation__.js', $output),
929 'translation_base' => $dir .'/', //prefix of filename (without moudle name))
930 'basedir' => $basedir,
931 'baseurl' => $baseurl,
932 'module_dir' => $dir,
939 * moduleJavascriptList: list the javascript files in a module
941 * The original version of this.. still needs more thought...
943 * Compiled is in Pman/_compiled_/{$mod}/{LATEST...}.js
944 * Translations are in Pman/_translations_/{$mod}.js
946 * if that stuff does not exist just list files in Pman/{$mod}/*.js
948 * Compiled could be done on the fly..
952 * @param {String} $mod the module to look at - eg. Pman/{$mod}/*.js
953 * @return {Array} list of include paths (either compiled or raw)
959 function moduleJavascriptList($mod)
963 $dir = $this->rootDir.'/Pman/'. $mod;
966 if (!file_exists($dir)) {
967 echo '<!-- missing directory '. htmlspecialchars($dir) .' -->';
971 $info = $this->moduleJavascriptFilesInfo($mod);
975 if (empty($info->files)) {
978 // finally sort the files, so they are in the right order..
980 // only compile this stuff if public_cache is set..
984 // public_cache_dir = /var/www/myproject_cache
985 // public_cache_url = /myproject_cache (with Alias apache /myproject_cache/ /var/www/myproject_cache/)
988 if (!$info->compile) {
989 echo "<!-- Javascript compile turned off (isDev on, or public_cache_dir not set) -->\n";
993 // where are we going to write all of this..
994 // This has to be done via a
995 if (!file_exists($info->basedir.'/'.$info->output) || !filesize($info->basedir.'/'.$info->output)) {
996 require_once 'Pman/Core/JsCompile.php';
997 $x = new Pman_Core_JsCompile();
999 $x->pack($info->filesmtime,$info->basedir.'/'.$info->output, $info->translation_base);
1001 echo "<!-- file exists not exist: {$info->basedir}/{$info->output} -->\n";
1004 if (file_exists($info->basedir.'/'.$info->output) &&
1005 filesize($info->basedir.'/'.$info->output)) {
1008 $info->baseurl.'/'. $info->output,
1011 // output all the ava
1012 // fixme - this needs the max datetime for the translation file..
1013 $ret[] = $this->baseURL."/Admin/InterfaceTranslations/".$mod.".js"; //?ts=".$info->translation_mtime;
1015 //if ($info->translation_mtime) {
1016 // $ret[] = $this->rootURL."/_translations_/". $info->smod.".js?ts=".$info->translation_mtime;
1023 // give up and output original files...
1026 return $info->files;
1033 * PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1035 function initErrorHandling()
1037 if (!class_exists('HTML_FlexyFramework2')) {
1038 // what about older code that still users PEAR?
1039 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1041 set_exception_handler(array($this,'onException'));
1046 static $permitError = false; // static why?
1048 var $showErrorToUser = true;
1050 function onPearError($err)
1052 return $this->onException($err);
1057 function onException($ex)
1059 static $reported = false;
1064 if (Pman::$permitError) {
1071 $out = is_a($ex,'Exception') || is_a($ex, 'Error') ? $ex->getMessage() : $ex->toString();
1074 //print_R($bt); exit;
1077 $bt = is_a($ex,'Exception')|| is_a($ex, 'Error') ? $ex->getTrace() : $ex->backtrace;
1078 if (is_a($ex,'Exception')|| is_a($ex, 'Error') ) {
1079 $ret[] = $ex->getFile() . '('. $ex->getLine() . ')';
1081 foreach( $bt as $b) {
1082 $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
1088 //convert the huge backtrace into something that is readable..
1089 $out .= "\n" . implode("\n", $ret);
1091 $this->addEvent("EXCEPTION", false, $out);
1093 if ($this->showErrorToUser) {
1096 // not sure why this is here... - perhaps doing a jerr() was actually caught by the UI, and hidden from the user..?
1097 $this->jerror(false,"An error Occured, please contact the website owner");
1099 //$this->jerr($out);
1106 * ---------------- Logging ---------------
1111 * Log an action (only if it has not been logged already.
1113 * @param {String} action - group/name of event
1114 * @param {DataObject|false} obj - dataobject action occured on.
1115 * @param {String} any remarks
1116 * @return {false|DB_DataObject} Event object.,
1119 function addEventOnce($act, $obj = false, $remarks = '')
1121 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1124 $e = DB_DataObject::factory('Events');
1125 $e->init($act,$obj,$remarks);
1126 if ($e->find(true)) {
1129 return $this->addEvent($act, $obj, $remarks);
1135 * @param {String} action - group/name of event
1136 * @param {DataObject|false} obj - dataobject action occured on.
1137 * @param {String} any remarks
1138 * @return {DB_DataObject} Event object.,
1141 function addEvent($act, $obj = false, $remarks = '')
1144 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1147 $au = $this->getAuthUser();
1149 $e = DB_DataObject::factory('Events');
1150 $e->init($act,$obj,$remarks);
1152 $e->event_when = $e->sqlValue('NOW()');
1154 $eid = $e->insert();
1156 // fixme - this should be in onInsert..
1157 $wa = DB_DataObject::factory('core_watch');
1158 if (method_exists($wa,'notifyEvent')) {
1159 $wa->notifyEvent($e); // trigger any actions..
1163 $e->onInsert(isset($_REQUEST) ? $_REQUEST : array() , $this);
1170 function addEventNotifyOnly($act, $obj = false, $remarks = '')
1172 $au = $this->getAuthUser();
1174 $e = DB_DataObject::factory('Events');
1175 $e->init($act,$obj,$remarks);
1177 $e->event_when = $e->sqlValue('NOW()');
1178 $wa = DB_DataObject::factory('core_watch');
1179 if (method_exists($wa,'notifyEvent')) {
1180 $wa->notifyEvent($e); // trigger any actions..
1185 // ------------------ DEPERCIATED ----------------------------
1187 // DEPRECITAED - use moduleslist
1188 function modules() { return $this->modulesList(); }
1191 // DEPRICATED USE Pman_Core_Mailer
1193 function emailTemplate($templateFile, $args)
1196 require_once 'Pman/Core/Mailer.php';
1197 $r = new Pman_Core_Mailer(array(
1198 'template'=>$templateFile,
1199 'contents' => $args,
1202 return $r->toData();
1205 // DEPRICATED - USE Pman_Core_Mailer
1206 // WHAT Part about DEPRICATED Does no one understand??
1207 function sendTemplate($templateFile, $args)
1209 require_once 'Pman/Core/Mailer.php';
1210 $r = new Pman_Core_Mailer(array(
1211 'template'=>$templateFile,
1212 'contents' => array(),