Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db/cats_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ CREATE TABLE `joborder` (
`is_hot` int(1) NOT NULL DEFAULT '0',
`openings` int(11) DEFAULT NULL,
`city` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`state` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`state` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`start_date` datetime DEFAULT NULL,
`date_created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`date_modified` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
Expand Down
4 changes: 2 additions & 2 deletions lib/DatabaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ public function makeQueryString($string)
*/
public function makeQueryStringOrNULL($string)
{
$string = trim($string);
$string = trim((string) $string);

if (empty($string))
if ($string === '')
{
return 'NULL';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/JobOrders.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function update($jobOrderID, $title, $companyJobID, $companyID,
$this->_db->makeQueryString($status),
$this->_db->makeQueryString($salary),
$this->_db->makeQueryString($city),
$this->_db->makeQueryString($state),
$this->_db->makeQueryStringOrNULL($state),
$this->_db->makeQueryInteger($departmentID),
$this->_db->makeQueryInteger($recruiter),
$this->_db->makeQueryInteger($owner),
Expand Down
4 changes: 2 additions & 2 deletions lib/StringUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ public static function makeInitialName($firstName, $lastName,
*/
public static function makeCityStateString($city, $state)
{
$city = trim($city);
$state = trim($state);
$city = trim((string) $city);
$state = trim((string) $state);

if (!empty($city))
{
Expand Down
4 changes: 4 additions & 0 deletions modules/install/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,10 @@ public static function get()
}
}
',
'378' => '
ALTER TABLE `joborder`
CHANGE `state` `state` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
',

);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/joborders/Add.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@
</td>
<td class="tdData">
<?php if ($this->selectedCompanyID !== false): ?>
<input type="text" tabindex="5" class="inputbox" id="state" name="state" value="<?php $this->_($this->selectedCompanyLocation['state']); ?>" style="width: 150px;" />&nbsp;*
<input type="text" tabindex="5" class="inputbox" id="state" name="state" value="<?php $this->_($this->selectedCompanyLocation['state']); ?>" style="width: 150px;" />
<?php else: ?>
<input type="text" tabindex="5" class="inputbox" id="state" name="state" style="width: 150px;" />&nbsp;*
<input type="text" tabindex="5" class="inputbox" id="state" name="state" style="width: 150px;" />
<?php endif; ?>
</td>

Expand Down
2 changes: 1 addition & 1 deletion modules/joborders/Edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<label id="stateLabel" for="state">State:</label>
</td>
<td class="tdData">
<input type="text" tabindex="5" class="inputbox" id="state" name="state" value="<?php $this->_($this->data['state']); ?>" style="width: 150px;" />&nbsp;*
<input type="text" tabindex="5" class="inputbox" id="state" name="state" value="<?php $this->_($this->data['state']); ?>" style="width: 150px;" />
</td>

<td class="tdVertical">
Expand Down
4 changes: 2 additions & 2 deletions modules/joborders/JobOrdersUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ private function onAdd()
$notes = $this->getTrimmedInput('notes', $_POST);

/* Bail out if any of the required fields are empty. */
if (empty($title) || empty($type) || empty($city) || empty($state))
if (empty($title) || empty($type) || empty($city))
{
CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.');
}
Expand Down Expand Up @@ -1163,7 +1163,7 @@ private function onEdit()
$notes = $this->getTrimmedInput('notes', $_POST);

/* Bail out if any of the required fields are empty. */
if (empty($title) || empty($type) || empty($city) || empty($state))
if (empty($title) || empty($type) || empty($city))
{
CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.');
}
Expand Down
25 changes: 0 additions & 25 deletions modules/joborders/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function checkAddForm(form)
errorMessage += checkCompany();
errorMessage += checkRecruiter();
errorMessage += checkCity();
errorMessage += checkState();
errorMessage += checkOpenings();

if (errorMessage != "")
Expand All @@ -36,7 +35,6 @@ function checkEditForm(form)
errorMessage += checkCompany();
errorMessage += checkRecruiter();
errorMessage += checkCity();
errorMessage += checkState();
errorMessage += checkOpenings();
errorMessage += checkOpeningsAvailable();
errorMessage += checkOwner();
Expand Down Expand Up @@ -135,26 +133,6 @@ function checkCity()
return errorMessage;
}

function checkState()
{
var errorMessage = "";

fieldValue = document.getElementById("state").value;
fieldLabel = document.getElementById("stateLabel");
if (fieldValue == "")
{
errorMessage = " - You must enter a state.\n";

fieldLabel.style.color = "#ff0000";
}
else
{
fieldLabel.style.color = "#000";
}

return errorMessage;
}

function checkCompany()
{
var errorMessage = "";
Expand Down Expand Up @@ -336,6 +314,3 @@ function checkFilename()

return errorMessage;
}



4 changes: 2 additions & 2 deletions src/OpenCATS/Entity/JobOrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function persist(JobOrder $jobOrder, \History $history)
$this->databaseConnection->makeQueryInteger($jobOrder->getAvailableOpenings()),
$this->databaseConnection->makeQueryString($jobOrder->getSalary()),
$this->databaseConnection->makeQueryString($jobOrder->getCity()),
$this->databaseConnection->makeQueryString($jobOrder->getState()),
$this->databaseConnection->makeQueryStringOrNULL($jobOrder->getState()),
$this->databaseConnection->makeQueryInteger($jobOrder->getDepartmentId()),
$this->databaseConnection->makeQueryStringOrNULL($jobOrder->getStartDate()),
$this->databaseConnection->makeQueryInteger($jobOrder->getEnteredBy()),
Expand All @@ -117,4 +117,4 @@ function persist(JobOrder $jobOrder, \History $history)
throw new JobOrderRepositoryException('errorPersistingJobOrder');
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ function testMakeQueryStringOrNULL()
array('te\'st', "'te\\'st'"),
array('\'; DELETE FROM test_table; SELECT \'', "'\'; DELETE FROM test_table; SELECT \''"),
array('te\'s`t', "'te\\'s`t'"),
array('0', "'0'"),
array(' ', 'NULL'),
array(' ', 'NULL'),
array(' ', 'NULL'),
array('', 'NULL')
array('', 'NULL'),
array(null, 'NULL')
);

