Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P#48327(Task) Make contact selectable #88

Merged
merged 27 commits into from
Mar 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2e30a45
make contact type selectable for form
kellyfa12 Jun 18, 2021
d425827
update unit test
kellyfa12 Jun 21, 2021
18760bf
update format code
kellyfa12 Jun 22, 2021
02c574f
update format code
kellyfa12 Jun 22, 2021
1157b14
update format code
kellyfa12 Jun 22, 2021
bb774ab
Merge branch 'master' of github.com:onOfficeGmbH/oo-wp-plugin into 13…
kellyfa12 Jul 23, 2021
bc29621
update fix conflict
kellyfa12 Jul 23, 2021
c7d99af
Merge branch 'master' of github.com:onOfficeGmbH/oo-wp-plugin into 13…
kellyfa12 Jul 29, 2021
7d4bd56
update unit test
kellyfa12 Jul 29, 2021
69dd045
update unit test
kellyfa12 Jul 30, 2021
f765224
update query alter table
hungnc89 Oct 27, 2021
a69808c
Merge branch 'master' of github.com:onOfficeGmbH/oo-wp-plugin into 13…
hungnc89 Oct 27, 2021
6f3d929
update query alter table
hungnc89 Oct 27, 2021
914307e
update query insert ignore
hungnc89 Oct 27, 2021
1ce37b0
update esc query
hungnc89 Oct 27, 2021
8fbf2b6
update label contact type
hungnc89 Nov 1, 2021
88bd1cd
remove debug
hungnc89 Nov 3, 2021
fc32cdd
Merge branch 'master' of github-egs:onOfficeGmbH/oo-wp-plugin into 13…
kellyfa12 Nov 17, 2021
6927d66
update test
kellyfa12 Nov 17, 2021
32369c1
fix migration and conflict
kellyfa12 Dec 8, 2021
86c90f9
Merge branch 'master' of github-egs.com:onOfficeGmbH/oo-wp-plugin int…
kellyfa12 Dec 20, 2021
272acc3
Merge branch 'master' of github-egs.com:onOfficeGmbH/oo-wp-plugin int…
kellyfa12 Jan 5, 2022
3ee3c3c
update unit test
kellyfa12 Jan 10, 2022
8d09228
Merge branch 'master' of github-egs.com:onOfficeGmbH/oo-wp-plugin int…
kellyfa12 Jan 10, 2022
403d5e2
update fix send newsletter
kellyfa12 Feb 8, 2022
daea708
fix conflict file DatabaseChange
tang-hien-egs Mar 2, 2022
66cc6ff
change const MAX_VERSION
tang-hien-egs Mar 2, 2022
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
38 changes: 21 additions & 17 deletions plugin/Installer/DatabaseChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function install()
}

if ($dbversion == 20) {
$this->addColumnContactTypePluginFormTable();
dbDelta($this->getQueryAddColumnContactTypePluginFormTable());
$dbversion = 21;
}

Expand Down Expand Up @@ -296,19 +296,22 @@ private function installDataQueryForms()
$template = $templatePathsForm;
}
}
$this->_pWPDB->insert(
$tableName,
array(
'name' => 'Default Form',
'form_type' => 'contact',
'template' => $template,
'country_active' => 1,
'zip_active' => 1,
'street_active' => 1,
'radius_active' => 1,
'geo_order' => 'street,zip,city,country,radius'
)
$data = array(
'name' => 'Default Form',
'form_type' => 'contact',
'template' => $template,
'country_active' => 1,
'zip_active' => 1,
'street_active' => 1,
'radius_active' => 1,
'geo_order' => 'street,zip,city,country,radius'
);
$name = $data['name'];
$result = $this->_pWPDB->query("SELECT name from $tableName where name = '$name'" );
jayay marked this conversation as resolved.
Show resolved Hide resolved
if (!$result) {
$this->_pWPDB->insert($tableName, $data);
}

$defaultFormId = $this->_pWPDB->insert_id;
$this->installDataQueryFormFieldConfig($defaultFormId);
}
Expand Down Expand Up @@ -689,14 +692,15 @@ private function deleteCommentFieldApplicantSearchForm()
}
}

public function addColumnContactTypePluginFormTable()
public function getQueryAddColumnContactTypePluginFormTable() :string
{
$prefix = $this->getPrefix();
$charsetCollate = $this->getCharsetCollate();
$tableName = $prefix . "oo_plugin_forms";

return $this->_pWPDB->query("ALTER TABLE $tableName
ADD COLUMN `contact_type` varchar(255) NULL DEFAULT NULL
");
return "CREATE TABLE $tableName (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unstable.
The best way to add a column to the table would be to add it to the CREATE TABLE definition in the method getCreateQueryForms.

Then change this block if ($dbversion == 20) { to

if ($dbversion == 20) {
	dbDelta($this->getCreateQueryForms());
	$dbversion = 21;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new column literally needs to be added in the method getCreateQueryForms.

`contact_type` varchar(255) NULL DEFAULT NULL
) $charsetCollate;";
}


Expand Down