PageRenderTime 74ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-osj2duser_leveladd.php

http://osjobber.googlecode.com/
PHP | 566 lines | 442 code | 59 blank | 65 comment | 118 complexity | 322a877c3802538b42295275b6303b80 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "add", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-user_level', TRUE);
  4. ?>
  5. <?php
  6. session_start(); // Initialize session data
  7. ob_start(); // Turn on output buffering
  8. ?>
  9. <?php include "osj-ewcfg50.php" ?>
  10. <?php include "osj-ewmysql50.php" ?>
  11. <?php include "osj-phpfn50.php" ?>
  12. <?php include "osj-osj2duser_levelinfo.php" ?>
  13. <?php include "osj-userfn50.php" ?>
  14. <?php include "osj-osj2dusersinfo.php" ?>
  15. <?php
  16. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  17. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  18. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  19. header("Cache-Control: post-check=0, pre-check=0", false);
  20. header("Pragma: no-cache"); // HTTP/1.0
  21. ?>
  22. <?php
  23. // Open connection to the database
  24. $conn = ew_Connect();
  25. ?>
  26. <?php
  27. $Security = new cAdvancedSecurity();
  28. ?>
  29. <?php
  30. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  31. $Security->LoadCurrentUserLevel('osj-user_level');
  32. if (!$Security->CanAdmin()) {
  33. $Security->SaveLastUrl();
  34. Page_Terminate("osj-login.php");
  35. }
  36. ?>
  37. <?php
  38. // Common page loading event (in userfn*.php)
  39. Page_Loading();
  40. ?>
  41. <?php
  42. // Page load event, used in current page
  43. Page_Load();
  44. ?>
  45. <?php
  46. $osj2Duser_level->Export = @$_GET["export"]; // Get export parameter
  47. $sExport = $osj2Duser_level->Export; // Get export parameter, used in header
  48. $sExportFile = $osj2Duser_level->TableVar; // Get export file, used in header
  49. ?>
  50. <?php
  51. // Load key values from QueryString
  52. $bCopy = TRUE;
  53. if (@$_GET["user_level_id"] != "") {
  54. $osj2Duser_level->user_level_id->setQueryStringValue($_GET["user_level_id"]);
  55. } else {
  56. $bCopy = FALSE;
  57. }
  58. // Create form object
  59. $objForm = new cFormObj();
  60. // Process form if post back
  61. if (@$_POST["a_add"] <> "") {
  62. $osj2Duser_level->CurrentAction = $_POST["a_add"]; // Get form action
  63. LoadFormValues(); // Load form values
  64. // Load values for user privileges
  65. $x_ewAllowAdd = @$_POST["x_ewAllowAdd"];
  66. if ($x_ewAllowAdd == "") $x_ewAllowAdd = 0;
  67. $x_ewAllowEdit = @$_POST["x_ewAllowEdit"];
  68. if ($x_ewAllowEdit == "") $x_ewAllowEdit = 0;
  69. $x_ewAllowDelete = @$_POST["x_ewAllowDelete"];
  70. if ($x_ewAllowDelete == "") $x_ewAllowDelete = 0;
  71. $x_ewAllowList = @$_POST["x_ewAllowList"];
  72. if ($x_ewAllowList == "") $x_ewAllowList = 0;
  73. if (defined("EW_USER_LEVEL_COMPAT")) {
  74. $x_ewPriv = intval($x_ewAllowAdd) + intval($x_ewAllowEdit) +
  75. intval($x_ewAllowDelete) + intval($x_ewAllowList);
  76. } else {
  77. $x_ewAllowView = @$_POST["x_ewAllowView"];
  78. if ($x_ewAllowView == "") $x_ewAllowView = 0;
  79. $x_ewAllowSearch = @$_POST["x_ewAllowSearch"];
  80. if ($x_ewAllowSearch == "") $x_ewAllowSearch = 0;
  81. $x_ewPriv = intval($x_ewAllowAdd) + intval($x_ewAllowEdit) +
  82. intval($x_ewAllowDelete) + intval($x_ewAllowList) +
  83. intval($x_ewAllowView) + intval($x_ewAllowSearch);
  84. }
  85. } else { // Not post back
  86. if ($bCopy) {
  87. $osj2Duser_level->CurrentAction = "C"; // Copy Record
  88. } else {
  89. $osj2Duser_level->CurrentAction = "I"; // Display Blank Record
  90. LoadDefaultValues(); // Load default values
  91. }
  92. }
  93. // Perform action based on action code
  94. switch ($osj2Duser_level->CurrentAction) {
  95. case "I": // Blank record, no action required
  96. break;
  97. case "C": // Copy an existing record
  98. if (!LoadRow()) { // Load record based on key
  99. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
  100. Page_Terminate($osj2Duser_level->getReturnUrl()); // Clean up and return
  101. }
  102. break;
  103. case "A": // ' Add new record
  104. $osj2Duser_level->SendEmail = TRUE; // Send email on add success
  105. if (AddRow()) { // Add successful
  106. $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
  107. Page_Terminate($osj2Duser_level->KeyUrl($osj2Duser_level->getReturnUrl())); // Clean up and return
  108. } else {
  109. RestoreFormValues(); // Add failed, restore form values
  110. }
  111. }
  112. // Render row based on row type
  113. $osj2Duser_level->RowType = EW_ROWTYPE_ADD; // Render add type
  114. RenderRow();
  115. ?>
  116. <?php include "osj-header.php" ?>
  117. <script type="text/javascript">
  118. <!--
  119. var EW_PAGE_ID = "add"; // Page id
  120. var EW_SHOW_HIGHLIGHT = "Show highlight";
  121. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  122. //-->
  123. </script>
  124. <script type="text/javascript">
  125. <!--
  126. function ew_ValidateForm(fobj) {
  127. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  128. return true;
  129. var i, elm, aelm, infix;
  130. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  131. for (i=0; i<rowcnt; i++) {
  132. infix = (fobj.key_count) ? String(i+1) : "";
  133. elm = fobj.elements["x" + infix + "_user_level_id"];
  134. if (elm && !ew_HasValue(elm)) {
  135. if (!ew_OnError(elm, "Please enter required field - user level id"))
  136. return false;
  137. }
  138. elm = fobj.elements["x" + infix + "_user_level_id"];
  139. if (elm && !ew_CheckInteger(elm.value)) {
  140. if (!ew_OnError(elm, "Incorrect integer - user level id"))
  141. return false;
  142. }
  143. elm = fobj.elements["x" + infix + "_user_level_name"];
  144. if (elm && !ew_HasValue(elm)) {
  145. if (!ew_OnError(elm, "Please enter required field - user level name"))
  146. return false;
  147. }
  148. elmId = fobj.elements["x" + infix + "_user_level_id"];
  149. elmName = fobj.elements["x" + infix + "_user_level_name"];
  150. if (elmId && elmName) {
  151. elmId.value = elmId.value.replace(/^\s+|\s+$/, '');
  152. elmName.value = elmName.value.replace(/^\s+|\s+$/, '');
  153. if (elmId && !ew_CheckInteger(elmId.value)) {
  154. if (!ew_OnError(elmId, "User Level ID must be integer"))
  155. return false;
  156. }
  157. var level = parseInt(elmId.value);
  158. if (level == 0) {
  159. if (elmName.value.toLowerCase() != "default") {
  160. if (!ew_OnError(elmName, "User level name for user level 0 must be 'Default'"))
  161. return false;
  162. }
  163. } else if (level == -1) {
  164. if (elmName.value.toLowerCase() != "administrator") {
  165. if (!ew_OnError(elmName, "User level name for user level -1 must be 'Administrator'"))
  166. return false;
  167. }
  168. } else if (level < -1) {
  169. if (!ew_OnError(elmId, "User defined User Level ID must be larger than 0"))
  170. return false;
  171. } else if (level > 0) {
  172. if (elmName.value.toLowerCase() == "administrator" || elmName.value.toLowerCase() == "default") {
  173. if (!ew_OnError(elmName, "User defined User Level name cannot be 'Administrator' or 'Default'"))
  174. return false;
  175. }
  176. }
  177. }
  178. }
  179. return true;
  180. }
  181. //-->
  182. </script>
  183. <script type="text/javascript">
  184. <!--
  185. var ew_DHTMLEditors = [];
  186. //-->
  187. </script>
  188. <script type="text/javascript">
  189. <!--
  190. // js for Popup Calendar
  191. //-->
  192. </script>
  193. <script type="text/javascript">
  194. <!--
  195. var ew_MultiPagePage = "Page"; // multi-page Page Text
  196. var ew_MultiPageOf = "of"; // multi-page Of Text
  197. var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
  198. var ew_MultiPageNext = "Next"; // multi-page Next Text
  199. //-->
  200. </script>
  201. <script language="JavaScript" type="text/javascript">
  202. <!--
  203. // Write your client script here, no need to add script tags.
  204. // To include another .js script, use:
  205. // ew_ClientScriptInclude("my_javascript.js");
  206. //-->
  207. </script>
  208. <p><span class="phpmaker">Add to TABLE: User Levels<br><br><a href="<?php echo $osj2Duser_level->getReturnUrl() ?>">Go Back</a></span></p>
  209. <?php
  210. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
  211. ?>
  212. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  213. <?php
  214. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
  215. }
  216. ?>
  217. <form name="fosj2Duser_leveladd" id="fosj2Duser_leveladd" action="osj-osj2duser_leveladd.php" method="post" onSubmit="return ew_ValidateForm(this);">
  218. <p>
  219. <input type="hidden" name="a_add" id="a_add" value="A">
  220. <table class="ewTable">
  221. <tr class="ewTableRow">
  222. <td class="ewTableHeader">user level id<span class='ewmsg'>&nbsp;*</span></td>
  223. <td<?php echo $osj2Duser_level->user_level_id->CellAttributes() ?>><span id="cb_x_user_level_id">
  224. <input type="text" name="x_user_level_id" id="x_user_level_id" title="User Level ID" size="30" value="<?php echo $osj2Duser_level->user_level_id->EditValue ?>"<?php echo $osj2Duser_level->user_level_id->EditAttributes() ?>>
  225. </span></td>
  226. </tr>
  227. <tr class="ewTableAltRow">
  228. <td class="ewTableHeader">user level name<span class='ewmsg'>&nbsp;*</span></td>
  229. <td<?php echo $osj2Duser_level->user_level_name->CellAttributes() ?>><span id="cb_x_user_level_name">
  230. <input type="text" name="x_user_level_name" id="x_user_level_name" title="User Level Description" size="30" maxlength="50" value="<?php echo $osj2Duser_level->user_level_name->EditValue ?>"<?php echo $osj2Duser_level->user_level_name->EditAttributes() ?>>
  231. </span></td>
  232. </tr>
  233. <!-- row for permission values -->
  234. <tr class="ewTableRow">
  235. <td class="ewTableHeader">Permission</td>
  236. <td>
  237. <input type="checkbox" name="x_ewAllowAdd" id="Add" value="<?php echo EW_ALLOW_ADD ?>">Add/Copy
  238. <input type="checkbox" name="x_ewAllowDelete" id="Delete" value="<?php echo EW_ALLOW_DELETE ?>">Delete
  239. <input type="checkbox" name="x_ewAllowEdit" id="Edit" value="<?php echo EW_ALLOW_EDIT ?>">Edit
  240. <?php if (defined("EW_USER_LEVEL_COMPAT")) { ?>
  241. <input type="checkbox" name="x_ewAllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>">List/Search/View
  242. <?php } else { ?>
  243. <input type="checkbox" name="x_ewAllowList" id="List" value="<?php echo EW_ALLOW_LIST ?>">List
  244. <input type="checkbox" name="x_ewAllowView" id="View" value="<?php echo EW_ALLOW_VIEW ?>">View
  245. <input type="checkbox" name="x_ewAllowSearch" id="Search" value="<?php echo EW_ALLOW_SEARCH ?>">Search
  246. <?php } ?>
  247. </td>
  248. </tr>
  249. </table>
  250. <p>
  251. <input type="submit" name="btnAction" id="btnAction" value=" Add ">
  252. </form>
  253. <script language="JavaScript" type="text/javascript">
  254. <!--
  255. // Write your table-specific startup script here
  256. // document.write("page loaded");
  257. //-->
  258. </script>
  259. <?php include "osj-footer.php" ?>
  260. <?php
  261. // If control is passed here, simply terminate the page without redirect
  262. Page_Terminate();
  263. // -----------------------------------------------------------------
  264. // Subroutine Page_Terminate
  265. // - called when exit page
  266. // - clean up connection and objects
  267. // - if url specified, redirect to url, otherwise end response
  268. function Page_Terminate($url = "") {
  269. global $conn;
  270. // Page unload event, used in current page
  271. Page_Unload();
  272. // Global page unloaded event (in userfn*.php)
  273. Page_Unloaded();
  274. // Close Connection
  275. $conn->Close();
  276. // Go to url if specified
  277. if ($url <> "") {
  278. ob_end_clean();
  279. header("Location: $url");
  280. }
  281. exit();
  282. }
  283. ?>
  284. <?php
  285. // Load default values
  286. function LoadDefaultValues() {
  287. global $osj2Duser_level;
  288. $osj2Duser_level->user_level_id->CurrentValue = 0;
  289. }
  290. ?>
  291. <?php
  292. // Load form values
  293. function LoadFormValues() {
  294. // Load from form
  295. global $objForm, $osj2Duser_level;
  296. $osj2Duser_level->user_level_id->setFormValue($objForm->GetValue("x_user_level_id"));
  297. $osj2Duser_level->user_level_name->setFormValue($objForm->GetValue("x_user_level_name"));
  298. }
  299. // Restore form values
  300. function RestoreFormValues() {
  301. global $osj2Duser_level;
  302. $osj2Duser_level->user_level_id->CurrentValue = $osj2Duser_level->user_level_id->FormValue;
  303. $osj2Duser_level->user_level_name->CurrentValue = $osj2Duser_level->user_level_name->FormValue;
  304. }
  305. ?>
  306. <?php
  307. // Load row based on key values
  308. function LoadRow() {
  309. global $conn, $Security, $osj2Duser_level;
  310. $sFilter = $osj2Duser_level->SqlKeyFilter();
  311. if (!is_numeric($osj2Duser_level->user_level_id->CurrentValue)) {
  312. return FALSE; // Invalid key, exit
  313. }
  314. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level->user_level_id->CurrentValue), $sFilter); // Replace key value
  315. // Call Row Selecting event
  316. $osj2Duser_level->Row_Selecting($sFilter);
  317. // Load sql based on filter
  318. $osj2Duser_level->CurrentFilter = $sFilter;
  319. $sSql = $osj2Duser_level->SQL();
  320. if ($rs = $conn->Execute($sSql)) {
  321. if ($rs->EOF) {
  322. $LoadRow = FALSE;
  323. } else {
  324. $LoadRow = TRUE;
  325. $rs->MoveFirst();
  326. LoadRowValues($rs); // Load row values
  327. // Call Row Selected event
  328. $osj2Duser_level->Row_Selected($rs);
  329. }
  330. $rs->Close();
  331. } else {
  332. $LoadRow = FALSE;
  333. }
  334. return $LoadRow;
  335. }
  336. // Load row values from recordset
  337. function LoadRowValues(&$rs) {
  338. global $osj2Duser_level;
  339. $osj2Duser_level->user_level_id->setDbValue($rs->fields('user_level_id'));
  340. if (is_null($osj2Duser_level->user_level_id->CurrentValue)) {
  341. $osj2Duser_level->user_level_id->CurrentValue = 0;
  342. } else {
  343. $osj2Duser_level->user_level_id->CurrentValue = intval($osj2Duser_level->user_level_id->CurrentValue);
  344. }
  345. $osj2Duser_level->user_level_name->setDbValue($rs->fields('user_level_name'));
  346. }
  347. ?>
  348. <?php
  349. // Render row values based on field settings
  350. function RenderRow() {
  351. global $conn, $Security, $osj2Duser_level;
  352. // Call Row Rendering event
  353. $osj2Duser_level->Row_Rendering();
  354. // Common render codes for all row types
  355. // user_level_id
  356. $osj2Duser_level->user_level_id->CellCssStyle = "";
  357. $osj2Duser_level->user_level_id->CellCssClass = "";
  358. // user_level_name
  359. $osj2Duser_level->user_level_name->CellCssStyle = "";
  360. $osj2Duser_level->user_level_name->CellCssClass = "";
  361. if ($osj2Duser_level->RowType == EW_ROWTYPE_VIEW) { // View row
  362. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_ADD) { // Add row
  363. // user_level_id
  364. $osj2Duser_level->user_level_id->EditCustomAttributes = "";
  365. $osj2Duser_level->user_level_id->EditValue = ew_HtmlEncode($osj2Duser_level->user_level_id->CurrentValue);
  366. // user_level_name
  367. $osj2Duser_level->user_level_name->EditCustomAttributes = "";
  368. $osj2Duser_level->user_level_name->EditValue = ew_HtmlEncode($osj2Duser_level->user_level_name->CurrentValue);
  369. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { // Edit row
  370. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_SEARCH) { // Search row
  371. }
  372. // Call Row Rendered event
  373. $osj2Duser_level->Row_Rendered();
  374. }
  375. ?>
  376. <?php
  377. // Add record
  378. function AddRow() {
  379. global $conn, $Security, $osj2Duser_level;
  380. if (trim(strval($osj2Duser_level->user_level_id->CurrentValue)) == "") {
  381. $_SESSION[EW_SESSION_MESSAGE] = "Missing User Level ID";
  382. } elseif (trim($osj2Duser_level->user_level_name->CurrentValue) == "") {
  383. $_SESSION[EW_SESSION_MESSAGE] = "Missing User Level name";
  384. } elseif (!is_numeric($osj2Duser_level->user_level_id->CurrentValue)) {
  385. $_SESSION[EW_SESSION_MESSAGE] = "User Level ID must be integer";
  386. } elseif (intval($osj2Duser_level->user_level_id->CurrentValue) < -1) {
  387. $_SESSION[EW_SESSION_MESSAGE] = "User defined User Level ID must be larger than 0";
  388. } elseif (intval($osj2Duser_level->user_level_id->CurrentValue) == 0 && strtolower(trim($osj2Duser_level->user_level_name->CurrentValue)) <> "default") {
  389. $_SESSION[EW_SESSION_MESSAGE] = "User level name for user level 0 must be 'Default'";
  390. } elseif (intval($osj2Duser_level->user_level_id->CurrentValue) == -1 && strtolower(trim($osj2Duser_level->user_level_name->CurrentValue)) <> "administrator") {
  391. $_SESSION[EW_SESSION_MESSAGE] = "User level name for user level -1 must be 'Administrator'";
  392. } elseif (intval($osj2Duser_level->user_level_id->CurrentValue) > 0 && (strtolower(trim($osj2Duser_level->user_level_name->CurrentValue)) == "administrator" || strtolower(trim($osj2Duser_level->user_level_name->CurrentValue)) == "default")) {
  393. $_SESSION[EW_SESSION_MESSAGE] = "User defined User Level name cannot be 'Administrator' or 'Default'";
  394. }
  395. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  396. return FALSE;
  397. }
  398. // Check for duplicate key
  399. $bCheckKey = TRUE;
  400. $sFilter = $osj2Duser_level->SqlKeyFilter();
  401. if (trim(strval($osj2Duser_level->user_level_id->CurrentValue)) == "") {
  402. $bCheckKey = FALSE;
  403. } else {
  404. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level->user_level_id->CurrentValue), $sFilter); // Replace key value
  405. }
  406. if (!is_numeric($osj2Duser_level->user_level_id->CurrentValue)) {
  407. $bCheckKey = FALSE;
  408. }
  409. if ($bCheckKey) {
  410. $rsChk = $osj2Duser_level->LoadRs($sFilter);
  411. if ($rsChk && !$rsChk->EOF) {
  412. $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
  413. $rsChk->Close();
  414. return FALSE;
  415. }
  416. }
  417. $rsnew = array();
  418. // Field user_level_id
  419. $osj2Duser_level->user_level_id->SetDbValueDef($osj2Duser_level->user_level_id->CurrentValue, 0);
  420. $rsnew['user_level_id'] =& $osj2Duser_level->user_level_id->DbValue;
  421. // Field user_level_name
  422. $osj2Duser_level->user_level_name->SetDbValueDef($osj2Duser_level->user_level_name->CurrentValue, "");
  423. $rsnew['user_level_name'] =& $osj2Duser_level->user_level_name->DbValue;
  424. // Call Row Inserting event
  425. $bInsertRow = $osj2Duser_level->Row_Inserting($rsnew);
  426. if ($bInsertRow) {
  427. $conn->raiseErrorFn = 'ew_ErrorFn';
  428. $AddRow = $conn->Execute($osj2Duser_level->InsertSQL($rsnew));
  429. $conn->raiseErrorFn = '';
  430. } else {
  431. if ($osj2Duser_level->CancelMessage <> "") {
  432. $_SESSION[EW_SESSION_MESSAGE] = $osj2Duser_level->CancelMessage;
  433. $osj2Duser_level->CancelMessage = "";
  434. } else {
  435. $_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
  436. }
  437. $AddRow = FALSE;
  438. }
  439. if ($AddRow) {
  440. // Call Row Inserted event
  441. $osj2Duser_level->Row_Inserted($rsnew);
  442. WriteAuditTrailOnAdd($rsnew);
  443. }
  444. // Add User Level priv
  445. if ($GLOBALS["x_ewPriv"] > 0 && is_array($GLOBALS["EW_USER_LEVEL_TABLE_NAME"])) {
  446. for ($i = 0; $i < count($GLOBALS["EW_USER_LEVEL_TABLE_NAME"]); $i++) {
  447. $sSql = "INSERT INTO " . EW_USER_LEVEL_PRIV_TABLE . " (" .
  448. EW_USER_LEVEL_PRIV_TABLE_NAME_FIELD . ", " .
  449. EW_USER_LEVEL_PRIV_USER_LEVEL_ID_FIELD . ", " .
  450. EW_USER_LEVEL_PRIV_PRIV_FIELD . ") VALUES ('" .
  451. ew_AdjustSql($GLOBALS["EW_USER_LEVEL_TABLE_NAME"][$i]) .
  452. "', " . $osj2Duser_level->user_level_id->CurrentValue . ", " . $GLOBALS["x_ewPriv"] . ")";
  453. $conn->Execute($sSql);
  454. }
  455. }
  456. return $AddRow;
  457. }
  458. ?>
  459. <?php
  460. // Write Audit Trail start/end for grid update
  461. function WriteAuditTrailDummy($typ) {
  462. $table = 'osj-user_level';
  463. // Write Audit Trail
  464. $filePfx = "log";
  465. $curDate = date("Y/m/d");
  466. $curTime = date("H:i:s");
  467. $id = ew_ScriptName();
  468. $user = CurrentUserID();
  469. $action = $typ;
  470. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  471. }
  472. ?>
  473. <?php
  474. // Write Audit Trail (add page)
  475. function WriteAuditTrailOnAdd(&$rs) {
  476. global $osj2Duser_level;
  477. $table = 'osj-user_level';
  478. // Get key value
  479. $key = "";
  480. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  481. $key .= $rs['user_level_id'];
  482. // Write Audit Trail
  483. $filePfx = "log";
  484. $curDate = date("Y/m/d");
  485. $curTime = date("H:i:s");
  486. $id = ew_ScriptName();
  487. $user = CurrentUserID();
  488. $action = "A";
  489. $oldvalue = "";
  490. foreach (array_keys($rs) as $fldname) {
  491. if ($osj2Duser_level->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  492. $newvalue = ($osj2Duser_level->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) ? "<MEMO>" : $rs[$fldname]; // Memo Field
  493. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  494. }
  495. }
  496. }
  497. ?>
  498. <?php
  499. // Page Load event
  500. function Page_Load() {
  501. //echo "Page Load";
  502. }
  503. // Page Unload event
  504. function Page_Unload() {
  505. //echo "Page Unload";
  506. }
  507. ?>