Esempio n. 1
0
 /**
  * Validates adding a new position
  */
 function validateAddPosition($getvars)
 {
     //assume valid to begin with
     $valid = true;
     if (!shn_vm_not_empty($getvars['title'])) {
         $valid = false;
         add_error(SHN_ERR_VM_NO_TITLE);
     }
     if (!shn_vm_not_empty($getvars['ptype_id'])) {
         $valid = false;
         add_error(SHN_ERR_VM_NO_POSITION_TYPE);
     }
     if (!shn_vm_not_empty($getvars['payrate']) || !is_numeric($getvars['payrate']) || $getvars['payrate'] <= 0) {
         $valid = false;
         add_error(SHN_ERR_VM_NO_PAYRATE);
     }
     if (!shn_vm_not_empty($getvars['numSlots']) || !is_numeric($getvars['numSlots']) || $getvars['numSlots'] <= 0) {
         $valid = false;
         add_error(SHN_ERR_VM_NO_TARGET);
     }
     if (!shn_vm_not_empty($getvars['description'])) {
         $valid = false;
         add_error(SHN_ERR_VM_NO_DESCRIPTION);
     }
     return $valid;
 }
Esempio n. 2
0
 /**
  * Validates the fields in the search form
  *
  * @return true if the form is valid, false otherwise
  */
 function validateSearchForm($getvars)
 {
     //print_r($_REQUEST);
     $validated = true;
     //validate that at least one field is specified if we are not assigning to a project
     if (!$getvars['assigning']) {
         if (!shn_vm_not_empty($getvars['vol_iden']) && !shn_vm_not_empty($getvars['vol_name']) && !shn_vm_skill_selected($getvars) && !shn_vm_not_empty($getvars['start_date']) && !shn_vm_not_empty($getvars['end_date']) && !shn_vm_location_selected() && $getvars['unassigned'] != 'true') {
             add_error(SHN_ERR_VM_SEARCH_NO_PARAMS);
             $validated = false;
         } else {
             if (strlen($getvars['vol_iden']) <= 3 && !shn_vm_not_empty($getvars['vol_name']) && !shn_vm_skill_selected($getvars) && !shn_vm_not_empty($getvars['start_date']) && !shn_vm_not_empty($getvars['end_date']) && !shn_vm_location_selected() && $getvars['unassigned'] != 'true') {
                 add_error(SHN_ERR_VM_SEARCH_BAD_ID);
                 $validated = false;
             }
         }
     }
     if ($getvars['date_constraint'] == 'full_date' && (!shn_vm_not_empty($getvars['start_date']) || !shn_vm_not_empty($getvars['end_date']))) {
         add_error(SHN_ERR_VM_BAD_DATE_RANGE);
         $validated = false;
     } else {
         if (!shn_vm_not_empty($getvars['start_date']) && shn_vm_not_empty($getvars['end_date'])) {
             add_error(SHN_ERR_VM_NO_START_DATE);
             $validated = false;
         }
     }
     $valid_start = null;
     $valid_end = null;
     if ($getvars['start_date'] != '') {
         if (!shn_vm_valid_date($getvars['start_date'])) {
             add_error(SHN_ERR_VM_BAD_PROJECT_DATES);
             $validated = false;
             $valid_start = false;
         } else {
             $valid_start = true;
         }
     }
     if ($getvars['end_date'] != '') {
         if (!shn_vm_valid_date($getvars['end_date'])) {
             if ($valid_start !== false) {
                 add_error(SHN_ERR_VM_BAD_PROJECT_DATES);
             }
             $valid_end = false;
             $validated = false;
         } else {
             $valid_end = true;
         }
     }
     if ($valid_start && $valid_end) {
         $validated = $validated && shn_vm_compatible_dates($getvars['start_date'], $getvars['end_date'], SHN_ERR_VM_DATES_INCOMPATIBLE);
     }
     return $validated;
 }
Esempio n. 3
0
 /**
  * Tests  shn_vm_not_empty()
  */
 public function testNotEmpty()
 {
     $this->assertTrue(shn_vm_not_empty('not null'));
     $this->assertFalse(shn_vm_not_empty(''));
     $this->assertFalse(shn_vm_not_empty('     '));
 }