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'))
132 (preg_match('/^192\.168/', $_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] == $_SERVER['HTTP_HOST'])
136 !empty($boot->Pman['enable_isdev_url'])
140 $boot->Pman['isDev'] = true;
144 // if a file Pman_{module}_Pman exists.. and it has an init function... - call that..
146 //var_dump($this->appModules);
152 * call a method on {module}/Pman.php
153 * * initially used on the main page load to call init();
154 * * also used for ccsIncludes??
156 * // usage: $this->callModules('init', $base)
160 function callModules($fn)
162 $args = func_get_args();
164 foreach(explode(',',$this->appModules) as $m) {
165 $cls = 'Pman_'. $m . '_Pman';
166 if (!file_exists($this->rootDir . '/'.str_replace('_','/', $cls). '.php')) {
169 require_once str_replace('_','/', $cls). '.php';
171 if (method_exists($c, $fn)) {
172 call_user_func_array(array($c,$fn),$args);
178 function get($base, $opts=array())
182 $this->callModules('init', $this, $base);
185 //$this->allowSignup= empty($opts['allowSignup']) ? 0 : 1;
186 $bits = explode('/', $base);
189 // should really be moved to Login...
191 if ($bits[0] == 'PasswordReset') {
192 $this->linkFail = $this->resetPassword(@$bits[1],@$bits[2],@$bits[3]);
193 header('Content-type: text/html; charset=utf-8');
198 $au = $this->getAuthUser();
200 $ff= HTML_FlexyFramework::get();
202 if (!empty($ff->Pman['auth_comptype']) && $au->id > 0 &&
203 ( !$au->company_id || ($ff->Pman['auth_comptype'] != $au->company()->comptype))) {
207 $this->jerr("Login not permited to outside companies - please reload");
209 $this->addEvent("RELOAD");
213 if (strlen($base) && $bits[0] != 'PasswordReset') {
214 $this->jerror("BADURL","invalid url: $base");
217 if (isset($_GET['onloadTrack'])) {
218 $this->onloadTrack = (int)$_GET['onloadTrack'];
220 // getting this to work with xhtml is a nightmare
221 // = nbsp / <img> issues screw everyting up.
222 //var_dump($this->isDev);
223 // force regeneration on load for development enviroments..
225 HTML_FlexyFramework::get()->generateDataobjectsCache($this->isDev && !empty($_REQUEST['isDev']));
227 //header('Content-type: application/xhtml+xml; charset=utf-8');
231 if ($this->company && $this->company->logo_id) {
232 $im = DB_DataObject::Factory('Images');
233 $im->get($this->company->logo_id);
234 $this->appLogo = $this->baseURL . '/Images/Thumb/x100/'. $this->company->logo_id .'/' . $im->filename;
237 header('Content-type: text/html; charset=utf-8');
240 function post($base) {
241 return $this->get($base);
245 // --------------- AUTHENTICATION or system information
248 * finds the compay with comptype=='OWNER'
249 * ?? what about comptype_id-name ?????
251 * @return {Pman_Core_DataObjects_Companies} the owner company
253 function loadOwnerCompany()
255 // only applies if authtable is person..
256 $ff = HTML_FlexyFramework::get();
257 if (!empty($ff->Pman['authTable']) && !in_array($ff->Pman['authTable'] , [ 'core_person', 'Person' ])) {
261 $this->company = DB_DataObject::Factory('core_company');
262 if (!is_a($this->company, 'DB_DataObject')) { // non-core pman projects
265 $e = DB_DataObject::Factory('core_enum')->lookupObject('COMPTYPE', 'OWNER');
267 $this->company->get('comptype_id', $e->id);
268 return $this->company;
272 static function staticGetAuthUser($t) {
273 if (!empty($t->authUser)) {
276 $ff = HTML_FlexyFramework::get();
277 $tbl = empty($ff->Pman['authTable']) ? 'core_person' : $ff->Pman['authTable'];
279 $u = DB_DataObject::factory( $tbl );
281 if (is_a($u,'PEAR_Error') || !$u->isAuth()) {
284 $t->authUser =$u->getAuthUser();
285 return $t->authUser ;
290 * getAuthUser: - get the authenticated user..
292 * @return {DB_DataObject} of type Pman[authTable] if authenticated.
295 function getAuthUser()
297 return self::staticGetAuthUser($this);
301 * wrapper arround authuser->hasPerm
302 * @see Pman_Core_DataObject_Core_person::hasPerm
304 * @param {String} $name The permission name (eg. Projects.List)
305 * @param {String} $lvl eg. (C)reate (E)dit (D)elete ... etc.
308 function hasPerm($name, $lvl) // do we have a permission
310 static $pcache = array();
311 $au = $this->getAuthUser();
312 return $au && $au->hasPerm($name,$lvl);
316 * modulesList: List the modules in the application
318 * @return {Array} list of modules
320 function modulesList()
322 $boot = HTML_FlexyFramework::get();
323 // echo'<PRE>';print_R($boot);exit;
326 $mods = explode(',', $boot->enable);
327 if (in_array('Core',$mods)) { // core has to be the first modules loaded as it contains Pman.js
328 array_unshift($mods, 'Core');
331 if (in_array($boot->appNameShort,$mods)) { // Project has to be the last modules loaded as it contains Pman.js
332 unset($mods[array_search($boot->appNameShort, $mods)]);
333 $mods[] = $boot->appNameShort;
336 $mods = array_unique($mods);
338 $disabled = explode(',', $boot->disable ? $boot->disable : '');
340 foreach($mods as $mod) {
341 // add the css file..
342 if (in_array($mod, $disabled)) {
353 function hasModule($name)
356 if (!strpos( $name,'.') ) {
357 // use enable / disable..
358 return in_array($name, $this->modules());
361 $x = DB_DataObject::factory('core_group_right');
362 $ar = $x->defaultPermData();
363 if (empty($ar[$name]) || empty($ar[$name][0])) {
371 function jsencode($v, $header = false)
374 header("Content-type: text/javascript");
376 if (function_exists("json_encode")) {
377 $ret= json_encode($v);
378 if ($ret !== false) {
382 require_once 'Services/JSON.php';
383 $js = new Services_JSON();
384 return $js->encodeUnsafe($v);
393 * ---------------- Global Tools ---------------
395 function checkFileUploadError() // check for file upload errors.
398 empty($_FILES['File'])
399 || empty($_FILES['File']['name'])
400 || empty($_FILES['File']['tmp_name'])
401 || empty($_FILES['File']['type'])
402 || !empty($_FILES['File']['error'])
403 || empty($_FILES['File']['size'])
405 $this->jerr("File upload error: <PRE>" . print_r($_FILES,true) . print_r($_POST,true) . "</PRE>");
409 static $deleteOnExit = false;
411 * generate a tempory file with an extension (dont forget to delete it)
414 function deleteOnExitAdd($name)
416 if (self::$deleteOnExit === false) {
417 register_shutdown_function(array('Pman','deleteOnExit'));
418 self::$deleteOnExit = array();
420 self::$deleteOnExit[] = $name;
423 function tempName($ext, $deleteOnExit=false)
426 $x = tempnam(ini_get('session.save_path'), HTML_FlexyFramework::get()->appNameShort.'TMP');
428 $ret = $x .'.'. $ext;
430 $this->deleteOnExitAdd($ret);
436 static function deleteOnExit()
439 foreach(self::$deleteOnExit as $fn) {
440 if (file_exists($fn)) {
447 * ------------- Authentication password reset ------ ??? MOVEME?
455 * jerrAuth: standard auth failure - with data that let's the UI know..
459 $au = $this->authUser();
461 // is it an authfailure?
462 $this->jerr("Permission denied to view this resource", array('authFailure' => true));
464 $this->jerr("Not authenticated", array('authFailure' => true));
470 * ---------------- Standard JSON outputers. - used everywhere
473 * ---------------- Standard JSON outputers. - used everywhere
474 * JSON error - simple error with logging.
478 function jerr($str, $errors=array(), $content_type = false) // standard error reporting..
480 return $this->jerror('ERROR', $str,$errors,$content_type);
483 * Recomended JSON error indicator
486 * @param string $type - normally 'ERROR' - you can use this to track error types.
487 * @param string $message - error message displayed to user.
488 * @param array $errors - optioanl data to pass to front end.
489 * @param string $content_type - use text/plain to return plan text - ?? not sure why...
493 function jerror($type, $str, $errors=array(), $content_type = false) // standard error reporting..
495 if ($this->transObj) {
496 $this->transObj->query('ROLLBACK');
499 $cli = HTML_FlexyFramework::get()->cli;
501 echo "ERROR: " .$str . "\n"; // print the error first, as DB might fail..
504 if ($type !== false) {
507 DB_DataObject::factory('Events')->writeEventLogExtra($errors);
510 $this->addEvent($type, false, $str);
514 $cli = HTML_FlexyFramework::get()->cli;
516 exit(1); // cli --- exit code to stop shell execution if necessary.
520 if ($content_type == 'text/plain') {
521 header('Content-Disposition: attachment; filename="error.txt"');
522 header('Content-type: '. $content_type);
523 echo "ERROR: " .$str . "\n";
529 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
530 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
533 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
537 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
542 header('Content-type: text/html');
543 echo "<HTML><HEAD></HEAD><BODY>";
544 echo $this->jsencode(array(
547 'message' => $str, // compate with exeption / loadexception.
549 'errors' => $errors ? $errors : true, // used by forms to flag errors.
550 'authFailure' => !empty($errors['authFailure']),
552 echo "</BODY></HTML>";
556 if (isset($_REQUEST['_debug'])) {
557 echo '<PRE>'.htmlspecialchars(print_r(array(
561 'message' => $str, // compate with exeption / loadexception.
562 'errors' => $errors ? $errors : true, // used by forms to flag errors.
563 'authFailure' => !empty($errors['authFailure']),
569 echo $this->jsencode(array(
574 'message' => $str, // compate with exeption / loadexception.
575 'errors' => $errors ? $errors : true, // used by forms to flag errors.
576 'authFailure' => !empty($errors['authFailure']),
585 if ($this->transObj ) {
586 $this->transObj->query( connection_aborted() ? 'ROLLBACK' : 'COMMIT');
589 $cli = HTML_FlexyFramework::get()->cli;
591 echo "OK: " .$str . "\n";
595 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
596 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
599 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
603 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
607 header('Content-type: text/html');
608 echo "<HTML><HEAD></HEAD><BODY>";
609 // encode html characters so they can be read..
610 echo str_replace(array('<','>'), array('\u003c','\u003e'),
611 $this->jsencode(array('success'=> true, 'data' => $str), false));
612 echo "</BODY></HTML>";
617 echo $this->jsencode(array('success'=> true, 'data' => $str),true);
623 * output data for grids or tree
624 * @ar {Array} ar Array of data
625 * @total {Number|false} total number of records (or false to return count(ar)
626 * @extra {Array} extra key value list of data to pass as extra data.
629 function jdata($ar,$total=false, $extra=array(), $cachekey = false)
631 // should do mobile checking???
632 if ($total == false) {
635 $extra= $extra ? $extra : array();
638 $retHTML = isset($_SERVER['CONTENT_TYPE']) &&
639 preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
642 if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
646 $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] !='NO';
651 header('Content-type: text/html');
652 echo "<HTML><HEAD></HEAD><BODY><![CDATA[";
653 // encode html characters so they can be read..
654 echo str_replace(array('<','>'), array('\u003c','\u003e'),
655 $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra, false));
656 echo "]]></BODY></HTML>";
661 // see if trimming will help...
662 if (!empty($_REQUEST['_pman_short'])) {
665 foreach($ar as $as) {
667 foreach($as as $k=>$v) {
668 if (is_string($v) && !strlen(trim($v))) {
680 $ret = $this->jsencode(array('success' => true, 'total'=> $total, 'data' => $ar) + $extra,true);
682 if (!empty($cachekey)) {
684 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
685 if (!file_exists(dirname($fn))) {
686 mkdir(dirname($fn), 0777,true);
688 file_put_contents($fn, $ret);
697 /** a daily cache **/
698 function jdataCache($cachekey)
700 $fn = ini_get('session.save_path') . '/json-cache'.date('/Y/m/d').'.'. $cachekey . '.cache.json';
701 if (file_exists($fn)) {
702 header('Content-type: application/json');
703 echo file_get_contents($fn);
713 * ---------------- OUTPUT
715 function hasBg($fn) // used on front page to check if logos exist..
717 return file_exists($this->rootDir.'/Pman/'.$this->appNameShort.'/templates/images/'. $fn);
720 * outputJavascriptIncludes:
722 * output <script....> for all the modules in the applcaiton
725 function outputJavascriptIncludes()
727 // BC support - currently 1 project still relies on this.. (MO portal)
728 $ff = HTML_FlexyFramework::get();
729 $o = isset($ff->Pman_Core) ? $ff->Pman_Core : array();
730 if (isset($o['packseed'])) {
731 return $this->outputJavascriptIncludesBC();
735 $mods = $this->modulesList();
737 $is_bootstrap = in_array('BAdmin', $mods);
739 foreach($mods as $mod) {
740 // add the css file..
743 if (!file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
744 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
750 $this->outputJavascriptDir("Pman/$mod/widgets", "*.js");
751 $this->outputJavascriptDir("Pman/$mod", "*.js");
755 if (empty($this->disable_jstemplate)) {
756 // and finally the JsTemplate...
757 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
760 $this->callModules('outputJavascriptIncludes', $this);
763 var $css_includes = array();
767 * output <link rel=stylesheet......> for all the modules in the applcaiton
770 * This could css minify as well.
772 function outputCSSIncludes() // includes on CSS links.
776 $mods = $this->modulesList();
777 $is_bootstrap = in_array('BAdmin', $mods);
779 $this->callModules('applyCSSIncludes', $this);
780 foreach($this->css_includes as $module => $ar) {
783 $this->assetArrayToHtml( $ar , 'css');
787 // old style... - probably remove this...
788 $this->callModules('outputCSSIncludes', $this);
790 foreach($mods as $mod) {
791 // add the css file..
792 if ($is_bootstrap && !file_exists($this->rootDir."/Pman/$mod/is_bootstrap")) {
793 echo '<!-- missing '. $this->rootDir."/Pman/$mod/is_bootstrap - skipping -->";
796 $this->outputCSSDir("Pman/$mod","*.css");
798 $this->outputSCSS($mod);
802 return ''; // needs to return something as we output it..
815 // --- OLD CODE - in for BC on MO project.... - needs removing...
817 // used on old versions.....
818 function outputJavascriptIncludesBC()
821 $mods = $this->modulesList();
823 foreach($mods as $mod) {
824 // add the css file..
827 $files = $this->moduleJavascriptList($mod.'/widgets');
828 foreach($files as $f) {
829 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
832 $files = $this->moduleJavascriptList($mod);
833 foreach($files as $f) {
834 echo '<script type="text/javascript" src="'. $f. '"></script>'."\n";
838 if (empty($this->disable_jstemplate)) {
839 // and finally the JsTemplate...
840 echo '<script type="text/javascript" src="'. $this->baseURL. '/Core/JsTemplate"></script>'."\n";
845 * Gather infor for javascript files..
847 * @param {String} $mod the module to get info about.
848 * @return {StdClass} details about module.
850 function moduleJavascriptFilesInfo($mod)
853 static $cache = array();
855 if (isset($cache[$mod])) {
860 $ff = HTML_FlexyFramework::get();
862 $base = dirname($_SERVER['SCRIPT_FILENAME']);
863 $dir = $this->rootDir.'/Pman/'. $mod;
864 $path = $this->rootURL ."/Pman/$mod/";
866 $ar = glob($dir . '/*.js');
872 foreach($ar as $fn) {
874 // got the 'module file..'
875 $mtime = filemtime($dir . '/'. $f);
876 $maxtime = max($mtime, $maxtime);
877 $arfiles[$fn] = $mtime;
878 $files[] = $path . $f . '?ts='.$mtime;
881 ksort($arfiles); // just sort by name so it's consistant for serialize..
883 // The original idea of this was to serve the files direct from a publicly available 'cache' directory.
884 // but that doesnt really make sense - as we can just serve it from the session directory where we stick
885 // cached data anyway.
888 $compile = empty($ff->Pman['public_cache_dir']) ? 0 : 1;
889 $basedir = $compile ? $ff->Pman['public_cache_dir'] : false;
890 $baseurl = $compile ? $ff->Pman['public_cache_url'] : false;
894 $basedir = session_save_path(). '/translate-cache/';
895 if (!file_exists($basedir)) {
896 mkdir($basedir,0755);
898 $baseurl = $this->baseURL . '/Admin/Translations';
900 if (PHP_VERSION_ID < 70000 ) {
901 $lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
902 usort($files, $lsort);
904 usort($files, function($a,$b) { return strlen($a) > strlen($b) ? 1 : -1; });
907 $smod = str_replace('/','.',$mod);
909 $output = date('Y-m-d-H-i-s-', $maxtime). $smod .'-'.md5(serialize($arfiles)) .'.js';
912 // why are translations done like this - we just build them on the fly frmo the database..
913 $tmtime = file_exists($this->rootDir.'/_translations_/'. $smod.'.js')
914 ? filemtime($this->rootDir.'/_translations_/'. $smod.'.js') : 0;
916 $cache[$mod] = (object) array(
917 'smod' => $smod, // module name without '/'
918 'files' => $files, // list of all files.
919 'filesmtime' => $arfiles, // map of mtime=>file
920 'maxtime' => $maxtime, // max mtime
921 'compile' => $this->isDev ? false : $compile,
922 'translation_file' => $base .'/_translations_/' . $smod . '.js',
923 'translation_mtime' => $tmtime,
925 'translation_data' => preg_replace('/\.js$/', '.__translation__.js', $output),
926 'translation_base' => $dir .'/', //prefix of filename (without moudle name))
927 'basedir' => $basedir,
928 'baseurl' => $baseurl,
929 'module_dir' => $dir,
936 * moduleJavascriptList: list the javascript files in a module
938 * The original version of this.. still needs more thought...
940 * Compiled is in Pman/_compiled_/{$mod}/{LATEST...}.js
941 * Translations are in Pman/_translations_/{$mod}.js
943 * if that stuff does not exist just list files in Pman/{$mod}/*.js
945 * Compiled could be done on the fly..
949 * @param {String} $mod the module to look at - eg. Pman/{$mod}/*.js
950 * @return {Array} list of include paths (either compiled or raw)
956 function moduleJavascriptList($mod)
960 $dir = $this->rootDir.'/Pman/'. $mod;
963 if (!file_exists($dir)) {
964 echo '<!-- missing directory '. htmlspecialchars($dir) .' -->';
968 $info = $this->moduleJavascriptFilesInfo($mod);
972 if (empty($info->files)) {
975 // finally sort the files, so they are in the right order..
977 // only compile this stuff if public_cache is set..
981 // public_cache_dir = /var/www/myproject_cache
982 // public_cache_url = /myproject_cache (with Alias apache /myproject_cache/ /var/www/myproject_cache/)
985 if (!$info->compile) {
986 echo "<!-- Javascript compile turned off (isDev on, or public_cache_dir not set) -->\n";
990 // where are we going to write all of this..
991 // This has to be done via a
992 if (!file_exists($info->basedir.'/'.$info->output) || !filesize($info->basedir.'/'.$info->output)) {
993 require_once 'Pman/Core/JsCompile.php';
994 $x = new Pman_Core_JsCompile();
996 $x->pack($info->filesmtime,$info->basedir.'/'.$info->output, $info->translation_base);
998 echo "<!-- file exists not exist: {$info->basedir}/{$info->output} -->\n";
1001 if (file_exists($info->basedir.'/'.$info->output) &&
1002 filesize($info->basedir.'/'.$info->output)) {
1005 $info->baseurl.'/'. $info->output,
1008 // output all the ava
1009 // fixme - this needs the max datetime for the translation file..
1010 $ret[] = $this->baseURL."/Admin/InterfaceTranslations/".$mod.".js"; //?ts=".$info->translation_mtime;
1012 //if ($info->translation_mtime) {
1013 // $ret[] = $this->rootURL."/_translations_/". $info->smod.".js?ts=".$info->translation_mtime;
1020 // give up and output original files...
1023 return $info->files;
1030 * PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1032 function initErrorHandling()
1034 if (!class_exists('HTML_FlexyFramework2')) {
1035 // what about older code that still users PEAR?
1036 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
1038 set_exception_handler(array($this,'onException'));
1043 static $permitError = false; // static why?
1045 var $showErrorToUser = true;
1047 function onPearError($err)
1049 return $this->onException($err);
1054 function onException($ex)
1056 static $reported = false;
1061 if (Pman::$permitError) {
1068 $out = is_a($ex,'Exception') || is_a($ex, 'Error') ? $ex->getMessage() : $ex->toString();
1071 //print_R($bt); exit;
1074 $bt = is_a($ex,'Exception')|| is_a($ex, 'Error') ? $ex->getTrace() : $ex->backtrace;
1075 if (is_a($ex,'Exception')|| is_a($ex, 'Error') ) {
1076 $ret[] = $ex->getFile() . '('. $ex->getLine() . ')';
1078 foreach( $bt as $b) {
1079 $ret[] = @$b['file'] . '(' . @$b['line'] . ')@' . @$b['class'] . '::' . @$b['function'];
1085 //convert the huge backtrace into something that is readable..
1086 $out .= "\n" . implode("\n", $ret);
1088 $this->addEvent("EXCEPTION", false, $out);
1090 if ($this->showErrorToUser) {
1093 // not sure why this is here... - perhaps doing a jerr() was actually caught by the UI, and hidden from the user..?
1094 $this->jerror(false,"An error Occured, please contact the website owner");
1096 //$this->jerr($out);
1103 * ---------------- Logging ---------------
1108 * Log an action (only if it has not been logged already.
1110 * @param {String} action - group/name of event
1111 * @param {DataObject|false} obj - dataobject action occured on.
1112 * @param {String} any remarks
1113 * @return {false|DB_DataObject} Event object.,
1116 function addEventOnce($act, $obj = false, $remarks = '')
1118 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1121 $e = DB_DataObject::factory('Events');
1122 $e->init($act,$obj,$remarks);
1123 if ($e->find(true)) {
1126 return $this->addEvent($act, $obj, $remarks);
1132 * @param {String} action - group/name of event
1133 * @param {DataObject|false} obj - dataobject action occured on.
1134 * @param {String} any remarks
1135 * @return {DB_DataObject} Event object.,
1138 function addEvent($act, $obj = false, $remarks = '')
1141 if (!empty(HTML_FlexyFramework::get()->Pman['disable_events'])) {
1144 $au = $this->getAuthUser();
1146 $e = DB_DataObject::factory('Events');
1147 $e->init($act,$obj,$remarks);
1149 $e->event_when = $e->sqlValue('NOW()');
1151 $eid = $e->insert();
1153 // fixme - this should be in onInsert..
1154 $wa = DB_DataObject::factory('core_watch');
1155 if (method_exists($wa,'notifyEvent')) {
1156 $wa->notifyEvent($e); // trigger any actions..
1160 $e->onInsert(isset($_REQUEST) ? $_REQUEST : array() , $this);
1167 function addEventNotifyOnly($act, $obj = false, $remarks = '')
1169 $au = $this->getAuthUser();
1171 $e = DB_DataObject::factory('Events');
1172 $e->init($act,$obj,$remarks);
1174 $e->event_when = $e->sqlValue('NOW()');
1175 $wa = DB_DataObject::factory('core_watch');
1176 if (method_exists($wa,'notifyEvent')) {
1177 $wa->notifyEvent($e); // trigger any actions..
1182 // ------------------ DEPERCIATED ----------------------------
1184 // DEPRECITAED - use moduleslist
1185 function modules() { return $this->modulesList(); }
1188 // DEPRICATED USE Pman_Core_Mailer
1190 function emailTemplate($templateFile, $args)
1193 require_once 'Pman/Core/Mailer.php';
1194 $r = new Pman_Core_Mailer(array(
1195 'template'=>$templateFile,
1196 'contents' => $args,
1199 return $r->toData();
1202 // DEPRICATED - USE Pman_Core_Mailer
1203 // WHAT Part about DEPRICATED Does no one understand??
1204 function sendTemplate($templateFile, $args)
1206 require_once 'Pman/Core/Mailer.php';
1207 $r = new Pman_Core_Mailer(array(
1208 'template'=>$templateFile,
1209 'contents' => array(),