PageRenderTime 105ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/osj-osj2duser_level_permissionslist.php

http://osjobber.googlecode.com/
PHP | 1304 lines | 1083 code | 107 blank | 114 comment | 299 complexity | 45cfb0317e3eae7b753591e5e9e89f47 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "list", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-user_level_permissions', 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_level_permissionsinfo.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_permissions');
  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_permissions->Export = @$_GET["export"]; // Get export parameter
  47. $sExport = $osj2Duser_level_permissions->Export; // Get export parameter, used in header
  48. $sExportFile = $osj2Duser_level_permissions->TableVar; // Get export file, used in header
  49. ?>
  50. <?php
  51. if ($osj2Duser_level_permissions->Export == "html") {
  52. // Printer friendly, no action required
  53. }
  54. if ($osj2Duser_level_permissions->Export == "xml") {
  55. header('Content-Type: text/xml');
  56. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  57. }
  58. if ($osj2Duser_level_permissions->Export == "csv") {
  59. header('Content-Type: application/csv');
  60. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  61. }
  62. ?>
  63. <?php
  64. // Paging variables
  65. $nStartRec = 0; // Start record index
  66. $nStopRec = 0; // Stop record index
  67. $nTotalRecs = 0; // Total number of records
  68. $nDisplayRecs = 10;
  69. $nRecRange = 10;
  70. $nRecCount = 0; // Record count
  71. // Search filters
  72. $sSrchAdvanced = ""; // Advanced search filter
  73. $sSrchBasic = ""; // Basic search filter
  74. $sSrchWhere = ""; // Search where clause
  75. $sFilter = "";
  76. // Master/Detail
  77. $sDbMasterFilter = ""; // Master filter
  78. $sDbDetailFilter = ""; // Detail filter
  79. $sSqlMaster = ""; // Sql for master record
  80. // Set up records per page dynamically
  81. SetUpDisplayRecs();
  82. // Handle reset command
  83. ResetCmd();
  84. // Check QueryString parameters
  85. if (@$_GET["a"] <> "") {
  86. $osj2Duser_level_permissions->CurrentAction = $_GET["a"];
  87. // Clear inline mode
  88. if ($osj2Duser_level_permissions->CurrentAction == "cancel") {
  89. ClearInlineMode();
  90. }
  91. // Switch to inline edit mode
  92. if ($osj2Duser_level_permissions->CurrentAction == "edit") {
  93. InlineEditMode();
  94. }
  95. } else {
  96. // Create form object
  97. $objForm = new cFormObj;
  98. if (@$_POST["a_list"] <> "") {
  99. $osj2Duser_level_permissions->CurrentAction = $_POST["a_list"]; // Get action
  100. // Inline Update
  101. if ($osj2Duser_level_permissions->CurrentAction == "update" && @$_SESSION[EW_SESSION_INLINE_MODE] == "edit") {
  102. InlineUpdate();
  103. }
  104. }
  105. }
  106. // Build filter
  107. $sFilter = "";
  108. if (!$Security->CanList()) {
  109. $sFilter = "(0=1)"; // Filter all records
  110. }
  111. if ($sDbDetailFilter <> "") {
  112. if ($sFilter <> "") $sFilter .= " AND ";
  113. $sFilter .= "(" . $sDbDetailFilter . ")";
  114. }
  115. if ($sSrchWhere <> "") {
  116. if ($sFilter <> "") $sFilter .= " AND ";
  117. $sFilter .= "(" . $sSrchWhere . ")";
  118. }
  119. // Set up filter in Session
  120. $osj2Duser_level_permissions->setSessionWhere($sFilter);
  121. $osj2Duser_level_permissions->CurrentFilter = "";
  122. // Set Up Sorting Order
  123. SetUpSortOrder();
  124. // Export data only
  125. if ($osj2Duser_level_permissions->Export == "xml" || $osj2Duser_level_permissions->Export == "csv") {
  126. ExportData();
  127. Page_Terminate(); // Terminate response
  128. }
  129. // Set Return Url
  130. $osj2Duser_level_permissions->setReturnUrl("osj-osj2duser_level_permissionslist.php");
  131. ?>
  132. <?php include "osj-header.php" ?>
  133. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  134. <script type="text/javascript">
  135. <!--
  136. var EW_PAGE_ID = "list"; // Page id
  137. var EW_SHOW_HIGHLIGHT = "Show highlight";
  138. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  139. //-->
  140. </script>
  141. <script type="text/javascript">
  142. <!--
  143. function ew_ValidateForm(fobj) {
  144. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  145. return true;
  146. var i, elm, aelm, infix;
  147. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  148. for (i=0; i<rowcnt; i++) {
  149. infix = (fobj.key_count) ? String(i+1) : "";
  150. elm = fobj.elements["x" + infix + "_user_level_table_name"];
  151. if (elm && !ew_HasValue(elm)) {
  152. if (!ew_OnError(elm, "Please enter required field - Permission To Do..."))
  153. return false;
  154. }
  155. elm = fobj.elements["x" + infix + "_user_level_permission"];
  156. if (elm && !ew_HasValue(elm)) {
  157. if (!ew_OnError(elm, "Please enter required field - Permission Level"))
  158. return false;
  159. }
  160. }
  161. return true;
  162. }
  163. //-->
  164. </script>
  165. <script type="text/javascript">
  166. <!--
  167. var firstrowoffset = 1; // First data row start at
  168. var lastrowoffset = 0; // Last data row end at
  169. var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
  170. var rowclass = 'ewTableRow'; // Row class
  171. var rowaltclass = 'ewTableAltRow'; // Row alternate class
  172. var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
  173. var rowselectedclass = 'ewTableSelectRow'; // Row selected class
  174. var roweditclass = 'ewTableEditRow'; // Row edit class
  175. //-->
  176. </script>
  177. <script type="text/javascript">
  178. <!--
  179. var ew_DHTMLEditors = [];
  180. //-->
  181. </script>
  182. <script type="text/javascript">
  183. <!--
  184. // js for Popup Calendar
  185. //-->
  186. </script>
  187. <script type="text/javascript">
  188. <!--
  189. function ew_SelectKey(elem) {
  190. var f = elem.form;
  191. if (!f.elements["key_m[]"]) return;
  192. if (f.elements["key_m[]"][0]) {
  193. for (var i=0; i<f.elements["key_m[]"].length; i++)
  194. f.elements["key_m[]"][i].checked = elem.checked;
  195. } else {
  196. f.elements["key_m[]"].checked = elem.checked;
  197. }
  198. ew_ClickAll(elem);
  199. }
  200. function ew_Selected(f) {
  201. if (!f.elements["key_m[]"]) return false;
  202. if (f.elements["key_m[]"][0]) {
  203. for (var i=0; i<f.elements["key_m[]"].length; i++)
  204. if (f.elements["key_m[]"][i].checked) return true;
  205. } else {
  206. return f.elements["key_m[]"].checked;
  207. }
  208. return false;
  209. }
  210. //-->
  211. </script>
  212. <script language="JavaScript" type="text/javascript">
  213. <!--
  214. // Write your client script here, no need to add script tags.
  215. // To include another .js script, use:
  216. // ew_ClientScriptInclude("my_javascript.js");
  217. //-->
  218. </script>
  219. <?php } ?>
  220. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  221. <?php } ?>
  222. <?php
  223. // Load recordset
  224. $bExportAll = (defined("EW_EXPORT_ALL") && $osj2Duser_level_permissions->Export <> "");
  225. $bSelectLimit = ($osj2Duser_level_permissions->Export == "" && $osj2Duser_level_permissions->SelectLimit);
  226. if (!$bSelectLimit) $rs = LoadRecordset();
  227. $nTotalRecs = ($bSelectLimit) ? $osj2Duser_level_permissions->SelectRecordCount() : $rs->RecordCount();
  228. $nStartRec = 1;
  229. if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
  230. if (!$bExportAll) SetUpStartRec(); // Set up start record position
  231. if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
  232. ?>
  233. <p><span class="phpmaker" style="white-space: nowrap;">TABLE: User Permissions
  234. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  235. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionslist.php?export=html">Printer Friendly</a>
  236. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionslist.php?export=xml">Export to XML</a>
  237. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionslist.php?export=csv">Export to CSV</a>
  238. <?php } ?>
  239. </span></p>
  240. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  241. <?php } ?>
  242. <?php
  243. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  244. ?>
  245. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  246. <?php
  247. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  248. }
  249. ?>
  250. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  251. <form action="osj-osj2duser_level_permissionslist.php" name="ewpagerform" id="ewpagerform">
  252. <table border="0" cellspacing="0" cellpadding="0">
  253. <tr>
  254. <td nowrap>
  255. <span class="phpmaker">
  256. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  257. <?php if ($Pager->RecordCount > 0) { ?>
  258. <?php if ($Pager->FirstButton->Enabled) { ?>
  259. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  260. <?php } ?>
  261. <?php if ($Pager->PrevButton->Enabled) { ?>
  262. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  263. <?php } ?>
  264. <?php foreach ($Pager->Items as $PagerItem) { ?>
  265. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  266. <?php } ?>
  267. <?php if ($Pager->NextButton->Enabled) { ?>
  268. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  269. <?php } ?>
  270. <?php if ($Pager->LastButton->Enabled) { ?>
  271. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  272. <?php } ?>
  273. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  274. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  275. <?php } else { ?>
  276. <?php if ($Security->CanList()) { ?>
  277. <?php if ($sSrchWhere == "0=101") { ?>
  278. Please enter search criteria
  279. <?php } else { ?>
  280. No records found
  281. <?php } ?>
  282. <?php } else { ?>
  283. You do not have the right permission to view the page
  284. <?php } ?>
  285. <?php } ?>
  286. </span>
  287. </td>
  288. <?php if ($nTotalRecs > 0) { ?>
  289. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  290. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  291. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  292. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  293. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  294. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  295. </select>
  296. </span></td>
  297. <?php } ?>
  298. </tr>
  299. </table>
  300. </form>
  301. <?php } ?>
  302. <form name="fosj2Duser_level_permissionslist" id="fosj2Duser_level_permissionslist" action="osj-osj2duser_level_permissionslist.php" method="post">
  303. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  304. <table>
  305. <tr><td><span class="phpmaker">
  306. <?php if ($Security->CanAdd()) { ?>
  307. <a href="osj-osj2duser_level_permissionsadd.php">Add</a>&nbsp;&nbsp;
  308. <?php } ?>
  309. <?php if ($nTotalRecs > 0) { ?>
  310. <?php if ($Security->CanDelete()) { ?>
  311. <a href="" onClick="if (!ew_Selected(document.fosj2Duser_level_permissionslist)) alert('No records selected'); else {document.fosj2Duser_level_permissionslist.action='osj-osj2duser_level_permissionsdelete.php';document.fosj2Duser_level_permissionslist.encoding='application/x-www-form-urlencoded';document.fosj2Duser_level_permissionslist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  312. <?php } ?>
  313. <?php } ?>
  314. </span></td></tr>
  315. </table>
  316. <?php } ?>
  317. <?php if ($nTotalRecs > 0) { ?>
  318. <table id="ewlistmain" class="ewTable">
  319. <?php
  320. $OptionCnt = 0;
  321. if ($Security->CanView()) {
  322. $OptionCnt++; // view
  323. }
  324. if ($Security->CanEdit()) {
  325. $OptionCnt++; // edit
  326. }
  327. if ($Security->CanDelete()) {
  328. $OptionCnt++; // multi select
  329. }
  330. ?>
  331. <!-- Table header -->
  332. <tr class="ewTableHeader">
  333. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  334. <?php if ($Security->CanView()) { ?>
  335. <td nowrap>&nbsp;</td>
  336. <?php } ?>
  337. <?php if ($Security->CanEdit()) { ?>
  338. <td nowrap>&nbsp;</td>
  339. <?php } ?>
  340. <?php if ($Security->CanDelete()) { ?>
  341. <td nowrap><input type="checkbox" class="phpmaker" onClick="ew_SelectKey(this);"></td>
  342. <?php } ?>
  343. <?php } ?>
  344. <td valign="top">
  345. <?php if ($osj2Duser_level_permissions->Export <> "") { ?>
  346. Permission To Do...
  347. <?php } else { ?>
  348. <a href="osj-osj2duser_level_permissionslist.php?order=<?php echo urlencode('user_level_table_name') ?>&ordertype=<?php echo $osj2Duser_level_permissions->user_level_table_name->ReverseSort() ?>">Permission To Do...<?php if ($osj2Duser_level_permissions->user_level_table_name->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Duser_level_permissions->user_level_table_name->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  349. <?php } ?>
  350. </td>
  351. <td valign="top">
  352. <?php if ($osj2Duser_level_permissions->Export <> "") { ?>
  353. Permission Level
  354. <?php } else { ?>
  355. <a href="osj-osj2duser_level_permissionslist.php?order=<?php echo urlencode('user_level_permission') ?>&ordertype=<?php echo $osj2Duser_level_permissions->user_level_permission->ReverseSort() ?>">Permission Level<?php if ($osj2Duser_level_permissions->user_level_permission->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Duser_level_permissions->user_level_permission->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  356. <?php } ?>
  357. </td>
  358. </tr>
  359. <?php
  360. if (defined("EW_EXPORT_ALL") && $osj2Duser_level_permissions->Export <> "") {
  361. $nStopRec = $nTotalRecs;
  362. } else {
  363. $nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
  364. }
  365. $nRecCount = $nStartRec - 1;
  366. if (!$rs->EOF) {
  367. $rs->MoveFirst();
  368. if (!$osj2Duser_level_permissions->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
  369. }
  370. $RowCnt = 0;
  371. $nEditRowCnt = 0;
  372. if ($osj2Duser_level_permissions->CurrentAction == "edit") $RowIndex = 1;
  373. while (!$rs->EOF && $nRecCount < $nStopRec) {
  374. $nRecCount++;
  375. if (intval($nRecCount) >= intval($nStartRec)) {
  376. $RowCnt++;
  377. // Init row class and style
  378. $osj2Duser_level_permissions->CssClass = "ewTableRow";
  379. $osj2Duser_level_permissions->CssStyle = "";
  380. // Init row event
  381. $osj2Duser_level_permissions->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  382. // Display alternate color for rows
  383. if ($RowCnt % 2 == 0) {
  384. $osj2Duser_level_permissions->CssClass = "ewTableAltRow";
  385. }
  386. LoadRowValues($rs); // Load row values
  387. $osj2Duser_level_permissions->RowType = EW_ROWTYPE_VIEW; // Render view
  388. if ($osj2Duser_level_permissions->CurrentAction == "edit") {
  389. if (CheckInlineEditKey() && $nEditRowCnt == 0) { // Inline edit
  390. $osj2Duser_level_permissions->RowType = EW_ROWTYPE_EDIT; // Render edit
  391. }
  392. }
  393. if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT && $osj2Duser_level_permissions->EventCancelled) { // Update failed
  394. if ($osj2Duser_level_permissions->CurrentAction == "edit") {
  395. RestoreFormValues(); // Restore form values
  396. }
  397. }
  398. if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { // Edit row
  399. $nEditRowCnt++;
  400. $osj2Duser_level_permissions->CssClass = "ewTableEditRow";
  401. $osj2Duser_level_permissions->RowClientEvents = "onmouseover='this.edit=true;ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  402. }
  403. RenderRow();
  404. ?>
  405. <!-- Table body -->
  406. <tr<?php echo $osj2Duser_level_permissions->DisplayAttributes() ?>>
  407. <?php if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { ?>
  408. <?php if ($osj2Duser_level_permissions->CurrentAction == "edit") { ?>
  409. <td colspan="<?php echo $OptionCnt ?>" align="right"><span class="phpmaker">
  410. <a href="" onClick="if (ew_ValidateForm(document.fosj2Duser_level_permissionslist)) document.fosj2Duser_level_permissionslist.submit();return false;">Update</a>&nbsp;<a href="osj-osj2duser_level_permissionslist.php?a=cancel">Cancel</a>
  411. <input type="hidden" name="a_list" id="a_list" value="update">
  412. </span></td>
  413. <?php } ?>
  414. <?php } else { ?>
  415. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  416. <?php if ($Security->CanView()) { ?>
  417. <td nowrap><span class="phpmaker">
  418. <a href="<?php echo $osj2Duser_level_permissions->ViewUrl() ?>">View</a>
  419. </span></td>
  420. <?php } ?>
  421. <?php if ($Security->CanEdit()) { ?>
  422. <td nowrap><span class="phpmaker">
  423. <a href="<?php echo $osj2Duser_level_permissions->EditUrl() ?>">Edit</a><span class="ewSeparator">&nbsp;|&nbsp;</span><a href="<?php echo $osj2Duser_level_permissions->InlineEditUrl() ?>">Inline Edit</a>
  424. </span></td>
  425. <?php } ?>
  426. <?php if ($Security->CanDelete()) { ?>
  427. <td nowrap><span class="phpmaker">
  428. <input type="checkbox" name="key_m[]" id="key_m[]" value="<?php echo ew_HtmlEncode($osj2Duser_level_permissions->user_level_id->CurrentValue . EW_COMPOSITE_KEY_SEPARATOR . $osj2Duser_level_permissions->user_level_table_name->CurrentValue) ?>" class="phpmaker" onclick='ew_ClickMultiCheckbox(this);'>
  429. </span></td>
  430. <?php } ?>
  431. <?php } ?>
  432. <?php } ?>
  433. <?php if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { ?>
  434. <input type="hidden" name="x<?php echo $RowIndex ?>_user_level_id" id="x<?php echo $RowIndex ?>_user_level_id" value="<?php echo ew_HtmlEncode($osj2Duser_level_permissions->user_level_id->CurrentValue) ?>">
  435. <?php } ?>
  436. <!-- user_level_table_name -->
  437. <td<?php echo $osj2Duser_level_permissions->user_level_table_name->CellAttributes() ?>>
  438. <?php if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  439. <div<?php echo $osj2Duser_level_permissions->user_level_table_name->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_table_name->EditValue ?></div>
  440. <input type="hidden" name="x<?php echo $RowIndex ?>_user_level_table_name" id="x<?php echo $RowIndex ?>_user_level_table_name" value="<?php echo ew_HtmlEncode($osj2Duser_level_permissions->user_level_table_name->CurrentValue) ?>">
  441. <?php } else { ?>
  442. <div<?php echo $osj2Duser_level_permissions->user_level_table_name->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_table_name->ViewValue ?></div>
  443. <?php } ?>
  444. </td>
  445. <!-- user_level_permission -->
  446. <td<?php echo $osj2Duser_level_permissions->user_level_permission->CellAttributes() ?>>
  447. <?php if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  448. <select id="x<?php echo $RowIndex ?>_user_level_permission" name="x<?php echo $RowIndex ?>_user_level_permission"<?php echo $osj2Duser_level_permissions->user_level_permission->EditAttributes() ?>>
  449. <!--option value="">Please Select</option-->
  450. <?php
  451. if (is_array($osj2Duser_level_permissions->user_level_permission->EditValue)) {
  452. $arwrk = $osj2Duser_level_permissions->user_level_permission->EditValue;
  453. $rowswrk = count($arwrk);
  454. for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
  455. $selwrk = (strval($osj2Duser_level_permissions->user_level_permission->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
  456. ?>
  457. <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
  458. <?php echo $arwrk[$rowcntwrk][1] ?>
  459. </option>
  460. <?php
  461. }
  462. }
  463. ?>
  464. </select>
  465. <?php } else { ?>
  466. <div<?php echo $osj2Duser_level_permissions->user_level_permission->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_permission->ViewValue ?></div>
  467. <?php } ?>
  468. </td>
  469. </tr>
  470. <?php if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { ?>
  471. <?php } ?>
  472. <?php
  473. }
  474. $rs->MoveNext();
  475. }
  476. ?>
  477. </table>
  478. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  479. <table>
  480. <tr><td><span class="phpmaker">
  481. <?php if ($Security->CanAdd()) { ?>
  482. <a href="osj-osj2duser_level_permissionsadd.php">Add</a>&nbsp;&nbsp;
  483. <?php } ?>
  484. <?php if ($nTotalRecs > 0) { ?>
  485. <?php if ($Security->CanDelete()) { ?>
  486. <a href="" onClick="if (!ew_Selected(document.fosj2Duser_level_permissionslist)) alert('No records selected'); else {document.fosj2Duser_level_permissionslist.action='osj-osj2duser_level_permissionsdelete.php';document.fosj2Duser_level_permissionslist.encoding='application/x-www-form-urlencoded';document.fosj2Duser_level_permissionslist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  487. <?php } ?>
  488. <?php } ?>
  489. </span></td></tr>
  490. </table>
  491. <?php } ?>
  492. <?php } ?>
  493. <?php if ($osj2Duser_level_permissions->CurrentAction == "edit") { ?>
  494. <input type="hidden" name="key_count" id="key_count" value="<?php echo $RowIndex ?>">
  495. <?php } ?>
  496. </form>
  497. <?php
  498. // Close recordset and connection
  499. if ($rs) $rs->Close();
  500. ?>
  501. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  502. <form action="osj-osj2duser_level_permissionslist.php" name="ewpagerform" id="ewpagerform">
  503. <table border="0" cellspacing="0" cellpadding="0">
  504. <tr>
  505. <td nowrap>
  506. <span class="phpmaker">
  507. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  508. <?php if ($Pager->RecordCount > 0) { ?>
  509. <?php if ($Pager->FirstButton->Enabled) { ?>
  510. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  511. <?php } ?>
  512. <?php if ($Pager->PrevButton->Enabled) { ?>
  513. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  514. <?php } ?>
  515. <?php foreach ($Pager->Items as $PagerItem) { ?>
  516. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  517. <?php } ?>
  518. <?php if ($Pager->NextButton->Enabled) { ?>
  519. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  520. <?php } ?>
  521. <?php if ($Pager->LastButton->Enabled) { ?>
  522. <a href="osj-osj2duser_level_permissionslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  523. <?php } ?>
  524. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  525. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  526. <?php } else { ?>
  527. <?php if ($Security->CanList()) { ?>
  528. <?php if ($sSrchWhere == "0=101") { ?>
  529. Please enter search criteria
  530. <?php } else { ?>
  531. No records found
  532. <?php } ?>
  533. <?php } else { ?>
  534. You do not have the right permission to view the page
  535. <?php } ?>
  536. <?php } ?>
  537. </span>
  538. </td>
  539. <?php if ($nTotalRecs > 0) { ?>
  540. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  541. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  542. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  543. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  544. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  545. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  546. </select>
  547. </span></td>
  548. <?php } ?>
  549. </tr>
  550. </table>
  551. </form>
  552. <?php } ?>
  553. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  554. <?php } ?>
  555. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  556. <script language="JavaScript" type="text/javascript">
  557. <!--
  558. // Write your table-specific startup script here
  559. // document.write("page loaded");
  560. //-->
  561. </script>
  562. <?php } ?>
  563. <?php include "osj-footer.php" ?>
  564. <?php
  565. // If control is passed here, simply terminate the page without redirect
  566. Page_Terminate();
  567. // -----------------------------------------------------------------
  568. // Subroutine Page_Terminate
  569. // - called when exit page
  570. // - clean up connection and objects
  571. // - if url specified, redirect to url, otherwise end response
  572. function Page_Terminate($url = "") {
  573. global $conn;
  574. // Page unload event, used in current page
  575. Page_Unload();
  576. // Global page unloaded event (in userfn*.php)
  577. Page_Unloaded();
  578. // Close Connection
  579. $conn->Close();
  580. // Go to url if specified
  581. if ($url <> "") {
  582. ob_end_clean();
  583. header("Location: $url");
  584. }
  585. exit();
  586. }
  587. ?>
  588. <?php
  589. // Set up number of records displayed per page
  590. function SetUpDisplayRecs() {
  591. global $nDisplayRecs, $nStartRec, $osj2Duser_level_permissions;
  592. $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
  593. if ($sWrk <> "") {
  594. if (is_numeric($sWrk)) {
  595. $nDisplayRecs = intval($sWrk);
  596. } else {
  597. if (strtolower($sWrk) == "all") { // Display all records
  598. $nDisplayRecs = -1;
  599. } else {
  600. $nDisplayRecs = 10; // Non-numeric, load default
  601. }
  602. }
  603. $osj2Duser_level_permissions->setRecordsPerPage($nDisplayRecs); // Save to Session
  604. // Reset start position
  605. $nStartRec = 1;
  606. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  607. } else {
  608. if ($osj2Duser_level_permissions->getRecordsPerPage() <> "") {
  609. $nDisplayRecs = $osj2Duser_level_permissions->getRecordsPerPage(); // Restore from Session
  610. } else {
  611. $nDisplayRecs = 10; // Load default
  612. }
  613. }
  614. }
  615. // Exit out of inline mode
  616. function ClearInlineMode() {
  617. global $osj2Duser_level_permissions;
  618. $osj2Duser_level_permissions->setKey("user_level_id", ""); // Clear inline edit key
  619. $osj2Duser_level_permissions->setKey("user_level_table_name", ""); // Clear inline edit key
  620. $osj2Duser_level_permissions->CurrentAction = ""; // Clear action
  621. $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
  622. }
  623. // Switch to Inline Edit Mode
  624. function InlineEditMode() {
  625. global $Security, $osj2Duser_level_permissions;
  626. if (!$Security->CanEdit()) Page_Terminate("osj-login.php"); // Go to login page
  627. $bInlineEdit = TRUE;
  628. if (@$_GET["user_level_id"] <> "") {
  629. $osj2Duser_level_permissions->user_level_id->setQueryStringValue($_GET["user_level_id"]);
  630. } else {
  631. $bInlineEdit = FALSE;
  632. }
  633. if (@$_GET["user_level_table_name"] <> "") {
  634. $osj2Duser_level_permissions->user_level_table_name->setQueryStringValue($_GET["user_level_table_name"]);
  635. } else {
  636. $bInlineEdit = FALSE;
  637. }
  638. if ($bInlineEdit) {
  639. if (LoadRow()) {
  640. $osj2Duser_level_permissions->setKey("user_level_id", $osj2Duser_level_permissions->user_level_id->CurrentValue); // Set up inline edit key
  641. $osj2Duser_level_permissions->setKey("user_level_table_name", $osj2Duser_level_permissions->user_level_table_name->CurrentValue); // Set up inline edit key
  642. $_SESSION[EW_SESSION_INLINE_MODE] = "edit"; // Enable inline edit
  643. }
  644. }
  645. }
  646. // Peform update to inline edit record
  647. function InlineUpdate() {
  648. global $objForm, $osj2Duser_level_permissions;
  649. $objForm->Index = 1;
  650. LoadFormValues(); // Get form values
  651. if (CheckInlineEditKey()) { // Check key
  652. $osj2Duser_level_permissions->SendEmail = TRUE; // Send email on update success
  653. $bInlineUpdate = EditRow(); // Update record
  654. } else {
  655. $bInlineUpdate = FALSE;
  656. }
  657. if ($bInlineUpdate) { // Update success
  658. $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Set success message
  659. ClearInlineMode(); // Clear inline edit mode
  660. } else {
  661. if (@$_SESSION[EW_SESSION_MESSAGE] == "") {
  662. $_SESSION[EW_SESSION_MESSAGE] = "Update failed"; // Set update failed message
  663. }
  664. $osj2Duser_level_permissions->EventCancelled = TRUE; // Cancel event
  665. $osj2Duser_level_permissions->CurrentAction = "edit"; // Stay in edit mode
  666. }
  667. }
  668. // Check inline edit key
  669. function CheckInlineEditKey() {
  670. global $osj2Duser_level_permissions;
  671. //CheckInlineEditKey = True
  672. if (strval($osj2Duser_level_permissions->getKey("user_level_id")) <> strval($osj2Duser_level_permissions->user_level_id->CurrentValue)) {
  673. return FALSE;
  674. }
  675. if (strval($osj2Duser_level_permissions->getKey("user_level_table_name")) <> strval($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) {
  676. return FALSE;
  677. }
  678. return TRUE;
  679. }
  680. // Set up Sort parameters based on Sort Links clicked
  681. function SetUpSortOrder() {
  682. global $osj2Duser_level_permissions;
  683. // Check for an Order parameter
  684. if (@$_GET["order"] <> "") {
  685. $osj2Duser_level_permissions->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
  686. $osj2Duser_level_permissions->CurrentOrderType = @$_GET["ordertype"];
  687. // Field user_level_table_name
  688. $osj2Duser_level_permissions->UpdateSort($osj2Duser_level_permissions->user_level_table_name);
  689. // Field user_level_permission
  690. $osj2Duser_level_permissions->UpdateSort($osj2Duser_level_permissions->user_level_permission);
  691. $osj2Duser_level_permissions->setStartRecordNumber(1); // Reset start position
  692. }
  693. $sOrderBy = $osj2Duser_level_permissions->getSessionOrderBy(); // Get order by from Session
  694. if ($sOrderBy == "") {
  695. if ($osj2Duser_level_permissions->SqlOrderBy() <> "") {
  696. $sOrderBy = $osj2Duser_level_permissions->SqlOrderBy();
  697. $osj2Duser_level_permissions->setSessionOrderBy($sOrderBy);
  698. }
  699. }
  700. }
  701. // Reset command based on querystring parameter cmd=
  702. // - RESET: reset search parameters
  703. // - RESETALL: reset search & master/detail parameters
  704. // - RESETSORT: reset sort parameters
  705. function ResetCmd() {
  706. global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
  707. global $osj2Duser_level_permissions;
  708. // Get reset cmd
  709. if (@$_GET["cmd"] <> "") {
  710. $sCmd = $_GET["cmd"];
  711. // Reset Sort Criteria
  712. if (strtolower($sCmd) == "resetsort") {
  713. $sOrderBy = "";
  714. $osj2Duser_level_permissions->setSessionOrderBy($sOrderBy);
  715. $osj2Duser_level_permissions->user_level_table_name->setSort("");
  716. $osj2Duser_level_permissions->user_level_permission->setSort("");
  717. }
  718. // Reset start position
  719. $nStartRec = 1;
  720. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  721. }
  722. }
  723. ?>
  724. <?php
  725. // Set up Starting Record parameters based on Pager Navigation
  726. function SetUpStartRec() {
  727. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Duser_level_permissions;
  728. if ($nDisplayRecs == 0) return;
  729. // Check for a START parameter
  730. if (@$_GET[EW_TABLE_START_REC] <> "") {
  731. $nStartRec = $_GET[EW_TABLE_START_REC];
  732. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  733. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  734. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  735. if (is_numeric($nPageNo)) {
  736. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  737. if ($nStartRec <= 0) {
  738. $nStartRec = 1;
  739. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  740. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  741. }
  742. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  743. } else {
  744. $nStartRec = $osj2Duser_level_permissions->getStartRecordNumber();
  745. }
  746. } else {
  747. $nStartRec = $osj2Duser_level_permissions->getStartRecordNumber();
  748. }
  749. // Check if correct start record counter
  750. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  751. $nStartRec = 1; // Reset start record counter
  752. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  753. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  754. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  755. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  756. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  757. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  758. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  759. }
  760. }
  761. ?>
  762. <?php
  763. // Load form values
  764. function LoadFormValues() {
  765. // Load from form
  766. global $objForm, $osj2Duser_level_permissions;
  767. $osj2Duser_level_permissions->user_level_id->setFormValue($objForm->GetValue("x_user_level_id"));
  768. $osj2Duser_level_permissions->user_level_table_name->setFormValue($objForm->GetValue("x_user_level_table_name"));
  769. $osj2Duser_level_permissions->user_level_permission->setFormValue($objForm->GetValue("x_user_level_permission"));
  770. }
  771. // Restore form values
  772. function RestoreFormValues() {
  773. global $osj2Duser_level_permissions;
  774. $osj2Duser_level_permissions->user_level_id->CurrentValue = $osj2Duser_level_permissions->user_level_id->FormValue;
  775. $osj2Duser_level_permissions->user_level_table_name->CurrentValue = $osj2Duser_level_permissions->user_level_table_name->FormValue;
  776. $osj2Duser_level_permissions->user_level_permission->CurrentValue = $osj2Duser_level_permissions->user_level_permission->FormValue;
  777. }
  778. ?>
  779. <?php
  780. // Load recordset
  781. function LoadRecordset($offset = -1, $rowcnt = -1) {
  782. global $conn, $osj2Duser_level_permissions;
  783. // Call Recordset Selecting event
  784. $osj2Duser_level_permissions->Recordset_Selecting($osj2Duser_level_permissions->CurrentFilter);
  785. // Load list page sql
  786. $sSql = $osj2Duser_level_permissions->SelectSQL();
  787. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  788. // Load recordset
  789. $conn->raiseErrorFn = 'ew_ErrorFn';
  790. $rs = $conn->Execute($sSql);
  791. $conn->raiseErrorFn = '';
  792. // Call Recordset Selected event
  793. $osj2Duser_level_permissions->Recordset_Selected($rs);
  794. return $rs;
  795. }
  796. ?>
  797. <?php
  798. // Load row based on key values
  799. function LoadRow() {
  800. global $conn, $Security, $osj2Duser_level_permissions;
  801. $sFilter = $osj2Duser_level_permissions->SqlKeyFilter();
  802. if (!is_numeric($osj2Duser_level_permissions->user_level_id->CurrentValue)) {
  803. return FALSE; // Invalid key, exit
  804. }
  805. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level_permissions->user_level_id->CurrentValue), $sFilter); // Replace key value
  806. $sFilter = str_replace("@user_level_table_name@", ew_AdjustSql($osj2Duser_level_permissions->user_level_table_name->CurrentValue), $sFilter); // Replace key value
  807. // Call Row Selecting event
  808. $osj2Duser_level_permissions->Row_Selecting($sFilter);
  809. // Load sql based on filter
  810. $osj2Duser_level_permissions->CurrentFilter = $sFilter;
  811. $sSql = $osj2Duser_level_permissions->SQL();
  812. if ($rs = $conn->Execute($sSql)) {
  813. if ($rs->EOF) {
  814. $LoadRow = FALSE;
  815. } else {
  816. $LoadRow = TRUE;
  817. $rs->MoveFirst();
  818. LoadRowValues($rs); // Load row values
  819. // Call Row Selected event
  820. $osj2Duser_level_permissions->Row_Selected($rs);
  821. }
  822. $rs->Close();
  823. } else {
  824. $LoadRow = FALSE;
  825. }
  826. return $LoadRow;
  827. }
  828. // Load row values from recordset
  829. function LoadRowValues(&$rs) {
  830. global $osj2Duser_level_permissions;
  831. $osj2Duser_level_permissions->user_level_id->setDbValue($rs->fields('user_level_id'));
  832. $osj2Duser_level_permissions->user_level_table_name->setDbValue($rs->fields('user_level_table_name'));
  833. $osj2Duser_level_permissions->user_level_permission->setDbValue($rs->fields('user_level_permission'));
  834. }
  835. ?>
  836. <?php
  837. // Render row values based on field settings
  838. function RenderRow() {
  839. global $conn, $Security, $osj2Duser_level_permissions;
  840. // Call Row Rendering event
  841. $osj2Duser_level_permissions->Row_Rendering();
  842. // Common render codes for all row types
  843. // user_level_table_name
  844. $osj2Duser_level_permissions->user_level_table_name->CellCssStyle = "";
  845. $osj2Duser_level_permissions->user_level_table_name->CellCssClass = "";
  846. // user_level_permission
  847. $osj2Duser_level_permissions->user_level_permission->CellCssStyle = "";
  848. $osj2Duser_level_permissions->user_level_permission->CellCssClass = "";
  849. if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_VIEW) { // View row
  850. // user_level_table_name
  851. if (!is_null($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) {
  852. switch ($osj2Duser_level_permissions->user_level_table_name->CurrentValue) {
  853. case "osj-applications":
  854. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Applications";
  855. break;
  856. case "osj-applications":
  857. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Applications";
  858. break;
  859. case "osj-posts":
  860. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Postings";
  861. break;
  862. case "osj-resumes":
  863. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Resumes";
  864. break;
  865. case "osj-users":
  866. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Users";
  867. break;
  868. case "osj-user_detail":
  869. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Detail Page";
  870. break;
  871. case "osj-user_level":
  872. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Levels";
  873. break;
  874. case "osj-user_level_permissions":
  875. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Permission Levels";
  876. break;
  877. default:
  878. $osj2Duser_level_permissions->user_level_table_name->ViewValue = $osj2Duser_level_permissions->user_level_table_name->CurrentValue;
  879. }
  880. } else {
  881. $osj2Duser_level_permissions->user_level_table_name->ViewValue = NULL;
  882. }
  883. $osj2Duser_level_permissions->user_level_table_name->CssStyle = "";
  884. $osj2Duser_level_permissions->user_level_table_name->CssClass = "";
  885. $osj2Duser_level_permissions->user_level_table_name->ViewCustomAttributes = "";
  886. // user_level_permission
  887. if (!is_null($osj2Duser_level_permissions->user_level_permission->CurrentValue)) {
  888. switch ($osj2Duser_level_permissions->user_level_permission->CurrentValue) {
  889. case "0":
  890. $osj2Duser_level_permissions->user_level_permission->ViewValue = "No Permission";
  891. break;
  892. case "1":
  893. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add Only";
  894. break;
  895. case "2":
  896. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Delete Only";
  897. break;
  898. case "4":
  899. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Edit Only";
  900. break;
  901. case "8":
  902. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View Only";
  903. break;
  904. case "5":
  905. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Edit";
  906. break;
  907. case "3":
  908. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Delete";
  909. break;
  910. case "7":
  911. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Edit/Delete";
  912. break;
  913. case "6":
  914. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Edit/Delete";
  915. break;
  916. case "9":
  917. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add";
  918. break;
  919. case "11":
  920. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Delete";
  921. break;
  922. case "12":
  923. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Edit";
  924. break;
  925. case "10":
  926. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Delete";
  927. break;
  928. case "14":
  929. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Edit/Delete";
  930. break;
  931. case "13":
  932. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Edit";
  933. break;
  934. case "15":
  935. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Edit/Delete";
  936. break;
  937. default:
  938. $osj2Duser_level_permissions->user_level_permission->ViewValue = $osj2Duser_level_permissions->user_level_permission->CurrentValue;
  939. }
  940. } else {
  941. $osj2Duser_level_permissions->user_level_permission->ViewValue = NULL;
  942. }
  943. $osj2Duser_level_permissions->user_level_permission->CssStyle = "";
  944. $osj2Duser_level_permissions->user_level_permission->CssClass = "";
  945. $osj2Duser_level_permissions->user_level_permission->ViewCustomAttributes = "";
  946. // user_level_table_name
  947. $osj2Duser_level_permissions->user_level_table_name->HrefValue = "";
  948. // user_level_permission
  949. $osj2Duser_level_permissions->user_level_permission->HrefValue = "";
  950. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_ADD) { // Add row
  951. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { // Edit row
  952. // user_level_table_name
  953. $osj2Duser_level_permissions->user_level_table_name->EditCustomAttributes = "";
  954. if (!is_null($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) {
  955. switch ($osj2Duser_level_permissions->user_level_table_name->CurrentValue) {
  956. case "osj-applications":
  957. $osj2Duser_level_permissions->user_level_table_name->EditValue = "Applications";
  958. break;
  959. case "osj-applications":
  960. $osj2Duser_level_permissions->user_level_table_name->EditValue = "Applications";
  961. break;
  962. case "osj-posts":
  963. $osj2Duser_level_permissions->user_level_table_name->EditValue = "Postings";
  964. break;
  965. case "osj-resumes":
  966. $osj2Duser_level_permissions->user_level_table_name->EditValue = "Resumes";
  967. break;
  968. case "osj-users":
  969. $osj2Duser_level_permissions->user_level_table_name->EditValue = "Users";
  970. break;
  971. case "osj-user_detail":
  972. $osj2Duser_level_permissions->user_level_table_name->EditValue = "User Detail Page";
  973. break;
  974. case "osj-user_level":
  975. $osj2Duser_level_permissions->user_level_table_name->EditValue = "User Levels";
  976. break;
  977. case "osj-user_level_permissions":
  978. $osj2Duser_level_permissions->user_level_table_name->EditValue = "User Permission Levels";
  979. break;
  980. default:
  981. $osj2Duser_level_permissions->user_level_table_name->EditValue = $osj2Duser_level_permissions->user_level_table_name->CurrentValue;
  982. }
  983. } else {
  984. $osj2Duser_level_permissions->user_level_table_name->EditValue = NULL;
  985. }
  986. $osj2Duser_level_permissions->user_level_table_name->CssStyle = "";
  987. $osj2Duser_level_permissions->user_level_table_name->CssClass = "";
  988. $osj2Duser_level_permissions->user_level_table_name->ViewCustomAttributes = "";
  989. // user_level_permission
  990. $osj2Duser_level_permissions->user_level_permission->EditCustomAttributes = "";
  991. $arwrk = array();
  992. $arwrk[] = array("0", "No Permission");
  993. $arwrk[] = array("1", "Add Only");
  994. $arwrk[] = array("2", "Delete Only");
  995. $arwrk[] = array("4", "Edit Only");
  996. $arwrk[] = array("8", "View Only");
  997. $arwrk[] = array("5", "Add/Edit");
  998. $arwrk[] = array("3", "Add/Delete");
  999. $arwrk[] = array("7", "Add/Edit/Delete");
  1000. $arwrk[] = array("6", "Edit/Delete");
  1001. $arwrk[] = array("9", "View/Add");
  1002. $arwrk[] = array("11", "View/Add/Delete");
  1003. $arwrk[] = array("12", "View/Edit");
  1004. $arwrk[] = array("10", "View/Delete");
  1005. $arwrk[] = array("14", "View/Edit/Delete");
  1006. $arwrk[] = array("13", "View/Add/Edit");
  1007. $arwrk[] = array("15", "View/Add/Edit/Delete");
  1008. array_unshift($arwrk, array("", "Please Select"));
  1009. $osj2Duser_level_permissions->user_level_permission->EditValue = $arwrk;
  1010. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_SEARCH) { // Search row
  1011. }
  1012. // Call Row Rendered event
  1013. $osj2Duser_level_permissions->Row_Rendered();
  1014. }
  1015. ?>
  1016. <?php
  1017. // Update record based on key values
  1018. function EditRow() {
  1019. global $conn, $Security, $osj2Duser_level_permissions;
  1020. $sFilter = $osj2Duser_level_permissions->SqlKeyFilter();
  1021. if (!is_numeric($osj2Duser_level_permissions->user_level_id->CurrentValue)) {
  1022. return FALSE;
  1023. }
  1024. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level_permissions->user_level_id->CurrentValue), $sFilter); // Replace key value
  1025. $sFilter = str_replace("@user_level_table_name@", ew_AdjustSql($osj2Duser_level_permissions->user_level_table_name->CurrentValue), $sFilter); // Replace key value
  1026. $osj2Duser_level_permissions->CurrentFilter = $sFilter;
  1027. $sSql = $osj2Duser_level_permissions->SQL();
  1028. $conn->raiseErrorFn = 'ew_ErrorFn';
  1029. $rs = $conn->Execute($sSql);
  1030. $conn->raiseErrorFn = '';
  1031. if ($rs === FALSE)
  1032. return FALSE;
  1033. if ($rs->EOF) {
  1034. $EditRow = FALSE; // Update Failed
  1035. } else {
  1036. // Save old values
  1037. $rsold =& $rs->fields;
  1038. $rsnew = array();
  1039. // Field user_level_table_name
  1040. // Field user_level_permission
  1041. $osj2Duser_level_permissions->user_level_permission->SetDbValueDef($osj2Duser_level_permissions->user_level_permission->CurrentValue, 0);
  1042. $rsnew['user_level_permission'] =& $osj2Duser_level_permissions->user_level_permission->DbValue;
  1043. // Call Row Updating event
  1044. $bUpdateRow = $osj2Duser_level_permissions->Row_Updating($rsold, $rsnew);
  1045. if ($bUpdateRow) {
  1046. $conn->raiseErrorFn = 'ew_ErrorFn';
  1047. $EditRow = $conn->Execute($osj2Duser_level_permissions->UpdateSQL($rsnew));
  1048. $conn->raiseErrorFn = '';
  1049. } else {
  1050. if ($osj2Duser_level_permissions->CancelMessage <> "") {
  1051. $_SESSION[EW_SESSION_MESSAGE] = $osj2Duser_level_permissions->CancelMessage;
  1052. $osj2Duser_level_permissions->CancelMessage = "";
  1053. } else {
  1054. $_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
  1055. }
  1056. $EditRow = FALSE;
  1057. }
  1058. }
  1059. // Call Row Updated event
  1060. if ($EditRow) {
  1061. $osj2Duser_level_permissions->Row_Updated($rsold, $rsnew);
  1062. }
  1063. if ($EditRow) {
  1064. WriteAuditTrailOnEdit($rsold, $rsnew);
  1065. }
  1066. $rs->Close();
  1067. return $EditRow;
  1068. }
  1069. ?>
  1070. <?php
  1071. // Export data in Xml or Csv format
  1072. function ExportData() {
  1073. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Duser_level_permissions;
  1074. $sCsvStr = "";
  1075. $rs = LoadRecordset();
  1076. $nTotalRecs = $rs->RecordCount();
  1077. $nStartRec = 1;
  1078. // Export all
  1079. if (defined("EW_EXPORT_ALL")) {
  1080. $nStopRec = $nTotalRecs;
  1081. } else { // Export 1 page only
  1082. SetUpStartRec(); // Set Up Start Record Position
  1083. // Set the last record to display
  1084. if ($nDisplayRecs < 0) {
  1085. $nStopRec = $nTotalRecs;
  1086. } else {
  1087. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  1088. }
  1089. }
  1090. if ($osj2Duser_level_permissions->Export == "xml") {
  1091. $XmlDoc = new cXMLDocument();
  1092. }
  1093. if ($osj2Duser_level_permissions->Export == "csv") {
  1094. $sCsvStr .= "user_level_table_name" . ",";
  1095. $sCsvStr .= "user_level_permission" . ",";
  1096. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  1097. $sCsvStr .= "\n";
  1098. }
  1099. // Move to first record directly for performance reason
  1100. $nRecCount = $nStartRec - 1;
  1101. if (!$rs->EOF) {
  1102. $rs->MoveFirst();
  1103. $rs->Move($nStartRec - 1);
  1104. }
  1105. while (!$rs->EOF && $nRecCount < $nStopRec) {
  1106. $nRecCount++;
  1107. if (intval($nRecCount) >= intval($nStartRec)) {
  1108. LoadRowValues($rs);
  1109. if ($osj2Duser_level_permissions->Export == "xml") {
  1110. $XmlDoc->BeginRow();
  1111. $XmlDoc->AddField('user_level_table_name', $osj2Duser_level_permissions->user_level_table_name->CurrentValue);
  1112. $XmlDoc->AddField('user_level_permission', $osj2Duser_level_permissions->user_level_permission->CurrentValue);
  1113. $XmlDoc->EndRow();
  1114. }
  1115. if ($osj2Duser_level_permissions->Export == "csv") {
  1116. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) . '",';
  1117. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level_permissions->user_level_permission->CurrentValue)) . '",';
  1118. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  1119. $sCsvStr .= "\n";
  1120. }
  1121. }
  1122. $rs->MoveNext();
  1123. }
  1124. // Close recordset
  1125. $rs->Close();
  1126. if ($osj2Duser_level_permissions->Export == "xml") {
  1127. header("Content-Type: text/xml");
  1128. echo $XmlDoc->XML();
  1129. }
  1130. if ($osj2Duser_level_permissions->Export == "csv") {
  1131. echo $sCsvStr;
  1132. }
  1133. }
  1134. ?>
  1135. <?php
  1136. // Write Audit Trail start/end for grid update
  1137. function WriteAuditTrailDummy($typ) {
  1138. $table = 'osj-user_level_permissions';
  1139. // Write Audit Trail
  1140. $filePfx = "log";
  1141. $curDate = date("Y/m/d");
  1142. $curTime = date("H:i:s");
  1143. $id = ew_ScriptName();
  1144. $user = CurrentUserID();
  1145. $action = $typ;
  1146. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  1147. }
  1148. ?>
  1149. <?php
  1150. // Write Audit Trail (edit page)
  1151. function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
  1152. global $osj2Duser_level_permissions;
  1153. $table = 'osj-user_level_permissions';
  1154. // Get key value
  1155. $key = "";
  1156. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  1157. $key .= $rsold['user_level_id'];
  1158. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  1159. $key .= $rsold['user_level_table_name'];
  1160. // Write Audit Trail
  1161. $filePfx = "log";
  1162. $curDate = date("Y/m/d");
  1163. $curTime = date("H:i:s");
  1164. $id = ew_ScriptName();
  1165. $user = CurrentUserID();
  1166. $action = "U";
  1167. foreach (array_keys($rsnew) as $fldname) {
  1168. if ($osj2Duser_level_permissions->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  1169. if ($osj2Duser_level_permissions->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // DateTime Field
  1170. $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
  1171. } else {
  1172. $modified = ($rsold[$fldname] <> $rsnew[$fldname]);
  1173. }
  1174. if ($modified) {
  1175. if ($osj2Duser_level_permissions->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo Field
  1176. $oldvalue = "<MEMO>";
  1177. $newvalue = "<MEMO>";
  1178. } else {
  1179. $oldvalue = $rsold[$fldname];
  1180. $newvalue = $rsnew[$fldname];
  1181. }
  1182. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  1183. }
  1184. }
  1185. }
  1186. }
  1187. ?>
  1188. <?php
  1189. // Page Load event
  1190. function Page_Load() {
  1191. //echo "Page Load";
  1192. }
  1193. // Page Unload event
  1194. function Page_Unload() {
  1195. //echo "Page Unload";
  1196. }
  1197. ?>