PageRenderTime 131ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/osj-osj2dpostsadd.php

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