function buildMetaComponent($metaRelatedRecords, $canModify) { global $log; foreach ($metaRelatedRecords as $metaItem) { $name = $metaItem->getField('__pk_ID'); $label = $metaItem->getField('Label'); $instructions = $metaItem->getField('Instructions'); $order_n = $metaItem->getField('#'); $input_type = $metaItem->getField('Input_Type'); $value_required_n = $metaItem->getField('Value_Required_n'); $answer_values_pipe_ct = $metaItem->getField('Answer_Values_Pipe_ct'); $input_values_pipe_ct = $metaItem->getField('Input_Values_Pipe_ct'); $answer = $metaItem->getField('Answer'); switch (strtolower($input_type)) { case "text": processTextField($label, $order_n, $name, $value_required_n, $instructions, $answer); break; case "radio button": processRadioButton($input_values_pipe_ct, $name, $label, $order_n, $value_required_n, $answer); break; case "date calendar": processDatePicker($name, $label, $order_n, $value_required_n, $instructions, $answer); break; case "pop-up menu": processDropDown($input_values_pipe_ct, $name, $label, $order_n, $value_required_n, explodedCrString($answer)); break; case 'drop-down list': processDropDown($input_values_pipe_ct, $name, $label, $order_n, $value_required_n, explodedCrString($answer)); break; case "checkbox": processCheckBox($input_values_pipe_ct, $label, $order_n, $value_required_n, explodedCrString($answer), $name); break; case "file": $fileUrl = $metaItem->getField('Answer_Container_Data_r'); $fileName = $metaItem->getField('Upload_Filename_Original_t'); processFilePicker($label, $order_n, $value_required_n, $fileName, $name, $fileUrl, $canModify); break; case "image": $imageUrl = $metaItem->getField('Answer_Container_Data_r'); $fileName = $metaItem->getField('Upload_Filename_Original_t'); processImagePicker($label, $order_n, $value_required_n, $fileName, $name, $imageUrl, $canModify); break; default: $log->warn("This Field was not defined input type: " . $input_type . " field"); break; } } }
/** * Created by IntelliJ IDEA. * User: Bill * Date: 10/17/2014 * Time: 5:17 PM * This method processes data to display a text box field from FileMaker database data. The method * accounts for instructions for text box and display previously entered data * * $question text label for questions * $question_num text number to display to user * $name text field to display FileMaker __pk_ID as name/id fields * $required numeric/boolean 1 on blank/zero/blank off tro denote field is required * $instructions text field used as Bootstrap placeholder * $answer text previously entered data or post processing data for this field * Added display of textarea or display a single line text input box or empty text box with placeholder */ function processTextField($label, $question_num, $name, $required, $instructions, $answer) { //Setup controls for textarea so no more that 5 rows appear in the viewing area $maxRows = 5; $rows = 0; $lineCount = count(explodedCrString($answer)); $lineCount <= $maxRows ? $rows = $lineCount : ($rows = $maxRows); ?> <div class="row"> <div class="col-xs-12 col-lg-12"> <h6><strong> <?php echo $question_num . ". "; echo $label; ?> <?php if ($required) { ?> <i class="text-danger"> *(REQUIRED)</i> <?php } ?> </strong></h6> </div> </div> <div class="row"> <div class="col-xs-12 col-lg-12"> <?php if ($rows > 1) { ?> <textarea class="form-control" rows="<?php echo $rows; ?> " placeholder="<?php echo $instructions; ?> " id="<?php echo $name; ?> " name="<?php echo $name; ?> "><?php echo $answer; ?> </textarea> <?php } else { if (strlen($answer) > 0) { ?> <input type="text" class="form-control" placeholder="<?php echo $instructions; ?> " value="<?php echo $answer; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> "/> <?php } else { ?> <!-- End of if answer has value --> <input type="text" class="form-control" placeholder="<?php echo $instructions; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> "/> <?php } } ?> </div> </div> <?php }
/** * A single method to setup Session information regardless which authentication method was used. * @param $userRecord FileMaker user record handle * @param $site_prefix String site URL address */ function setSessionData($userRecord, $site_prefix) { global $log, $onWebPlugin, $companyLogoSmallPropertyName, $imageDir, $appConfigName, $imageSmallFileName, $imageSplashFileName, $companyLogoSplashPropertyName, $root; if (!session_id()) { session_start(); } $log->debug("setSessionData - Session was started now populate session Array"); $_SESSION['authenticated'] = true; $_SESSION['firstName'] = $userRecord->getField('User_FirstName_ct'); $_SESSION['lastName'] = $userRecord->getField('User_LastName_ct'); $accessLevel = $userRecord->getField('User_Privs_t'); $log->debug("User Privi Set: " . $accessLevel); $_SESSION['accessLevel'] = convertPipeToArray($accessLevel); $_SESSION['userName'] = $userRecord->getField('User_Name_ct'); $_SESSION['LAST_ACTIVITY'] = time(); $pipeInstalledPlugins = $userRecord->getField('z_SYS_LicensedPlugins_ct'); //Force the Array items to uppercase just in case the character case was mixed at entry $_SESSION['installedPlugins'] = array_map("strtoupper", convertPipeToArray($pipeInstalledPlugins)); //New values to capture from [WEB] Login view to be used when determining which users can view Spots // based on account name and we also need to capture PK for the contact ID $_SESSION['contact_pk'] = $userRecord->getField('User_Contact__pk_ID_ct'); //System preference apply if 1 or else value is null $_SESSION['system_preference'] = $userRecord->getField('z_PRO_SeparateWorkByPrograming_cn'); //Accounts associated with user in cr delaminated field //$_SESSION['user_accounts'] = array(stripControlChars($userRecord->getField('User_Contact_Programming_Type_Associations_ct'))); $_SESSION['user_accounts'] = explodedCrString($userRecord->getField('User_Contact_Programming_Type_Associations_ct')); foreach ($_SESSION['user_accounts'] as $account) { $log->debug("User: "******" has an account: " . $account); } //Now test for ON-WEB from the PLUGIN array to validate that the user has the License authority to access web validatePlugin($_SESSION['userName'], $_SESSION['installedPlugins'], $onWebPlugin); //Now the login ands plugin validation is processed now write the tdc-app-config.php and set small logo location //Only perform this operation if the tdc-app-conf.php is not present in the directory. If the file exists then //it is ass-u-me(d) that the logo name and location 'was' resolved and is available to the presentation layer //This is a run once method as once the file is written is should never run unless the file is deleted //TODO remove these comments lines after the authentication flow is resolved // if(!file_exists($root .$appConfigName)){ // writeFilesDynamically($userRecord, $imageDir, $imageSmallFileName,$companyLogoSmallPropertyName, // $imageSplashFileName,$companyLogoSplashPropertyName, $appConfigName); // } if (!empty($_SESSION['forwardingUrl'])) { $log->debug("setSessionData - User logged in and is being forwarded to: " . $_SESSION['forwardingUrl']); //added this fix to forward user to page they expected to see prior to login. Assigned session item to var //then unset session item then forward user $forwardingUrl = $_SESSION['forwardingUrl']; unset($_SESSION['forwardingUrl']); header("location:" . $forwardingUrl); exit; } else { $log->debug("setSessionData - No previous forwarding is defined so go to index page"); header("location: " . $site_prefix . "index.php"); exit; } }