PageRenderTime 102ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/osj-osj2duser_level_permissionsview.php

http://osjobber.googlecode.com/
PHP | 693 lines | 574 code | 56 blank | 63 comment | 127 complexity | 2d28409b73b2183ef207309998d84aca MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "view", 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 (@$_GET["user_level_id"] <> "") {
  52. if ($sExportFile <> "") $sExportFile .= "_";
  53. $sExportFile .= ew_StripSlashes($_GET["user_level_id"]);
  54. }
  55. if (@$_GET["user_level_table_name"] <> "") {
  56. if ($sExportFile <> "") $sExportFile .= "_";
  57. $sExportFile .= ew_StripSlashes($_GET["user_level_table_name"]);
  58. }
  59. if ($osj2Duser_level_permissions->Export == "html") {
  60. // Printer friendly, no action required
  61. }
  62. if ($osj2Duser_level_permissions->Export == "xml") {
  63. header('Content-Type: text/xml');
  64. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  65. }
  66. if ($osj2Duser_level_permissions->Export == "csv") {
  67. header('Content-Type: application/csv');
  68. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  69. }
  70. ?>
  71. <?php
  72. // Paging variables
  73. $nStartRec = 0; // Start record index
  74. $nStopRec = 0; // Stop record index
  75. $nTotalRecs = 0; // Total number of records
  76. $nDisplayRecs = 1;
  77. $nRecRange = 10;
  78. // Load current record
  79. $bLoadCurrentRecord = FALSE;
  80. if (@$_GET["user_level_id"] <> "") {
  81. $osj2Duser_level_permissions->user_level_id->setQueryStringValue($_GET["user_level_id"]);
  82. } else {
  83. $bLoadCurrentRecord = TRUE;
  84. }
  85. if (@$_GET["user_level_table_name"] <> "") {
  86. $osj2Duser_level_permissions->user_level_table_name->setQueryStringValue($_GET["user_level_table_name"]);
  87. } else {
  88. $bLoadCurrentRecord = TRUE;
  89. }
  90. // Get action
  91. if (@$_POST["a_view"] <> "") {
  92. $osj2Duser_level_permissions->CurrentAction = $_POST["a_view"];
  93. } else {
  94. $osj2Duser_level_permissions->CurrentAction = "I"; // Display form
  95. }
  96. switch ($osj2Duser_level_permissions->CurrentAction) {
  97. case "I": // Get a record to display
  98. $nStartRec = 1; // Initialize start position
  99. $rs = LoadRecordset(); // Load records
  100. $nTotalRecs = $rs->RecordCount(); // Get record count
  101. if ($nTotalRecs <= 0) { // No record found
  102. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  103. Page_Terminate("osj-osj2duser_level_permissionslist.php"); // Return to list page
  104. } elseif ($bLoadCurrentRecord) { // Load current record position
  105. SetUpStartRec(); // Set up start record position
  106. // Point to current record
  107. if (intval($nStartRec) <= intval($nTotalRecs)) {
  108. $rs->Move($nStartRec-1);
  109. }
  110. } else { // Match key values
  111. $bMatchRecord = FALSE;
  112. while (!$rs->EOF) {
  113. if (strval($osj2Duser_level_permissions->user_level_id->CurrentValue) == strval($rs->fields('user_level_id')) AND strval($osj2Duser_level_permissions->user_level_table_name->CurrentValue) == strval($rs->fields('user_level_table_name'))) {
  114. $bMatchRecord = TRUE;
  115. break;
  116. } else {
  117. $nStartRec++;
  118. $rs->MoveNext();
  119. }
  120. }
  121. if (!$bMatchRecord) {
  122. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  123. Page_Terminate("osj-osj2duser_level_permissionslist.php"); // Return to list
  124. } else {
  125. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec); // Save record position
  126. }
  127. }
  128. LoadRowValues($rs); // Load row values
  129. }
  130. // Export data only
  131. if ($osj2Duser_level_permissions->Export == "xml" || $osj2Duser_level_permissions->Export == "csv") {
  132. ExportData();
  133. Page_Terminate(); // Terminate response
  134. }
  135. // Set return url
  136. $osj2Duser_level_permissions->setReturnUrl("osj-osj2duser_level_permissionsview.php");
  137. // Render row
  138. $osj2Duser_level_permissions->RowType = EW_ROWTYPE_VIEW;
  139. RenderRow();
  140. ?>
  141. <?php include "osj-header.php" ?>
  142. <script type="text/javascript">
  143. <!--
  144. var EW_PAGE_ID = "view"; // Page id
  145. var EW_SHOW_HIGHLIGHT = "Show highlight";
  146. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  147. //-->
  148. </script>
  149. <script language="JavaScript" type="text/javascript">
  150. <!--
  151. // Write your client script here, no need to add script tags.
  152. // To include another .js script, use:
  153. // ew_ClientScriptInclude("my_javascript.js");
  154. //-->
  155. </script>
  156. <p><span class="phpmaker">View TABLE: User Permissions
  157. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  158. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionsview.php?export=html&user_level_id=<?php echo urlencode($osj2Duser_level_permissions->user_level_id->CurrentValue) ?>&user_level_table_name=<?php echo urlencode($osj2Duser_level_permissions->user_level_table_name->CurrentValue) ?>">Printer Friendly</a>
  159. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionsview.php?export=xml&user_level_id=<?php echo urlencode($osj2Duser_level_permissions->user_level_id->CurrentValue) ?>&user_level_table_name=<?php echo urlencode($osj2Duser_level_permissions->user_level_table_name->CurrentValue) ?>">Export to XML</a>
  160. &nbsp;&nbsp;<a href="osj-osj2duser_level_permissionsview.php?export=csv&user_level_id=<?php echo urlencode($osj2Duser_level_permissions->user_level_id->CurrentValue) ?>&user_level_table_name=<?php echo urlencode($osj2Duser_level_permissions->user_level_table_name->CurrentValue) ?>">Export to CSV</a>
  161. <?php } ?>
  162. <br><br>
  163. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  164. <a href="osj-osj2duser_level_permissionslist.php">Back to List</a>&nbsp;
  165. <?php if ($Security->CanAdd()) { ?>
  166. <a href="osj-osj2duser_level_permissionsadd.php">Add</a>&nbsp;
  167. <?php } ?>
  168. <?php if ($Security->CanEdit()) { ?>
  169. <a href="<?php echo $osj2Duser_level_permissions->EditUrl() ?>">Edit</a>&nbsp;
  170. <?php } ?>
  171. <?php if ($Security->CanDelete()) { ?>
  172. <a href="<?php echo $osj2Duser_level_permissions->DeleteUrl() ?>">Delete</a>&nbsp;
  173. <?php } ?>
  174. <?php } ?>
  175. </span>
  176. </p>
  177. <?php
  178. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  179. ?>
  180. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  181. <?php
  182. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  183. }
  184. ?>
  185. <p>
  186. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  187. <form action="osj-osj2duser_level_permissionsview.php" name="ewpagerform" id="ewpagerform">
  188. <table border="0" cellspacing="0" cellpadding="0">
  189. <tr>
  190. <td nowrap>
  191. <span class="phpmaker">
  192. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  193. <?php if ($Pager->RecordCount > 0) { ?>
  194. <?php if ($Pager->FirstButton->Enabled) { ?>
  195. <a href="osj-osj2duser_level_permissionsview.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  196. <?php } ?>
  197. <?php if ($Pager->PrevButton->Enabled) { ?>
  198. <a href="osj-osj2duser_level_permissionsview.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  199. <?php } ?>
  200. <?php foreach ($Pager->Items as $PagerItem) { ?>
  201. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_level_permissionsview.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  202. <?php } ?>
  203. <?php if ($Pager->NextButton->Enabled) { ?>
  204. <a href="osj-osj2duser_level_permissionsview.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  205. <?php } ?>
  206. <?php if ($Pager->LastButton->Enabled) { ?>
  207. <a href="osj-osj2duser_level_permissionsview.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  208. <?php } ?>
  209. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  210. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  211. <?php } else { ?>
  212. <?php if ($Security->CanList()) { ?>
  213. <?php if ($sSrchWhere == "0=101") { ?>
  214. Please enter search criteria
  215. <?php } else { ?>
  216. No records found
  217. <?php } ?>
  218. <?php } else { ?>
  219. You do not have the right permission to view the page
  220. <?php } ?>
  221. <?php } ?>
  222. </span>
  223. </td>
  224. </tr>
  225. </table>
  226. </form>
  227. <?php } ?>
  228. <form>
  229. <table class="ewTable">
  230. <tr class="ewTableRow">
  231. <td class="ewTableHeader">user level id</td>
  232. <td<?php echo $osj2Duser_level_permissions->user_level_id->CellAttributes() ?>>
  233. <div<?php echo $osj2Duser_level_permissions->user_level_id->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_id->ViewValue ?></div>
  234. </td>
  235. </tr>
  236. <tr class="ewTableAltRow">
  237. <td class="ewTableHeader">Permission To Do...</td>
  238. <td<?php echo $osj2Duser_level_permissions->user_level_table_name->CellAttributes() ?>>
  239. <div<?php echo $osj2Duser_level_permissions->user_level_table_name->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_table_name->ViewValue ?></div>
  240. </td>
  241. </tr>
  242. <tr class="ewTableRow">
  243. <td class="ewTableHeader">Permission Level</td>
  244. <td<?php echo $osj2Duser_level_permissions->user_level_permission->CellAttributes() ?>>
  245. <div<?php echo $osj2Duser_level_permissions->user_level_permission->ViewAttributes() ?>><?php echo $osj2Duser_level_permissions->user_level_permission->ViewValue ?></div>
  246. </td>
  247. </tr>
  248. </table>
  249. </form>
  250. <?php if ($osj2Duser_level_permissions->Export == "") { ?>
  251. <form action="osj-osj2duser_level_permissionsview.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_permissionsview.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_permissionsview.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_permissionsview.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_permissionsview.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_permissionsview.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. </tr>
  289. </table>
  290. </form>
  291. <?php } ?>
  292. <p>
  293. <script language="JavaScript" type="text/javascript">
  294. <!--
  295. // Write your table-specific startup script here
  296. // document.write("page loaded");
  297. //-->
  298. </script>
  299. <?php include "osj-footer.php" ?>
  300. <?php
  301. // If control is passed here, simply terminate the page without redirect
  302. Page_Terminate();
  303. // -----------------------------------------------------------------
  304. // Subroutine Page_Terminate
  305. // - called when exit page
  306. // - clean up connection and objects
  307. // - if url specified, redirect to url, otherwise end response
  308. function Page_Terminate($url = "") {
  309. global $conn;
  310. // Page unload event, used in current page
  311. Page_Unload();
  312. // Global page unloaded event (in userfn*.php)
  313. Page_Unloaded();
  314. // Close Connection
  315. $conn->Close();
  316. // Go to url if specified
  317. if ($url <> "") {
  318. ob_end_clean();
  319. header("Location: $url");
  320. }
  321. exit();
  322. }
  323. ?>
  324. <?php
  325. // Load recordset
  326. function LoadRecordset($offset = -1, $rowcnt = -1) {
  327. global $conn, $osj2Duser_level_permissions;
  328. // Call Recordset Selecting event
  329. $osj2Duser_level_permissions->Recordset_Selecting($osj2Duser_level_permissions->CurrentFilter);
  330. // Load list page sql
  331. $sSql = $osj2Duser_level_permissions->SelectSQL();
  332. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  333. // Load recordset
  334. $conn->raiseErrorFn = 'ew_ErrorFn';
  335. $rs = $conn->Execute($sSql);
  336. $conn->raiseErrorFn = '';
  337. // Call Recordset Selected event
  338. $osj2Duser_level_permissions->Recordset_Selected($rs);
  339. return $rs;
  340. }
  341. ?>
  342. <?php
  343. // Load row based on key values
  344. function LoadRow() {
  345. global $conn, $Security, $osj2Duser_level_permissions;
  346. $sFilter = $osj2Duser_level_permissions->SqlKeyFilter();
  347. if (!is_numeric($osj2Duser_level_permissions->user_level_id->CurrentValue)) {
  348. return FALSE; // Invalid key, exit
  349. }
  350. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level_permissions->user_level_id->CurrentValue), $sFilter); // Replace key value
  351. $sFilter = str_replace("@user_level_table_name@", ew_AdjustSql($osj2Duser_level_permissions->user_level_table_name->CurrentValue), $sFilter); // Replace key value
  352. // Call Row Selecting event
  353. $osj2Duser_level_permissions->Row_Selecting($sFilter);
  354. // Load sql based on filter
  355. $osj2Duser_level_permissions->CurrentFilter = $sFilter;
  356. $sSql = $osj2Duser_level_permissions->SQL();
  357. if ($rs = $conn->Execute($sSql)) {
  358. if ($rs->EOF) {
  359. $LoadRow = FALSE;
  360. } else {
  361. $LoadRow = TRUE;
  362. $rs->MoveFirst();
  363. LoadRowValues($rs); // Load row values
  364. // Call Row Selected event
  365. $osj2Duser_level_permissions->Row_Selected($rs);
  366. }
  367. $rs->Close();
  368. } else {
  369. $LoadRow = FALSE;
  370. }
  371. return $LoadRow;
  372. }
  373. // Load row values from recordset
  374. function LoadRowValues(&$rs) {
  375. global $osj2Duser_level_permissions;
  376. $osj2Duser_level_permissions->user_level_id->setDbValue($rs->fields('user_level_id'));
  377. $osj2Duser_level_permissions->user_level_table_name->setDbValue($rs->fields('user_level_table_name'));
  378. $osj2Duser_level_permissions->user_level_permission->setDbValue($rs->fields('user_level_permission'));
  379. }
  380. ?>
  381. <?php
  382. // Render row values based on field settings
  383. function RenderRow() {
  384. global $conn, $Security, $osj2Duser_level_permissions;
  385. // Call Row Rendering event
  386. $osj2Duser_level_permissions->Row_Rendering();
  387. // Common render codes for all row types
  388. // user_level_id
  389. $osj2Duser_level_permissions->user_level_id->CellCssStyle = "";
  390. $osj2Duser_level_permissions->user_level_id->CellCssClass = "";
  391. // user_level_table_name
  392. $osj2Duser_level_permissions->user_level_table_name->CellCssStyle = "";
  393. $osj2Duser_level_permissions->user_level_table_name->CellCssClass = "";
  394. // user_level_permission
  395. $osj2Duser_level_permissions->user_level_permission->CellCssStyle = "";
  396. $osj2Duser_level_permissions->user_level_permission->CellCssClass = "";
  397. if ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_VIEW) { // View row
  398. // user_level_id
  399. if (!is_null($osj2Duser_level_permissions->user_level_id->CurrentValue)) {
  400. $sSqlWrk = "SELECT `user_level_name` FROM `osj-user_level` WHERE `user_level_id` = " . ew_AdjustSql($osj2Duser_level_permissions->user_level_id->CurrentValue) . "";
  401. $sSqlWrk .= " ORDER BY `user_level_name` Asc";
  402. $rswrk = $conn->Execute($sSqlWrk);
  403. if ($rswrk) {
  404. if (!$rswrk->EOF) {
  405. $osj2Duser_level_permissions->user_level_id->ViewValue = $rswrk->fields('user_level_name');
  406. }
  407. $rswrk->Close();
  408. } else {
  409. $osj2Duser_level_permissions->user_level_id->ViewValue = $osj2Duser_level_permissions->user_level_id->CurrentValue;
  410. }
  411. } else {
  412. $osj2Duser_level_permissions->user_level_id->ViewValue = NULL;
  413. }
  414. $osj2Duser_level_permissions->user_level_id->CssStyle = "";
  415. $osj2Duser_level_permissions->user_level_id->CssClass = "";
  416. $osj2Duser_level_permissions->user_level_id->ViewCustomAttributes = "";
  417. // user_level_table_name
  418. if (!is_null($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) {
  419. switch ($osj2Duser_level_permissions->user_level_table_name->CurrentValue) {
  420. case "osj-applications":
  421. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Applications";
  422. break;
  423. case "osj-applications":
  424. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Applications";
  425. break;
  426. case "osj-posts":
  427. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Postings";
  428. break;
  429. case "osj-resumes":
  430. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Resumes";
  431. break;
  432. case "osj-users":
  433. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "Users";
  434. break;
  435. case "osj-user_detail":
  436. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Detail Page";
  437. break;
  438. case "osj-user_level":
  439. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Levels";
  440. break;
  441. case "osj-user_level_permissions":
  442. $osj2Duser_level_permissions->user_level_table_name->ViewValue = "User Permission Levels";
  443. break;
  444. default:
  445. $osj2Duser_level_permissions->user_level_table_name->ViewValue = $osj2Duser_level_permissions->user_level_table_name->CurrentValue;
  446. }
  447. } else {
  448. $osj2Duser_level_permissions->user_level_table_name->ViewValue = NULL;
  449. }
  450. $osj2Duser_level_permissions->user_level_table_name->CssStyle = "";
  451. $osj2Duser_level_permissions->user_level_table_name->CssClass = "";
  452. $osj2Duser_level_permissions->user_level_table_name->ViewCustomAttributes = "";
  453. // user_level_permission
  454. if (!is_null($osj2Duser_level_permissions->user_level_permission->CurrentValue)) {
  455. switch ($osj2Duser_level_permissions->user_level_permission->CurrentValue) {
  456. case "0":
  457. $osj2Duser_level_permissions->user_level_permission->ViewValue = "No Permission";
  458. break;
  459. case "1":
  460. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add Only";
  461. break;
  462. case "2":
  463. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Delete Only";
  464. break;
  465. case "4":
  466. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Edit Only";
  467. break;
  468. case "8":
  469. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View Only";
  470. break;
  471. case "5":
  472. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Edit";
  473. break;
  474. case "3":
  475. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Delete";
  476. break;
  477. case "7":
  478. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Add/Edit/Delete";
  479. break;
  480. case "6":
  481. $osj2Duser_level_permissions->user_level_permission->ViewValue = "Edit/Delete";
  482. break;
  483. case "9":
  484. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add";
  485. break;
  486. case "11":
  487. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Delete";
  488. break;
  489. case "12":
  490. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Edit";
  491. break;
  492. case "10":
  493. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Delete";
  494. break;
  495. case "14":
  496. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Edit/Delete";
  497. break;
  498. case "13":
  499. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Edit";
  500. break;
  501. case "15":
  502. $osj2Duser_level_permissions->user_level_permission->ViewValue = "View/Add/Edit/Delete";
  503. break;
  504. default:
  505. $osj2Duser_level_permissions->user_level_permission->ViewValue = $osj2Duser_level_permissions->user_level_permission->CurrentValue;
  506. }
  507. } else {
  508. $osj2Duser_level_permissions->user_level_permission->ViewValue = NULL;
  509. }
  510. $osj2Duser_level_permissions->user_level_permission->CssStyle = "";
  511. $osj2Duser_level_permissions->user_level_permission->CssClass = "";
  512. $osj2Duser_level_permissions->user_level_permission->ViewCustomAttributes = "";
  513. // user_level_id
  514. $osj2Duser_level_permissions->user_level_id->HrefValue = "";
  515. // user_level_table_name
  516. $osj2Duser_level_permissions->user_level_table_name->HrefValue = "";
  517. // user_level_permission
  518. $osj2Duser_level_permissions->user_level_permission->HrefValue = "";
  519. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_ADD) { // Add row
  520. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_EDIT) { // Edit row
  521. } elseif ($osj2Duser_level_permissions->RowType == EW_ROWTYPE_SEARCH) { // Search row
  522. }
  523. // Call Row Rendered event
  524. $osj2Duser_level_permissions->Row_Rendered();
  525. }
  526. ?>
  527. <?php
  528. // Export data in Xml or Csv format
  529. function ExportData() {
  530. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Duser_level_permissions;
  531. $sCsvStr = "";
  532. $rs = LoadRecordset();
  533. $nTotalRecs = $rs->RecordCount();
  534. $nStartRec = 1;
  535. SetUpStartRec(); // Set Up Start Record Position
  536. // Set the last record to display
  537. if ($nDisplayRecs < 0) {
  538. $nStopRec = $nTotalRecs;
  539. } else {
  540. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  541. }
  542. if ($osj2Duser_level_permissions->Export == "xml") {
  543. $XmlDoc = new cXMLDocument();
  544. }
  545. if ($osj2Duser_level_permissions->Export == "csv") {
  546. $sCsvStr .= "user_level_id" . ",";
  547. $sCsvStr .= "user_level_table_name" . ",";
  548. $sCsvStr .= "user_level_permission" . ",";
  549. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  550. $sCsvStr .= "\n";
  551. }
  552. // Move to first record directly for performance reason
  553. $nRecCount = $nStartRec - 1;
  554. if (!$rs->EOF) {
  555. $rs->MoveFirst();
  556. $rs->Move($nStartRec - 1);
  557. }
  558. while (!$rs->EOF && $nRecCount < $nStopRec) {
  559. $nRecCount++;
  560. if (intval($nRecCount) >= intval($nStartRec)) {
  561. LoadRowValues($rs);
  562. if ($osj2Duser_level_permissions->Export == "xml") {
  563. $XmlDoc->BeginRow();
  564. $XmlDoc->AddField('user_level_id', $osj2Duser_level_permissions->user_level_id->CurrentValue);
  565. $XmlDoc->AddField('user_level_table_name', $osj2Duser_level_permissions->user_level_table_name->CurrentValue);
  566. $XmlDoc->AddField('user_level_permission', $osj2Duser_level_permissions->user_level_permission->CurrentValue);
  567. $XmlDoc->EndRow();
  568. }
  569. if ($osj2Duser_level_permissions->Export == "csv") {
  570. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level_permissions->user_level_id->CurrentValue)) . '",';
  571. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level_permissions->user_level_table_name->CurrentValue)) . '",';
  572. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level_permissions->user_level_permission->CurrentValue)) . '",';
  573. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  574. $sCsvStr .= "\n";
  575. }
  576. }
  577. $rs->MoveNext();
  578. }
  579. // Close recordset
  580. $rs->Close();
  581. if ($osj2Duser_level_permissions->Export == "xml") {
  582. header("Content-Type: text/xml");
  583. echo $XmlDoc->XML();
  584. }
  585. if ($osj2Duser_level_permissions->Export == "csv") {
  586. echo $sCsvStr;
  587. }
  588. }
  589. ?>
  590. <?php
  591. // Set up Starting Record parameters based on Pager Navigation
  592. function SetUpStartRec() {
  593. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Duser_level_permissions;
  594. if ($nDisplayRecs == 0) return;
  595. // Check for a START parameter
  596. if (@$_GET[EW_TABLE_START_REC] <> "") {
  597. $nStartRec = $_GET[EW_TABLE_START_REC];
  598. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  599. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  600. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  601. if (is_numeric($nPageNo)) {
  602. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  603. if ($nStartRec <= 0) {
  604. $nStartRec = 1;
  605. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  606. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  607. }
  608. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  609. } else {
  610. $nStartRec = $osj2Duser_level_permissions->getStartRecordNumber();
  611. }
  612. } else {
  613. $nStartRec = $osj2Duser_level_permissions->getStartRecordNumber();
  614. }
  615. // Check if correct start record counter
  616. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  617. $nStartRec = 1; // Reset start record counter
  618. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  619. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  620. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  621. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  622. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  623. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  624. $osj2Duser_level_permissions->setStartRecordNumber($nStartRec);
  625. }
  626. }
  627. ?>
  628. <?php
  629. // Page Load event
  630. function Page_Load() {
  631. //echo "Page Load";
  632. }
  633. // Page Unload event
  634. function Page_Unload() {
  635. //echo "Page Unload";
  636. }
  637. ?>