foreach ($strings as $key => $value)
Expand Down
38 changes: 38 additions & 0 deletions src/OpenCATS/Tests/UnitTests/StringUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,44 @@
);
}

function testMakeCityStateString()
{
$this->assertSame(
'Chicago, IL',
StringUtility::makeCityStateString('Chicago', 'IL')

Check warning on line 563 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L563

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'Chicago',
StringUtility::makeCityStateString('Chicago', '')

Check warning on line 568 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L568

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'IL',
StringUtility::makeCityStateString('', 'IL')

Check warning on line 573 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L573

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'',
StringUtility::makeCityStateString('', '')

Check warning on line 578 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L578

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'Chicago',
StringUtility::makeCityStateString('Chicago', null)

Check warning on line 583 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L583

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'IL',
StringUtility::makeCityStateString(null, 'IL')

Check warning on line 588 in src/OpenCATS/Tests/UnitTests/StringUtilityTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/OpenCATS/Tests/UnitTests/StringUtilityTest.php#L588

Avoid using static access to class 'StringUtility' in method 'testMakeCityStateString'.
);

$this->assertSame(
'',
StringUtility::makeCityStateString(null, null)
);
}

/* Tests for escapeSingleQuotes(). */
function testEscapeSingleQuotes()
{
Expand Down
1 change: 0 additions & 1 deletion test/features/job-orders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Feature: Job Orders
Then I should see "Form Error" in alert popup
And I should see "You must select a company" in alert popup
And I should see "You must enter a city" in alert popup
And I should see "You must enter a state" in alert popup
And I confirm the popup

@javascript
Expand Down
Loading