/osj-osj2duserslist.php
PHP | 1713 lines | 1376 code | 165 blank | 172 comment | 447 complexity | 4f17a5fed223d4a674237e65e78f1ca3 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- <?php
- define("EW_PAGE_ID", "list", TRUE); // Page ID
- define("EW_TABLE_NAME", 'osj-users', TRUE);
- ?>
- <?php
- session_start(); // Initialize session data
- ob_start(); // Turn on output buffering
- ?>
- <?php include "osj-ewcfg50.php" ?>
- <?php include "osj-ewmysql50.php" ?>
- <?php include "osj-phpfn50.php" ?>
- <?php include "osj-osj2dusersinfo.php" ?>
- <?php include "osj-userfn50.php" ?>
- <?php
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
- header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache"); // HTTP/1.0
- ?>
- <?php
-
- // Open connection to the database
- $conn = ew_Connect();
- ?>
- <?php
- $Security = new cAdvancedSecurity();
- ?>
- <?php
- if (!$Security->IsLoggedIn()) $Security->AutoLogin();
- $Security->LoadCurrentUserLevel('osj-users');
- if (!$Security->IsLoggedIn()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-login.php");
- }
- if (!$Security->CanList()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-login.php");
- }
- if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
- $_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
- Page_Terminate("osj-login.php");
- }
- ?>
- <?php
-
- // Common page loading event (in userfn*.php)
- Page_Loading();
- ?>
- <?php
-
- // Page load event, used in current page
- Page_Load();
- ?>
- <?php
- $osj2Dusers->Export = @$_GET["export"]; // Get export parameter
- $sExport = $osj2Dusers->Export; // Get export parameter, used in header
- $sExportFile = $osj2Dusers->TableVar; // Get export file, used in header
- ?>
- <?php
- if ($osj2Dusers->Export == "html") {
-
- // Printer friendly, no action required
- }
- if ($osj2Dusers->Export == "xml") {
- header('Content-Type: text/xml');
- header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
- }
- if ($osj2Dusers->Export == "csv") {
- header('Content-Type: application/csv');
- header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
- }
- ?>
- <?php
-
- // Paging variables
- $nStartRec = 0; // Start record index
- $nStopRec = 0; // Stop record index
- $nTotalRecs = 0; // Total number of records
- $nDisplayRecs = 10;
- $nRecRange = 10;
- $nRecCount = 0; // Record count
-
- // Search filters
- $sSrchAdvanced = ""; // Advanced search filter
- $sSrchBasic = ""; // Basic search filter
- $sSrchWhere = ""; // Search where clause
- $sFilter = "";
-
- // Master/Detail
- $sDbMasterFilter = ""; // Master filter
- $sDbDetailFilter = ""; // Detail filter
- $sSqlMaster = ""; // Sql for master record
-
- // Set up records per page dynamically
- SetUpDisplayRecs();
-
- // Handle reset command
- ResetCmd();
-
- // Check QueryString parameters
- if (@$_GET["a"] <> "") {
- $osj2Dusers->CurrentAction = $_GET["a"];
-
- // Clear inline mode
- if ($osj2Dusers->CurrentAction == "cancel") {
- ClearInlineMode();
- }
-
- // Switch to inline edit mode
- if ($osj2Dusers->CurrentAction == "edit") {
- InlineEditMode();
- }
- } else {
-
- // Create form object
- $objForm = new cFormObj;
- if (@$_POST["a_list"] <> "") {
- $osj2Dusers->CurrentAction = $_POST["a_list"]; // Get action
-
- // Inline Update
- if ($osj2Dusers->CurrentAction == "update" && @$_SESSION[EW_SESSION_INLINE_MODE] == "edit") {
- InlineUpdate();
- }
- }
- }
-
- // Get search criteria for advanced search
- $sSrchAdvanced = AdvancedSearchWhere();
-
- // Get basic search criteria
- $sSrchBasic = BasicSearchWhere();
-
- // Build search criteria
- if ($sSrchAdvanced <> "") {
- if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
- $sSrchWhere .= "(" . $sSrchAdvanced . ")";
- }
- if ($sSrchBasic <> "") {
- if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
- $sSrchWhere .= "(" . $sSrchBasic . ")";
- }
-
- // Save search criteria
- if ($sSrchWhere <> "") {
- if ($sSrchBasic == "") ResetBasicSearchParms();
- if ($sSrchAdvanced == "") ResetAdvancedSearchParms();
- $osj2Dusers->setSearchWhere($sSrchWhere); // Save to Session
- $nStartRec = 1; // Reset start record counter
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } else {
- RestoreSearchParms();
- }
-
- // Build filter
- $sFilter = "";
- if (!$Security->CanList()) {
- $sFilter = "(0=1)"; // Filter all records
- }
- if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
- $sFilter = $osj2Dusers->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
- }
- if ($sDbDetailFilter <> "") {
- if ($sFilter <> "") $sFilter .= " AND ";
- $sFilter .= "(" . $sDbDetailFilter . ")";
- }
- if ($sSrchWhere <> "") {
- if ($sFilter <> "") $sFilter .= " AND ";
- $sFilter .= "(" . $sSrchWhere . ")";
- }
-
- // Set up filter in Session
- $osj2Dusers->setSessionWhere($sFilter);
- $osj2Dusers->CurrentFilter = "";
-
- // Set Up Sorting Order
- SetUpSortOrder();
-
- // Export data only
- if ($osj2Dusers->Export == "xml" || $osj2Dusers->Export == "csv") {
- ExportData();
- Page_Terminate(); // Terminate response
- }
-
- // Set Return Url
- $osj2Dusers->setReturnUrl("osj-osj2duserslist.php");
- ?>
- <?php include "osj-header.php" ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <script type="text/javascript">
- <!--
- var EW_PAGE_ID = "list"; // Page id
- var EW_SHOW_HIGHLIGHT = "Show highlight";
- var EW_HIDE_HIGHLIGHT = "Hide highlight";
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- function ew_ValidateForm(fobj) {
- if (fobj.a_confirm && fobj.a_confirm.value == "F")
- return true;
- var i, elm, aelm, infix;
- var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
- for (i=0; i<rowcnt; i++) {
- infix = (fobj.key_count) ? String(i+1) : "";
- elm = fobj.elements["x" + infix + "_user_id"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - User ID"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_email"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Email"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_email"];
- if (elm && !ew_CheckEmail(elm.value)) {
- if (!ew_OnError(elm, "Users must provide a valid email address."))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_password"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Password"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_level"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - User Level"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_user_status"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - User Status"))
- return false;
- }
- }
- return true;
- }
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
- var firstrowoffset = 1; // First data row start at
- var lastrowoffset = 0; // Last data row end at
- var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
- var rowclass = 'ewTableRow'; // Row class
- var rowaltclass = 'ewTableAltRow'; // Row alternate class
- var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
- var rowselectedclass = 'ewTableSelectRow'; // Row selected class
- var roweditclass = 'ewTableEditRow'; // Row edit class
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
- var ew_DHTMLEditors = [];
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- // js for Popup Calendar
- //-->
-
- </script>
- <script type="text/javascript">
- <!--
-
- function ew_SelectKey(elem) {
- var f = elem.form;
- if (!f.elements["key_m[]"]) return;
- if (f.elements["key_m[]"][0]) {
- for (var i=0; i<f.elements["key_m[]"].length; i++)
- f.elements["key_m[]"][i].checked = elem.checked;
- } else {
- f.elements["key_m[]"].checked = elem.checked;
- }
- ew_ClickAll(elem);
- }
-
- function ew_Selected(f) {
- if (!f.elements["key_m[]"]) return false;
- if (f.elements["key_m[]"][0]) {
- for (var i=0; i<f.elements["key_m[]"].length; i++)
- if (f.elements["key_m[]"][i].checked) return true;
- } else {
- return f.elements["key_m[]"].checked;
- }
- return false;
- }
-
- //-->
- </script>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your client script here, no need to add script tags.
- // To include another .js script, use:
- // ew_ClientScriptInclude("my_javascript.js");
- //-->
-
- </script>
- <?php } ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <?php } ?>
- <?php
-
- // Load recordset
- $bExportAll = (defined("EW_EXPORT_ALL") && $osj2Dusers->Export <> "");
- $bSelectLimit = ($osj2Dusers->Export == "" && $osj2Dusers->SelectLimit);
- if (!$bSelectLimit) $rs = LoadRecordset();
- $nTotalRecs = ($bSelectLimit) ? $osj2Dusers->SelectRecordCount() : $rs->RecordCount();
- $nStartRec = 1;
- if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
- if (!$bExportAll) SetUpStartRec(); // Set up start record position
- if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
- ?>
- <p><span class="phpmaker" style="white-space: nowrap;">TABLE: Users
- <?php if ($osj2Dusers->Export == "") { ?>
- <a href="osj-osj2duserslist.php?export=html">Printer Friendly</a>
- <a href="osj-osj2duserslist.php?export=xml">Export to XML</a>
- <a href="osj-osj2duserslist.php?export=csv">Export to CSV</a>
- <?php } ?>
- </span></p>
- <?php if ($osj2Dusers->Export == "") { ?>
- <?php if ($Security->CanSearch()) { ?>
- <form name="fosj2Duserslistsrch" id="fosj2Duserslistsrch" action="osj-osj2duserslist.php" >
- <table class="ewBasicSearch">
- <tr>
- <td><span class="phpmaker">
- <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()) ?>">
- <input type="Submit" name="Submit" id="Submit" value="Search (*)">
- <a href="osj-osj2duserslist.php?cmd=reset">Show all</a>
- <a href="osj-osj2duserssrch.php">Advanced Search</a>
- <?php if ($sSrchWhere <> "" && $nTotalRecs > 0) { ?>
- <a href="javascript:void(0);" onclick="ew_ToggleHighlight(this);">Hide highlight</a>
- <?php } ?>
- </span></td>
- </tr>
- <tr>
- <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 <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 <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>
- </tr>
- </table>
- </form>
- <?php } ?>
- <?php } ?>
- <?php
- if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
- ?>
- <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
- <?php
- $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
- }
- ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <form action="osj-osj2duserslist.php" name="ewpagerform" id="ewpagerform">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td nowrap>
- <span class="phpmaker">
- <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
- <?php if ($Pager->RecordCount > 0) { ?>
- <?php if ($Pager->FirstButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>
- <?php } ?>
- <?php if ($Pager->PrevButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>
- <?php } ?>
- <?php foreach ($Pager->Items as $PagerItem) { ?>
- <?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 } ?>
- <?php } ?>
- <?php if ($Pager->NextButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>
- <?php } ?>
- <?php if ($Pager->LastButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>
- <?php } ?>
- <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
- Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
- <?php } else { ?>
- <?php if ($Security->CanList()) { ?>
- <?php if ($sSrchWhere == "0=101") { ?>
- Please enter search criteria
- <?php } else { ?>
- No records found
- <?php } ?>
- <?php } else { ?>
- You do not have the right permission to view the page
- <?php } ?>
- <?php } ?>
- </span>
- </td>
- <?php if ($nTotalRecs > 0) { ?>
- <td nowrap> </td>
- <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page
- <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
- <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
- <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
- <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
- </select>
- </span></td>
- <?php } ?>
- </tr>
- </table>
- </form>
- <?php } ?>
- <form name="fosj2Duserslist" id="fosj2Duserslist" action="osj-osj2duserslist.php" method="post">
- <?php if ($osj2Dusers->Export == "") { ?>
- <table>
- <tr><td><span class="phpmaker">
- <?php if ($Security->CanAdd()) { ?>
- <a href="osj-osj2dusersadd.php">Add</a>
- <?php } ?>
- <?php if ($nTotalRecs > 0) { ?>
- <?php if ($Security->CanDelete()) { ?>
- <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>
- <?php } ?>
- <?php } ?>
- </span></td></tr>
- </table>
- <?php } ?>
- <?php if ($nTotalRecs > 0) { ?>
- <table id="ewlistmain" class="ewTable">
- <?php
- $OptionCnt = 0;
- if ($Security->CanView()) {
- $OptionCnt++; // view
- }
- if ($Security->CanEdit()) {
- $OptionCnt++; // edit
- }
- if ($Security->CanDelete()) {
- $OptionCnt++; // multi select
- }
- ?>
- <!-- Table header -->
- <tr class="ewTableHeader">
- <?php if ($osj2Dusers->Export == "") { ?>
- <?php if ($Security->CanView()) { ?>
- <td nowrap> </td>
- <?php } ?>
- <?php if ($Security->CanEdit()) { ?>
- <td nowrap> </td>
- <?php } ?>
- <?php if ($Security->CanDelete()) { ?>
- <td nowrap><input type="checkbox" class="phpmaker" onClick="ew_SelectKey(this);"></td>
- <?php } ?>
- <?php } ?>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- User ID
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- Creation Date
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- Edit Date
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- Email
- <?php } else { ?>
- <a href="osj-osj2duserslist.php?order=<?php echo urlencode('user_email') ?>&ordertype=<?php echo $osj2Dusers->user_email->ReverseSort() ?>">Email (*)<?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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- Password
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- User Level
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- <td valign="top">
- <?php if ($osj2Dusers->Export <> "") { ?>
- User Status
- <?php } else { ?>
- <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>
- <?php } ?>
- </td>
- </tr>
- <?php
- if (defined("EW_EXPORT_ALL") && $osj2Dusers->Export <> "") {
- $nStopRec = $nTotalRecs;
- } else {
- $nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
- }
- $nRecCount = $nStartRec - 1;
- if (!$rs->EOF) {
- $rs->MoveFirst();
- if (!$osj2Dusers->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
- }
- $RowCnt = 0;
- $nEditRowCnt = 0;
- if ($osj2Dusers->CurrentAction == "edit") $RowIndex = 1;
- while (!$rs->EOF && $nRecCount < $nStopRec) {
- $nRecCount++;
- if (intval($nRecCount) >= intval($nStartRec)) {
- $RowCnt++;
-
- // Init row class and style
- $osj2Dusers->CssClass = "ewTableRow";
- $osj2Dusers->CssStyle = "";
-
- // Init row event
- $osj2Dusers->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
-
- // Display alternate color for rows
- if ($RowCnt % 2 == 0) {
- $osj2Dusers->CssClass = "ewTableAltRow";
- }
- LoadRowValues($rs); // Load row values
- $osj2Dusers->RowType = EW_ROWTYPE_VIEW; // Render view
- if ($osj2Dusers->CurrentAction == "edit") {
- if (CheckInlineEditKey() && $nEditRowCnt == 0) { // Inline edit
- $osj2Dusers->RowType = EW_ROWTYPE_EDIT; // Render edit
- }
- }
- if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT && $osj2Dusers->EventCancelled) { // Update failed
- if ($osj2Dusers->CurrentAction == "edit") {
- RestoreFormValues(); // Restore form values
- }
- }
- if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit row
- $nEditRowCnt++;
- $osj2Dusers->CssClass = "ewTableEditRow";
- $osj2Dusers->RowClientEvents = "onmouseover='this.edit=true;ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
- }
- RenderRow();
- ?>
- <!-- Table body -->
- <tr<?php echo $osj2Dusers->DisplayAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { ?>
- <?php if ($osj2Dusers->CurrentAction == "edit") { ?>
- <td colspan="<?php echo $OptionCnt ?>" align="right"><span class="phpmaker">
- <a href="" onClick="if (ew_ValidateForm(document.fosj2Duserslist)) document.fosj2Duserslist.submit();return false;">Update</a> <a href="osj-osj2duserslist.php?a=cancel">Cancel</a>
- <input type="hidden" name="a_list" id="a_list" value="update">
- </span></td>
- <?php } ?>
- <?php } else { ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <?php if ($Security->CanView()) { ?>
- <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
- <a href="<?php echo $osj2Dusers->ViewUrl() ?>">View</a>
- <?php } ?></span></td>
- <?php } ?>
- <?php if ($Security->CanEdit()) { ?>
- <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
- <a href="<?php echo $osj2Dusers->EditUrl() ?>">Edit</a><span class="ewSeparator"> | </span><a href="<?php echo $osj2Dusers->InlineEditUrl() ?>">Inline Edit</a>
- <?php } ?></span></td>
- <?php } ?>
- <?php if ($Security->CanDelete()) { ?>
- <td nowrap><span class="phpmaker"><?php if (ShowOptionLink()) { ?>
- <input type="checkbox" name="key_m[]" id="key_m[]" value="<?php echo ew_HtmlEncode($osj2Dusers->user_id->CurrentValue) ?>" class="phpmaker" onclick='ew_ClickMultiCheckbox(this);'>
- <?php } ?></span></td>
- <?php } ?>
- <?php } ?>
- <?php } ?>
- <!-- user_id -->
- <td<?php echo $osj2Dusers->user_id->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <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) ?>">
- <?php } else { ?>
- <?php } ?>
- </td>
- <!-- user_creation_date -->
- <td<?php echo $osj2Dusers->user_creation_date->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <?php } else { ?>
- <?php } ?>
- </td>
- <!-- user_edit_date -->
- <td<?php echo $osj2Dusers->user_edit_date->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <?php } else { ?>
- <?php } ?>
- </td>
- <!-- user_email -->
- <td<?php echo $osj2Dusers->user_email->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <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() ?>>
- <?php } else { ?>
- <div<?php echo $osj2Dusers->user_email->ViewAttributes() ?>><?php echo $osj2Dusers->user_email->ViewValue ?></div>
- <?php } ?>
- </td>
- <!-- user_password -->
- <td<?php echo $osj2Dusers->user_password->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <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() ?>>
- <?php } else { ?>
- <div<?php echo $osj2Dusers->user_password->ViewAttributes() ?>><?php echo $osj2Dusers->user_password->ViewValue ?></div>
- <?php } ?>
- </td>
- <!-- user_level -->
- <td<?php echo $osj2Dusers->user_level->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <?php if (!$Security->IsAdmin() && $Security->IsLoggedIn()) { // Non system admin ?>
- <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->EditValue ?></div>
- <?php } else { ?>
- <select id="x<?php echo $RowIndex ?>_user_level" name="x<?php echo $RowIndex ?>_user_level"<?php echo $osj2Dusers->user_level->EditAttributes() ?>>
- <!--option value="">Please Select</option-->
- <?php
- if (is_array($osj2Dusers->user_level->EditValue)) {
- $arwrk = $osj2Dusers->user_level->EditValue;
- $rowswrk = count($arwrk);
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($osj2Dusers->user_level->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- <?php
- $sSqlWrk = "SELECT `user_level_id`, `user_level_name` FROM `osj-user_level`";
- $sSqlWrk .= " WHERE (" . "`user_level_name` != 'Default' AND `user_level_name`!= 'Administrator'" . ")";
- $sSqlWrk = TEAencrypt($sSqlWrk, EW_RANDOM_KEY);
- ?>
- <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">
- <?php } ?>
- <?php } else { ?>
- <div<?php echo $osj2Dusers->user_level->ViewAttributes() ?>><?php echo $osj2Dusers->user_level->ViewValue ?></div>
- <?php } ?>
- </td>
- <!-- user_status -->
- <td<?php echo $osj2Dusers->user_status->CellAttributes() ?>>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
- <select id="x<?php echo $RowIndex ?>_user_status" name="x<?php echo $RowIndex ?>_user_status"<?php echo $osj2Dusers->user_status->EditAttributes() ?>>
- <!--option value="">Please Select</option-->
- <?php
- if (is_array($osj2Dusers->user_status->EditValue)) {
- $arwrk = $osj2Dusers->user_status->EditValue;
- $rowswrk = count($arwrk);
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($osj2Dusers->user_status->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- <?php } else { ?>
- <div<?php echo $osj2Dusers->user_status->ViewAttributes() ?>><?php echo $osj2Dusers->user_status->ViewValue ?></div>
- <?php } ?>
- </td>
- </tr>
- <?php if ($osj2Dusers->RowType == EW_ROWTYPE_EDIT) { ?>
- <script language="JavaScript">
- <!--
- var f = document.fosj2Duserslist;
- ew_AjaxUpdateOpt(f.x<?php echo $RowIndex ?>_user_level, f.x<?php echo $RowIndex ?>_user_level, false);
-
- //-->
- </script>
- <?php } ?>
- <?php
- }
- $rs->MoveNext();
- }
- ?>
- </table>
- <?php if ($osj2Dusers->Export == "") { ?>
- <table>
- <tr><td><span class="phpmaker">
- <?php if ($Security->CanAdd()) { ?>
- <a href="osj-osj2dusersadd.php">Add</a>
- <?php } ?>
- <?php if ($nTotalRecs > 0) { ?>
- <?php if ($Security->CanDelete()) { ?>
- <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>
- <?php } ?>
- <?php } ?>
- </span></td></tr>
- </table>
- <?php } ?>
- <?php } ?>
- <?php if ($osj2Dusers->CurrentAction == "edit") { ?>
- <input type="hidden" name="key_count" id="key_count" value="<?php echo $RowIndex ?>">
- <?php } ?>
- </form>
- <?php
-
- // Close recordset and connection
- if ($rs) $rs->Close();
- ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <form action="osj-osj2duserslist.php" name="ewpagerform" id="ewpagerform">
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td nowrap>
- <span class="phpmaker">
- <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
- <?php if ($Pager->RecordCount > 0) { ?>
- <?php if ($Pager->FirstButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>
- <?php } ?>
- <?php if ($Pager->PrevButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>
- <?php } ?>
- <?php foreach ($Pager->Items as $PagerItem) { ?>
- <?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 } ?>
- <?php } ?>
- <?php if ($Pager->NextButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>
- <?php } ?>
- <?php if ($Pager->LastButton->Enabled) { ?>
- <a href="osj-osj2duserslist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>
- <?php } ?>
- <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
- Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
- <?php } else { ?>
- <?php if ($Security->CanList()) { ?>
- <?php if ($sSrchWhere == "0=101") { ?>
- Please enter search criteria
- <?php } else { ?>
- No records found
- <?php } ?>
- <?php } else { ?>
- You do not have the right permission to view the page
- <?php } ?>
- <?php } ?>
- </span>
- </td>
- <?php if ($nTotalRecs > 0) { ?>
- <td nowrap> </td>
- <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page
- <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
- <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
- <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
- <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
- </select>
- </span></td>
- <?php } ?>
- </tr>
- </table>
- </form>
- <?php } ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <?php } ?>
- <?php if ($osj2Dusers->Export == "") { ?>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php } ?>
- <?php include "osj-footer.php" ?>
- <?php
-
- // If control is passed here, simply terminate the page without redirect
- Page_Terminate();
-
- // -----------------------------------------------------------------
- // Subroutine Page_Terminate
- // - called when exit page
- // - clean up connection and objects
- // - if url specified, redirect to url, otherwise end response
- function Page_Terminate($url = "") {
- global $conn;
-
- // Page unload event, used in current page
- Page_Unload();
-
- // Global page unloaded event (in userfn*.php)
- Page_Unloaded();
-
- // Close Connection
- $conn->Close();
-
- // Go to url if specified
- if ($url <> "") {
- ob_end_clean();
- header("Location: $url");
- }
- exit();
- }
- ?>
- <?php
-
- // Set up number of records displayed per page
- function SetUpDisplayRecs() {
- global $nDisplayRecs, $nStartRec, $osj2Dusers;
- $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
- if ($sWrk <> "") {
- if (is_numeric($sWrk)) {
- $nDisplayRecs = intval($sWrk);
- } else {
- if (strtolower($sWrk) == "all") { // Display all records
- $nDisplayRecs = -1;
- } else {
- $nDisplayRecs = 10; // Non-numeric, load default
- }
- }
- $osj2Dusers->setRecordsPerPage($nDisplayRecs); // Save to Session
-
- // Reset start position
- $nStartRec = 1;
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } else {
- if ($osj2Dusers->getRecordsPerPage() <> "") {
- $nDisplayRecs = $osj2Dusers->getRecordsPerPage(); // Restore from Session
- } else {
- $nDisplayRecs = 10; // Load default
- }
- }
- }
-
- // Exit out of inline mode
- function ClearInlineMode() {
- global $osj2Dusers;
- $osj2Dusers->setKey("user_id", ""); // Clear inline edit key
- $osj2Dusers->CurrentAction = ""; // Clear action
- $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
- }
-
- // Switch to Inline Edit Mode
- function InlineEditMode() {
- global $Security, $osj2Dusers;
- if (!$Security->CanEdit()) Page_Terminate("osj-login.php"); // Go to login page
- $bInlineEdit = TRUE;
- if (@$_GET["user_id"] <> "") {
- $osj2Dusers->user_id->setQueryStringValue($_GET["user_id"]);
- } else {
- $bInlineEdit = FALSE;
- }
- if ($bInlineEdit) {
- if (LoadRow()) {
- $osj2Dusers->setKey("user_id", $osj2Dusers->user_id->CurrentValue); // Set up inline edit key
- $_SESSION[EW_SESSION_INLINE_MODE] = "edit"; // Enable inline edit
- }
- }
- }
-
- // Peform update to inline edit record
- function InlineUpdate() {
- global $objForm, $osj2Dusers;
- $objForm->Index = 1;
- LoadFormValues(); // Get form values
- if (CheckInlineEditKey()) { // Check key
- $osj2Dusers->SendEmail = TRUE; // Send email on update success
- $bInlineUpdate = EditRow(); // Update record
- } else {
- $bInlineUpdate = FALSE;
- }
- if ($bInlineUpdate) { // Update success
- $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Set success message
- ClearInlineMode(); // Clear inline edit mode
- } else {
- if (@$_SESSION[EW_SESSION_MESSAGE] == "") {
- $_SESSION[EW_SESSION_MESSAGE] = "Update failed"; // Set update failed message
- }
- $osj2Dusers->EventCancelled = TRUE; // Cancel event
- $osj2Dusers->CurrentAction = "edit"; // Stay in edit mode
- }
- }
-
- // Check inline edit key
- function CheckInlineEditKey() {
- global $osj2Dusers;
-
- //CheckInlineEditKey = True
- if (strval($osj2Dusers->getKey("user_id")) <> strval($osj2Dusers->user_id->CurrentValue)) {
- return FALSE;
- }
- return TRUE;
- }
-
- // Return Advanced Search Where based on QueryString parameters
- function AdvancedSearchWhere() {
- global $Security, $osj2Dusers;
- $sWhere = "";
- if (!$Security->CanSearch()) return "";
-
- // Field user_id
- 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"]);
-
- // Field user_creation_date
- 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"]);
-
- // Field user_edit_date
- 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"]);
-
- // Field user_email
- 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"]);
-
- // Field user_level
- 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"]);
-
- // Field user_status
- 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"]);
-
- //AdvancedSearchWhere = sWhere
- // Set up search parm
-
- if ($sWhere <> "") {
-
- // Field user_id
- SetSearchParm($osj2Dusers->user_id, @$_GET["x_user_id"], @$_GET["z_user_id"], @$_GET["v_user_id"], @$_GET["y_user_id"], @$_GET["w_user_id"]);
-
- // Field user_creation_date
- 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"]);
-
- // Field user_edit_date
- 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"]);
-
- // Field user_email
- SetSearchParm($osj2Dusers->user_email, @$_GET["x_user_email"], @$_GET["z_user_email"], @$_GET["v_user_email"], @$_GET["y_user_email"], @$_GET["w_user_email"]);
-
- // Field user_level
- SetSearchParm($osj2Dusers->user_level, @$_GET["x_user_level"], @$_GET["z_user_level"], @$_GET["v_user_level"], @$_GET["y_user_level"], @$_GET["w_user_level"]);
-
- // Field user_status
- SetSearchParm($osj2Dusers->user_status, @$_GET["x_user_status"], @$_GET["z_user_status"], @$_GET["v_user_status"], @$_GET["y_user_status"], @$_GET["w_user_status"]);
- }
- return $sWhere;
- }
-
- // Build search sql
- function BuildSearchSql(&$Where, &$Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
- $sWrk = "";
- $FldParm = substr($Fld->FldVar, 2);
- $FldVal = ew_StripSlashes($FldVal);
- if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
- $FldVal2 = ew_StripSlashes($FldVal2);
- if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
- $FldOpr = strtoupper(trim($FldOpr));
- if ($FldOpr == "") $FldOpr = "=";
- $FldOpr2 = strtoupper(trim($FldOpr2));
- if ($FldOpr2 == "") $FldOpr2 = "=";
- if ($Fld->FldDataType == EW_DATATYPE_BOOLEAN) {
- if ($FldVal <> "") $FldVal = ($FldVal == "1") ? $Fld->TrueValue : $Fld->FalseValue;
- if ($FldVal2 <> "") $FldVal2 = ($FldVal2 == "1") ? $Fld->TrueValue : $Fld->FalseValue;
- } elseif ($Fld->FldDataType == EW_DATATYPE_DATE) {
- if ($FldVal <> "") $FldVal = ew_UnFormatDateTime($FldVal, $Fld->FldDateTimeFormat);
- if ($FldVal2 <> "") $FldVal2 = ew_UnFormatDateTime($FldVal2, $Fld->FldDateTimeFormat);
- }
- if ($FldOpr == "BETWEEN") {
- $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal) && is_numeric($FldVal2)));
- if ($FldVal <> "" && $FldVal2 <> "" && $IsValidValue) {
- $sWrk = $Fld->FldExpression . " BETWEEN " . ew_QuotedValue($FldVal, $Fld->FldDataType) .
- " AND " . ew_QuotedValue($FldVal2, $Fld->FldDataType);
- }
- } elseif ($FldOpr == "IS NULL" || $FldOpr == "IS NOT NULL") {
- $sWrk = $Fld->FldExpression . " " . $FldOpr;
- } else {
- $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal)));
- if ($FldVal <> "" && $IsValidValue && ew_IsValidOpr($FldOpr, $Fld->FldDataType)) {
- $sWrk = $Fld->FldExpression . SearchString($FldOpr, $FldVal, $Fld->FldDataType);
- }
- $IsValidValue = (($Fld->FldDataType <> EW_DATATYPE_NUMBER) ||
- ($Fld->FldDataType == EW_DATATYPE_NUMBER && is_numeric($FldVal2)));
- if ($FldVal2 <> "" && $IsValidValue && ew_IsValidOpr($FldOpr2, $Fld->FldDataType)) {
- if ($sWrk <> "") {
- $sWrk .= " " . (($FldCond=="OR")?"OR":"AND") . " ";
- }
- $sWrk .= $Fld->FldExpression . SearchString($FldOpr2, $FldVal2, $Fld->FldDataType);
- }
- }
- if ($sWrk <> "") {
- if ($Where <> "") $Where .= " AND ";
- $Where .= "(" . $sWrk . ")";
- }
- }
-
- // Return search string
- function SearchString($FldOpr, $FldVal, $FldType) {
- if ($FldOpr == "LIKE" || $FldOpr == "NOT LIKE") {
- return " " . $FldOpr . " " . ew_QuotedValue("%" . $FldVal . "%", $FldType);
- } elseif ($FldOpr == "STARTS WITH") {
- return " LIKE " . ew_QuotedValue($FldVal . "%", $FldType);
- } else {
- return " " . $FldOpr . " " . ew_QuotedValue($FldVal, $FldType);
- }
- }
-
- // Set search parm
- function SetSearchParm($Fld, $FldVal, $FldOpr, $FldCond, $FldVal2, $FldOpr2) {
- global $osj2Dusers;
- $FldParm = substr($Fld->FldVar, 2);
- $FldVal = ew_StripSlashes($FldVal);
- if (is_array($FldVal)) $FldVal = implode(",", $FldVal);
- $FldVal2 = ew_StripSlashes($FldVal2);
- if (is_array($FldVal2)) $FldVal2 = implode(",", $FldVal2);
- $osj2Dusers->setAdvancedSearch("x_" . $FldParm, $FldVal);
- $osj2Dusers->setAdvancedSearch("z_" . $FldParm, $FldOpr);
- $osj2Dusers->setAdvancedSearch("v_" . $FldParm, $FldCond);
- $osj2Dusers->setAdvancedSearch("y_" . $FldParm, $FldVal2);
- $osj2Dusers->setAdvancedSearch("w_" . $FldParm, $FldOpr2);
- }
-
- // Return Basic Search sql
- function BasicSearchSQL($Keyword) {
- $sKeyword = ew_AdjustSql($Keyword);
- $sql = "";
- $sql .= "`user_email` LIKE '%" . $sKeyword . "%' OR ";
- if (substr($sql, -4) == " OR ") $sql = substr($sql, 0, strlen($sql)-4);
- return $sql;
- }
-
- // Return Basic Search Where based on search keyword and type
- function BasicSearchWhere() {
- global $Security, $osj2Dusers;
- $sSearchStr = "";
- if (!$Security->CanSearch()) return "";
- $sSearchKeyword = ew_StripSlashes(@$_GET[EW_TABLE_BASIC_SEARCH]);
- $sSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
- if ($sSearchKeyword <> "") {
- $sSearch = trim($sSearchKeyword);
- if ($sSearchType <> "") {
- while (strpos($sSearch, " ") !== FALSE)
- $sSearch = str_replace(" ", " ", $sSearch);
- $arKeyword = explode(" ", trim($sSearch));
- foreach ($arKeyword as $sKeyword) {
- if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
- $sSearchStr .= "(" . BasicSearchSQL($sKeyword) . ")";
- }
- } else {
- $sSearchStr = BasicSearchSQL($sSearch);
- }
- }
- if ($sSearchKeyword <> "") {
- $osj2Dusers->setBasicSearchKeyword($sSearchKeyword);
- $osj2Dusers->setBasicSearchType($sSearchType);
- }
- return $sSearchStr;
- }
-
- // Clear all search parameters
- function ResetSearchParms() {
-
- // Clear search where
- global $osj2Dusers;
- $sSrchWhere = "";
- $osj2Dusers->setSearchWhere($sSrchWhere);
-
- // Clear basic search parameters
- ResetBasicSearchParms();
-
- // Clear advanced search parameters
- ResetAdvancedSearchParms();
- }
-
- // Clear all basic search parameters
- function ResetBasicSearchParms() {
-
- // Clear basic search parameters
- global $osj2Dusers;
- $osj2Dusers->setBasicSearchKeyword("");
- $osj2Dusers->setBasicSearchType("");
- }
-
- // Clear all advanced search parameters
- function ResetAdvancedSearchParms() {
-
- // Clear advanced search parameters
- global $osj2Dusers;
- $osj2Dusers->setAdvancedSearch("x_user_id", "");
- $osj2Dusers->setAdvancedSearch("v_user_id", "AND");
- $osj2Dusers->setAdvancedSearch("y_user_id", "");
- $osj2Dusers->setAdvancedSearch("w_user_id", "");
- $osj2Dusers->setAdvancedSearch("x_user_creation_date", "");
- $osj2Dusers->setAdvancedSearch("y_user_creation_date", "");
- $osj2Dusers->setAdvancedSearch("x_user_edit_date", "");
- $osj2Dusers->setAdvancedSearch("y_user_edit_date", "");
- $osj2Dusers->setAdvancedSearch("x_user_email", "");
- $osj2Dusers->setAdvancedSearch("v_user_email", "AND");
- $osj2Dusers->setAdvancedSearch("y_user_email", "");
- $osj2Dusers->setAdvancedSearch("w_user_email", "");
- $osj2Dusers->setAdvancedSearch("x_user_level", "");
- $osj2Dusers->setAdvancedSearch("x_user_status", "");
- }
-
- // Restore all search parameters
- function RestoreSearchParms() {
- global $sSrchWhere, $osj2Dusers;
- $sSrchWhere = $osj2Dusers->getSearchWhere();
-
- // Restore advanced search settings
- RestoreAdvancedSearchParms();
- }
-
- // Restore all advanced search parameters
- function RestoreAdvancedSearchParms() {
-
- // Restore advanced search parms
- global $osj2Dusers;
- $osj2Dusers->user_id->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_id");
- $osj2Dusers->user_id->AdvancedSearch->SearchCondition = $osj2Dusers->getAdvancedSearch("v_user_id");
- $osj2Dusers->user_id->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_id");
- $osj2Dusers->user_id->AdvancedSearch->SearchOperator = $osj2Dusers->getAdvancedSearch("w_user_id");
- $osj2Dusers->user_creation_date->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_creation_date");
- $osj2Dusers->user_creation_date->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_creation_date");
- $osj2Dusers->user_edit_date->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_edit_date");
- $osj2Dusers->user_edit_date->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_edit_date");
- $osj2Dusers->user_email->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_email");
- $osj2Dusers->user_email->AdvancedSearch->SearchCondition = $osj2Dusers->getAdvancedSearch("v_user_email");
- $osj2Dusers->user_email->AdvancedSearch->SearchValue2 = $osj2Dusers->getAdvancedSearch("y_user_email");
- $osj2Dusers->user_email->AdvancedSearch->SearchOperator = $osj2Dusers->getAdvancedSearch("w_user_email");
- $osj2Dusers->user_level->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_level");
- $osj2Dusers->user_status->AdvancedSearch->SearchValue = $osj2Dusers->getAdvancedSearch("x_user_status");
- }
-
- // Set up Sort parameters based on Sort Links clicked
- function SetUpSortOrder() {
- global $osj2Dusers;
-
- // Check for an Order parameter
- if (@$_GET["order"] <> "") {
- $osj2Dusers->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
- $osj2Dusers->CurrentOrderType = @$_GET["ordertype"];
-
- // Field user_id
- $osj2Dusers->UpdateSort($osj2Dusers->user_id);
-
- // Field user_creation_date
- $osj2Dusers->UpdateSort($osj2Dusers->user_creation_date);
-
- // Field user_edit_date
- $osj2Dusers->UpdateSort($osj2Dusers->user_edit_date);
-
- // Field user_email
- $osj2Dusers->UpdateSort($osj2Dusers->user_email);
-
- // Field user_password
- $osj2Dusers->UpdateSort($osj2Dusers->user_password);
-
- // Field user_level
- $osj2Dusers->UpdateSort($osj2Dusers->user_level);
-
- // Field user_status
- $osj2Dusers->UpdateSort($osj2Dusers->user_status);
- $osj2Dusers->setStartRecordNumber(1); // Reset start position
- }
- $sOrderBy = $osj2Dusers->getSessionOrderBy(); // Get order by from Session
- if ($sOrderBy == "") {
- if ($osj2Dusers->SqlOrderBy() <> "") {
- $sOrderBy = $osj2Dusers->SqlOrderBy();
- $osj2Dusers->setSessionOrderBy($sOrderBy);
- }
- }
- }
-
- // Reset command based on querystring parameter cmd=
- // - RESET: reset search parameters
- // - RESETALL: reset search & master/detail parameters
- // - RESETSORT: reset sort parameters
- function ResetCmd() {
- global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
- global $osj2Dusers;
-
- // Get reset cmd
- if (@$_GET["cmd"] <> "") {
- $sCmd = $_GET["cmd"];
-
- // Reset search criteria
- if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall") {
- ResetSearchParms();
- }
-
- // Reset Sort Criteria
- if (strtolower($sCmd) == "resetsort") {
- $sOrderBy = "";
- $osj2Dusers->setSessionOrderBy($sOrderBy);
- $osj2Dusers->user_id->setSort("");
- $osj2Dusers->user_creation_date->setSort("");
- $osj2Dusers->user_edit_date->setSort("");
- $osj2Dusers->user_email->setSort("");
- $osj2Dusers->user_password->setSort("");
- $osj2Dusers->user_level->setSort("");
- $osj2Dusers->user_status->setSort("");
- }
-
- // Reset start position
- $nStartRec = 1;
- $osj2Dusers->setStartRecordNumber($nStartRec);
- }
- }
- ?>
- <?php
-
- // Set up Starting Record parameters based on Pager Navigation
- function SetUpStartRec() {
- global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Dusers;
- if ($nDisplayRecs == 0) return;
-
- // Check for a START parameter
- if (@$_GET[EW_TABLE_START_REC] <> "") {
- $nStartRec = $_GET[EW_TABLE_START_REC];
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
- $nPageNo = $_GET[EW_TABLE_PAGE_NO];
- if (is_numeric($nPageNo)) {
- $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
- if ($nStartRec <= 0) {
- $nStartRec = 1;
- } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
- $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
- }
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } else {
- $nStartRec = $osj2Dusers->getStartRecordNumber();
- }
- } else {
- $nStartRec = $osj2Dusers->getStartRecordNumber();
- }
-
- // Check if correct start record counter
- if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
- $nStartRec = 1; // Reset start record counter
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
- $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
- $osj2Dusers->setStartRecordNumber($nStartRec);
- } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
- $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
- $osj2Dusers->setStartRecordNumber($nStartRec);
- }
- }
- ?>
- <?php
-
- // Load form values
- function LoadFormValues() {
-
- // Load from form
- global $objForm, $osj2Dusers;
- $osj2Dusers->user_id->setFormValue($objForm->GetValue("x_user_id"));
- $osj2Dusers->user_creation_date->setFormValue($objForm->GetValue("x_user_creation_date"));
- $osj2Dusers->user_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_creation_date->CurrentValue, 6);
- $osj2Dusers->user_edit_date->setFormValue($objForm->GetValue("x_user_edit_date"));
- $osj2Dusers->user_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dusers->user_edit_date->CurrentValue, 6);
- $osj2Dusers->user_email->setFormValue($objForm->GetValue("x_user_email"));
- $osj2Dusers->user_password->setFormValue($objForm->GetValue("x_user_password"));
- $osj2Dusers->user_level->setFormValue($objForm->GetValue("x_user_level"));
- $osj2Dusers->user_status->setFormValue($objFor…
Large files files are truncated, but you can click here to view the full file