function loadClientPrograms($bShowHidden = true) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $cUF = new muser_fields(); $cperms = new mpermissions(); if ($bShowHidden) { $strHidden = ''; } else { $strHidden = ' AND NOT cp_bHidden '; } if ($this->sqlOrder == '') { $strOrder = ' cp_strProgramName, cp_lKeyID '; } else { $strOrder = $this->sqlOrder; } $sqlStr = "SELECT\n cp_lKeyID, cp_strProgramName, cp_strDescription,\n cp_strVocEnroll, cp_strVocAttendance,\n cp_lEnrollmentTableID, cp_lAttendanceTableID, cp_lActivityFieldID,\n cp_dteStart, cp_dteEnd,\n cp_bMentorMentee,\n\n cp_strE_VerificationModule, cp_strE_VModEntryPoint,\n cp_strA_VerificationModule, cp_strA_VModEntryPoint,\n\n ute.pft_bReadOnly AS bETableReadOnly,\n uta.pft_bReadOnly AS bATableReadOnly,\n\n cp_bHidden, cp_bRetired,\n cp_lOriginID, cp_lLastUpdateID,\n\n UNIX_TIMESTAMP(cp_dteOrigin) AS dteOrigin,\n UNIX_TIMESTAMP(cp_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\n FROM cprograms\n INNER JOIN uf_tables AS ute ON ute.pft_lKeyID = cp_lEnrollmentTableID\n INNER JOIN uf_tables AS uta ON uta.pft_lKeyID = cp_lAttendanceTableID\n INNER JOIN admin_users AS uc ON uc.us_lKeyID=cp_lOriginID\n INNER JOIN admin_users AS ul ON ul.us_lKeyID=cp_lLastUpdateID\n\n WHERE NOT cp_bRetired {$this->sqlWhere} {$strHidden}\n ORDER BY {$strOrder};"; $query = $this->db->query($sqlStr); $this->lNumCProgs = $numRows = $query->num_rows(); $this->cprogs = array(); if ($numRows == 0) { $this->cprogs[0] = new stdClass(); $cprog =& $this->cprogs[0]; $cprog->lKeyID = $cprog->strProgramName = $cprog->strEnrollmentLabel = $cprog->strAttendanceLabel = $cprog->strSafeEnrollLabel = $cprog->strSafeAttendLabel = $cprog->bETableReadOnly = $cprog->bATableReadOnly = $cprog->strE_VerificationModule = $cprog->strE_VModEntryPoint = $cprog->strA_VerificationModule = $cprog->strA_VModEntryPoint = $cprog->strDescription = $cprog->dteMysqlStart = $cprog->dteMysqlEnd = $cprog->dteStart = $cprog->dteEnd = $cprog->bHidden = $cprog->lEnrollmentTableID = $cprog->lAttendanceTableID = $cprog->lActivityFieldID = $cprog->strActivityFN = $cprog->bMentorMentee = $cprog->lOriginID = $cprog->lLastUpdateID = $cprog->dteOrigin = $cprog->dteLastUpdate = $cprog->ucstrFName = $cprog->ucstrLName = $cprog->ulstrFName = $cprog->ulstrLName = null; } else { $idx = 0; foreach ($query->result() as $row) { $this->cprogs[$idx] = new stdClass(); $cprog =& $this->cprogs[$idx]; $cprog->lKeyID = $lCProgID = (int) $row->cp_lKeyID; $cprog->strProgramName = $row->cp_strProgramName; $cprog->strEnrollmentLabel = $row->cp_strVocEnroll; $cprog->strAttendanceLabel = $row->cp_strVocAttendance; $cprog->strSafeEnrollLabel = htmlspecialchars($row->cp_strVocEnroll); $cprog->strSafeAttendLabel = htmlspecialchars($row->cp_strVocAttendance); $cprog->bETableReadOnly = (bool) $row->bETableReadOnly; $cprog->bATableReadOnly = (bool) $row->bATableReadOnly; $cprog->strE_VerificationModule = $row->cp_strE_VerificationModule; $cprog->strE_VModEntryPoint = $row->cp_strE_VModEntryPoint; $cprog->strA_VerificationModule = $row->cp_strA_VerificationModule; $cprog->strA_VModEntryPoint = $row->cp_strA_VModEntryPoint; $cprog->strDescription = $row->cp_strDescription; $cprog->dteMysqlStart = $row->cp_dteStart; $cprog->dteMysqlEnd = $row->cp_dteEnd; $cprog->dteStart = dteMySQLDate2Unix($row->cp_dteStart); $cprog->dteEnd = dteMySQLDate2Unix($row->cp_dteEnd); $cprog->bHidden = (bool) $row->cp_bHidden; $cprog->lEnrollmentTableID = (int) $row->cp_lEnrollmentTableID; $cprog->lAttendanceTableID = $lATableID = (int) $row->cp_lAttendanceTableID; $cprog->strEnrollmentTable = $cUF->strGenUF_TableName($cprog->lEnrollmentTableID); $cprog->strETableFNPrefix = $cUF->strGenUF_KeyFieldPrefix($cprog->lEnrollmentTableID); $cprog->strAttendanceTable = $cUF->strGenUF_TableName($cprog->lAttendanceTableID); $cprog->strATableFNPrefix = $cUF->strGenUF_KeyFieldPrefix($cprog->lAttendanceTableID); $cprog->lActivityFieldID = $lActivityFieldID = (int) $row->cp_lActivityFieldID; $cprog->strActivityFN = $this->strActivityDDLFN($lATableID, $lActivityFieldID); $cprog->bMentorMentee = (bool) $row->cp_bMentorMentee; $cprog->lOriginID = (int) $row->cp_lOriginID; $cprog->lLastUpdateID = (int) $row->cp_lLastUpdateID; $cprog->dteOrigin = (int) $row->dteOrigin; $cprog->dteLastUpdate = (int) $row->dteLastUpdate; $cprog->ucstrFName = $row->strUCFName; $cprog->ucstrLName = $row->strUCLName; $cprog->ulstrFName = $row->strULFName; $cprog->ulstrLName = $row->strULLName; // user-group permissions for this program $cprog->lNumPerms = $cperms->lGroupPerms($lCProgID, CENUM_CONTEXT_CPROGRAM, $cprog->perms); ++$idx; } } }
public function loadUserDirectoryPage($strWhereExtra, $lStartRec, $lRecsPerPage) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $cperm = new mpermissions(); $this->directory = array(); $sqlStr = "SELECT\n us_lKeyID, us_strUserName, us_strFirstName, us_strLastName,\n us_bInactive, us_bAdmin, us_bVolAccount, us_bDebugger,\n us_strEmail, us_strPhone\n FROM admin_users\n WHERE 1\n {$strWhereExtra}\n ORDER BY us_strLastName, us_strFirstName, us_lKeyID\n LIMIT {$lStartRec}, {$lRecsPerPage};"; $query = $this->db->query($sqlStr); $this->lNumDirRows = $numRows = $query->num_rows(); if ($numRows == 0) { // nobodyHome($strDirLetter); } else { $idx = 0; foreach ($query->result() as $row) { $this->directory[$idx] = new stdClass(); $uDir =& $this->directory[$idx]; $uDir->lUserID = $lUserID = $row->us_lKeyID; $uDir->bAdmin = (bool) $row->us_bAdmin; $uDir->bVolAccount = (bool) $row->us_bVolAccount; $uDir->us_bDebugger = (bool) $row->us_bDebugger; $uDir->dteLastLogin = $this->dteMostRecentLogin($lUserID); $uDir->us_strLastName = $row->us_strLastName; $uDir->us_strFirstName = $row->us_strFirstName; $uDir->us_strUserName = $row->us_strUserName; $uDir->us_strPhone = $row->us_strPhone; $uDir->us_strEmail = $row->us_strEmail; $uDir->bInactive = $row->us_bInactive; $cperm->loadUserGroups($lUserID, $uDir->userGroups, $uDir->lGroupIDs); ++$idx; } } }
function bVerifyUserAccessToReport($report, &$lNumFails, &$failTables) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- global $glUserID, $gbAdmin; $lNumFails = 0; $failTables = array(); if ($gbAdmin) { return true; } $lReportID = $report->lKeyID; // load search terms $this->loadSearchTermViaReportID($lReportID); // load sort terms $this->loadSortFieldsViaReportID($lReportID, $lNumSortTerms, $sortTerms); $this->uf = new muser_fields(); // tables needed for the report crptTables\tablesUsed($report, $this->terms, $sortTerms, $tableIDs); if (count($tableIDs) == 0) { return true; } $cperm = new mpermissions(); $cperm->loadUserAcctInfo($glUserID, $acctAccess); $cUF = new muser_fields(); $cUF->lTableID = array(); foreach ($tableIDs as $TID) { $cUF->lTableID[] = $TID; } $cUF->loadTableViaTableID(false); foreach ($cUF->userTables as $utable) { if (!$cperm->bDoesUserHaveAccess($acctAccess, $utable->lNumConsolidated, $utable->cperms)) { $failTables[$lNumFails] = '[' . $utable->enumTType . '] ' . $utable->strUserTableName; ++$lNumFails; } } return $lNumFails == 0; }
function loadPPTestsGeneric(&$lNumPPTests, &$ppTests, $bShowHidden = true) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $cperms = new mpermissions(); $ppTests = array(); if ($bShowHidden) { $strHidden = ''; } else { $strHidden = ' AND NOT cpp_bHidden '; } if ($this->sqlOrder == '') { $strOrder = ' cpp_strTestName, cpp_lKeyID '; } else { $strOrder = $this->sqlOrder; } $sqlStr = "SELECT\n cpp_lKeyID, cpp_strTestName, cpp_strDescription, cpp_bPublished,\n cpp_lTestCat, lgen_strListItem,\n cpp_bHidden, cpp_bRetired,\n cpp_lOriginID, cpp_lLastUpdateID,\n\n UNIX_TIMESTAMP(cpp_dteOrigin) AS dteOrigin,\n UNIX_TIMESTAMP(cpp_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\n FROM cpp_tests\n INNER JOIN admin_users AS uc ON uc.us_lKeyID = cpp_lOriginID\n INNER JOIN admin_users AS ul ON ul.us_lKeyID = cpp_lLastUpdateID\n LEFT JOIN lists_generic ON cpp_lTestCat = lgen_lKeyID\n\n WHERE NOT cpp_bRetired {$this->sqlWhere} {$strHidden}\n ORDER BY {$strOrder};"; $query = $this->db->query($sqlStr); $lNumPPTests = $numRows = $query->num_rows(); // $this->ppTests = array(); if ($numRows == 0) { $ppTests[0] = new stdClass(); $pptest =& $ppTests[0]; $pptest->lKeyID = $pptest->strTestName = $pptest->strDescription = $pptest->lTestCatID = $pptest->strPPTestCat = $pptest->bPublished = $pptest->bHidden = $pptest->bRetired = $pptest->lOriginID = $pptest->lLastUpdateID = $pptest->dteOrigin = $pptest->dteLastUpdate = $pptest->ucstrFName = $pptest->ucstrLName = $pptest->ulstrFName = $pptest->ulstrLName = $pptest->lNumPerms = null; } else { $idx = 0; foreach ($query->result() as $row) { $ppTests[$idx] = new stdClass(); $pptest =& $ppTests[$idx]; $pptest->lKeyID = $lPPTestID = (int) $row->cpp_lKeyID; $pptest->strTestName = $row->cpp_strTestName; $pptest->strDescription = $row->cpp_strDescription; $pptest->lTestCatID = $row->cpp_lTestCat; $pptest->strPPTestCat = $row->lgen_strListItem . ''; $pptest->bPublished = (bool) $row->cpp_bPublished; $pptest->bHidden = (bool) $row->cpp_bHidden; $pptest->bRetired = (bool) $row->cpp_bRetired; $pptest->lOriginID = (int) $row->cpp_lOriginID; $pptest->lLastUpdateID = (int) $row->cpp_lLastUpdateID; $pptest->dteOrigin = $row->dteOrigin; $pptest->dteLastUpdate = $row->dteLastUpdate; $pptest->ucstrFName = $row->strUCFName; $pptest->ucstrLName = $row->strUCLName; $pptest->ulstrFName = $row->strULFName; $pptest->ulstrLName = $row->strULLName; // user-group permissions for this program $pptest->lNumPerms = $cperms->lGroupPerms($lPPTestID, CENUM_CONTEXT_CPREPOST, $pptest->perms); $pptest->lNumQuest = $this->lNumQuestsViaPPTID($lPPTestID); ++$idx; } } }
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 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); } } } }
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; } } }