Skip to content

Commit

Permalink
Merge pull request #2767 from compucorp/revert-2765-PCHR-3542-custom-…
Browse files Browse the repository at this point in the history
…group-updates

Revert "PCHR-3542: Custom Group Updates"
  • Loading branch information
davialexandre authored Jul 17, 2018
2 parents 7eed24a + d8ec530 commit 4053afb
Show file tree
Hide file tree
Showing 31 changed files with 884 additions and 562 deletions.
1 change: 1 addition & 0 deletions bin/drush-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ uk.co.compucorp.civicrm.hremails
## List of extensions defining basic entity types
ENTITY_EXTS=\
org.civicrm.hrbank,\
org.civicrm.hrdemog,\
org.civicrm.hrjobcontract,\
com.civicrm.hrjobroles,\
org.civicrm.hrmed,\
Expand Down
1 change: 1 addition & 0 deletions bin/git-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fileName=""
ENTITY_EXTS=( hrbank \
hrcareer \
hrcase \
hrdemog \
hrim \
hrmed \
hrprofile \
Expand Down
28 changes: 0 additions & 28 deletions doc/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,4 @@ The [civihr-installer](https://github.com/compucorp/civihr-installer) script has
$ civibuild create hr17
```

Read the drush-install.sh for details.

## Install (Option B: Manual)

CiviHR includes over a dozen extensions. These can be activated piecemeal.
The following extensions provide the major features and may be activated
individually:

* org.civicrm.hrbank: Bank Details
* org.civicrm.hrcareer: Career History
* org.civicrm.hremerg: Emergency Contacts
* org.civicrm.hrabsence: Absences
* org.civicrm.hrjobcontract: Job Contracts
* org.civicrm.hrmed: Medical and Disability
* org.civicrm.hrqual: Qualifications
* org.civicrm.hrreport: Reporting
* org.civicrm.hrstaffdir: Staff Directory
* org.civicrm.hrcase: Case
* org.civicrm.hrcaseutils: Case Utils
* org.civicrm.hrim: Instant messanger link
* org.civicrm.hrrecruitment: Recruitment
* org.civicrm.hrprofile: Profile

Finally, these two extensions build on top of the others:

* uk.co.compucorp.civicrm.hrsampledata: Generate random example data
* org.civicrm.hrui: Trim/revise CiviCRM UI for CiviHR users

Please check the [civibuild documentation](https://docs.civicrm.org/dev/en/latest/tools/civibuild/) for more information on all the available params.
185 changes: 185 additions & 0 deletions hrdemog/CRM/HRDemog/Upgrader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviHR version 1.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
* Collection of upgrade steps
*/
class CRM_HRDemog_Upgrader extends CRM_HRDemog_Upgrader_Base {

// By convention, functions that look like "function upgrade_NNNN()" are
// upgrade tasks. They are executed in order (like Drupal's hook_update_N).

/**
* Example: Run an external SQL script when the module is installed
*
public function install() {
$this->executeSqlFile('sql/myinstall.sql');
}
/**
* Example: Run an external SQL script when the module is uninstalled
*
public function uninstall() {
$this->executeSqlFile('sql/myuninstall.sql');
}
/**
* Example: Run a simple query when a module is enabled
*
public function enable() {
CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"');
}
/**
* Example: Run a simple query when a module is disabled
*
public function disable() {
CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"');
}
/**
* Example: Run a couple simple queries
*
* @return TRUE on success
* @throws Exception
*
public function upgrade_4200() {
$this->ctx->log->info('Applying update 4200');
CRM_Core_DAO::executeQuery('UPDATE foo SET bar = "whiz"');
CRM_Core_DAO::executeQuery('DELETE FROM bang WHERE willy = wonka(2)');
return TRUE;
} // */


/**
* Example: Run an external SQL script
*
* @return TRUE on success
* @throws Exception
public function upgrade_4201() {
$this->ctx->log->info('Applying update 4201');
// this path is relative to the extension base dir
$this->executeSqlFile('sql/upgrade_4201.sql');
return TRUE;
} // */


/**
* Example: Run a slow upgrade process by breaking it up into smaller chunk
*
* @return TRUE on success
* @throws Exception
public function upgrade_4202() {
$this->ctx->log->info('Planning update 4202'); // PEAR Log interface
$this->addTask(ts('Process first step'), 'processPart1', $arg1, $arg2);
$this->addTask(ts('Process second step'), 'processPart2', $arg3, $arg4);
$this->addTask(ts('Process second step'), 'processPart3', $arg5);
return TRUE;
}
public function processPart1($arg1, $arg2) { sleep(10); return TRUE; }
public function processPart2($arg3, $arg4) { sleep(10); return TRUE; }
public function processPart3($arg5) { sleep(10); return TRUE; }
// */


/**
* Example: Run an upgrade with a query that touches many (potentially
* millions) of records by breaking it up into smaller chunks.
*
* @return TRUE on success
* @throws Exception
public function upgrade_4203() {
$this->ctx->log->info('Planning update 4203'); // PEAR Log interface
$minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
$maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
$endId = $startId + self::BATCH_SIZE - 1;
$title = ts('Upgrade Batch (%1 => %2)', array(
1 => $startId,
2 => $endId,
));
$sql = '
UPDATE civicrm_contribution SET foobar = whiz(wonky()+wanker)
WHERE id BETWEEN %1 and %2
';
$params = array(
1 => array($startId, 'Integer'),
2 => array($endId, 'Integer'),
);
$this->addTask($title, 'executeSql', $sql, $params);
}
return TRUE;
} // */

public function upgrade_1400() {
$this->ctx->log->info('Planning update 1400'); // PEAR Log interface
foreach (array('ethnicity_20130725123943', 'religion_20130725124132', 'sexual_orientation_20130725124348', 'marital_status_20130913084916') as $key => $value) {
$optParams = array(
'option_group_id' => $value,
'label' => 'Prefer Not to Say',
'value' => 'Prefer Not to Say',
'name' => 'Prefer_Not_to_Say',
);
civicrm_api3('OptionValue', 'create', $optParams);
$optParam = array(
'option_group_id' => $value,
'label' => 'Not Applicable',
'value' => 'Not Applicable',
'name' => 'Not_Applicable',
);
civicrm_api3('OptionValue', 'create', $optParam);
}

$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'";
CRM_Core_DAO::executeQuery($sql);
CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET is_reserved = 0, collapse_display = 1 where name = 'Extended_Demographics'");
return TRUE;
}

/**
* Upgrade CustomGroup, setting Extended_Demographics is_reserved value to YES
*
* @return bool
*/
public function upgrade_1401() {
$result = civicrm_api3('CustomGroup', 'get', [
'sequential' => 1,
'return' => ['id'],
'name' => 'Extended_Demographics',
]);

civicrm_api3('CustomGroup', 'create', [
'id' => $result['id'],
'is_reserved' => 1,
]);

return TRUE;
}

}
Loading

0 comments on commit 4053afb

Please sign in to comment.