From: Steve Sutton Date: Wed, 17 Dec 2014 17:35:39 +0000 (-0500) Subject: Work on forms X-Git-Tag: v1.0.1~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7b3e3429331baf5a3894983b2259db447580e29f;p=WP-Plugins%2Fglm-employment.git Work on forms testing form found some bugs not saving initial application properly (fixed) test in https --- diff --git a/config/settings7.php b/config/settings7.php index 6cd86f2..34f11c9 100644 --- a/config/settings7.php +++ b/config/settings7.php @@ -179,7 +179,7 @@ $copies = [ $form = [ $topHeader, $header2, - [$name], + [$app_name], [$app_address], [$app_city, $app_state, $app_zip], [$app_social], diff --git a/controllers/admin.php b/controllers/admin.php index 119a20d..5c39663 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -70,7 +70,9 @@ class glm_employment_admin */ public function get_applications() { - $action = filter_var($_GET['action'], FILTER_SANITIZE_STRING); + $action = (isset($_GET['action'])) + ? filter_var($_GET['action'], FILTER_SANITIZE_STRING) + : null; switch ($action) { case 'view': $this->view_application(); diff --git a/controllers/front.php b/controllers/front.php index cb4a766..ff5ff84 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -118,7 +118,6 @@ class glm_employment_front // form Action $formAction = ''; -// echo '
'.print_r($formPart, true).'
'; switch ($formPart) { case 1: case 2: @@ -128,13 +127,8 @@ class glm_employment_front case 6: case 7: if ($this->formSubmitted) { -// $form = $this->load_form_settings($formPart); - $this->appId = $appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT); + $this->appId = $appId = (isset($_REQUEST['appId'])) ? filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT): null; $form = $this->form_process($formPart); -// echo '
'.print_r('appId:' . $this->appId, true).'
'; -// echo '
'.print_r('fname:' . $this->fname, true).'
'; -// echo '
'.print_r('form:' . $form, true).'
'; -// wp_die('test'); if (!$this->appId && $this->fname) { // insert new application and form data @@ -179,11 +173,11 @@ class glm_employment_front */ public function store_resume_file() { - echo '
'.print_r($form, true).'
'; +// echo '
'.print_r($form, true).'
'; if (!$appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) { return false; } - echo '
'.print_r($_FILES, true).'
'; +// echo '
'.print_r($_FILES, true).'
'; preg_match("%\.[A-Za-z]*$%", $_FILES['resume_file']['name'], $ext); $size = getImageSize($_FILES['resume_file']['tmp_name']); $resumeFile = tempnam(GLM_EMP_UPLOAD_DIR, "RESUME"); @@ -210,9 +204,15 @@ class glm_employment_front */ public function store_application_data($form) { - if ($this->appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) { - return $this->appId; - } else if ($this->appId = filter_var($_SESSION['glmJobsApplication'], FILTER_VALIDATE_INT)) { + $appId = (isset($_REQUEST['appId'])) + ? filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT) + : null; + $this->appId = (isset($_SESSION['glmJobsApplication'])) + ? filter_var($_SESSION['glmJobsApplication'], FILTER_VALIDATE_INT) + : null; + if ($appId) { + return $appId; + } else if ($this->appId) { return $this->appId; } $this->wpdb->insert( @@ -318,37 +318,38 @@ class glm_employment_front if ($jobId = filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)) { $this->job = $jobId; } - foreach ($form as $rowKey => $row) { - if ($row['type'] != 'header') { - foreach ($row as $fieldKey => $field) { - if (!isset($field['name'])) { - continue; - } -// $form[$rowKey][$fieldKey]['value'] -// = filter_var($_REQUEST[$field['name']], FILTER_SANITIZE_STRING); - $form[$rowKey][$fieldKey]['value'] - = filter_input(INPUT_POST, $field['name'], FILTER_SANITIZE_STRING); - if (in_array($field['name'], array('fname', 'lname', 'mname'))) { - $this->$field['name'] = $form[$rowKey][$fieldKey]['value']; - } - if ( $field['type'] == 'checkbox' - && isset($field['opts']) - && !empty($field['opts']) - ) { - foreach ($field['opts'] as $opKey => $option) { - if (isset($_POST[$option['name']])) { - $form[$rowKey][$fieldKey]['opts'][$opKey]['checked'] = true; - } + if (isset($row['type']) && $row['type'] == 'header') { + continue; + } + foreach ($row as $fieldKey => $field) { + if (!isset($field['name'])) { + continue; + } + $form[$rowKey][$fieldKey]['value'] + = filter_input(INPUT_POST, $field['name'], FILTER_SANITIZE_STRING); + if (in_array($field['name'], array('fname', 'lname', 'mname'))) { + $this->$field['name'] = $form[$rowKey][$fieldKey]['value']; + } + if ( $field['type'] == 'checkbox' + && isset($field['opts']) + && !empty($field['opts']) + ) { + foreach ($field['opts'] as $opKey => $option) { + if (isset($_POST[$option['name']])) { + $form[$rowKey][$fieldKey]['opts'][$opKey]['checked'] = true; + $_POST[$option['name']] = $option['value']; } } - if ( isset($field['req']) - && $field['req'] == true - && $_POST[$field['name']] == '' - ) { - $form[$rowKey][$fieldKey]['error'] = $field['label'] . ' is required!'; - ++$this->errorCount; - } + } + if ( isset($field['req']) + && $field['req'] == true + && $_POST[$field['name']] == '' + && (isset($field['type'])) + && $field['type'] != 'radio' + ) { + $form[$rowKey][$fieldKey]['error'] = $field['label'] . ' is required!'; + ++$this->errorCount; } } } diff --git a/models/list-applications.php b/models/list-applications.php index 987d7c5..0443a67 100644 --- a/models/list-applications.php +++ b/models/list-applications.php @@ -22,11 +22,14 @@ class List_Applications extends GLM_List_Table public function get_data() { $where = array(); - if ($_POST['s']) { + if (isset($_REQUEST['s'])) { $search = filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING); $where[] = "CONCAT(UPPER(fname), UPPER(lname)) like '%".strtoupper($search)."%'"; } - if ($archived = filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN)) { + $archived = (isset($_REQUEST['archived'])) + ? filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN) + : false; + if ($archived) { $where[] = "archived = true"; } else { $where[] = "archived <> true"; @@ -101,7 +104,10 @@ class List_Applications extends GLM_List_Table function column_fname($item){ //Build row actions $urlFormat = '?post_type=%s&page=%s&action=%s&application=%s&archived=%d'; - if ($archivedList = filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN)) { + $archivedList = (isset($_REQUEST['archived'])) + ? filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN) + : false; + if ($archivedList ) { $actions = array( 'unarchive' => sprintf( 'Unarchive', @@ -257,7 +263,10 @@ class List_Applications extends GLM_List_Table * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles' **************************************************************************/ function get_bulk_actions() { - if ($archivedList = filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN)) { + $archivedList = (isset($_REQUEST['archived'])) + ? filter_var($_REQUEST['archived'], FILTER_VALIDATE_BOOLEAN) + : false; + if ($archivedList) { $actions = array( 'delete' => 'Delete Permanently', 'unarchive' => 'Unarchive' diff --git a/views/admin/applicationList.php b/views/admin/applicationList.php index d318cfd..ca7a0c1 100644 --- a/views/admin/applicationList.php +++ b/views/admin/applicationList.php @@ -1,6 +1,9 @@

Applications

Search Results for "' . $search.'"'; } ?> @@ -13,7 +16,7 @@ if ($search = filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING)) {
diff --git a/views/admin/form_1.php b/views/admin/form_1.php index a9ac962..e885cbe 100644 --- a/views/admin/form_1.php +++ b/views/admin/form_1.php @@ -2,14 +2,14 @@
- +

- class="error"> - + class="error"> + @@ -17,8 +17,8 @@ - '.$field['placeholder'].'';}?> - + '.$field['placeholder'].'';}?> + @@ -30,14 +30,14 @@ - ( ( ) - +
diff --git a/views/front/formTemplate.php b/views/front/formTemplate.php index 2993c1e..f383fc9 100644 --- a/views/front/formTemplate.php +++ b/views/front/formTemplate.php @@ -14,93 +14,93 @@
-

+

- + - + - +

- +

- +

-
+
- class="error"> - + class="error"> + - - - + + + + pattern="" name="" type="text" - value="" /> + value="" /> - - + + + pattern="" name="" type="tel" - value="" /> + value="" /> - - + + + pattern="" name="" type="email" - value="" /> + value="" /> - + + value=""> - - + + + pattern="" id="" name="" type="radio" - value="" - " + /> @@ -109,23 +109,23 @@ - - + + + pattern="" id="" name="" type="checkbox" - value="" - " + /> - +