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

/osj-osj2dusersview.php

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