PageRenderTime 128ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-osj2duserslist.php

http://osjobber.googlecode.com/
PHP | 1713 lines | 1376 code | 165 blank | 172 comment | 447 complexity | 4f17a5fed223d4a674237e65e78f1ca3 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-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->CanList()) {
  36. $Security->SaveLastUrl();
  37. Page_Terminate("osj-login.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 ($osj2Dusers->Export == "html") {
  59. // Printer friendly, no action required
  60. }
  61. if ($osj2Dusers->Export == "xml") {
  62. header('Content-Type: text/xml');
  63. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  64. }
  65. if ($osj2Dusers->Export == "csv") {
  66. header('Content-Type: application/csv');
  67. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  68. }
  69. ?>
  70. <?php
  71. // Paging variables
  72. $nStartRec = 0; // Start record index
  73. $nStopRec = 0; // Stop record index
  74. $nTotalRecs = 0; // Total number of records
  75. $nDisplayRecs = 10;
  76. $nRecRange = 10;
  77. $nRecCount = 0; // Record count
  78. // Search filters
  79. $sSrchAdvanced = ""; // Advanced search filter
  80. $sSrchBasic = ""; // Basic search filter
  81. $sSrchWhere = ""; // Search where clause
  82. $sFilter = "";
  83. // Master/Detail
  84. $sDbMasterFilter = ""; // Master filter
  85. $sDbDetailFilter = ""; // Detail filter
  86. $sSqlMaster = ""; // Sql for master record
  87. // Set up records per page dynamically
  88. SetUpDisplayRecs();
  89. // Handle reset command
  90. ResetCmd();
  91. // Check QueryString parameters
  92. if (@$_GET["a"] <> "") {
  93. $osj2Dusers->CurrentAction = $_GET["a"];
  94. // Clear inline mode
  95. if ($osj2Dusers->CurrentAction == "cancel") {
  96. ClearInlineMode();
  97. }
  98. // Switch to inline edit mode
  99. if ($osj2Dusers->CurrentAction == "edit") {
  100. InlineEditMode();
  101. }
  102. } else {
  103. // Create form object
  104. $objForm = new cFormObj;
  105. if (@$_POST["a_list"] <> "") {
  106. $osj2Dusers->CurrentAction = $_POST["a_list"]; // Get action
  107. // Inline Update
  108. if ($osj2Dusers->CurrentAction == "update" && @$_SESSION[EW_SESSION_INLINE_MODE] == "edit") {
  109. InlineUpdate();
  110. }
  111. }
  112. }
  113. // Get search criteria for advanced search
  114. $sSrchAdvanced = AdvancedSearchWhere();
  115. // Get basic search criteria
  116. $sSrchBasic = BasicSearchWhere();
  117. // Build search criteria
  118. if ($sSrchAdvanced <> "") {
  119. if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
  120. $sSrchWhere .= "(" . $sSrchAdvanced . ")";
  121. }
  122. if ($sSrchBasic <> "") {
  123. if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
  124. $sSrchWhere .= "(" . $sSrchBasic . ")";
  125. }
  126. // Save search criteria
  127. if ($sSrchWhere <> "") {
  128. if ($sSrchBasic == "") ResetBasicSearchParms();
  129. if ($sSrchAdvanced == "") ResetAdvancedSearchParms();
  130. $osj2Dusers->setSearchWhere($sSrchWhere); // Save to Session
  131. $nStartRec = 1; // Reset start record counter
  132. $osj2Dusers->setStartRecordNumber($nStartRec);
  133. } else {
  134. RestoreSearchParms();
  135. }
  136. // Build filter
  137. $sFilter = "";
  138. if (!$Security->CanList()) {
  139. $sFilter = "(0=1)"; // Filter all records
  140. }
  141. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  142. $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  143. }
  144. if ($sDbDetailFilter <> "") {
  145. if ($sFilter <> "") $sFilter .= " AND ";
  146. $sFilter .= "(" . $sDbDetailFilter . ")";
  147. }
  148. if ($sSrchWhere <> "") {
  149. if ($sFilter <> "") $sFilter .= " AND ";
  150. $sFilter .= "(" . $sSrchWhere . ")";
  151. }
  152. // Set up filter in Session
  153. $osj2Dusers->setSessionWhere($sFilter);
  154. $osj2Dusers->CurrentFilter = "";
  155. // Set Up Sorting Order
  156. SetUpSortOrder();
  157. // Export data only
  158. if ($osj2Dusers->Export == "xml" || $osj2Dusers->Export == "csv") {
  159. ExportData();
  160. Page_Terminate(); // Terminate response
  161. }
  162. // Set Return Url
  163. $osj2Dusers->setReturnUrl("osj-osj2duserslist.php");
  164. ?>
  165. <?php include "osj-header.php" ?>
  166. <?php if ($osj2Dusers->Export == "") { ?>
  167. <script type="text/javascript">
  168. <!--
  169. var EW_PAGE_ID = "list"; // Page id
  170. var EW_SHOW_HIGHLIGHT = "Show highlight";
  171. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  172. //-->
  173. </script>
  174. <script type="text/javascript">
  175. <!--
  176. function ew_ValidateForm(fobj) {
  177. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  178. return true;
  179. var i, elm, aelm, infix;
  180. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  181. for (i=0; i<rowcnt; i++) {
  182. infix = (fobj.key_count) ? String(i+1) : "";
  183. elm = fobj.elements["x" + infix + "_user_id"];
  184. if (elm && !ew_HasValue(elm)) {
  185. if (!ew_OnError(elm, "Please enter required field - User ID"))
  186. return false;
  187. }
  188. elm = fobj.elements["x" + infix + "_user_email"];
  189. if (elm && !ew_HasValue(elm)) {
  190. if (!ew_OnError(elm, "Please enter required field - Email"))
  191. return false;
  192. }
  193. elm = fobj.elements["x" + infix + "_user_email"];
  194. if (elm && !ew_CheckEmail(elm.value)) {
  195. if (!ew_OnError(elm, "Users must provide a valid email address."))
  196. return false;
  197. }
  198. elm = fobj.elements["x" + infix + "_user_password"];
  199. if (elm && !ew_HasValue(elm)) {
  200. if (!ew_OnError(elm, "Please enter required field - Password"))
  201. return false;
  202. }
  203. elm = fobj.elements["x" + infix + "_user_level"];
  204. if (elm && !ew_HasValue(elm)) {
  205. if (!ew_OnError(elm, "Please enter required field - User Level"))
  206. return false;
  207. }
  208. elm = fobj.elements["x" + infix + "_user_status"];
  209. if (elm && !ew_HasValue(elm)) {
  210. if (!ew_OnError(elm, "Please enter required field - User Status"))
  211. return false;
  212. }
  213. }
  214. return true;
  215. }
  216. //-->
  217. </script>
  218. <script type="text/javascript">
  219. <!--
  220. var firstrowoffset = 1; // First data row start at
  221. var lastrowoffset = 0; // Last data row end at
  222. var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
  223. var rowclass = 'ewTableRow'; // Row class
  224. var rowaltclass = 'ewTableAltRow'; // Row alternate class
  225. var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
  226. var rowselectedclass = 'ewTableSelectRow'; // Row selected class
  227. var roweditclass = 'ewTableEditRow'; // Row edit class
  228. //-->
  229. </script>
  230. <script type="text/javascript">
  231. <!--
  232. var ew_DHTMLEditors = [];
  233. //-->
  234. </script>
  235. <script type="text/javascript">
  236. <!--
  237. // js for Popup Calendar
  238. //-->
  239. </script>
  240. <script type="text/javascript">
  241. <!--
  242. function ew_SelectKey(elem) {
  243. var f = elem.form;
  244. if (!f.elements["key_m[]"]) return;
  245. if (f.elements["key_m[]"][0]) {
  246. for (var i=0; i<f.elements["key_m[]"].length; i++)
  247. f.elements["key_m[]"][i].checked = elem.checked;
  248. } else {
  249. f.elements["key_m[]"].checked = elem.checked;
  250. }
  251. ew_ClickAll(elem);
  252. }
  253. function ew_Selected(f) {
  254. if (!f.elements["key_m[]"]) return false;
  255. if (f.elements["key_m[]"][0]) {
  256. for (var i=0; i<f.elements["key_m[]"].length; i++)
  257. if (f.elements["key_m[]"][i].checked) return true;
  258. } else {
  259. return f.elements["key_m[]"].checked;
  260. }
  261. return false;
  262. }
  263. //-->
  264. </script>
  265. <script language="JavaScript" type="text/javascript">
  266. <!--
  267. // Write your client script here, no need to add script tags.
  268. // To include another .js script, use:
  269. // ew_ClientScriptInclude("my_javascript.js");
  270. //-->
  271. </script>
  272. <?php } ?>
  273. <?php if ($osj2Dusers->Export == "") { ?>
  274. <?php } ?>
  275. <?php
  276. // Load recordset
  277. $bExportAll = (defined("EW_EXPORT_ALL") && $osj2Dusers->Export <> "");
  278. $bSelectLimit = ($osj2Dusers->Export == "" && $osj2Dusers->SelectLimit);
  279. if (!$bSelectLimit) $rs = LoadRecordset();
  280. $nTotalRecs = ($bSelectLimit) ? $osj2Dusers->SelectRecordCount() : $rs->RecordCount();
  281. $nStartRec = 1;
  282. if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
  283. if (!$bExportAll) SetUpStartRec(); // Set up start record position
  284. if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
  285. ?>
  286. <p><span class="phpmaker" style="white-space: nowrap;">TABLE: Users
  287. <?php if ($osj2Dusers->Export == "") { ?>
  288. &nbsp;&nbsp;<a href="osj-osj2duserslist.php?export=html">Printer Friendly</a>
  289. &nbsp;&nbsp;<a href="osj-osj2duserslist.php?export=xml">Export to XML</a>
  290. &nbsp;&nbsp;<a href="osj-osj2duserslist.php?export=csv">Export to CSV</a>
  291. <?php } ?>
  292. </span></p>
  293. <?php if ($osj2Dusers->Export == "") { ?>
  294. <?php if ($Security->CanSearch()) { ?>
  295. <form name="fosj2Duserslistsrch" id="fosj2Duserslistsrch" action="osj-osj2duserslist.php" >
  296. <table class="ewBasicSearch">
  297. <tr>
  298. <td><span class="phpmaker">
  299. <input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($osj2Dusers->getBasicSearchKeyword()) ?>">
  300. <input type="Submit" name="Submit" id="Submit" value="Search (*)">&nbsp;
  301. <a href="osj-osj2duserslist.php?cmd=reset">Show all</a>&nbsp;
  302. <a href="osj-osj2duserssrch.php">Advanced Search</a>&nbsp;
  303. <?php if ($sSrchWhere <> "" && $nTotalRecs > 0) { ?>
  304. <a href="javascript:void(0);" onclick="ew_ToggleHighlight(this);">Hide highlight</a>
  305. <?php } ?>
  306. </span></td>
  307. </tr>
  308. <tr>
  309. <td><span class="phpmaker"><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="" <?php if ($osj2Dusers->getBasicSearchType() == "") { ?>checked<?php } ?>>Exact phrase&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND" <?php if ($osj2Dusers->getBasicSearchType() == "AND") { ?>checked<?php } ?>>All words&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR" <?php if ($osj2Dusers->getBasicSearchType() == "OR") { ?>checked<?php } ?>>Any word</span></td>
  310. </tr>
  311. </table>
  312. </form>
  313. <?php } ?>
  314. <?php } ?>
  315. <?php
  316. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  317. ?>
  318. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  319. <?php
  320. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  321. }
  322. ?>
  323. <?php if ($osj2Dusers->Export == "") { ?>
  324. <form action="osj-osj2duserslist.php" name="ewpagerform" id="ewpagerform">
  325. <table border="0" cellspacing="0" cellpadding="0">
  326. <tr>
  327. <td nowrap>
  328. <span class="phpmaker">
  329. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  330. <?php if ($Pager->RecordCount > 0) { ?>
  331. <?php if ($Pager->FirstButton->Enabled) { ?>
  332. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  333. <?php } ?>
  334. <?php if ($Pager->PrevButton->Enabled) { ?>
  335. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  336. <?php } ?>
  337. <?php foreach ($Pager->Items as $PagerItem) { ?>
  338. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duserslist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  339. <?php } ?>
  340. <?php if ($Pager->NextButton->Enabled) { ?>
  341. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  342. <?php } ?>
  343. <?php if ($Pager->LastButton->Enabled) { ?>
  344. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  345. <?php } ?>
  346. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  347. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  348. <?php } else { ?>
  349. <?php if ($Security->CanList()) { ?>
  350. <?php if ($sSrchWhere == "0=101") { ?>
  351. Please enter search criteria
  352. <?php } else { ?>
  353. No records found
  354. <?php } ?>
  355. <?php } else { ?>
  356. You do not have the right permission to view the page
  357. <?php } ?>
  358. <?php } ?>
  359. </span>
  360. </td>
  361. <?php if ($nTotalRecs > 0) { ?>
  362. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  363. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  364. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  365. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  366. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  367. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  368. </select>
  369. </span></td>
  370. <?php } ?>
  371. </tr>
  372. </table>
  373. </form>
  374. <?php } ?>
  375. <form name="fosj2Duserslist" id="fosj2Duserslist" action="osj-osj2duserslist.php" method="post">
  376. <?php if ($osj2Dusers->Export == "") { ?>
  377. <table>
  378. <tr><td><span class="phpmaker">
  379. <?php if ($Security->CanAdd()) { ?>
  380. <a href="osj-osj2dusersadd.php">Add</a>&nbsp;&nbsp;
  381. <?php } ?>
  382. <?php if ($nTotalRecs > 0) { ?>
  383. <?php if ($Security->CanDelete()) { ?>
  384. <a href="" onClick="if (!ew_Selected(document.fosj2Duserslist)) alert('No records selected'); else {document.fosj2Duserslist.action='osj-osj2dusersdelete.php';document.fosj2Duserslist.encoding='application/x-www-form-urlencoded';document.fosj2Duserslist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  385. <?php } ?>
  386. <?php } ?>
  387. </span></td></tr>
  388. </table>
  389. <?php } ?>
  390. <?php if ($nTotalRecs > 0) { ?>
  391. <table id="ewlistmain" class="ewTable">
  392. <?php
  393. $OptionCnt = 0;
  394. if ($Security->CanView()) {
  395. $OptionCnt++; // view
  396. }
  397. if ($Security->CanEdit()) {
  398. $OptionCnt++; // edit
  399. }
  400. if ($Security->CanDelete()) {
  401. $OptionCnt++; // multi select
  402. }
  403. ?>
  404. <!-- Table header -->
  405. <tr class="ewTableHeader">
  406. <?php if ($osj2Dusers->Export == "") { ?>
  407. <?php if ($Security->CanView()) { ?>
  408. <td nowrap>&nbsp;</td>
  409. <?php } ?>
  410. <?php if ($Security->CanEdit()) { ?>
  411. <td nowrap>&nbsp;</td>
  412. <?php } ?>
  413. <?php if ($Security->CanDelete()) { ?>
  414. <td nowrap><input type="checkbox" class="phpmaker" onClick="ew_SelectKey(this);"></td>
  415. <?php } ?>
  416. <?php } ?>
  417. <td valign="top">
  418. <?php if ($osj2Dusers->Export <> "") { ?>
  419. User ID
  420. <?php } else { ?>
  421. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_id') ?>&ordertype=<?php echo $osj2Dusers->user_id->ReverseSort() ?>">User ID<?php if ($osj2Dusers->user_id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_id->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  422. <?php } ?>
  423. </td>
  424. <td valign="top">
  425. <?php if ($osj2Dusers->Export <> "") { ?>
  426. Creation Date
  427. <?php } else { ?>
  428. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_creation_date') ?>&ordertype=<?php echo $osj2Dusers->user_creation_date->ReverseSort() ?>">Creation Date<?php if ($osj2Dusers->user_creation_date->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_creation_date->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  429. <?php } ?>
  430. </td>
  431. <td valign="top">
  432. <?php if ($osj2Dusers->Export <> "") { ?>
  433. Edit Date
  434. <?php } else { ?>
  435. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_edit_date') ?>&ordertype=<?php echo $osj2Dusers->user_edit_date->ReverseSort() ?>">Edit Date<?php if ($osj2Dusers->user_edit_date->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_edit_date->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  436. <?php } ?>
  437. </td>
  438. <td valign="top">
  439. <?php if ($osj2Dusers->Export <> "") { ?>
  440. Email
  441. <?php } else { ?>
  442. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_email') ?>&ordertype=<?php echo $osj2Dusers->user_email->ReverseSort() ?>">Email&nbsp;(*)<?php if ($osj2Dusers->user_email->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_email->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  443. <?php } ?>
  444. </td>
  445. <td valign="top">
  446. <?php if ($osj2Dusers->Export <> "") { ?>
  447. Password
  448. <?php } else { ?>
  449. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_password') ?>&ordertype=<?php echo $osj2Dusers->user_password->ReverseSort() ?>">Password<?php if ($osj2Dusers->user_password->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_password->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  450. <?php } ?>
  451. </td>
  452. <td valign="top">
  453. <?php if ($osj2Dusers->Export <> "") { ?>
  454. User Level
  455. <?php } else { ?>
  456. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_level') ?>&ordertype=<?php echo $osj2Dusers->user_level->ReverseSort() ?>">User Level<?php if ($osj2Dusers->user_level->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_level->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  457. <?php } ?>
  458. </td>
  459. <td valign="top">
  460. <?php if ($osj2Dusers->Export <> "") { ?>
  461. User Status
  462. <?php } else { ?>
  463. <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_status') ?>&ordertype=<?php echo $osj2Dusers->user_status->ReverseSort() ?>">User Status<?php if ($osj2Dusers->user_status->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Dusers->user_status->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  464. <?php } ?>
  465. </td>
  466. </tr>
  467. <?php
  468. if (defined("EW_EXPORT_ALL") && $osj2Dusers->Export <> "") {
  469. $nStopRec = $nTotalRecs;
  470. } else {
  471. $nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
  472. }
  473. $nRecCount = $nStartRec - 1;
  474. if (!$rs->EOF) {
  475. $rs->MoveFirst();
  476. if (!$osj2Dusers->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
  477. }
  478. $RowCnt = 0;
  479. $nEditRowCnt = 0;
  480. if ($osj2Dusers->CurrentAction == "edit") $RowIndex = 1;
  481. while (!$rs->EOF && $nRecCount < $nStopRec) {
  482. $nRecCount++;
  483. if (intval($nRecCount) >= intval($nStartRec)) {
  484. $RowCnt++;
  485. // Init row class and style
  486. $osj2Dusers->CssClass = "ewTableRow";
  487. $osj2Dusers->CssStyle = "";
  488. // Init row event
  489. $osj2Dusers->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  490. // Display alternate color for rows
  491. if ($RowCnt % 2 == 0) {
  492. $osj2Dusers->CssClass = "ewTableAltRow";
  493. }
  494. LoadRowValues($rs); // Load row values
  495. $osj2Dusers->RowType = EW_ROWTYPE_VIEW; // Render view
  496. if ($osj2Dusers->CurrentAction == "edit") {
  497. if (CheckInlineEditKey() && $nEditRowCnt == 0) { // Inline edit
  498. $osj2Dusers->RowType = EW_ROWTYPE_EDIT; // Render edit
  499. }
  500. }
  501. if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT && $osj2Dusers->EventCancelled) { // Update failed
  502. if ($osj2Dusers->CurrentAction == "edit") {
  503. RestoreFormValues(); // Restore form values
  504. }
  505. }
  506. if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit row
  507. $nEditRowCnt++;
  508. $osj2Dusers->CssClass = "ewTableEditRow";
  509. $osj2Dusers->RowClientEvents = "onmouseover='this.edit=true;ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  510. }
  511. RenderRow();
  512. ?>
  513. <!-- Table body -->
  514. <tr<?php echo $osj2Dusers->DisplayAttributes() ?>>
  515. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { ?>
  516. <?php if ($osj2Dusers->CurrentAction == "edit") { ?>
  517. <td colspan="<?php echo $OptionCnt ?>" align="right"><span class="phpmaker">
  518. <a href="" onClick="if (ew_ValidateForm(document.fosj2Duserslist)) document.fosj2Duserslist.submit();return false;">Update</a>&nbsp;<a href="osj-osj2duserslist.php?a=cancel">Cancel</a>
  519. <input type="hidden" name="a_list" id="a_list" value="update">
  520. </span></td>
  521. <?php } ?>
  522. <?php } else { ?>
  523. <?php if ($osj2Dusers->Export == "") { ?>
  524. <?php if ($Security->CanView()) { ?>
  525. <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
  526. <a href="<?php echo $osj2Dusers->ViewUrl() ?>">View</a>
  527. <?php } ?></span></td>
  528. <?php } ?>
  529. <?php if ($Security->CanEdit()) { ?>
  530. <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
  531. <a href="<?php echo $osj2Dusers->EditUrl() ?>">Edit</a><span class="ewSeparator">&nbsp;|&nbsp;</span><a href="<?php echo $osj2Dusers->InlineEditUrl() ?>">Inline Edit</a>
  532. <?php } ?></span></td>
  533. <?php } ?>
  534. <?php if ($Security->CanDelete()) { ?>
  535. <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
  536. <input type="checkbox" name="key_m[]" id="key_m[]" value="<?php echo ew_HtmlEncode($osj2Dusers->user_id->CurrentValue) ?>" class="phpmaker" onclick='ew_ClickMultiCheckbox(this);'>
  537. <?php } ?></span></td>
  538. <?php } ?>
  539. <?php } ?>
  540. <?php } ?>
  541. <!-- user_id -->
  542. <td<?php echo $osj2Dusers->user_id->CellAttributes() ?>>
  543. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  544. <input type="hidden" name="x<?php echo $RowIndex ?>_user_id" id="x<?php echo $RowIndex ?>_user_id" value="<?php echo ew_HtmlEncode($osj2Dusers->user_id->CurrentValue) ?>">
  545. <?php } else { ?>
  546. <?php } ?>
  547. </td>
  548. <!-- user_creation_date -->
  549. <td<?php echo $osj2Dusers->user_creation_date->CellAttributes() ?>>
  550. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  551. <?php } else { ?>
  552. <?php } ?>
  553. </td>
  554. <!-- user_edit_date -->
  555. <td<?php echo $osj2Dusers->user_edit_date->CellAttributes() ?>>
  556. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  557. <?php } else { ?>
  558. <?php } ?>
  559. </td>
  560. <!-- user_email -->
  561. <td<?php echo $osj2Dusers->user_email->CellAttributes() ?>>
  562. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  563. <input type="text" name="x<?php echo $RowIndex ?>_user_email" id="x<?php echo $RowIndex ?>_user_email" title="Email" size="30" maxlength="255" value="<?php echo $osj2Dusers->user_email->EditValue ?>"<?php echo $osj2Dusers->user_email->EditAttributes() ?>>
  564. <?php } else { ?>
  565. <div<?php echo $osj2Dusers->user_email->ViewAttributes() ?>><?php echo $osj2Dusers->user_email->ViewValue ?></div>
  566. <?php } ?>
  567. </td>
  568. <!-- user_password -->
  569. <td<?php echo $osj2Dusers->user_password->CellAttributes() ?>>
  570. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  571. <input type="password" name="x<?php echo $RowIndex ?>_user_password" id="x<?php echo $RowIndex ?>_user_password" title="Password" value="<?php echo $osj2Dusers->user_password->EditValue ?>" size="30" maxlength="255"<?php echo $osj2Dusers->user_password->EditAttributes() ?>>
  572. <?php } else { ?>
  573. <div<?php echo $osj2Dusers->user_password->ViewAttributes() ?>><?php echo $osj2Dusers->user_password->ViewValue ?></div>
  574. <?php } ?>
  575. </td>
  576. <!-- user_level -->
  577. <td<?php echo $osj2Dusers->user_level->CellAttributes() ?>>
  578. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  579. <?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
  580. <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->EditValue ?></div>
  581. <?php } else { ?>
  582. <select id="x<?php echo $RowIndex ?>_user_level" name="x<?php echo $RowIndex ?>_user_level"<?php echo $osj2Dusers->user_level->EditAttributes() ?>>
  583. <!--option value="">Please Select</option-->
  584. <?php
  585. if (is_array($osj2Dusers->user_level->EditValue)) {
  586. $arwrk = $osj2Dusers->user_level->EditValue;
  587. $rowswrk = count($arwrk);
  588. for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
  589. $selwrk = (strval($osj2Dusers->user_level->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
  590. ?>
  591. <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
  592. <?php echo $arwrk[$rowcntwrk][1] ?>
  593. </option>
  594. <?php
  595. }
  596. }
  597. ?>
  598. </select>
  599. <?php
  600. $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
  601. $sSqlWrk .= " WHERE (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
  602. $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
  603. ?>
  604. <input type="hidden" name="s_x<?php echo $RowIndex ?>_user_level" id="s_x<?php echo $RowIndex ?>_user_level" value="<?php echo $sSqlWrk ?>"><input type="hidden" name="lc_x<?php echo $RowIndex ?>_user_level" id="lc_x<?php echo $RowIndex ?>_user_level" value="2"><input type="hidden" name="ld1_x<?php echo $RowIndex ?>_user_level" id="ld1_x<?php echo $RowIndex ?>_user_level" value="1"><input type="hidden" name="ld2_x<?php echo $RowIndex ?>_user_level" id="ld2_x<?php echo $RowIndex ?>_user_level" value="-1"><input type="hidden" name="lft_x<?php echo $RowIndex ?>_user_level" id="lft_x<?php echo $RowIndex ?>_user_level" value="1">
  605. <?php } ?>
  606. <?php } else { ?>
  607. <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->ViewValue ?></div>
  608. <?php } ?>
  609. </td>
  610. <!-- user_status -->
  611. <td<?php echo $osj2Dusers->user_status->CellAttributes() ?>>
  612. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  613. <select id="x<?php echo $RowIndex ?>_user_status" name="x<?php echo $RowIndex ?>_user_status"<?php echo $osj2Dusers->user_status->EditAttributes() ?>>
  614. <!--option value="">Please Select</option-->
  615. <?php
  616. if (is_array($osj2Dusers->user_status->EditValue)) {
  617. $arwrk = $osj2Dusers->user_status->EditValue;
  618. $rowswrk = count($arwrk);
  619. for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
  620. $selwrk = (strval($osj2Dusers->user_status->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
  621. ?>
  622. <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
  623. <?php echo $arwrk[$rowcntwrk][1] ?>
  624. </option>
  625. <?php
  626. }
  627. }
  628. ?>
  629. </select>
  630. <?php } else { ?>
  631. <div<?php echo $osj2Dusers->user_status->ViewAttributes() ?>><?php echo $osj2Dusers->user_status->ViewValue ?></div>
  632. <?php } ?>
  633. </td>
  634. </tr>
  635. <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { ?>
  636. <script language="JavaScript">
  637. <!--
  638. var f = document.fosj2Duserslist;
  639. ew_AjaxUpdateOpt(f.x<?php echo $RowIndex ?>_user_level, f.x<?php echo $RowIndex ?>_user_level, false);
  640. //-->
  641. </script>
  642. <?php } ?>
  643. <?php
  644. }
  645. $rs->MoveNext();
  646. }
  647. ?>
  648. </table>
  649. <?php if ($osj2Dusers->Export == "") { ?>
  650. <table>
  651. <tr><td><span class="phpmaker">
  652. <?php if ($Security->CanAdd()) { ?>
  653. <a href="osj-osj2dusersadd.php">Add</a>&nbsp;&nbsp;
  654. <?php } ?>
  655. <?php if ($nTotalRecs > 0) { ?>
  656. <?php if ($Security->CanDelete()) { ?>
  657. <a href="" onClick="if (!ew_Selected(document.fosj2Duserslist)) alert('No records selected'); else {document.fosj2Duserslist.action='osj-osj2dusersdelete.php';document.fosj2Duserslist.encoding='application/x-www-form-urlencoded';document.fosj2Duserslist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  658. <?php } ?>
  659. <?php } ?>
  660. </span></td></tr>
  661. </table>
  662. <?php } ?>
  663. <?php } ?>
  664. <?php if ($osj2Dusers->CurrentAction == "edit") { ?>
  665. <input type="hidden" name="key_count" id="key_count" value="<?php echo $RowIndex ?>">
  666. <?php } ?>
  667. </form>
  668. <?php
  669. // Close recordset and connection
  670. if ($rs) $rs->Close();
  671. ?>
  672. <?php if ($osj2Dusers->Export == "") { ?>
  673. <form action="osj-osj2duserslist.php" name="ewpagerform" id="ewpagerform">
  674. <table border="0" cellspacing="0" cellpadding="0">
  675. <tr>
  676. <td nowrap>
  677. <span class="phpmaker">
  678. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  679. <?php if ($Pager->RecordCount > 0) { ?>
  680. <?php if ($Pager->FirstButton->Enabled) { ?>
  681. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  682. <?php } ?>
  683. <?php if ($Pager->PrevButton->Enabled) { ?>
  684. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  685. <?php } ?>
  686. <?php foreach ($Pager->Items as $PagerItem) { ?>
  687. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duserslist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  688. <?php } ?>
  689. <?php if ($Pager->NextButton->Enabled) { ?>
  690. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  691. <?php } ?>
  692. <?php if ($Pager->LastButton->Enabled) { ?>
  693. <a href="osj-osj2duserslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  694. <?php } ?>
  695. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  696. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  697. <?php } else { ?>
  698. <?php if ($Security->CanList()) { ?>
  699. <?php if ($sSrchWhere == "0=101") { ?>
  700. Please enter search criteria
  701. <?php } else { ?>
  702. No records found
  703. <?php } ?>
  704. <?php } else { ?>
  705. You do not have the right permission to view the page
  706. <?php } ?>
  707. <?php } ?>
  708. </span>
  709. </td>
  710. <?php if ($nTotalRecs > 0) { ?>
  711. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  712. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  713. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  714. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  715. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  716. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  717. </select>
  718. </span></td>
  719. <?php } ?>
  720. </tr>
  721. </table>
  722. </form>
  723. <?php } ?>
  724. <?php if ($osj2Dusers->Export == "") { ?>
  725. <?php } ?>
  726. <?php if ($osj2Dusers->Export == "") { ?>
  727. <script language="JavaScript" type="text/javascript">
  728. <!--
  729. // Write your table-specific startup script here
  730. // document.write("page loaded");
  731. //-->
  732. </script>
  733. <?php } ?>
  734. <?php include "osj-footer.php" ?>
  735. <?php
  736. // If control is passed here, simply terminate the page without redirect
  737. Page_Terminate();
  738. // -----------------------------------------------------------------
  739. // Subroutine Page_Terminate
  740. // - called when exit page
  741. // - clean up connection and objects
  742. // - if url specified, redirect to url, otherwise end response
  743. function Page_Terminate($url = "") {
  744. global $conn;
  745. // Page unload event, used in current page
  746. Page_Unload();
  747. // Global page unloaded event (in userfn*.php)
  748. Page_Unloaded();
  749. // Close Connection
  750. $conn->Close();
  751. // Go to url if specified
  752. if ($url <> "") {
  753. ob_end_clean();
  754. header("Location: $url");
  755. }
  756. exit();
  757. }
  758. ?>
  759. <?php
  760. // Set up number of records displayed per page
  761. function SetUpDisplayRecs() {
  762. global $nDisplayRecs, $nStartRec, $osj2Dusers;
  763. $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
  764. if ($sWrk <> "") {
  765. if (is_numeric($sWrk)) {
  766. $nDisplayRecs = intval($sWrk);
  767. } else {
  768. if (strtolower($sWrk) == "all") { // Display all records
  769. $nDisplayRecs = -1;
  770. } else {
  771. $nDisplayRecs = 10; // Non-numeric, load default
  772. }
  773. }
  774. $osj2Dusers->setRecordsPerPage($nDisplayRecs); // Save to Session
  775. // Reset start position
  776. $nStartRec = 1;
  777. $osj2Dusers->setStartRecordNumber($nStartRec);
  778. } else {
  779. if ($osj2Dusers->getRecordsPerPage() <> "") {
  780. $nDisplayRecs = $osj2Dusers->getRecordsPerPage(); // Restore from Session
  781. } else {
  782. $nDisplayRecs = 10; // Load default
  783. }
  784. }
  785. }
  786. // Exit out of inline mode
  787. function ClearInlineMode() {
  788. global $osj2Dusers;
  789. $osj2Dusers->setKey("user_id", ""); // Clear inline edit key
  790. $osj2Dusers->CurrentAction = ""; // Clear action
  791. $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
  792. }
  793. // Switch to Inline Edit Mode
  794. function InlineEditMode() {
  795. global $Security, $osj2Dusers;
  796. if (!$Security->CanEdit()) Page_Terminate("osj-login.php"); // Go to login page
  797. $bInlineEdit = TRUE;
  798. if (@$_GET["user_id"] <> "") {
  799. $osj2Dusers->user_id->setQueryStringValue($_GET["user_id"]);
  800. } else {
  801. $bInlineEdit = FALSE;
  802. }
  803. if ($bInlineEdit) {
  804. if (LoadRow()) {
  805. $osj2Dusers->setKey("user_id", $osj2Dusers->user_id->CurrentValue); // Set up inline edit key
  806. $_SESSION[EW_SESSION_INLINE_MODE] = "edit"; // Enable inline edit
  807. }
  808. }
  809. }
  810. // Peform update to inline edit record
  811. function InlineUpdate() {
  812. global $objForm, $osj2Dusers;
  813. $objForm->Index = 1;
  814. LoadFormValues(); // Get form values
  815. if (CheckInlineEditKey()) { // Check key
  816. $osj2Dusers->SendEmail = TRUE; // Send email on update success
  817. $bInlineUpdate = EditRow(); // Update record
  818. } else {
  819. $bInlineUpdate = FALSE;
  820. }
  821. if ($bInlineUpdate) { // Update success
  822. $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Set success message
  823. ClearInlineMode(); // Clear inline edit mode
  824. } else {
  825. if (@$_SESSION[EW_SESSION_MESSAGE] == "") {
  826. $_SESSION[EW_SESSION_MESSAGE] = "Update failed"; // Set update failed message
  827. }
  828. $osj2Dusers->EventCancelled = TRUE; // Cancel event
  829. $osj2Dusers->CurrentAction = "edit"; // Stay in edit mode
  830. }
  831. }
  832. // Check inline edit key
  833. function CheckInlineEditKey() {
  834. global $osj2Dusers;
  835. //CheckInlineEditKey = True
  836. if (strval($osj2Dusers->getKey("user_id")) <> strval($osj2Dusers->user_id->CurrentValue)) {
  837. return FALSE;
  838. }
  839. return TRUE;
  840. }
  841. // Return Advanced Search Where based on QueryString parameters
  842. function AdvancedSearchWhere() {
  843. global $Security, $osj2Dusers;
  844. $sWhere = "";
  845. if (!$Security->CanSearch()) return "";
  846. // Field user_id
  847. BuildSearchSql($sWhere, $osj2Dusers->user_id, @$_GET["x_user_id"], @$_GET["z_user_id"], @$_GET["v_user_id"], @$_GET["y_user_id"], @$_GET["w_user_id"]);
  848. // Field user_creation_date
  849. BuildSearchSql($sWhere, $osj2Dusers->user_creation_date, ew_UnFormatDateTime(@$_GET["x_user_creation_date"],6), @$_GET["z_user_creation_date"], @$_GET["v_user_creation_date"], ew_UnFormatDateTime(@$_GET["y_user_creation_date"],6), @$_GET["w_user_creation_date"]);
  850. // Field user_edit_date
  851. BuildSearchSql($sWhere, $osj2Dusers->user_edit_date, ew_UnFormatDateTime(@$_GET["x_user_edit_date"],6), @$_GET["z_user_edit_date"], @$_GET["v_user_edit_date"], ew_UnFormatDateTime(@$_GET["y_user_edit_date"],6), @$_GET["w_user_edit_date"]);
  852. // Field user_email
  853. BuildSearchSql($sWhere, $osj2Dusers->user_email, @$_GET["x_user_email"], @$_GET["z_user_email"], @$_GET["v_user_email"], @$_GET["y_user_email"], @$_GET["w_user_email"]);
  854. // Field user_level
  855. BuildSearchSql($sWhere, $osj2Dusers->user_level, @$_GET["x_user_level"], @$_GET["z_user_level"], @$_GET["v_user_level"], @$_GET["y_user_level"], @$_GET["w_user_level"]);
  856. // Field user_status
  857. BuildSearchSql($sWhere, $osj2Dusers->user_status, @$_GET["x_user_status"], @$_GET["z_user_status"], @$_GET["v_user_status"], @$_GET["y_user_status"], @$_GET["w_user_status"]);
  858. //AdvancedSearchWhere = sWhere
  859. // Set up search parm
  860. if ($sWhere <> "") {
  861. // Field user_id
  862. SetSearchParm($osj2Dusers->user_id, @$_GET["x_user_id"], @$_GET["z_user_id"], @$_GET["v_user_id"], @$_GET["y_user_id"], @$_GET["w_user_id"]);
  863. // Field user_creation_date
  864. SetSearchParm($osj2Dusers->user_creation_date, ew_UnFormatDateTime(@$_GET["x_user_creation_date"],6), @$_GET["z_user_creation_date"], @$_GET["v_user_creation_date"], ew_UnFormatDateTime(@$_GET["y_user_creation_date"],6), @$_GET["w_user_creation_date"]);
  865. // Field user_edit_date
  866. SetSearchParm($osj2Dusers->user_edit_date, ew_UnFormatDateTime(@$_GET["x_user_edit_date"],6), @$_GET["z_user_edit_date"], @$_GET["v_user_edit_date"], ew_UnFormatDateTime(@$_GET["y_user_edit_date"],6), @$_GET["w_user_edit_date"]);
  867. // Field user_email
  868. SetSearchParm($osj2Dusers->user_email, @$_GET["x_user_email"], @$_GET["z_user_email"], @$_GET["v_user_email"], @$_GET["y_user_email"], @$_GET["w_user_email"]);
  869. // Field user_level
  870. SetSearchParm($osj2Dusers->user_level, @$_GET["x_user_level"], @$_GET["z_user_level"], @$_GET["v_user_level"], @$_GET["y_user_level"], @$_GET["w_user_level"]);
  871. // Field user_status
  872. SetSearchParm($osj2Dusers->user_status, @$_GET["x_user_status"], @$_GET["z_user_status"], @$_GET["v_user_status"], @$_GET["y_user_status"], @$_GET["w_user_status"]);
  873. }
  874. return $sWhere;
  875. }
  876. // Build search sql
  877. function BuildSearchSql(&$Where, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
  878. $sWrk = "";
  879. $FldParm = substr($Fld->FldVar, 2);
  880. $FldVal = ew_StripSlashes($FldVal);
  881. if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
  882. $FldVal2 = ew_StripSlashes($FldVal2);
  883. if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
  884. $FldOpr = strtoupper(trim($FldOpr));
  885. if ($FldOpr == "") $FldOpr = "=";
  886. $FldOpr2 = strtoupper(trim($FldOpr2));
  887. if ($FldOpr2 == "") $FldOpr2 = "=";
  888. if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) {
  889. if ($FldVal <> "") $FldVal = ($FldVal == "1") ? $Fld->TrueValue : $Fld->FalseValue;
  890. if ($FldVal2 <> "") $FldVal2 = ($FldVal2 == "1") ? $Fld->TrueValue : $Fld->FalseValue;
  891. } elseif ($Fld->FldDataType == EW_DATATYPE_DATE) {
  892. if ($FldVal <> "") $FldVal = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
  893. if ($FldVal2 <> "") $FldVal2 = ew_UnFormatDateTime($FldVal2, $Fld->FldDateTimeFormat);
  894. }
  895. if ($FldOpr == "BETWEEN") {
  896. $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  897. ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2)));
  898. if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
  899. $sWrk = $Fld->FldExpression . " BETWEEN " . ew_QuotedValue($FldVal, $Fld->FldDataType) .
  900. " AND " . ew_QuotedValue($FldVal2, $Fld->FldDataType);
  901. }
  902. } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
  903. $sWrk = $Fld->FldExpression . " " . $FldOpr;
  904. } else {
  905. $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  906. ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal)));
  907. if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
  908. $sWrk = $Fld->FldExpression . SearchString($FldOpr, $FldVal, $Fld->FldDataType);
  909. }
  910. $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
  911. ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2)));
  912. if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
  913. if ($sWrk <> "") {
  914. $sWrk .= " " . (($FldCond=="OR")?"OR":"AND") . " ";
  915. }
  916. $sWrk .= $Fld->FldExpression . SearchString($FldOpr2, $FldVal2, $Fld->FldDataType);
  917. }
  918. }
  919. if ($sWrk <> "") {
  920. if ($Where <> "") $Where .= " AND ";
  921. $Where .= "(" . $sWrk . ")";
  922. }
  923. }
  924. // Return search string
  925. function SearchString($FldOpr, $FldVal, $FldType) {
  926. if ($FldOpr == "LIKE" || $FldOpr == "NOT LIKE") {
  927. return " " . $FldOpr . " " . ew_QuotedValue("%" . $FldVal . "%", $FldType);
  928. } elseif ($FldOpr == "STARTS WITH") {
  929. return " LIKE " . ew_QuotedValue($FldVal . "%", $FldType);
  930. } else {
  931. return " " . $FldOpr . " " . ew_QuotedValue($FldVal, $FldType);
  932. }
  933. }
  934. // Set search parm
  935. function SetSearchParm($Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
  936. global $osj2Dusers;
  937. $FldParm = substr($Fld->FldVar, 2);
  938. $FldVal = ew_StripSlashes($FldVal);
  939. if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
  940. $FldVal2 = ew_StripSlashes($FldVal2);
  941. if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
  942. $osj2Dusers->setAdvancedSearch("x_" . $FldParm, $FldVal);
  943. $osj2Dusers->setAdvancedSearch("z_" . $FldParm, $FldOpr);
  944. $osj2Dusers->setAdvancedSearch("v_" . $FldParm, $FldCond);
  945. $osj2Dusers->setAdvancedSearch("y_" . $FldParm, $FldVal2);
  946. $osj2Dusers->setAdvancedSearch("w_" . $FldParm, $FldOpr2);
  947. }
  948. // Return Basic Search sql
  949. function BasicSearchSQL($Keyword) {
  950. $sKeyword = ew_AdjustSql($Keyword);
  951. $sql = "";
  952. $sql .= "`user_email` LIKE '%" . $sKeyword . "%' OR ";
  953. if (substr($sql, -4) == " OR ") $sql = substr($sql, 0, strlen($sql)-4);
  954. return $sql;
  955. }
  956. // Return Basic Search Where based on search keyword and type
  957. function BasicSearchWhere() {
  958. global $Security, $osj2Dusers;
  959. $sSearchStr = "";
  960. if (!$Security->CanSearch()) return "";
  961. $sSearchKeyword = ew_StripSlashes(@$_GET[EW_TABLE_BASIC_SEARCH]);
  962. $sSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
  963. if ($sSearchKeyword <> "") {
  964. $sSearch = trim($sSearchKeyword);
  965. if ($sSearchType <> "") {
  966. while (strpos($sSearch, " ") !== FALSE)
  967. $sSearch = str_replace(" ", " ", $sSearch);
  968. $arKeyword = explode(" ", trim($sSearch));
  969. foreach ($arKeyword as $sKeyword) {
  970. if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
  971. $sSearchStr .= "(" . BasicSearchSQL($sKeyword) . ")";
  972. }
  973. } else {
  974. $sSearchStr = BasicSearchSQL($sSearch);
  975. }
  976. }
  977. if ($sSearchKeyword <> "") {
  978. $osj2Dusers->setBasicSearchKeyword($sSearchKeyword);
  979. $osj2Dusers->setBasicSearchType($sSearchType);
  980. }
  981. return $sSearchStr;
  982. }
  983. // Clear all search parameters
  984. function ResetSearchParms() {
  985. // Clear search where
  986. global $osj2Dusers;
  987. $sSrchWhere = "";
  988. $osj2Dusers->setSearchWhere($sSrchWhere);
  989. // Clear basic search parameters
  990. ResetBasicSearchParms();
  991. // Clear advanced search parameters
  992. ResetAdvancedSearchParms();
  993. }
  994. // Clear all basic search parameters
  995. function ResetBasicSearchParms() {
  996. // Clear basic search parameters
  997. global $osj2Dusers;
  998. $osj2Dusers->setBasicSearchKeyword("");
  999. $osj2Dusers->setBasicSearchType("");
  1000. }
  1001. // Clear all advanced search parameters
  1002. function ResetAdvancedSearchParms() {
  1003. // Clear advanced search parameters
  1004. global $osj2Dusers;
  1005. $osj2Dusers->setAdvancedSearch("x_user_id", "");
  1006. $osj2Dusers->setAdvancedSearch("v_user_id", "AND");
  1007. $osj2Dusers->setAdvancedSearch("y_user_id", "");
  1008. $osj2Dusers->setAdvancedSearch("w_user_id", "");
  1009. $osj2Dusers->setAdvancedSearch("x_user_creation_date", "");
  1010. $osj2Dusers->setAdvancedSearch("y_user_creation_date", "");
  1011. $osj2Dusers->setAdvancedSearch("x_user_edit_date", "");
  1012. $osj2Dusers->setAdvancedSearch("y_user_edit_date", "");
  1013. $osj2Dusers->setAdvancedSearch("x_user_email", "");
  1014. $osj2Dusers->setAdvancedSearch("v_user_email", "AND");
  1015. $osj2Dusers->setAdvancedSearch("y_user_email", "");
  1016. $osj2Dusers->setAdvancedSearch("w_user_email", "");
  1017. $osj2Dusers->setAdvancedSearch("x_user_level", "");
  1018. $osj2Dusers->setAdvancedSearch("x_user_status", "");
  1019. }
  1020. // Restore all search parameters
  1021. function RestoreSearchParms() {
  1022. global $sSrchWhere, $osj2Dusers;
  1023. $sSrchWhere = $osj2Dusers->getSearchWhere();
  1024. // Restore advanced search settings
  1025. RestoreAdvancedSearchParms();
  1026. }
  1027. // Restore all advanced search parameters
  1028. function RestoreAdvancedSearchParms() {
  1029. // Restore advanced search parms
  1030. global $osj2Dusers;
  1031. $osj2Dusers->user_id->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_id");
  1032. $osj2Dusers->user_id->AdvancedSearch->SearchCondition = $osj2Dusers->getAdvancedSearch("v_user_id");
  1033. $osj2Dusers->user_id->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_id");
  1034. $osj2Dusers->user_id->AdvancedSearch->SearchOperator = $osj2Dusers->getAdvancedSearch("w_user_id");
  1035. $osj2Dusers->user_creation_date->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_creation_date");
  1036. $osj2Dusers->user_creation_date->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_creation_date");
  1037. $osj2Dusers->user_edit_date->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_edit_date");
  1038. $osj2Dusers->user_edit_date->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_edit_date");
  1039. $osj2Dusers->user_email->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_email");
  1040. $osj2Dusers->user_email->AdvancedSearch->SearchCondition = $osj2Dusers->getAdvancedSearch("v_user_email");
  1041. $osj2Dusers->user_email->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_email");
  1042. $osj2Dusers->user_email->AdvancedSearch->SearchOperator = $osj2Dusers->getAdvancedSearch("w_user_email");
  1043. $osj2Dusers->user_level->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_level");
  1044. $osj2Dusers->user_status->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_status");
  1045. }
  1046. // Set up Sort parameters based on Sort Links clicked
  1047. function SetUpSortOrder() {
  1048. global $osj2Dusers;
  1049. // Check for an Order parameter
  1050. if (@$_GET["order"] <> "") {
  1051. $osj2Dusers->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
  1052. $osj2Dusers->CurrentOrderType = @$_GET["ordertype"];
  1053. // Field user_id
  1054. $osj2Dusers->UpdateSort($osj2Dusers->user_id);
  1055. // Field user_creation_date
  1056. $osj2Dusers->UpdateSort($osj2Dusers->user_creation_date);
  1057. // Field user_edit_date
  1058. $osj2Dusers->UpdateSort($osj2Dusers->user_edit_date);
  1059. // Field user_email
  1060. $osj2Dusers->UpdateSort($osj2Dusers->user_email);
  1061. // Field user_password
  1062. $osj2Dusers->UpdateSort($osj2Dusers->user_password);
  1063. // Field user_level
  1064. $osj2Dusers->UpdateSort($osj2Dusers->user_level);
  1065. // Field user_status
  1066. $osj2Dusers->UpdateSort($osj2Dusers->user_status);
  1067. $osj2Dusers->setStartRecordNumber(1); // Reset start position
  1068. }
  1069. $sOrderBy = $osj2Dusers->getSessionOrderBy(); // Get order by from Session
  1070. if ($sOrderBy == "") {
  1071. if ($osj2Dusers->SqlOrderBy() <> "") {
  1072. $sOrderBy = $osj2Dusers->SqlOrderBy();
  1073. $osj2Dusers->setSessionOrderBy($sOrderBy);
  1074. }
  1075. }
  1076. }
  1077. // Reset command based on querystring parameter cmd=
  1078. // - RESET: reset search parameters
  1079. // - RESETALL: reset search & master/detail parameters
  1080. // - RESETSORT: reset sort parameters
  1081. function ResetCmd() {
  1082. global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
  1083. global $osj2Dusers;
  1084. // Get reset cmd
  1085. if (@$_GET["cmd"] <> "") {
  1086. $sCmd = $_GET["cmd"];
  1087. // Reset search criteria
  1088. if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall") {
  1089. ResetSearchParms();
  1090. }
  1091. // Reset Sort Criteria
  1092. if (strtolower($sCmd) == "resetsort") {
  1093. $sOrderBy = "";
  1094. $osj2Dusers->setSessionOrderBy($sOrderBy);
  1095. $osj2Dusers->user_id->setSort("");
  1096. $osj2Dusers->user_creation_date->setSort("");
  1097. $osj2Dusers->user_edit_date->setSort("");
  1098. $osj2Dusers->user_email->setSort("");
  1099. $osj2Dusers->user_password->setSort("");
  1100. $osj2Dusers->user_level->setSort("");
  1101. $osj2Dusers->user_status->setSort("");
  1102. }
  1103. // Reset start position
  1104. $nStartRec = 1;
  1105. $osj2Dusers->setStartRecordNumber($nStartRec);
  1106. }
  1107. }
  1108. ?>
  1109. <?php
  1110. // Set up Starting Record parameters based on Pager Navigation
  1111. function SetUpStartRec() {
  1112. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Dusers;
  1113. if ($nDisplayRecs == 0) return;
  1114. // Check for a START parameter
  1115. if (@$_GET[EW_TABLE_START_REC] <> "") {
  1116. $nStartRec = $_GET[EW_TABLE_START_REC];
  1117. $osj2Dusers->setStartRecordNumber($nStartRec);
  1118. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  1119. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  1120. if (is_numeric($nPageNo)) {
  1121. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  1122. if ($nStartRec <= 0) {
  1123. $nStartRec = 1;
  1124. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  1125. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  1126. }
  1127. $osj2Dusers->setStartRecordNumber($nStartRec);
  1128. } else {
  1129. $nStartRec = $osj2Dusers->getStartRecordNumber();
  1130. }
  1131. } else {
  1132. $nStartRec = $osj2Dusers->getStartRecordNumber();
  1133. }
  1134. // Check if correct start record counter
  1135. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  1136. $nStartRec = 1; // Reset start record counter
  1137. $osj2Dusers->setStartRecordNumber($nStartRec);
  1138. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  1139. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  1140. $osj2Dusers->setStartRecordNumber($nStartRec);
  1141. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  1142. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  1143. $osj2Dusers->setStartRecordNumber($nStartRec);
  1144. }
  1145. }
  1146. ?>
  1147. <?php
  1148. // Load form values
  1149. function LoadFormValues() {
  1150. // Load from form
  1151. global $objForm, $osj2Dusers;
  1152. $osj2Dusers->user_id->setFormValue($objForm->GetValue("x_user_id"));
  1153. $osj2Dusers->user_creation_date->setFormValue($objForm->GetValue("x_user_creation_date"));
  1154. $osj2Dusers->user_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_creation_date->CurrentValue, 6);
  1155. $osj2Dusers->user_edit_date->setFormValue($objForm->GetValue("x_user_edit_date"));
  1156. $osj2Dusers->user_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_edit_date->CurrentValue, 6);
  1157. $osj2Dusers->user_email->setFormValue($objForm->GetValue("x_user_email"));
  1158. $osj2Dusers->user_password->setFormValue($objForm->GetValue("x_user_password"));
  1159. $osj2Dusers->user_level->setFormValue($objForm->GetValue("x_user_level"));
  1160. $osj2Dusers->user_status->setFormValue($objForm->GetValue("x_user_status"));
  1161. }
  1162. // Restore form values
  1163. function RestoreFormValues() {
  1164. global $osj2Dusers;
  1165. $osj2Dusers->user_id->CurrentValue = $osj2Dusers->user_id->FormValue;
  1166. $osj2Dusers->user_creation_date->CurrentValue = $osj2Dusers->user_creation_date->FormValue;
  1167. $osj2Dusers->user_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_creation_date->CurrentValue, 6);
  1168. $osj2Dusers->user_edit_date->CurrentValue = $osj2Dusers->user_edit_date->FormValue;
  1169. $osj2Dusers->user_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_edit_date->CurrentValue, 6);
  1170. $osj2Dusers->user_email->CurrentValue = $osj2Dusers->user_email->FormValue;
  1171. $osj2Dusers->user_password->CurrentValue = $osj2Dusers->user_password->FormValue;
  1172. $osj2Dusers->user_level->CurrentValue = $osj2Dusers->user_level->FormValue;
  1173. $osj2Dusers->user_status->CurrentValue = $osj2Dusers->user_status->FormValue;
  1174. }
  1175. ?>
  1176. <?php
  1177. // Load recordset
  1178. function LoadRecordset($offset = -1, $rowcnt = -1) {
  1179. global $conn, $osj2Dusers;
  1180. // Call Recordset Selecting event
  1181. $osj2Dusers->Recordset_Selecting($osj2Dusers->CurrentFilter);
  1182. // Load list page sql
  1183. $sSql = $osj2Dusers->SelectSQL();
  1184. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  1185. // Load recordset
  1186. $conn->raiseErrorFn = 'ew_ErrorFn';
  1187. $rs = $conn->Execute($sSql);
  1188. $conn->raiseErrorFn = '';
  1189. // Call Recordset Selected event
  1190. $osj2Dusers->Recordset_Selected($rs);
  1191. return $rs;
  1192. }
  1193. ?>
  1194. <?php
  1195. // Load row based on key values
  1196. function LoadRow() {
  1197. global $conn, $Security, $osj2Dusers;
  1198. $sFilter = $osj2Dusers->SqlKeyFilter();
  1199. if (!is_numeric($osj2Dusers->user_id->CurrentValue)) {
  1200. return FALSE; // Invalid key, exit
  1201. }
  1202. $sFilter = str_replace("@user_id@", ew_AdjustSql($osj2Dusers->user_id->CurrentValue), $sFilter); // Replace key value
  1203. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  1204. $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  1205. }
  1206. // Call Row Selecting event
  1207. $osj2Dusers->Row_Selecting($sFilter);
  1208. // Load sql based on filter
  1209. $osj2Dusers->CurrentFilter = $sFilter;
  1210. $sSql = $osj2Dusers->SQL();
  1211. if ($rs = $conn->Execute($sSql)) {
  1212. if ($rs->EOF) {
  1213. $LoadRow = FALSE;
  1214. } else {
  1215. $LoadRow = TRUE;
  1216. $rs->MoveFirst();
  1217. LoadRowValues($rs); // Load row values
  1218. // Call Row Selected event
  1219. $osj2Dusers->Row_Selected($rs);
  1220. }
  1221. $rs->Close();
  1222. } else {
  1223. $LoadRow = FALSE;
  1224. }
  1225. return $LoadRow;
  1226. }
  1227. // Load row values from recordset
  1228. function LoadRowValues(&$rs) {
  1229. global $osj2Dusers;
  1230. $osj2Dusers->user_id->setDbValue($rs->fields('user_id'));
  1231. $osj2Dusers->user_creation_date->setDbValue($rs->fields('user_creation_date'));
  1232. $osj2Dusers->user_edit_date->setDbValue($rs->fields('user_edit_date'));
  1233. $osj2Dusers->user_email->setDbValue($rs->fields('user_email'));
  1234. $osj2Dusers->user_password->setDbValue($rs->fields('user_password'));
  1235. $osj2Dusers->user_level->setDbValue($rs->fields('user_level'));
  1236. $osj2Dusers->user_status->setDbValue($rs->fields('user_status'));
  1237. }
  1238. ?>
  1239. <?php
  1240. // Render row values based on field settings
  1241. function RenderRow() {
  1242. global $conn, $Security, $osj2Dusers;
  1243. // Call Row Rendering event
  1244. $osj2Dusers->Row_Rendering();
  1245. // Common render codes for all row types
  1246. // user_id
  1247. $osj2Dusers->user_id->CellCssStyle = "";
  1248. $osj2Dusers->user_id->CellCssClass = "";
  1249. // user_creation_date
  1250. $osj2Dusers->user_creation_date->CellCssStyle = "";
  1251. $osj2Dusers->user_creation_date->CellCssClass = "";
  1252. // user_edit_date
  1253. $osj2Dusers->user_edit_date->CellCssStyle = "";
  1254. $osj2Dusers->user_edit_date->CellCssClass = "";
  1255. // user_email
  1256. $osj2Dusers->user_email->CellCssStyle = "";
  1257. $osj2Dusers->user_email->CellCssClass = "";
  1258. // user_password
  1259. $osj2Dusers->user_password->CellCssStyle = "";
  1260. $osj2Dusers->user_password->CellCssClass = "";
  1261. // user_level
  1262. $osj2Dusers->user_level->CellCssStyle = "";
  1263. $osj2Dusers->user_level->CellCssClass = "";
  1264. // user_status
  1265. $osj2Dusers->user_status->CellCssStyle = "";
  1266. $osj2Dusers->user_status->CellCssClass = "";
  1267. if ($osj2Dusers->RowType == EW_ROWTYPE_VIEW) { // View row
  1268. // user_id
  1269. $osj2Dusers->user_id->CssStyle = "";
  1270. $osj2Dusers->user_id->CssClass = "";
  1271. $osj2Dusers->user_id->ViewCustomAttributes = "";
  1272. // user_creation_date
  1273. $osj2Dusers->user_creation_date->ViewValue = ew_FormatDateTime($osj2Dusers->user_creation_date->ViewValue, 6);
  1274. $osj2Dusers->user_creation_date->CssStyle = "";
  1275. $osj2Dusers->user_creation_date->CssClass = "";
  1276. $osj2Dusers->user_creation_date->ViewCustomAttributes = "";
  1277. // user_edit_date
  1278. $osj2Dusers->user_edit_date->ViewValue = ew_FormatDateTime($osj2Dusers->user_edit_date->ViewValue, 6);
  1279. $osj2Dusers->user_edit_date->CssStyle = "";
  1280. $osj2Dusers->user_edit_date->CssClass = "";
  1281. $osj2Dusers->user_edit_date->ViewCustomAttributes = "";
  1282. // user_email
  1283. $osj2Dusers->user_email->ViewValue = $osj2Dusers->user_email->CurrentValue;
  1284. $osj2Dusers->user_email->ViewValue = ew_Highlight($osj2Dusers->user_email->ViewValue, $osj2Dusers->getBasicSearchKeyword(), $osj2Dusers->getBasicSearchType(), $osj2Dusers->getAdvancedSearch("x_user_email"));
  1285. $osj2Dusers->user_email->CssStyle = "";
  1286. $osj2Dusers->user_email->CssClass = "";
  1287. $osj2Dusers->user_email->ViewCustomAttributes = "";
  1288. // user_password
  1289. $osj2Dusers->user_password->ViewValue = "********";
  1290. $osj2Dusers->user_password->CssStyle = "";
  1291. $osj2Dusers->user_password->CssClass = "";
  1292. $osj2Dusers->user_password->ViewCustomAttributes = "";
  1293. // user_level
  1294. if ($Security->CanAdmin()) { // System admin
  1295. if (!is_null($osj2Dusers->user_level->CurrentValue)) {
  1296. $sSqlWrk = "SELECT `user_level_name` FROM `osj-user_level` WHERE `user_level_id` = " . ew_AdjustSql($osj2Dusers->user_level->CurrentValue) . "";
  1297. $sSqlWrk .= " AND (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
  1298. $rswrk = $conn->Execute($sSqlWrk);
  1299. if ($rswrk) {
  1300. if (!$rswrk->EOF) {
  1301. $osj2Dusers->user_level->ViewValue = $rswrk->fields('user_level_name');
  1302. }
  1303. $rswrk->Close();
  1304. } else {
  1305. $osj2Dusers->user_level->ViewValue = $osj2Dusers->user_level->CurrentValue;
  1306. }
  1307. } else {
  1308. $osj2Dusers->user_level->ViewValue = NULL;
  1309. }
  1310. } else {
  1311. $osj2Dusers->user_level->ViewValue = "********";
  1312. }
  1313. $osj2Dusers->user_level->CssStyle = "";
  1314. $osj2Dusers->user_level->CssClass = "";
  1315. $osj2Dusers->user_level->ViewCustomAttributes = "";
  1316. // user_status
  1317. if (!is_null($osj2Dusers->user_status->CurrentValue)) {
  1318. switch ($osj2Dusers->user_status->CurrentValue) {
  1319. case "0":
  1320. $osj2Dusers->user_status->ViewValue = "Inactive";
  1321. break;
  1322. case "1":
  1323. $osj2Dusers->user_status->ViewValue = "Active";
  1324. break;
  1325. default:
  1326. $osj2Dusers->user_status->ViewValue = $osj2Dusers->user_status->CurrentValue;
  1327. }
  1328. } else {
  1329. $osj2Dusers->user_status->ViewValue = NULL;
  1330. }
  1331. $osj2Dusers->user_status->CssStyle = "";
  1332. $osj2Dusers->user_status->CssClass = "";
  1333. $osj2Dusers->user_status->ViewCustomAttributes = "";
  1334. // user_id
  1335. $osj2Dusers->user_id->HrefValue = "";
  1336. // user_creation_date
  1337. $osj2Dusers->user_creation_date->HrefValue = "";
  1338. // user_edit_date
  1339. $osj2Dusers->user_edit_date->HrefValue = "";
  1340. // user_email
  1341. $osj2Dusers->user_email->HrefValue = "";
  1342. // user_password
  1343. $osj2Dusers->user_password->HrefValue = "";
  1344. // user_level
  1345. $osj2Dusers->user_level->HrefValue = "";
  1346. // user_status
  1347. $osj2Dusers->user_status->HrefValue = "";
  1348. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_ADD) { // Add row
  1349. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit row
  1350. // user_id
  1351. $osj2Dusers->user_id->EditCustomAttributes = "";
  1352. $osj2Dusers->user_id->CssStyle = "";
  1353. $osj2Dusers->user_id->CssClass = "";
  1354. $osj2Dusers->user_id->ViewCustomAttributes = "";
  1355. // user_edit_date
  1356. $osj2Dusers->user_edit_date->EditCustomAttributes = "";
  1357. // user_email
  1358. $osj2Dusers->user_email->EditCustomAttributes = "";
  1359. $osj2Dusers->user_email->EditValue = ew_HtmlEncode($osj2Dusers->user_email->CurrentValue);
  1360. // user_password
  1361. $osj2Dusers->user_password->EditCustomAttributes = "";
  1362. $osj2Dusers->user_password->EditValue = ew_HtmlEncode($osj2Dusers->user_password->CurrentValue);
  1363. // user_level
  1364. $osj2Dusers->user_level->EditCustomAttributes = "";
  1365. if (!$Security->CanAdmin()) { // System admin
  1366. $osj2Dusers->user_level->EditValue = "********";
  1367. } else {
  1368. $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
  1369. if (trim(strval($osj2Dusers->user_level->CurrentValue)) == "") {
  1370. $sSqlWrk .= " WHERE 0=1";
  1371. } else {
  1372. $sSqlWrk .= " WHERE `user_level_id` = " . ew_AdjustSql($osj2Dusers->user_level->CurrentValue) . "";
  1373. }
  1374. $sSqlWrk .= " AND (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
  1375. $rswrk = $conn->Execute($sSqlWrk);
  1376. $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
  1377. if ($rswrk) $rswrk->Close();
  1378. array_unshift($arwrk, array("", "Please Select"));
  1379. $osj2Dusers->user_level->EditValue = $arwrk;
  1380. }
  1381. // user_status
  1382. $osj2Dusers->user_status->EditCustomAttributes = "";
  1383. $arwrk = array();
  1384. $arwrk[] = array("0", "Inactive");
  1385. $arwrk[] = array("1", "Active");
  1386. array_unshift($arwrk, array("", "Please Select"));
  1387. $osj2Dusers->user_status->EditValue = $arwrk;
  1388. } elseif ($osj2Dusers->RowType == EW_ROWTYPE_SEARCH) { // Search row
  1389. }
  1390. // Call Row Rendered event
  1391. $osj2Dusers->Row_Rendered();
  1392. }
  1393. ?>
  1394. <?php
  1395. // Update record based on key values
  1396. function EditRow() {
  1397. global $conn, $Security, $osj2Dusers;
  1398. $sFilter = $osj2Dusers->SqlKeyFilter();
  1399. if (!is_numeric($osj2Dusers->user_id->CurrentValue)) {
  1400. return FALSE;
  1401. }
  1402. $sFilter = str_replace("@user_id@", ew_AdjustSql($osj2Dusers->user_id->CurrentValue), $sFilter); // Replace key value
  1403. if ($osj2Dusers->user_email->CurrentValue <> "") { // Check field with unique index
  1404. $sFilterChk = "(`user_email` = '" . ew_AdjustSql($osj2Dusers->user_email->CurrentValue) . "')";
  1405. $sFilterChk .= " AND NOT (" . $sFilter . ")";
  1406. $osj2Dusers->CurrentFilter = $sFilterChk;
  1407. $sSqlChk = $osj2Dusers->SQL();
  1408. $conn->raiseErrorFn = 'ew_ErrorFn';
  1409. $rsChk = $conn->Execute($sSqlChk);
  1410. $conn->raiseErrorFn = '';
  1411. if ($rsChk === FALSE) {
  1412. return FALSE;
  1413. } elseif (!$rsChk->EOF) {
  1414. $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for index or primary key -- `user_email`, value = " . $osj2Dusers->user_email->CurrentValue;
  1415. $rsChk->Close();
  1416. return FALSE;
  1417. }
  1418. $rsChk->Close();
  1419. }
  1420. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  1421. $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  1422. $osj2Dusers->CurrentFilter = $sFilter;
  1423. }
  1424. $osj2Dusers->CurrentFilter = $sFilter;
  1425. $sSql = $osj2Dusers->SQL();
  1426. $conn->raiseErrorFn = 'ew_ErrorFn';
  1427. $rs = $conn->Execute($sSql);
  1428. $conn->raiseErrorFn = '';
  1429. if ($rs === FALSE)
  1430. return FALSE;
  1431. if ($rs->EOF) {
  1432. $EditRow = FALSE; // Update Failed
  1433. } else {
  1434. // Save old values
  1435. $rsold =& $rs->fields;
  1436. $rsnew = array();
  1437. // Field user_id
  1438. // Field user_creation_date
  1439. $osj2Dusers->user_creation_date->SetDbValueDef(ew_CurrentDateTime(), ew_CurrentDate());
  1440. $rsnew['user_creation_date'] =& $osj2Dusers->user_creation_date->DbValue;
  1441. // Field user_edit_date
  1442. $osj2Dusers->user_edit_date->SetDbValueDef(ew_UnFormatDateTime($osj2Dusers->user_edit_date->CurrentValue, 6), NULL);
  1443. $rsnew['user_edit_date'] =& $osj2Dusers->user_edit_date->DbValue;
  1444. // Field user_email
  1445. $osj2Dusers->user_email->SetDbValueDef($osj2Dusers->user_email->CurrentValue, "");
  1446. $rsnew['user_email'] =& $osj2Dusers->user_email->DbValue;
  1447. // Field user_password
  1448. $osj2Dusers->user_password->SetDbValueDef($osj2Dusers->user_password->CurrentValue, "");
  1449. $rsnew['user_password'] =& $osj2Dusers->user_password->DbValue;
  1450. // Field user_level
  1451. if ($Security->CanAdmin()) { // System admin
  1452. $osj2Dusers->user_level->SetDbValueDef($osj2Dusers->user_level->CurrentValue, 0);
  1453. $rsnew['user_level'] =& $osj2Dusers->user_level->DbValue;
  1454. }
  1455. // Field user_status
  1456. $osj2Dusers->user_status->SetDbValueDef($osj2Dusers->user_status->CurrentValue, 0);
  1457. $rsnew['user_status'] =& $osj2Dusers->user_status->DbValue;
  1458. // Call Row Updating event
  1459. $bUpdateRow = $osj2Dusers->Row_Updating($rsold, $rsnew);
  1460. if ($bUpdateRow) {
  1461. $conn->raiseErrorFn = 'ew_ErrorFn';
  1462. $EditRow = $conn->Execute($osj2Dusers->UpdateSQL($rsnew));
  1463. $conn->raiseErrorFn = '';
  1464. } else {
  1465. if ($osj2Dusers->CancelMessage <> "") {
  1466. $_SESSION[EW_SESSION_MESSAGE] = $osj2Dusers->CancelMessage;
  1467. $osj2Dusers->CancelMessage = "";
  1468. } else {
  1469. $_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
  1470. }
  1471. $EditRow = FALSE;
  1472. }
  1473. }
  1474. // Call Row Updated event
  1475. if ($EditRow) {
  1476. $osj2Dusers->Row_Updated($rsold, $rsnew);
  1477. }
  1478. if ($EditRow) {
  1479. WriteAuditTrailOnEdit($rsold, $rsnew);
  1480. }
  1481. $rs->Close();
  1482. return $EditRow;
  1483. }
  1484. ?>
  1485. <?php
  1486. // Load advanced search
  1487. function LoadAdvancedSearch() {
  1488. global $osj2Dusers;
  1489. }
  1490. ?>
  1491. <?php
  1492. // Export data in Xml or Csv format
  1493. function ExportData() {
  1494. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Dusers;
  1495. $sCsvStr = "";
  1496. $rs = LoadRecordset();
  1497. $nTotalRecs = $rs->RecordCount();
  1498. $nStartRec = 1;
  1499. // Export all
  1500. if (defined("EW_EXPORT_ALL")) {
  1501. $nStopRec = $nTotalRecs;
  1502. } else { // Export 1 page only
  1503. SetUpStartRec(); // Set Up Start Record Position
  1504. // Set the last record to display
  1505. if ($nDisplayRecs < 0) {
  1506. $nStopRec = $nTotalRecs;
  1507. } else {
  1508. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  1509. }
  1510. }
  1511. if ($osj2Dusers->Export == "xml") {
  1512. $XmlDoc = new cXMLDocument();
  1513. }
  1514. if ($osj2Dusers->Export == "csv") {
  1515. $sCsvStr .= "user_id" . ",";
  1516. $sCsvStr .= "user_creation_date" . ",";
  1517. $sCsvStr .= "user_edit_date" . ",";
  1518. $sCsvStr .= "user_email" . ",";
  1519. $sCsvStr .= "user_password" . ",";
  1520. $sCsvStr .= "user_level" . ",";
  1521. $sCsvStr .= "user_status" . ",";
  1522. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  1523. $sCsvStr .= "\n";
  1524. }
  1525. // Move to first record directly for performance reason
  1526. $nRecCount = $nStartRec - 1;
  1527. if (!$rs->EOF) {
  1528. $rs->MoveFirst();
  1529. $rs->Move($nStartRec - 1);
  1530. }
  1531. while (!$rs->EOF && $nRecCount < $nStopRec) {
  1532. $nRecCount++;
  1533. if (intval($nRecCount) >= intval($nStartRec)) {
  1534. LoadRowValues($rs);
  1535. if ($osj2Dusers->Export == "xml") {
  1536. $XmlDoc->BeginRow();
  1537. $XmlDoc->AddField('user_id', $osj2Dusers->user_id->CurrentValue);
  1538. $XmlDoc->AddField('user_creation_date', $osj2Dusers->user_creation_date->CurrentValue);
  1539. $XmlDoc->AddField('user_edit_date', $osj2Dusers->user_edit_date->CurrentValue);
  1540. $XmlDoc->AddField('user_email', $osj2Dusers->user_email->CurrentValue);
  1541. $XmlDoc->AddField('user_password', $osj2Dusers->user_password->CurrentValue);
  1542. $XmlDoc->AddField('user_level', $osj2Dusers->user_level->CurrentValue);
  1543. $XmlDoc->AddField('user_status', $osj2Dusers->user_status->CurrentValue);
  1544. $XmlDoc->EndRow();
  1545. }
  1546. if ($osj2Dusers->Export == "csv") {
  1547. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dusers->user_id->CurrentValue)) . '",';
  1548. $sCsvStr .= '"' . str_replace('"', '""', strva