Skip to content

Commit 398c997

Browse files
committed
INTERIM: hc setting update
1 parent 9098616 commit 398c997

File tree

4 files changed

+41
-70
lines changed

4 files changed

+41
-70
lines changed

code/web/Drivers/AbstractIlsDriver.php

+4
Original file line numberDiff line numberDiff line change
@@ -922,4 +922,8 @@ public function loadLibraries() : array {
922922
public function hasIlsConsentSupport(): bool {
923923
return false;
924924
}
925+
926+
public function hasAdditionalFields(): bool {
927+
return false;
928+
}
925929
}

code/web/Drivers/Koha.php

+26-7
Original file line numberDiff line numberDiff line change
@@ -3080,31 +3080,46 @@ public function getAdditionalFieldValuesByTable(string $tableName) {
30803080
return $values;
30813081
}
30823082

3083-
public function getAdditionalFieldsNamesByTable(string $tableName, string $category = null): array {
3083+
public function getAdditionalFieldNames(string|null $tableName, string|null $category): array {
30843084
$fieldNamesList = [];
3085-
foreach($this->getAdditionalFieldsByTable($tableName, $category) as $fields) {
3085+
foreach($this->getAdditionalFields($tableName, $category) as $fields) {
30863086
$fieldNamesList[] = $fields['name'];
30873087
}
30883088
return $fieldNamesList;
30893089
}
30903090

3091-
private function getAdditionalFieldsByTable(string $tableName, string $category = null): array {
3091+
private function getAdditionalFields(string|null $tableName, string|null $category): array {
30923092
// TODO: refactor to send a GET request to the api/v1/extended_attribute_types endpoint instead
30933093
$this->initDatabaseConnection();
30943094
/** @noinspection SqlResolve */
3095-
$query = "SELECT * FROM additional_fields WHERE tablename = '" . mysqli_escape_string($this->dbConnection, $tableName) . "'";
3095+
$query = "SELECT * FROM additional_fields";
3096+
3097+
if ($tableName) {
3098+
$query .= " WHERE tablename =?";
3099+
}
3100+
30963101
if ($category) {
3097-
$query .= " AND authorised_value_category='" . mysqli_escape_string($this->dbConnection, $category) . "'";
3102+
$query .= " AND authorised_value_category=?";
3103+
}
3104+
3105+
$stmt = $this->dbConnection->prepare($query);
3106+
3107+
if ($tableName && $category) {
3108+
$stmt->bind_param("ss", $tableName, $category);
3109+
} else if ($tableName) {
3110+
$stmt->bind_param("s", $tableName);
30983111
}
30993112

3100-
$additionalFieldsResponse = mysqli_query($this->dbConnection, $query);
3113+
$stmt->execute();
3114+
$additionalFieldsResponse = $stmt->get_result();
31013115
$additionalFields = [];
3116+
31023117
if ($additionalFieldsResponse->num_rows > 0) {
31033118
while ($allAdditionalFieldsRow = $additionalFieldsResponse->fetch_assoc()) {
31043119
$additionalFields[] = $allAdditionalFieldsRow;
31053120
}
31063121
}
3107-
$additionalFieldsResponse->close();
3122+
$stmt->close();
31083123
return $additionalFields;
31093124
}
31103125

@@ -8781,4 +8796,8 @@ private function getConsentTypes(): array {
87818796
public function hasIlsConsentSupport(): bool {
87828797
return true;
87838798
}
8799+
8800+
public function hasAdditionalFields(): bool {
8801+
return true;
8802+
}
87848803
}

code/web/sys/ECommerce/HeyCentricSetting.php

-29
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,6 @@ static function getObjectStructure($context = ''): array {
7979
'description' => 'The HeyCentric Private Key for your site',
8080
'maxLength' => 50,
8181
],
82-
'client' => [
83-
'property' => 'client',
84-
'type' => 'text',
85-
'label' => 'Client',
86-
'description' => '',
87-
],
88-
'till' => [
89-
'property' => 'till',
90-
'type' => 'text',
91-
'label' => 'Till',
92-
'description' => '',
93-
'maxLength' => 10,
94-
],
95-
'area' => [
96-
'property' => 'area',
97-
'type' => 'text',
98-
'label' => 'Area',
99-
'description' => '',
100-
'maxLength' => 50,
101-
],
102-
'rurl' => [
103-
'property' => 'rurl',
104-
'type' => 'hidden',
105-
'hideInLists' => true,
106-
'label' => 'Return URL',
107-
'description' => 'the URL to return the patron to once the payment has been processed',
108-
'maxLength' => 50,
109-
'default' => ROOT_DIR . '/MyAccount/AJAX?method=completeHeyCentricOrder'
110-
],
11182
'urlParameters' => [
11283
'property' => 'urlParameters',
11384
'type' => 'section',

code/web/sys/ECommerce/HeyCentricUrlParameterSettings.php

+11-34
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ static function getObjectStructure($context = ''): array {
1717
$accountProfile = $library->getAccountProfile();
1818
$catalogDriverName = trim($accountProfile->driver);
1919
$catalogDriver = CatalogFactory::getCatalogConnectionInstance($catalogDriverName, $accountProfile);
20-
$additionaFields = $catalogDriver->getAdditionalFieldsNamesByTable('account_debit_types');
21-
array_unshift($additionaFields, '');
20+
$additionalFields = $catalogDriver->hasAdditionalFields() ? $catalogDriver->getAdditionalFieldNames(null, null) : null;
21+
array_unshift($additionalFields, null);
2222

2323
$structure = [
2424
'value' => [
2525
'property' => 'value',
2626
'type' => 'text',
2727
'label' => 'Parameter value',
28-
'description' => 'If the parameter value is know and can be tied to a setting, please enter it here.',
28+
'description' => 'If the parameter value is known and can be tied to a setting, please enter it here.',
2929
'hideInLists' => false,
3030
'default' => false,
3131
],
@@ -45,44 +45,21 @@ static function getObjectStructure($context = ''): array {
4545
'hideInLists' => false,
4646
'default' => false,
4747
],
48-
// Should be drop down?
49-
'dbTableName' => [
50-
'property' => 'dbTableName',
51-
'type' => 'text',
52-
'label' => 'Name of the matching ILS database table',
53-
'description' => 'The name of the ILS database table where the parameter value is stored',
54-
'hideInLists' => false,
55-
'default' => null,
56-
],
57-
// Should be drop down?
58-
'dbTableFieldName' => [
59-
'property' => 'dbTableFieldName',
60-
'type' => 'text',
61-
'label' => 'Name of the matching ILS database field',
62-
'description' => 'The name of the ILS database field where the parameter value is stored',
63-
'hideInLists' => false,
64-
'default' => null,
65-
],
66-
'isKohaAdditionalField' => [
67-
'property' => 'valueIsKohaAdditionalField',
68-
'type' => 'checkbox',
69-
'label' => 'Is Koha Additional Field',
70-
'description' => 'Whether this ILS database field in a Koha additional field',
71-
'hideInLists' => false,
72-
'default' => false,
73-
],
74-
// TODO: toggle based on isKohaAdditionalField value
75-
'valueIsFromKohaAdditionalField' => [
76-
'property' => 'valueIsFromKohaAdditionalField',
48+
'kohaAdditionalFieldName' => [
49+
'property' => 'kohaAdditionalFieldName',
7750
'type' => 'enum',
7851
'label' => 'Name of the matching Koha additional field if any',
79-
'description' => 'The name of the additional field in Koha where the parameter value is stored',
80-
'values' => $additionaFields,
52+
'description' => 'If the value to be used for this parameter is stored in a Koha additional field, select its name here. Otherwise, please leave this blank.',
53+
'values' => $additionalFields,
8154
'hideInLists' => false,
8255
'default' => null,
8356
],
8457
];
8558

59+
if (!$additionalFields) {
60+
unset($structure['kohaAdditionalFieldName']);
61+
}
62+
8663
return $structure;
8764
}
8865
}

0 commit comments

Comments
 (0)