function loadUFSchema($bIncludePerms = false, $strOrderBy = '') { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- global $glUserID; if (!isset($this->schema)) { $this->schema = array(); } if ($bIncludePerms) { $perms = new mpermissions(); $perms->loadUserAcctInfo($glUserID, $acctAccess); } if ($strOrderBy == '') { $strOrderBy = 'pft_strUserTableName, pft_lKeyID'; } $sqlStr = 'SELECT pft_lKeyID, pft_strUserTableName, pft_strDataTableName, pft_bHidden, pft_strDescription, pft_bCollapsibleHeadings, pft_bCollapseDefaultHide, pft_enumAttachType, pft_bMultiEntry, pft_lPermissions, pft_bAlertIfNoEntry, pft_strAlertMsg, pft_bReadOnly, pft_strVerificationModule, pft_strVModEntryPoint FROM uf_tables WHERE NOT pft_bRetired ' . $this->sqlWhereExtra . ' ORDER BY ' . $strOrderBy . ';'; $query = $this->db->query($sqlStr); $this->lNumTables = $lNumTables = $query->num_rows(); if ($lNumTables > 0) { foreach ($query->result() as $row) { $lTableID = (int) $row->pft_lKeyID; $this->schema[$lTableID] = new stdClass(); $utable =& $this->schema[$lTableID]; $utable->lTableID = $lTableID; $utable->strUserTableName = $row->pft_strUserTableName; $utable->strDataTableName = $row->pft_strDataTableName; $utable->enumAttachType = $row->pft_enumAttachType; $utable->strDescription = $row->pft_strDescription; $utable->bHidden = (bool) $row->pft_bHidden; $utable->bMultiEntry = (bool) $row->pft_bMultiEntry; $utable->bReadOnly = (bool) $row->pft_bReadOnly; $utable->bCollapsibleHeadings = (bool) $row->pft_bCollapsibleHeadings; $utable->bCollapseDefaultHide = (bool) $row->pft_bCollapseDefaultHide; $utable->strVerificationModule = $row->pft_strVerificationModule; $utable->strVModEntryPoint = $row->pft_strVModEntryPoint; $utable->bAlertIfNoEntry = (bool) $row->pft_bAlertIfNoEntry; $utable->strAlertMsg = $row->pft_strAlertMsg; $utable->lPermissions = $row->pft_lPermissions; $utable->strFieldPrefix = 'uf' . str_pad($lTableID, 6, '0', STR_PAD_LEFT); $utable->strDataTableKeyID = $utable->strFieldPrefix . '_lKeyID'; $utable->strDataTableFID = $utable->strFieldPrefix . '_lForeignKey'; if ($this->bLoadFields) { $this->loadUTableFields($lTableID, $utable->lNumFields, $utable->fields); } if ($bIncludePerms) { $perms->tablePerms($lTableID, $utable->lNumPerms, $utable->perms); $perms->consolidateTablePerms($utable->lNumPerms, $utable->perms, $utable->lNumConsolidated, $utable->cperms); $utable->bAllowAccess = $perms->bDoesUserHaveAccess($acctAccess, $utable->lNumConsolidated, $utable->cperms); } } } }
public function loadTableInfoGeneric($bViaTType, $bViaTID, $bExcludeHidden = true) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $cperms = new mpermissions(); if ($bViaTType) { $strWhere = ' AND (NOT pft_bRetired) AND (pft_enumAttachType=' . strPrepStr($this->enumTType) . ') '; } elseif ($bViaTID) { if (is_array($this->lTableID)) { $strWhere = ' AND pft_lKeyID IN (' . implode(',', $this->lTableID) . ') '; } else { $strWhere = " AND pft_lKeyID={$this->lTableID} "; } } else { screamForHelp('Invalid processing type<br>error on line ' . __LINE__ . ',<br>file ' . __FILE__ . ',<br>function ' . __FUNCTION__); } if ($bExcludeHidden) { $strWhere .= ' AND (NOT pft_bHidden) '; } $sqlStr = "SELECT\n pft_lKeyID, pft_strUserTableName, pft_strDescription,\n pft_bMultiEntry, pft_bReadOnly, pft_bHidden,\n pft_bCollapsibleHeadings, pft_bCollapseDefaultHide,\n pft_strDataTableName, pft_enumAttachType,\n pft_bAlertIfNoEntry, pft_strAlertMsg,\n pft_strVerificationModule,\n pft_strVModEntryPoint\n FROM uf_tables\n WHERE 1 {$strWhere} {$this->sqlWhereTableExtra}\n ORDER BY pft_strUserTableName, pft_lKeyID;"; $query = $this->db->query($sqlStr); $this->lNumTables = $numRows = $query->num_rows(); $this->userTables = array(); if ($numRows == 0) { $this->userTables[0] = new stdClass(); $uTable =& $this->userTables[0]; $uTable->lKeyID = $uTable->strUserTableName = $uTable->strDescription = $uTable->strDataTableName = $uTable->enumTType = $uTable->bMultiEntry = $uTable->bReadOnly = $uTable->bHidden = $uTable->bCollapsibleHeadings = $uTable->bCollapseDefaultHide = $uTable->bMultiEntry = $uTable->bAlertIfNoEntry = $uTable->strAlertMsg = $uTable->strVerificationModule = $uTable->strVModEntryPoint = $uTable->strFieldPrefix = null; } else { $idx = 0; foreach ($query->result() as $row) { $lTableID = (int) $row->pft_lKeyID; $this->userTables[$idx] = new stdClass(); $uTable =& $this->userTables[$idx]; $uTable->lKeyID = $lTableID; $uTable->strUserTableName = $row->pft_strUserTableName; $uTable->strDescription = $row->pft_strDescription; $uTable->strDataTableName = $row->pft_strDataTableName; $uTable->enumTType = $row->pft_enumAttachType; $uTable->bMultiEntry = (bool) $row->pft_bMultiEntry; $uTable->bReadOnly = (bool) $row->pft_bReadOnly; $uTable->bHidden = (bool) $row->pft_bHidden; $uTable->bCollapsibleHeadings = $row->pft_bCollapsibleHeadings; $uTable->bCollapseDefaultHide = $row->pft_bCollapseDefaultHide; $uTable->strFieldPrefix = $this->strGenUF_KeyFieldPrefix($lTableID); $uTable->strVerificationModule = $row->pft_strVerificationModule; $uTable->strVModEntryPoint = $row->pft_strVModEntryPoint; // client program tables - a special class of client personalized tables; // these fields are set in admin/uf_multirecord: addEditMultiRecord() $uTable->bCProg = false; $uTable->bEnrollment = false; // for single-entry tables: raise alert if not entered? $uTable->bAlertIfNoEntry = (bool) $row->pft_bAlertIfNoEntry; $uTable->strAlertMsg = $row->pft_strAlertMsg; // table permissions $cperms->tablePerms($lTableID, $uTable->lNumPerms, $uTable->perms); $cperms->consolidateTablePerms($uTable->lNumPerms, $uTable->perms, $uTable->lNumConsolidated, $uTable->cperms); ++$idx; } } }
function loadCustomForms() { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $this->customForms = array(); $clsUF = new muser_fields(); $cperms = new mpermissions(); if ($this->strOrder == '') { $strOrder = ' cf_strFormName, cf_lKeyID '; } else { $strOrder = $this->strOrder; } $sqlStr = "\n SELECT\n cf_lKeyID, cf_strFormName, cf_strDescription,\n cf_strIntro, cf_strSubmissionText, cf_strBannerTitle,\n cf_strContact, cf_enumContextType,\n cf_bCreateNewParent, cf_lParentGroupID,\n cf_strVerificationModule, cf_strVModEntryPoint,\n\n cf_bRetired, cf_lOriginID, cf_lLastUpdateID,\n\n UNIX_TIMESTAMP(cf_dteOrigin) AS dteOrigin,\n UNIX_TIMESTAMP(cf_dteLastUpdate) AS dteLastUpdate,\n uc.us_strFirstName AS strUCFName, uc.us_strLastName AS strUCLName,\n ul.us_strFirstName AS strULFName, ul.us_strLastName AS strULLName\n FROM custom_forms\n INNER JOIN admin_users AS uc ON uc.us_lKeyID=cf_lOriginID\n INNER JOIN admin_users AS ul ON ul.us_lKeyID=cf_lLastUpdateID\n\n WHERE NOT cf_bRetired {$this->strWhereExtra}\n ORDER BY {$strOrder};"; $query = $this->db->query($sqlStr); $this->lNumCustomForms = $numRows = $query->num_rows(); if ($numRows == 0) { $this->customForms[0] = new stdClass(); $cform =& $this->customForms[0]; $cform->lKeyID = $cform->strFormName = $cform->strDescription = $cform->strIntro = $cform->strSubmissionText = $cform->strBannerTitle = $cform->strContact = $cform->enumContextType = $cform->lParentGroupID = null; $cform->strVerificationModule = $cform->strVModEntryPoint = $cform->bRetired = $cform->lOriginID = $cform->lLastUpdateID = $cform->dteOrigin = $cform->dteLastUpdate = $cform->strUCFName = $cform->strUCLName = $cform->strULFName = $cform->strULLName = null; } else { $idx = 0; foreach ($query->result() as $row) { $this->customForms[$idx] = new stdClass(); $cform =& $this->customForms[$idx]; $cform->lKeyID = $lCFID = (int) $row->cf_lKeyID; $cform->strFormName = $row->cf_strFormName; $cform->strDescription = $row->cf_strDescription; $cform->strIntro = $row->cf_strIntro; $cform->strSubmissionText = $row->cf_strSubmissionText; $cform->strBannerTitle = $row->cf_strBannerTitle; $cform->strContact = $row->cf_strContact; $cform->enumContextType = $row->cf_enumContextType; $cform->lParentGroupID = (int) $row->cf_lParentGroupID; $cform->strVerificationModule = $row->cf_strVerificationModule; $cform->strVModEntryPoint = $row->cf_strVModEntryPoint; $cform->bRetired = (bool) $row->cf_bRetired; $cform->lOriginID = (int) $row->cf_lOriginID; $cform->lLastUpdateID = (int) $row->cf_lLastUpdateID; $cform->dteOrigin = (int) $row->dteOrigin; $cform->dteLastUpdate = (int) $row->dteLastUpdate; $cform->strUCFName = $row->strUCFName; $cform->strUCLName = $row->strUCLName; $cform->strULFName = $row->strULFName; $cform->strULLName = $row->strULLName; $cform->bAnyTablesMulti = false; // constituent tables and associated user-group permissions $cform->lNumPerms = 0; $this->loadPTablesForDisplay($lCFID, $clsUF, false); $cform->lNumTables = $lNumTables = $this->lNumTables; if ($lNumTables > 0) { $cform->utables = arrayCopy($this->utables); $cform->tableIDs = array(); foreach ($cform->utables as $utable) { $cform->tableIDs[] = $utable->lTableID; if ($utable->bMultiEntry) { $cform->bAnyTablesMulti = true; } } $cperms->tablePerms($cform->tableIDs, $cform->lNumPerms, $cform->perms); $cperms->consolidateTablePerms($cform->lNumPerms, $cform->perms, $cform->lNumConsolidated, $cform->cperms); } ++$idx; } } }