Skip to content

Commit d8ec530

Browse files
Revert "PCHR-3542: Custom Group Updates"
1 parent 7eed24a commit d8ec530

File tree

31 files changed

+884
-562
lines changed

31 files changed

+884
-562
lines changed

bin/drush-install.sh

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ uk.co.compucorp.civicrm.hremails
1111
## List of extensions defining basic entity types
1212
ENTITY_EXTS=\
1313
org.civicrm.hrbank,\
14+
org.civicrm.hrdemog,\
1415
org.civicrm.hrjobcontract,\
1516
com.civicrm.hrjobroles,\
1617
org.civicrm.hrmed,\

bin/git-release.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fileName=""
55
ENTITY_EXTS=( hrbank \
66
hrcareer \
77
hrcase \
8+
hrdemog \
89
hrim \
910
hrmed \
1011
hrprofile \

doc/INSTALL.md

-28
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,4 @@ The [civihr-installer](https://github.com/compucorp/civihr-installer) script has
1616
$ civibuild create hr17
1717
```
1818

19-
Read the drush-install.sh for details.
20-
21-
## Install (Option B: Manual)
22-
23-
CiviHR includes over a dozen extensions. These can be activated piecemeal.
24-
The following extensions provide the major features and may be activated
25-
individually:
26-
27-
* org.civicrm.hrbank: Bank Details
28-
* org.civicrm.hrcareer: Career History
29-
* org.civicrm.hremerg: Emergency Contacts
30-
* org.civicrm.hrabsence: Absences
31-
* org.civicrm.hrjobcontract: Job Contracts
32-
* org.civicrm.hrmed: Medical and Disability
33-
* org.civicrm.hrqual: Qualifications
34-
* org.civicrm.hrreport: Reporting
35-
* org.civicrm.hrstaffdir: Staff Directory
36-
* org.civicrm.hrcase: Case
37-
* org.civicrm.hrcaseutils: Case Utils
38-
* org.civicrm.hrim: Instant messanger link
39-
* org.civicrm.hrrecruitment: Recruitment
40-
* org.civicrm.hrprofile: Profile
41-
42-
Finally, these two extensions build on top of the others:
43-
44-
* uk.co.compucorp.civicrm.hrsampledata: Generate random example data
45-
* org.civicrm.hrui: Trim/revise CiviCRM UI for CiviHR users
46-
4719
Please check the [civibuild documentation](https://docs.civicrm.org/dev/en/latest/tools/civibuild/) for more information on all the available params.

hrdemog/CRM/HRDemog/Upgrader.php

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?php
2+
/*
3+
+--------------------------------------------------------------------+
4+
| CiviHR version 1.4 |
5+
+--------------------------------------------------------------------+
6+
| Copyright CiviCRM LLC (c) 2004-2014 |
7+
+--------------------------------------------------------------------+
8+
| This file is a part of CiviCRM. |
9+
| |
10+
| CiviCRM is free software; you can copy, modify, and distribute it |
11+
| under the terms of the GNU Affero General Public License |
12+
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13+
| |
14+
| CiviCRM is distributed in the hope that it will be useful, but |
15+
| WITHOUT ANY WARRANTY; without even the implied warranty of |
16+
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17+
| See the GNU Affero General Public License for more details. |
18+
| |
19+
| You should have received a copy of the GNU Affero General Public |
20+
| License and the CiviCRM Licensing Exception along |
21+
| with this program; if not, contact CiviCRM LLC |
22+
| at info[AT]civicrm[DOT]org. If you have questions about the |
23+
| GNU Affero General Public License or the licensing of CiviCRM, |
24+
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+
+--------------------------------------------------------------------+
26+
*/
27+
28+
/**
29+
* Collection of upgrade steps
30+
*/
31+
class CRM_HRDemog_Upgrader extends CRM_HRDemog_Upgrader_Base {
32+
33+
// By convention, functions that look like "function upgrade_NNNN()" are
34+
// upgrade tasks. They are executed in order (like Drupal's hook_update_N).
35+
36+
/**
37+
* Example: Run an external SQL script when the module is installed
38+
*
39+
public function install() {
40+
$this->executeSqlFile('sql/myinstall.sql');
41+
}
42+
43+
/**
44+
* Example: Run an external SQL script when the module is uninstalled
45+
*
46+
public function uninstall() {
47+
$this->executeSqlFile('sql/myuninstall.sql');
48+
}
49+
50+
/**
51+
* Example: Run a simple query when a module is enabled
52+
*
53+
public function enable() {
54+
CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"');
55+
}
56+
57+
/**
58+
* Example: Run a simple query when a module is disabled
59+
*
60+
public function disable() {
61+
CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"');
62+
}
63+
64+
/**
65+
* Example: Run a couple simple queries
66+
*
67+
* @return TRUE on success
68+
* @throws Exception
69+
*
70+
public function upgrade_4200() {
71+
$this->ctx->log->info('Applying update 4200');
72+
CRM_Core_DAO::executeQuery('UPDATE foo SET bar = "whiz"');
73+
CRM_Core_DAO::executeQuery('DELETE FROM bang WHERE willy = wonka(2)');
74+
return TRUE;
75+
} // */
76+
77+
78+
/**
79+
* Example: Run an external SQL script
80+
*
81+
* @return TRUE on success
82+
* @throws Exception
83+
public function upgrade_4201() {
84+
$this->ctx->log->info('Applying update 4201');
85+
// this path is relative to the extension base dir
86+
$this->executeSqlFile('sql/upgrade_4201.sql');
87+
return TRUE;
88+
} // */
89+
90+
91+
/**
92+
* Example: Run a slow upgrade process by breaking it up into smaller chunk
93+
*
94+
* @return TRUE on success
95+
* @throws Exception
96+
public function upgrade_4202() {
97+
$this->ctx->log->info('Planning update 4202'); // PEAR Log interface
98+
99+
$this->addTask(ts('Process first step'), 'processPart1', $arg1, $arg2);
100+
$this->addTask(ts('Process second step'), 'processPart2', $arg3, $arg4);
101+
$this->addTask(ts('Process second step'), 'processPart3', $arg5);
102+
return TRUE;
103+
}
104+
public function processPart1($arg1, $arg2) { sleep(10); return TRUE; }
105+
public function processPart2($arg3, $arg4) { sleep(10); return TRUE; }
106+
public function processPart3($arg5) { sleep(10); return TRUE; }
107+
// */
108+
109+
110+
/**
111+
* Example: Run an upgrade with a query that touches many (potentially
112+
* millions) of records by breaking it up into smaller chunks.
113+
*
114+
* @return TRUE on success
115+
* @throws Exception
116+
public function upgrade_4203() {
117+
$this->ctx->log->info('Planning update 4203'); // PEAR Log interface
118+
119+
$minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
120+
$maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
121+
for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
122+
$endId = $startId + self::BATCH_SIZE - 1;
123+
$title = ts('Upgrade Batch (%1 => %2)', array(
124+
1 => $startId,
125+
2 => $endId,
126+
));
127+
$sql = '
128+
UPDATE civicrm_contribution SET foobar = whiz(wonky()+wanker)
129+
WHERE id BETWEEN %1 and %2
130+
';
131+
$params = array(
132+
1 => array($startId, 'Integer'),
133+
2 => array($endId, 'Integer'),
134+
);
135+
$this->addTask($title, 'executeSql', $sql, $params);
136+
}
137+
return TRUE;
138+
} // */
139+
140+
public function upgrade_1400() {
141+
$this->ctx->log->info('Planning update 1400'); // PEAR Log interface
142+
foreach (array('ethnicity_20130725123943', 'religion_20130725124132', 'sexual_orientation_20130725124348', 'marital_status_20130913084916') as $key => $value) {
143+
$optParams = array(
144+
'option_group_id' => $value,
145+
'label' => 'Prefer Not to Say',
146+
'value' => 'Prefer Not to Say',
147+
'name' => 'Prefer_Not_to_Say',
148+
);
149+
civicrm_api3('OptionValue', 'create', $optParams);
150+
$optParam = array(
151+
'option_group_id' => $value,
152+
'label' => 'Not Applicable',
153+
'value' => 'Not Applicable',
154+
'name' => 'Not_Applicable',
155+
);
156+
civicrm_api3('OptionValue', 'create', $optParam);
157+
}
158+
159+
$sql = "UPDATE civicrm_custom_field JOIN civicrm_custom_group ON civicrm_custom_group.id = civicrm_custom_field.custom_group_id SET civicrm_custom_field.default_value = CASE WHEN civicrm_custom_field.name = 'Ethnicity' THEN ' Not Applicable ' ELSE 'Not Applicable' END WHERE civicrm_custom_field.name IN ('Ethnicity','Religion', 'Sexual_Orientation', 'Marital_Status') AND civicrm_custom_group.name = 'Extended_Demographics'";
160+
CRM_Core_DAO::executeQuery($sql);
161+
CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET is_reserved = 0, collapse_display = 1 where name = 'Extended_Demographics'");
162+
return TRUE;
163+
}
164+
165+
/**
166+
* Upgrade CustomGroup, setting Extended_Demographics is_reserved value to YES
167+
*
168+
* @return bool
169+
*/
170+
public function upgrade_1401() {
171+
$result = civicrm_api3('CustomGroup', 'get', [
172+
'sequential' => 1,
173+
'return' => ['id'],
174+
'name' => 'Extended_Demographics',
175+
]);
176+
177+
civicrm_api3('CustomGroup', 'create', [
178+
'id' => $result['id'],
179+
'is_reserved' => 1,
180+
]);
181+
182+
return TRUE;
183+
}
184+
185+
}

0 commit comments

Comments
 (0)