Skip to content

Commit

Permalink
Merge pull request #373 from compucorp/staging
Browse files Browse the repository at this point in the history
Sync master with staging
  • Loading branch information
davialexandre authored Jun 5, 2018
2 parents c33931d + 3ab3cfb commit fd84b7f
Show file tree
Hide file tree
Showing 47 changed files with 1,123 additions and 442 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function preProcess() {
*
* @return void
*/
function setDefaultValues() {
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
return $defaults;
}
Expand All @@ -53,34 +53,36 @@ function setDefaultValues() {
*/
public function buildQuickForm() {
parent::buildQuickForm();

$newOptions = array();
if ($this->elementExists('component_id')) {
$componentSelectElement = $this->getElement('component_id');
$options = $componentSelectElement->_options;
foreach ($options as $value) {
$newOptions[$value['attr']['value']] = $value['text'];
}

$isNewOptionValue = empty($this->get('id'));

if ($isNewOptionValue) {
CRM_Utils_System::setTitle('Add New Task / Document Type');
}

$civiTaskId = CRM_Core_Component::getComponentID('CiviTask');
if ($civiTaskId !== null)
{
$newOptions[$civiTaskId] = t('Tasks and Assignments');
else {
CRM_Utils_System::setTitle('Edit Task / Document Type');
}

$categoryOptions = [];

$civiTaskId = CRM_Core_Component::getComponentID('CiviTask');
$civiDocumentId = CRM_Core_Component::getComponentID('CiviDocument');
if ($civiDocumentId !== null)
{
$newOptions[$civiDocumentId] = t('Documents and Assignments');

if ($civiTaskId !== NULL) {
$categoryOptions[$civiTaskId] = t('Tasks');
}

if ($civiDocumentId !== NULL) {
$categoryOptions[$civiDocumentId] = t('Documents');
}

$this->add('select',
'component_id',
ts('Component'),
$newOptions, FALSE
ts('Category'),
$categoryOptions, FALSE
);
//$this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this);

Civi::resources()->addScriptFile('uk.co.compucorp.civicrm.tasksassignments', 'js/CRM/Form/Options.js');
}

/**
Expand All @@ -94,7 +96,7 @@ public function buildQuickForm() {
* @access public
* @static
*/
static function formRule($fields, $files, $self) {
public static function formRule($fields, $files, $self) {
return parent::formRule($fields, $files, $self);
}

Expand All @@ -108,4 +110,5 @@ static function formRule($fields, $files, $self) {
public function postProcess() {
return parent::postProcess();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class CRM_Tasksassignments_Upgrader extends CRM_Tasksassignments_Upgrader_Base {
const OPEN_CASE_TYPE = 'Open Case';

public function install() {

// $this->executeCustomDataFile('xml/customdata.xml');
Expand Down Expand Up @@ -860,6 +862,64 @@ public function upgrade_1035() {
return TRUE;
}

/**
* Removes the Open Case activity type from any Case Type that contains them in one
* of their timelines.
*
* @return bool
*/
public function upgrade_1036() {
$caseTypes = civicrm_api3('CaseType', 'get', ['sequential' => 1]);
$needsToRemoveOpenType = FALSE;

foreach ($caseTypes['values'] as $caseType) {
$activitySets = $caseType['definition']['activitySets'];

foreach ($activitySets as $setIndex => $set) {
$openCaseIndex = array_search(self::OPEN_CASE_TYPE, array_column($set['activityTypes'], 'name'));

if ($openCaseIndex !== FALSE) {
$needsToRemoveOpenType = TRUE;

// needs to unset the full path for the activity to be properly removed:
unset($caseType['definition']['activitySets'][$setIndex]['activityTypes'][$openCaseIndex]);
}
}

// Removes Open Case activities from the Case Type only if they include this activity type:
if ($needsToRemoveOpenType) {
civicrm_api3('CaseType', 'create', $caseType);
}
}

return TRUE;
}

/**
* Adds a new menu item for Activity Types under the tasks administration menu.
*
* @return bool
*/
public function upgrade_1037() {
$activityTypeMenuItem = civicrm_api3('Navigation', 'get', [
'name' => 'task_and_document_types_administer',
]);

// Create the menu item only if it doesn't exist:
if ($activityTypeMenuItem['count'] === 0) {
civicrm_api3('Navigation', 'create', [
'label' => 'Task and Document Types',
'name' => 'task_and_document_types_administer',
'url' => 'civicrm/admin/options/activity_type?reset=1',
'permission' => 'administer CiviCase',
'parent_id' => 'tasksassignments_administer',
'is_active' => 1,
]);
}

return TRUE;
}

public function uninstall() {
CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name IN ('tasksassignments', 'ta_dashboard_tasks', 'ta_dashboard_documents', 'ta_dashboard_calendar', 'ta_dashboard_keydates', 'tasksassignments_administer', 'ta_settings')");
CRM_Core_BAO_Navigation::resetNavigation();
Expand Down
4 changes: 2 additions & 2 deletions uk.co.compucorp.civicrm.tasksassignments/api/v3/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ function civicrm_api3_document_getoptions($params) {

foreach ($types as $type) {
if (!$sequential) {
$result[$type['value']] = $type['name'];
$result[$type['value']] = $type['label'];
}
else {
$result[] = [
'key' => $type['value'],
'value' => $type['name'],
'value' => $type['label'],
];
}
}
Expand Down
4 changes: 2 additions & 2 deletions uk.co.compucorp.civicrm.tasksassignments/api/v3/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,12 @@ function civicrm_api3_task_getoptions($params) {

foreach ($types as $type) {
if (!$sequential) {
$result[$type['value']] = $type['name'];
$result[$type['value']] = $type['label'];
}
else {
$result[] = array(
'key' => $type['value'],
'value' => $type['name'],
'value' => $type['label'],
);
}
}
Expand Down
Loading

0 comments on commit fd84b7f

Please sign in to comment.