* - authentication reset password ?? MOVEME?
* ?? arrayClean.. what's it doing here?!? ;)
*
- *
+ * Usefull implemetors
+ * DB_DataObject*:*toEventString (for logging - this is generically prefixed to all database operations.)
+ * - any data object where this method exists, the result will get prefixed to the log remarks
*/
class Pman extends HTML_FlexyFramework_Page
require_once 'Services/JSON.php';
$json = new Services_JSON();
+ $this->addEvent("ERROR", false, $str);
+
if (!empty($_REQUEST['returnHTML']) ||
(isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
) {
echo $json->encodeUnsafe(array(
'success'=> false,
'errorMsg' => $str,
- 'message' => $str, // compate with exeption / loadexception.
+ 'message' => $str, // compate with exeption / loadexception.
'errors' => $errors ? $errors : true, // used by forms to flag errors.
'authFailure' => !empty($errors['authFailure']),
echo "</BODY></HTML>";
exit;
}
-
+
echo $json->encode(array(
'success'=> false,
'data'=> array(),
if (file_exists($cfile)) {
// $ctime = max(filemtime($cfile), filectime($cfile));
// otherwise use compile dfile..
- $cfile = basename(array_pop(glob($cfile . '/' . $mod . '*.js')));
+ $maxm = 0;
+ $ar = glob($cfile . '/' . $mod . '*.js');
+ // default to first..
+ $cfile = basename($ar[count($ar) -1]);
+ foreach($ar as $fn) {
+ if (filemtime($fn) > $maxm) {
+ $cfile = basename($fn);
+ $maxm = filemtime($fn);
+ }
+
+ }
+
$files = array( $this->rootURL. "/_compiled_/".$mod . "/" . $cfile);
if (file_exists($lfile)) {
array_push($files, $this->rootURL."/_translations_/$mod.js");
* ---------------- Logging ---------------
*/
+ /**
+ * addEventOnce:
+ * Log an action (only if it has not been logged already.
+ *
+ * @param {String} action - group/name of event
+ * @param {DataObject|false} obj - dataobject action occured on.
+ * @param {String} any remarks
+ */
-
-
-
- function addEvent($act, $obj = false, $remarks = '') {
+ function addEventOnce($act, $obj = false, $remarks = '')
+ {
$au = $this->getAuthUser();
$e = DB_DataObject::factory('Events');
-
- if (is_a($e, 'PEAR_Error')) {
- return; // no event table!
+ $e->init($act,$obj,$remarks);
+ if ($e->find(true)) {
+ return;
}
- $e->person_name = $au ? $au->name : '';
- $e->person_id = $au ? $au->id : '';
+ $this->addEvent($act, $obj, $remarks);
+ }
+ /**
+ * addEvent:
+ * Log an action.
+ *
+ * @param {String} action - group/name of event
+ * @param {DataObject|false} obj - dataobject action occured on.
+ * @param {String} any remarks
+ */
+
+ function addEvent($act, $obj = false, $remarks = '')
+ {
+ $au = $this->getAuthUser();
+ $e = DB_DataObject::factory('Events');
+ $e->init($act,$obj,$remarks);
+
$e->event_when = date('Y-m-d H:i:s');
- $e->ipaddr = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : 'cli';
- $e->action = $act;
- $e->on_table = $obj ? $obj->tableName() : '';
- $pk = $obj ? $obj->keys() : false;
-
- $e->on_id = $obj && $pk ? $obj->{$pk[0]}: 0;
- $e->remarks = $remarks;
$eid = $e->insert();
$ff = HTML_FlexyFramework::get();
if (empty($ff->Pman['event_log_dir'])) {
}
$file = $ff->Pman['event_log_dir']. date('/Y/m/d/'). $eid . ".php";
if (!file_exists(dirname($file))) {
- mkdir(dirname($file),0666,true);
+ mkdir(dirname($file),0700,true);
}
file_put_contents($file, var_export(array(
- 'REQUEST_URI' => $SERVER['REQUEST_URI'],
+ 'REQUEST_URI' => empty($_SERVER['REQUEST_URI']) ? 'cli' : $_SERVER['REQUEST_URI'],
'GET' => empty($_GET) ? array() : $_GET,
'POST' => empty($_POST) ? array() : $_POST,
), true));