/osj-osj2dusersedit.php
PHP | 632 lines | 599 code | 16 blank | 17 comment | 42 complexity | 7c192e38c11642f6a2e8403d2cac8c92 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
- <?php
- define("EW_PAGE_ID", "edit", TRUE); // Page ID
- define("EW_TABLE_NAME", 'osj-users', TRUE);
- ?>
- <?php
- session_start(); // Initialize session data
- ob_start(); // Turn on output buffering
- ?>
- <?php include "osj-ewcfg50.php" ?>
- <?php include "osj-ewmysql50.php" ?>
- <?php include "osj-phpfn50.php" ?>
- <?php include "osj-osj2dusersinfo.php" ?>
- <?php include "osj-userfn50.php" ?>
- <?php
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
- header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache"); // HTTP/1.0
- ?>
- <?php
-
- // Open connection to the database
- $conn = ew_Connect();
- ?>
- <?php
- $Security = new cAdvancedSecurity();
- ?>
- <?php
- if (!$Security->IsLoggedIn()) $Security->AutoLogin();
- $Security->LoadCurrentUserLevel('osj-users');
- if (!$Security->IsLoggedIn()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-login.php");
- }
- if (!$Security->CanEdit()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-osj2duserslist.php");
- }
- if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
- $_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
- Page_Terminate("osj-login.php");
- }
- ?>
- <?php
-
- // Common page loading event (in userfn*.php)
- Page_Loading();
- ?>
- <?php
-
- // Page load event, used in current page
- Page_Load();
- ?>
- <?php
- $osj2Dusers->Export = @$_GET["export"]; // Get export parameter
- $sExport = $osj2Dusers->Export; // Get export parameter, used in header
- $sExportFile = $osj2Dusers->TableVar; // Get export file, used in header
- ?>
- <?php
-
- // Load key from QueryString
- if (@$_GET["user_id"] <> "") {
- $osj2Dusers->user_id->setQueryStringValue($_GET["user_id"]);
- }
-
- // Create form object
- $objForm = new cFormObj();
- if (@$_POST["a_edit"] <> "") {
- $osj2Dusers->CurrentAction = $_POST["a_edit"]; // Get action code
- LoadFormValues(); // Get form values
- } else {
- $osj2Dusers->CurrentAction = "I"; // Default action is display
- }
-
- // Check if valid key
- if ($osj2Dusers->user_id->CurrentValue == "") Page_Terminate($osj2Dusers->getReturnUrl()); // Invalid key, exit
- switch ($osj2Dusers->CurrentAction) {
- case "I": // Get a record to display
- if (!LoadRow()) { // Load Record based on key
- $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
- Page_Terminate($osj2Dusers->getReturnUrl()); // Return to caller
- }
- break;
- Case "U": // Update
- $osj2Dusers->SendEmail = TRUE; // Send email on update success
- if (EditRow()) { // Update Record based on key
- $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Update success
- Page_Terminate($osj2Dusers->getReturnUrl()); // Return to caller
- } else {
- RestoreFormValues(); // Restore form values if update failed
- }
- }
-
- // Render the record
- $osj2Dusers->RowType = EW_ROWTYPE_EDIT; // Render as edit
- RenderRow();
- ?>
- <?php include "osj-header.php" ?>
- <script type="text/javascript">
- <!--
- var EW_PAGE_ID = "edit"; // Page id
- var EW_SHOW_HIGHLIGHT = "Show highlight";
- var EW_HIDE_HIGHLIGHT = "Hide highlight";
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- function ew_ValidateForm(fobj) {
- if (fobj.a_confirm && fobj.a_confirm.value == "F")
- return true;
- var i, elm, aelm, infix;
- var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
- for (i=0; i<rowcnt; i++) {
- infix = (fobj.key_count) ? String(i+1) : "";
- elm = fobj.elements["x" + infix + "_user_email"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Email"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_email"];
- if (elm && !ew_CheckEmail(elm.value)) {
- if (!ew_OnError(elm, "Users must provide a valid email address."))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_password"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Password"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_level"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - User Level"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_status"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - User Status"))
- return false;
- }
- }
- return true;
- }
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
- var ew_DHTMLEditors = [];
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- // js for Popup Calendar
- //-->
-
- </script>
- <script type="text/javascript">
- <!--
- var ew_MultiPagePage = "Page"; // multi-page Page Text
- var ew_MultiPageOf = "of"; // multi-page Of Text
- var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
- var ew_MultiPageNext = "Next"; // multi-page Next Text
-
- //-->
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your client script here, no need to add script tags.
- // To include another .js script, use:
- // ew_ClientScriptInclude("my_javascript.js");
- //-->
-
- </script>
- <p><span class="phpmaker">Edit TABLE: Users<br><br><a href="<?php echo $osj2Dusers->getReturnUrl() ?>">Go Back</a></span></p>
- <?php
- if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
- ?>
- <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
- <?php
- $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
- }
- ?>
- <form name="fosj2Dusersedit" id="fosj2Dusersedit" action="osj-osj2dusersedit.php" method="post" onSubmit="return ew_ValidateForm(this);">
- <p>
- <input type="hidden" name="a_edit" id="a_edit" value="U">
- <table class="ewTable">
- <input type="hidden" name="x_user_id" id="x_user_id" value="<?php echo ew_HtmlEncode($osj2Dusers->user_id->CurrentValue) ?>">
- <tr class="ewTableRow">
- <td class="ewTableHeader">Email<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dusers->user_email->CellAttributes() ?>><span id="cb_x_user_email">
- <input type="text" name="x_user_email" id="x_user_email" title="Email" size="30" maxlength="255" value="<?php echo $osj2Dusers->user_email->EditValue ?>"<?php echo $osj2Dusers->user_email->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Password<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dusers->user_password->CellAttributes() ?>><span id="cb_x_user_password">
- <input type="password" name="x_user_password" id="x_user_password" title="Password" value="<?php echo $osj2Dusers->user_password->EditValue ?>" size="30" maxlength="255"<?php echo $osj2Dusers->user_password->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableRow">
- <td class="ewTableHeader">User Level<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dusers->user_level->CellAttributes() ?>><span id="cb_x_user_level">
- <?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
- <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->EditValue ?></div>
- <?php } else { ?>
- <select id="x_user_level" name="x_user_level"<?php echo $osj2Dusers->user_level->EditAttributes() ?>>
- <!--option value="">Please Select</option-->
- <?php
- if (is_array($osj2Dusers->user_level->EditValue)) {
- $arwrk = $osj2Dusers->user_level->EditValue;
- $rowswrk = count($arwrk);
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($osj2Dusers->user_level->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- <?php
- $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
- $sSqlWrk .= " WHERE (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
- $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
- ?>
- <input type="hidden" name="s_x_user_level" id="s_x_user_level" value="<?php echo $sSqlWrk ?>"><input type="hidden" name="lc_x_user_level" id="lc_x_user_level" value="2"><input type="hidden" name="ld1_x_user_level" id="ld1_x_user_level" value="1"><input type="hidden" name="ld2_x_user_level" id="ld2_x_user_level" value="-1"><input type="hidden" name="lft_x_user_level" id="lft_x_user_level" value="1">
- <a href="javascript:void(0);" onclick="ew_ShowAddOption('x_user_level');">Add User Level</a>
- </span><span>
- <div id="ao_x_user_level" style="display: none;">
- <input type="hidden" id="ltn_x_user_level" value="osj-user_level">
- <input type="hidden" id="lfn_x_user_level" value="user_level_id">
- <input type="hidden" id="dfn_x_user_level" value="user_level_name">
- <input type="hidden" id="lfm_x_user_level" value="Please enter required field - user level id">
- <input type="hidden" id="dfm_x_user_level" value="Please enter required field - user level name">
- <input type="hidden" id="lfq_x_user_level" value="">
- <input type="hidden" id="dfq_x_user_level" value="'">
- <table class="ewAddOption">
- <tr><td><span>user level id</span></td><td><input type="text" id="lf_x_user_level" size="30"></td></tr>
- <tr><td><span>user level name</span></td><td><input type="text" id="df_x_user_level" size="30" maxlength="50"></td></tr>
- <tr><td colspan="2" align="right"><input type="button" value="Add" onClick="ew_PostNewOption('x_user_level')"><input type="button" value="Cancel" onClick="ew_HideAddOption('x_user_level')"></td></tr>
- </table>
- </div>
- <?php } ?>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">User Status<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dusers->user_status->CellAttributes() ?>><span id="cb_x_user_status">
- <select id="x_user_status" name="x_user_status"<?php echo $osj2Dusers->user_status->EditAttributes() ?>>
- <!--option value="">Please Select</option-->
- <?php
- if (is_array($osj2Dusers->user_status->EditValue)) {
- $arwrk = $osj2Dusers->user_status->EditValue;
- $rowswrk = count($arwrk);
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($osj2Dusers->user_status->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- </span></td>
- </tr>
- </table>
- <p>
- <input type="submit" name="btnAction" id="btnAction" value=" Edit ">
- </form>
- <script language="JavaScript">
- <!--
- var f = document.fosj2Dusersedit;
- ew_AjaxUpdateOpt(f.x_user_level, f.x_user_level, false);
-
- //-->
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php include "osj-footer.php" ?>
- <?php
-
- // If control is passed here, simply terminate the page without redirect
- Page_Terminate();
-
- // -----------------------------------------------------------------
- // Subroutine Page_Terminate
- // - called when exit page
- // - clean up connection and objects
- // - if url specified, redirect to url, otherwise end response
- function Page_Terminate($url = "") {
- global $conn;
-
- // Page unload event, used in current page
- Page_Unload();
-
- // Global page unloaded event (in userfn*.php)
- Page_Unloaded();
-
- // Close Connection
- $conn->Close();
-
- // Go to url if specified
- if ($url <> "") {
- ob_end_clean();
- header("Location: $url");
- }
- exit();
- }
- ?>
- <?php
-
- // Load form values
- function LoadFormValues() {
-
- // Load from form
- global $objForm, $osj2Dusers;
- $osj2Dusers->user_id->setFormValue($objForm->GetValue("x_user_id"));
- $osj2Dusers->user_email->setFormValue($objForm->GetValue("x_user_email"));
- $osj2Dusers->user_password->setFormValue($objForm->GetValue("x_user_password"));
- $osj2Dusers->user_level->setFormValue($objForm->GetValue("x_user_level"));
- $osj2Dusers->user_status->setFormValue($objForm->GetValue("x_user_status"));
- }
-
- // Restore form values
- function RestoreFormValues() {
- global $osj2Dusers;
- $osj2Dusers->user_id->CurrentValue = $osj2Dusers->user_id->FormValue;
- $osj2Dusers->user_email->CurrentValue = $osj2Dusers->user_email->FormValue;
- $osj2Dusers->user_password->CurrentValue = $osj2Dusers->user_password->FormValue;
- $osj2Dusers->user_level->CurrentValue = $osj2Dusers->user_level->FormValue;
- $osj2Dusers->user_status->CurrentValue = $osj2Dusers->user_status->FormValue;
- }
- ?>
- <?php
-
- // Load row based on key values
- function LoadRow() {
- global $conn, $Security, $osj2Dusers;
- $sFilter = $osj2Dusers->SqlKeyFilter();
- if (!is_numeric($osj2Dusers->user_id->CurrentValue)) {
- return FALSE; // Invalid key, exit
- }
- $sFilter = str_replace("@user_id@", ew_AdjustSql($osj2Dusers->user_id->CurrentValue), $sFilter); // Replace key value
- if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
- $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
- }
-
- // Call Row Selecting event
- $osj2Dusers->Row_Selecting($sFilter);
-
- // Load sql based on filter
- $osj2Dusers->CurrentFilter = $sFilter;
- $sSql = $osj2Dusers->SQL();
- if ($rs = $conn->Execute($sSql)) {
- if ($rs->EOF) {
- $LoadRow = FALSE;
- } else {
- $LoadRow = TRUE;
- $rs->MoveFirst();
- LoadRowValues($rs); // Load row values
-
- // Call Row Selected event
- $osj2Dusers->Row_Selected($rs);
- }
- $rs->Close();
- } else {
- $LoadRow = FALSE;
- }
- return $LoadRow;
- }
-
- // Load row values from recordset
- function LoadRowValues(&$rs) {
- global $osj2Dusers;
- $osj2Dusers->user_id->setDbValue($rs->fields('user_id'));
- $osj2Dusers->user_creation_date->setDbValue($rs->fields('user_creation_date'));
- $osj2Dusers->user_edit_date->setDbValue($rs->fields('user_edit_date'));
- $osj2Dusers->user_email->setDbValue($rs->fields('user_email'));
- $osj2Dusers->user_password->setDbValue($rs->fields('user_password'));
- $osj2Dusers->user_level->setDbValue($rs->fields('user_level'));
- $osj2Dusers->user_status->setDbValue($rs->fields('user_status'));
- }
- ?>
- <?php
-
- // Render row values based on field settings
- function RenderRow() {
- global $conn, $Security, $osj2Dusers;
-
- // Call Row Rendering event
- $osj2Dusers->Row_Rendering();
-
- // Common render codes for all row types
- // user_email
-
- $osj2Dusers->user_email->CellCssStyle = "";
- $osj2Dusers->user_email->CellCssClass = "";
-
- // user_password
- $osj2Dusers->user_password->CellCssStyle = "";
- $osj2Dusers->user_password->CellCssClass = "";
-
- // user_level
- $osj2Dusers->user_level->CellCssStyle = "";
- $osj2Dusers->user_level->CellCssClass = "";
-
- // user_status
- $osj2Dusers->user_status->CellCssStyle = "";
- $osj2Dusers->user_status->CellCssClass = "";
- if ($osj2Dusers->RowType == EW_ROWTYPE_VIEW) { // View row
- } elseif ($osj2Dusers->RowType == EW_ROWTYPE_ADD) { // Add row
- } elseif ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit row
-
- // user_email
- $osj2Dusers->user_email->EditCustomAttributes = "";
- $osj2Dusers->user_email->EditValue = ew_HtmlEncode($osj2Dusers->user_email->CurrentValue);
-
- // user_password
- $osj2Dusers->user_password->EditCustomAttributes = "";
- $osj2Dusers->user_password->EditValue = ew_HtmlEncode($osj2Dusers->user_password->CurrentValue);
-
- // user_level
- $osj2Dusers->user_level->EditCustomAttributes = "";
- if (!$Security->CanAdmin()) { // System admin
- $osj2Dusers->user_level->EditValue = "********";
- } else {
- $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
- if (trim(strval($osj2Dusers->user_level->CurrentValue)) == "") {
- $sSqlWrk .= " WHERE 0=1";
- } else {
- $sSqlWrk .= " WHERE `user_level_id` = " . ew_AdjustSql($osj2Dusers->user_level->CurrentValue) . "";
- }
- $sSqlWrk .= " AND (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
- $rswrk = $conn->Execute($sSqlWrk);
- $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
- if ($rswrk) $rswrk->Close();
- array_unshift($arwrk, array("", "Please Select"));
- $osj2Dusers->user_level->EditValue = $arwrk;
- }
-
- // user_status
- $osj2Dusers->user_status->EditCustomAttributes = "";
- $arwrk = array();
- $arwrk[] = array("0", "Inactive");
- $arwrk[] = array("1", "Active");
- array_unshift($arwrk, array("", "Please Select"));
- $osj2Dusers->user_status->EditValue = $arwrk;
- } elseif ($osj2Dusers->RowType == EW_ROWTYPE_SEARCH) { // Search row
- }
-
- // Call Row Rendered event
- $osj2Dusers->Row_Rendered();
- }
- ?>
- <?php
-
- // Update record based on key values
- function EditRow() {
- global $conn, $Security, $osj2Dusers;
- $sFilter = $osj2Dusers->SqlKeyFilter();
- if (!is_numeric($osj2Dusers->user_id->CurrentValue)) {
- return FALSE;
- }
- $sFilter = str_replace("@user_id@", ew_AdjustSql($osj2Dusers->user_id->CurrentValue), $sFilter); // Replace key value
- if ($osj2Dusers->user_email->CurrentValue <> "") { // Check field with unique index
- $sFilterChk = "(`user_email` = '" . ew_AdjustSql($osj2Dusers->user_email->CurrentValue) . "')";
- $sFilterChk .= " AND NOT (" . $sFilter . ")";
- $osj2Dusers->CurrentFilter = $sFilterChk;
- $sSqlChk = $osj2Dusers->SQL();
- $conn->raiseErrorFn = 'ew_ErrorFn';
- $rsChk = $conn->Execute($sSqlChk);
- $conn->raiseErrorFn = '';
- if ($rsChk === FALSE) {
- return FALSE;
- } elseif (!$rsChk->EOF) {
- $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for index or primary key -- `user_email`, value = " . $osj2Dusers->user_email->CurrentValue;
- $rsChk->Close();
- return FALSE;
- }
- $rsChk->Close();
- }
- if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
- $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
- $osj2Dusers->CurrentFilter = $sFilter;
- }
- $osj2Dusers->CurrentFilter = $sFilter;
- $sSql = $osj2Dusers->SQL();
- $conn->raiseErrorFn = 'ew_ErrorFn';
- $rs = $conn->Execute($sSql);
- $conn->raiseErrorFn = '';
- if ($rs === FALSE)
- return FALSE;
- if ($rs->EOF) {
- $EditRow = FALSE; // Update Failed
- } else {
-
- // Save old values
- $rsold =& $rs->fields;
- $rsnew = array();
-
- // Field user_email
- $osj2Dusers->user_email->SetDbValueDef($osj2Dusers->user_email->CurrentValue, "");
- $rsnew['user_email'] =& $osj2Dusers->user_email->DbValue;
-
- // Field user_password
- $osj2Dusers->user_password->SetDbValueDef($osj2Dusers->user_password->CurrentValue, "");
- $rsnew['user_password'] =& $osj2Dusers->user_password->DbValue;
-
- // Field user_level
- if ($Security->CanAdmin()) { // System admin
- $osj2Dusers->user_level->SetDbValueDef($osj2Dusers->user_level->CurrentValue, 0);
- $rsnew['user_level'] =& $osj2Dusers->user_level->DbValue;
- }
-
- // Field user_status
- $osj2Dusers->user_status->SetDbValueDef($osj2Dusers->user_status->CurrentValue, 0);
- $rsnew['user_status'] =& $osj2Dusers->user_status->DbValue;
-
- // Call Row Updating event
- $bUpdateRow = $osj2Dusers->Row_Updating($rsold, $rsnew);
- if ($bUpdateRow) {
- $conn->raiseErrorFn = 'ew_ErrorFn';
- $EditRow = $conn->Execute($osj2Dusers->UpdateSQL($rsnew));
- $conn->raiseErrorFn = '';
- } else {
- if ($osj2Dusers->CancelMessage <> "") {
- $_SESSION[EW_SESSION_MESSAGE] = $osj2Dusers->CancelMessage;
- $osj2Dusers->CancelMessage = "";
- } else {
- $_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
- }
- $EditRow = FALSE;
- }
- }
-
- // Call Row Updated event
- if ($EditRow) {
- $osj2Dusers->Row_Updated($rsold, $rsnew);
- }
- if ($EditRow) {
- WriteAuditTrailOnEdit($rsold, $rsnew);
- }
- $rs->Close();
- return $EditRow;
- }
- ?>
- <?php
-
- // Write Audit Trail start/end for grid update
- function WriteAuditTrailDummy($typ) {
- $table = 'osj-users';
-
- // Write Audit Trail
- $filePfx = "log";
- $curDate = date("Y/m/d");
- $curTime = date("H:i:s");
- $id = ew_ScriptName();
- $user = CurrentUserID();
- $action = $typ;
- ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
- }
- ?>
- <?php
-
- // Write Audit Trail (edit page)
- function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
- global $osj2Dusers;
- $table = 'osj-users';
-
- // Get key value
- $key = "";
- if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
- $key .= $rsold['user_id'];
-
- // Write Audit Trail
- $filePfx = "log";
- $curDate = date("Y/m/d");
- $curTime = date("H:i:s");
- $id = ew_ScriptName();
- $user = CurrentUserID();
- $action = "U";
- foreach (array_keys($rsnew) as $fldname) {
- if ($osj2Dusers->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
- if ($osj2Dusers->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // DateTime Field
- $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
- } else {
- $modified = ($rsold[$fldname] <> $rsnew[$fldname]);
- }
- if ($modified) {
- if ($osj2Dusers->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo Field
- $oldvalue = "<MEMO>";
- $newvalue = "<MEMO>";
- } else {
- $oldvalue = $rsold[$fldname];
- $newvalue = $rsnew[$fldname];
- }
- ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
- }
- }
- }
- }
- ?>
- <?php
-
- // Page Load event
- function Page_Load() {
-
- //echo "Page Load";
- }
-
- // Page Unload event
- function Page_Unload() {
-
- //echo "Page Unload";
- }
- ?>