PageRenderTime 168ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/osj-osj2dpostsedit.php

http://osjobber.googlecode.com/
PHP | 595 lines | 561 code | 17 blank | 17 comment | 36 complexity | 171b1148ff8395d5b5591fccccd27ee6 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "edit", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-posts', 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-osj2dpostsinfo.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-posts');
  32. if (!$Security->IsLoggedIn()) {
  33. $Security->SaveLastUrl();
  34. Page_Terminate("osj-login.php");
  35. }
  36. if (!$Security->CanEdit()) {
  37. $Security->SaveLastUrl();
  38. Page_Terminate("osj-osj2dpostslist.php");
  39. }
  40. if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
  41. $_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
  42. Page_Terminate("osj-login.php");
  43. }
  44. ?>
  45. <?php
  46. // Common page loading event (in userfn*.php)
  47. Page_Loading();
  48. ?>
  49. <?php
  50. // Page load event, used in current page
  51. Page_Load();
  52. ?>
  53. <?php
  54. $osj2Dposts->Export = @$_GET["export"]; // Get export parameter
  55. $sExport = $osj2Dposts->Export; // Get export parameter, used in header
  56. $sExportFile = $osj2Dposts->TableVar; // Get export file, used in header
  57. ?>
  58. <?php
  59. // Load key from QueryString
  60. if (@$_GET["post_id"] <> "") {
  61. $osj2Dposts->post_id->setQueryStringValue($_GET["post_id"]);
  62. }
  63. // Create form object
  64. $objForm = new cFormObj();
  65. if (@$_POST["a_edit"] <> "") {
  66. $osj2Dposts->CurrentAction = $_POST["a_edit"]; // Get action code
  67. LoadFormValues(); // Get form values
  68. } else {
  69. $osj2Dposts->CurrentAction = "I"; // Default action is display
  70. }
  71. // Check if valid key
  72. if ($osj2Dposts->post_id->CurrentValue == "") Page_Terminate($osj2Dposts->getReturnUrl()); // Invalid key, exit
  73. switch ($osj2Dposts->CurrentAction) {
  74. case "I": // Get a record to display
  75. if (!LoadRow()) { // Load Record based on key
  76. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
  77. Page_Terminate($osj2Dposts->getReturnUrl()); // Return to caller
  78. }
  79. break;
  80. Case "U": // Update
  81. $osj2Dposts->SendEmail = TRUE; // Send email on update success
  82. if (EditRow()) { // Update Record based on key
  83. $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Update success
  84. Page_Terminate($osj2Dposts->getReturnUrl()); // Return to caller
  85. } else {
  86. RestoreFormValues(); // Restore form values if update failed
  87. }
  88. }
  89. // Render the record
  90. $osj2Dposts->RowType = EW_ROWTYPE_EDIT; // Render as edit
  91. RenderRow();
  92. ?>
  93. <?php include "osj-header.php" ?>
  94. <script type="text/javascript">
  95. <!--
  96. var EW_PAGE_ID = "edit"; // Page id
  97. var EW_SHOW_HIGHLIGHT = "Show highlight";
  98. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  99. //-->
  100. </script>
  101. <script type="text/javascript">
  102. <!--
  103. function ew_ValidateForm(fobj) {
  104. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  105. return true;
  106. var i, elm, aelm, infix;
  107. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  108. for (i=0; i<rowcnt; i++) {
  109. infix = (fobj.key_count) ? String(i+1) : "";
  110. elm = fobj.elements["x" + infix + "_post_title"];
  111. if (elm && !ew_HasValue(elm)) {
  112. if (!ew_OnError(elm, "Please enter required field - Title"))
  113. return false;
  114. }
  115. elm = fobj.elements["x" + infix + "_post_description"];
  116. if (elm && !ew_HasValue(elm)) {
  117. if (!ew_OnError(elm, "Please enter required field - Description"))
  118. return false;
  119. }
  120. elm = fobj.elements["x" + infix + "_post_email"];
  121. if (elm && !ew_HasValue(elm)) {
  122. if (!ew_OnError(elm, "Please enter required field - Post Response Email"))
  123. return false;
  124. }
  125. elm = fobj.elements["x" + infix + "_post_url"];
  126. if (elm && !ew_HasValue(elm)) {
  127. if (!ew_OnError(elm, "Please enter required field - Post Response URL"))
  128. return false;
  129. }
  130. }
  131. return true;
  132. }
  133. //-->
  134. </script>
  135. <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  136. <script type="text/javascript">
  137. <!--
  138. _width_multiplier = 16;
  139. _height_multiplier = 60;
  140. var ew_DHTMLEditors = [];
  141. function ew_UpdateTextArea() {
  142. if (typeof ew_DHTMLEditors != 'undefined' &&
  143. typeof FCKeditorAPI != 'undefined') {
  144. var inst;
  145. for (inst in FCKeditorAPI.__Instances)
  146. FCKeditorAPI.__Instances[inst].UpdateLinkedField();
  147. }
  148. }
  149. //-->
  150. </script>
  151. <script type="text/javascript">
  152. <!--
  153. // js for Popup Calendar
  154. //-->
  155. </script>
  156. <script type="text/javascript">
  157. <!--
  158. var ew_MultiPagePage = "Page"; // multi-page Page Text
  159. var ew_MultiPageOf = "of"; // multi-page Of Text
  160. var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
  161. var ew_MultiPageNext = "Next"; // multi-page Next Text
  162. //-->
  163. </script>
  164. <script language="JavaScript" type="text/javascript">
  165. <!--
  166. // Write your client script here, no need to add script tags.
  167. // To include another .js script, use:
  168. // ew_ClientScriptInclude("my_javascript.js");
  169. //-->
  170. </script>
  171. <p><span class="phpmaker">Edit TABLE: Posts<br><br><a href="<?php echo $osj2Dposts->getReturnUrl() ?>">Go Back</a></span></p>
  172. <?php
  173. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  174. ?>
  175. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  176. <?php
  177. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  178. }
  179. ?>
  180. <form name="fosj2Dpostsedit" id="fosj2Dpostsedit" action="osj-osj2dpostsedit.php" method="post">
  181. <p>
  182. <input type="hidden" name="a_edit" id="a_edit" value="U">
  183. <table class="ewTable">
  184. <input type="hidden" name="x_post_id" id="x_post_id" value="<?php echo ew_HtmlEncode($osj2Dposts->post_id->CurrentValue) ?>">
  185. <tr class="ewTableRow">
  186. <td class="ewTableHeader">Title<span class='ewmsg'>&nbsp;*</span></td>
  187. <td<?php echo $osj2Dposts->post_title->CellAttributes() ?>><span id="cb_x_post_title">
  188. <div><input type="text" name="x_post_title" id="x_post_title" size="30" value="<?php echo $osj2Dposts->post_title->EditValue ?>" onblur="ew_AstHideDiv('as_x_post_title');" onkeydown="ew_AstOnKeyDown('x_post_title', 'as_x_post_title', event);" onkeypress="return ew_AstOnKeyPress(event);" onkeyup="ew_AstOnKeyUp('x_post_title', 'as_x_post_title', event);" autocomplete="off"></div>
  189. <div class='ewAstList' style='visibility:hidden' id='as_x_post_title'></div>
  190. <input type="hidden" name="sv_x_post_title" id="sv_x_post_title" value="">
  191. <?php
  192. $sSqlWrk = "SELECT DISTINCT `post_title`, `post_description` FROM `osj-posts` WHERE (`post_title` LIKE '@FILTER_VALUE%')";
  193. $sSqlWrk .= " ORDER BY `post_creation_date` ";
  194. $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
  195. ?>
  196. <input type="hidden" name="s_x_post_title" id="s_x_post_title" value="<?php echo $sSqlWrk ?>">
  197. <input type="hidden" name="lt_x_post_title" id="lt_x_post_title" value="1">
  198. </span></td>
  199. </tr>
  200. <tr class="ewTableAltRow">
  201. <td class="ewTableHeader">Description<span class='ewmsg'>&nbsp;*</span></td>
  202. <td<?php echo $osj2Dposts->post_description->CellAttributes() ?>><span id="cb_x_post_description">
  203. <textarea name="x_post_description" id="x_post_description" cols="35" rows="4"<?php echo $osj2Dposts->post_description->EditAttributes() ?>><?php echo $osj2Dposts->post_description->EditValue ?></textarea>
  204. <script type="text/javascript">
  205. <!--
  206. var editor = new ew_DHTMLEditor("x_post_description");
  207. editor.create = function() {
  208. var sBasePath = 'fckeditor/';
  209. var oFCKeditor = new FCKeditor('x_post_description', 35*_width_multiplier, 4*_height_multiplier);
  210. oFCKeditor.BasePath = sBasePath;
  211. oFCKeditor.ReplaceTextarea();
  212. this.active = true;
  213. }
  214. ew_DHTMLEditors[ew_DHTMLEditors.length] = editor;
  215. -->
  216. </script>
  217. </span></td>
  218. </tr>
  219. <tr class="ewTableRow">
  220. <td class="ewTableHeader">Post Response Email<span class='ewmsg'>&nbsp;*</span></td>
  221. <td<?php echo $osj2Dposts->post_email->CellAttributes() ?>><span id="cb_x_post_email">
  222. <input type="text" name="x_post_email" id="x_post_email" size="30" maxlength="255" value="<?php echo $osj2Dposts->post_email->EditValue ?>"<?php echo $osj2Dposts->post_email->EditAttributes() ?>>
  223. </span></td>
  224. </tr>
  225. <tr class="ewTableAltRow">
  226. <td class="ewTableHeader">Category ID's<span class='ewmsg'>&nbsp;*</span></td>
  227. <td<?php echo $osj2Dposts->post_categories->CellAttributes() ?>><span id="cb_x_post_categories">
  228. <input type="text" name="x_post_categories" id="x_post_categories" size="30" maxlength="255" value="<?php echo $osj2Dposts->post_categories->EditValue ?>"<?php echo $osj2Dposts->post_categories->EditAttributes() ?>>
  229. </span></td>
  230. </tr>
  231. <tr class="ewTableRow">
  232. <td class="ewTableHeader">Post Response URL<span class='ewmsg'>&nbsp;*</span></td>
  233. <td<?php echo $osj2Dposts->post_url->CellAttributes() ?>><span id="cb_x_post_url">
  234. <input type="text" name="x_post_url" id="x_post_url" size="30" maxlength="255" value="<?php echo $osj2Dposts->post_url->EditValue ?>"<?php echo $osj2Dposts->post_url->EditAttributes() ?>>
  235. </span></td>
  236. </tr>
  237. </table>
  238. <p>
  239. <input type="button" name="btnAction" id="btnAction" value=" Edit " onClick="ew_SubmitForm(this.form);">
  240. </form>
  241. <script type="text/javascript">
  242. <!--
  243. ew_CreateEditor(); // Create DHTML editor(s)
  244. //-->
  245. </script>
  246. <script language="JavaScript" type="text/javascript">
  247. <!--
  248. // Write your table-specific startup script here
  249. // document.write("page loaded");
  250. //-->
  251. </script>
  252. <?php include "osj-footer.php" ?>
  253. <?php
  254. // If control is passed here, simply terminate the page without redirect
  255. Page_Terminate();
  256. // -----------------------------------------------------------------
  257. // Subroutine Page_Terminate
  258. // - called when exit page
  259. // - clean up connection and objects
  260. // - if url specified, redirect to url, otherwise end response
  261. function Page_Terminate($url = "") {
  262. global $conn;
  263. // Page unload event, used in current page
  264. Page_Unload();
  265. // Global page unloaded event (in userfn*.php)
  266. Page_Unloaded();
  267. // Close Connection
  268. $conn->Close();
  269. // Go to url if specified
  270. if ($url <> "") {
  271. ob_end_clean();
  272. header("Location: $url");
  273. }
  274. exit();
  275. }
  276. ?>
  277. <?php
  278. // Load form values
  279. function LoadFormValues() {
  280. // Load from form
  281. global $objForm, $osj2Dposts;
  282. $osj2Dposts->post_id->setFormValue($objForm->GetValue("x_post_id"));
  283. $osj2Dposts->post_creation_date->setFormValue($objForm->GetValue("x_post_creation_date"));
  284. $osj2Dposts->post_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dposts->post_creation_date->CurrentValue, 6);
  285. $osj2Dposts->post_title->setFormValue($objForm->GetValue("x_post_title"));
  286. $osj2Dposts->post_description->setFormValue($objForm->GetValue("x_post_description"));
  287. $osj2Dposts->post_email->setFormValue($objForm->GetValue("x_post_email"));
  288. $osj2Dposts->post_categories->setFormValue($objForm->GetValue("x_post_categories"));
  289. $osj2Dposts->post_url->setFormValue($objForm->GetValue("x_post_url"));
  290. }
  291. // Restore form values
  292. function RestoreFormValues() {
  293. global $osj2Dposts;
  294. $osj2Dposts->post_id->CurrentValue = $osj2Dposts->post_id->FormValue;
  295. $osj2Dposts->post_creation_date->CurrentValue = $osj2Dposts->post_creation_date->FormValue;
  296. $osj2Dposts->post_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dposts->post_creation_date->CurrentValue, 6);
  297. $osj2Dposts->post_title->CurrentValue = $osj2Dposts->post_title->FormValue;
  298. $osj2Dposts->post_description->CurrentValue = $osj2Dposts->post_description->FormValue;
  299. $osj2Dposts->post_email->CurrentValue = $osj2Dposts->post_email->FormValue;
  300. $osj2Dposts->post_categories->CurrentValue = $osj2Dposts->post_categories->FormValue;
  301. $osj2Dposts->post_url->CurrentValue = $osj2Dposts->post_url->FormValue;
  302. }
  303. ?>
  304. <?php
  305. // Load row based on key values
  306. function LoadRow() {
  307. global $conn, $Security, $osj2Dposts;
  308. $sFilter = $osj2Dposts->SqlKeyFilter();
  309. if (!is_numeric($osj2Dposts->post_id->CurrentValue)) {
  310. return FALSE; // Invalid key, exit
  311. }
  312. $sFilter = str_replace("@post_id@", ew_AdjustSql($osj2Dposts->post_id->CurrentValue), $sFilter); // Replace key value
  313. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  314. $sFilter = $osj2Dposts->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  315. }
  316. // Call Row Selecting event
  317. $osj2Dposts->Row_Selecting($sFilter);
  318. // Load sql based on filter
  319. $osj2Dposts->CurrentFilter = $sFilter;
  320. $sSql = $osj2Dposts->SQL();
  321. if ($rs = $conn->Execute($sSql)) {
  322. if ($rs->EOF) {
  323. $LoadRow = FALSE;
  324. } else {
  325. $LoadRow = TRUE;
  326. $rs->MoveFirst();
  327. LoadRowValues($rs); // Load row values
  328. // Call Row Selected event
  329. $osj2Dposts->Row_Selected($rs);
  330. }
  331. $rs->Close();
  332. } else {
  333. $LoadRow = FALSE;
  334. }
  335. return $LoadRow;
  336. }
  337. // Load row values from recordset
  338. function LoadRowValues(&$rs) {
  339. global $osj2Dposts;
  340. $osj2Dposts->post_id->setDbValue($rs->fields('post_id'));
  341. $osj2Dposts->user_id->setDbValue($rs->fields('user_id'));
  342. $osj2Dposts->post_creation_date->setDbValue($rs->fields('post_creation_date'));
  343. $osj2Dposts->post_title->setDbValue($rs->fields('post_title'));
  344. $osj2Dposts->post_description->setDbValue($rs->fields('post_description'));
  345. $osj2Dposts->post_email->setDbValue($rs->fields('post_email'));
  346. $osj2Dposts->post_categories->setDbValue($rs->fields('post_categories'));
  347. $osj2Dposts->post_url->setDbValue($rs->fields('post_url'));
  348. $osj2Dposts->post_edit_date->setDbValue($rs->fields('post_edit_date'));
  349. }
  350. ?>
  351. <?php
  352. // Render row values based on field settings
  353. function RenderRow() {
  354. global $conn, $Security, $osj2Dposts;
  355. // Call Row Rendering event
  356. $osj2Dposts->Row_Rendering();
  357. // Common render codes for all row types
  358. // post_creation_date
  359. $osj2Dposts->post_creation_date->CellCssStyle = "";
  360. $osj2Dposts->post_creation_date->CellCssClass = "";
  361. // post_title
  362. $osj2Dposts->post_title->CellCssStyle = "";
  363. $osj2Dposts->post_title->CellCssClass = "";
  364. // post_description
  365. $osj2Dposts->post_description->CellCssStyle = "";
  366. $osj2Dposts->post_description->CellCssClass = "";
  367. // post_email
  368. $osj2Dposts->post_email->CellCssStyle = "";
  369. $osj2Dposts->post_email->CellCssClass = "";
  370. // post_categories
  371. $osj2Dposts->post_categories->CellCssStyle = "";
  372. $osj2Dposts->post_categories->CellCssClass = "";
  373. // post_url
  374. $osj2Dposts->post_url->CellCssStyle = "";
  375. $osj2Dposts->post_url->CellCssClass = "";
  376. if ($osj2Dposts->RowType == EW_ROWTYPE_VIEW) { // View row
  377. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_ADD) { // Add row
  378. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_EDIT) { // Edit row
  379. // post_title
  380. $osj2Dposts->post_title->EditCustomAttributes = "";
  381. $osj2Dposts->post_title->EditValue = ew_HtmlEncode($osj2Dposts->post_title->CurrentValue);
  382. // post_description
  383. $osj2Dposts->post_description->EditCustomAttributes = "";
  384. $osj2Dposts->post_description->EditValue = ew_HtmlEncode($osj2Dposts->post_description->CurrentValue);
  385. // post_email
  386. $osj2Dposts->post_email->EditCustomAttributes = "";
  387. $osj2Dposts->post_email->EditValue = ew_HtmlEncode($osj2Dposts->post_email->CurrentValue);
  388. // post_categories
  389. $osj2Dposts->post_categories->EditCustomAttributes = "";
  390. $osj2Dposts->post_categories->EditValue = ew_HtmlEncode($osj2Dposts->post_categories->CurrentValue);
  391. // post_url
  392. $osj2Dposts->post_url->EditCustomAttributes = "";
  393. $osj2Dposts->post_url->EditValue = ew_HtmlEncode($osj2Dposts->post_url->CurrentValue);
  394. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_SEARCH) { // Search row
  395. }
  396. // Call Row Rendered event
  397. $osj2Dposts->Row_Rendered();
  398. }
  399. ?>
  400. <?php
  401. // Update record based on key values
  402. function EditRow() {
  403. global $conn, $Security, $osj2Dposts;
  404. $sFilter = $osj2Dposts->SqlKeyFilter();
  405. if (!is_numeric($osj2Dposts->post_id->CurrentValue)) {
  406. return FALSE;
  407. }
  408. $sFilter = str_replace("@post_id@", ew_AdjustSql($osj2Dposts->post_id->CurrentValue), $sFilter); // Replace key value
  409. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  410. $sFilter = $osj2Dposts->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  411. $osj2Dposts->CurrentFilter = $sFilter;
  412. }
  413. $osj2Dposts->CurrentFilter = $sFilter;
  414. $sSql = $osj2Dposts->SQL();
  415. $conn->raiseErrorFn = 'ew_ErrorFn';
  416. $rs = $conn->Execute($sSql);
  417. $conn->raiseErrorFn = '';
  418. if ($rs === FALSE)
  419. return FALSE;
  420. if ($rs->EOF) {
  421. $EditRow = FALSE; // Update Failed
  422. } else {
  423. // Save old values
  424. $rsold =& $rs->fields;
  425. $rsnew = array();
  426. // Field post_title
  427. $osj2Dposts->post_title->SetDbValueDef($osj2Dposts->post_title->CurrentValue, "");
  428. $rsnew['post_title'] =& $osj2Dposts->post_title->DbValue;
  429. // Field post_description
  430. $osj2Dposts->post_description->SetDbValueDef($osj2Dposts->post_description->CurrentValue, "");
  431. $rsnew['post_description'] =& $osj2Dposts->post_description->DbValue;
  432. // Field post_email
  433. $osj2Dposts->post_email->SetDbValueDef($osj2Dposts->post_email->CurrentValue, "");
  434. $rsnew['post_email'] =& $osj2Dposts->post_email->DbValue;
  435. // Field post_categories
  436. $osj2Dposts->post_categories->SetDbValueDef($osj2Dposts->post_categories->CurrentValue, "");
  437. $rsnew['post_categories'] =& $osj2Dposts->post_categories->DbValue;
  438. // Field post_url
  439. $osj2Dposts->post_url->SetDbValueDef($osj2Dposts->post_url->CurrentValue, "");
  440. $rsnew['post_url'] =& $osj2Dposts->post_url->DbValue;
  441. // Call Row Updating event
  442. $bUpdateRow = $osj2Dposts->Row_Updating($rsold, $rsnew);
  443. if ($bUpdateRow) {
  444. $conn->raiseErrorFn = 'ew_ErrorFn';
  445. $EditRow = $conn->Execute($osj2Dposts->UpdateSQL($rsnew));
  446. $conn->raiseErrorFn = '';
  447. } else {
  448. if ($osj2Dposts->CancelMessage <> "") {
  449. $_SESSION[EW_SESSION_MESSAGE] = $osj2Dposts->CancelMessage;
  450. $osj2Dposts->CancelMessage = "";
  451. } else {
  452. $_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
  453. }
  454. $EditRow = FALSE;
  455. }
  456. }
  457. // Call Row Updated event
  458. if ($EditRow) {
  459. $osj2Dposts->Row_Updated($rsold, $rsnew);
  460. }
  461. if ($EditRow) {
  462. WriteAuditTrailOnEdit($rsold, $rsnew);
  463. }
  464. $rs->Close();
  465. return $EditRow;
  466. }
  467. ?>
  468. <?php
  469. // Write Audit Trail start/end for grid update
  470. function WriteAuditTrailDummy($typ) {
  471. $table = 'osj-posts';
  472. // Write Audit Trail
  473. $filePfx = "log";
  474. $curDate = date("Y/m/d");
  475. $curTime = date("H:i:s");
  476. $id = ew_ScriptName();
  477. $user = CurrentUserID();
  478. $action = $typ;
  479. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  480. }
  481. ?>
  482. <?php
  483. // Write Audit Trail (edit page)
  484. function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
  485. global $osj2Dposts;
  486. $table = 'osj-posts';
  487. // Get key value
  488. $key = "";
  489. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  490. $key .= $rsold['post_id'];
  491. // Write Audit Trail
  492. $filePfx = "log";
  493. $curDate = date("Y/m/d");
  494. $curTime = date("H:i:s");
  495. $id = ew_ScriptName();
  496. $user = CurrentUserID();
  497. $action = "U";
  498. foreach (array_keys($rsnew) as $fldname) {
  499. if ($osj2Dposts->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  500. if ($osj2Dposts->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // DateTime Field
  501. $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
  502. } else {
  503. $modified = ($rsold[$fldname] <> $rsnew[$fldname]);
  504. }
  505. if ($modified) {
  506. if ($osj2Dposts->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo Field
  507. $oldvalue = "<MEMO>";
  508. $newvalue = "<MEMO>";
  509. } else {
  510. $oldvalue = $rsold[$fldname];
  511. $newvalue = $rsnew[$fldname];
  512. }
  513. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  514. }
  515. }
  516. }
  517. }
  518. ?>
  519. <?php
  520. // Page Load event
  521. function Page_Load() {
  522. //echo "Page Load";
  523. }
  524. // Page Unload event
  525. function Page_Unload() {
  526. //echo "Page Unload";
  527. }
  528. ?>