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

BTHAB-39: Update menu label #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CRM/Prospect/Helper/CaseTypeCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class CRM_Prospect_Helper_CaseTypeCategory {
/**
* Prospect category label.
*/
const PROSPECT_CASE_TYPE_CATEGORY_LABEL = 'Prospecting';
const PROSPECT_CASE_TYPE_CATEGORY_LABEL = 'Prospects';

/**
* Prospect category singular label.
*/
const PROSPECT_CASE_TYPE_CATEGORY_SINGULAR_LABEL = 'Prospecting';
const PROSPECT_CASE_TYPE_CATEGORY_SINGULAR_LABEL = 'Prospect';

/**
* Checks if Case Type ID/Name belongs to Prospect Category.
Expand Down
2 changes: 1 addition & 1 deletion CRM/Prospect/Service/SalesOpportunityTrackingMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CRM_Prospect_Service_SalesOpportunityTrackingMenu extends CRM_Civicase_Ser
public function getSubmenus(array $caseTypeCategory, array $permissions = NULL) {
$singularLabelForMenu = ucfirst(strtolower($caseTypeCategory['singular_label']));
$caseTypeCategoryName = $caseTypeCategory['name'];
$labelForMenu = ucfirst(strtolower($caseTypeCategoryName));
$labelForMenu = ucfirst(strtolower($caseTypeCategory['label']));
$categoryId = civicrm_api3('OptionValue', 'getsingle', [
'option_group_id' => 'case_type_categories',
'name' => $caseTypeCategoryName,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Prospect/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function enqueuePendingRevisions(CRM_Queue_Queue $queue) {
* The queue requires that true is returned on successful upgrade, but we
* use exceptions to indicate an error instead.
*/
public function runStepUpgrade(CRM_Queue_TaskContext $context, $step) {
public static function runStepUpgrade(CRM_Queue_TaskContext $context, $step) {
$step->apply();

return TRUE;
Expand Down
70 changes: 70 additions & 0 deletions CRM/Prospect/Upgrader/Steps/Step1011.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

use CRM_Civicase_Service_CaseCategoryPermission as CaseCategoryPermission;
use CRM_Prospect_Service_SalesOpportunityTrackingMenu as SalesOpportunityTrackingMenu;

use CRM_Certificate_ExtensionUtil as E;

/**
* Updates the Sales/Tracking case type category menu labels.
*/
class CRM_Prospect_Upgrader_Steps_Step1011 {

/**
* Updates the Sales/Tracking case type category menu labels.
*
* @return bool
* Return value in boolean.
*/
public function apply() {
try {
$this->updateCaseCategoryMenuLabel();
$this->updateCaseCategorySubmenusLabel();
CRM_Core_BAO_Navigation::resetNavigation();

return TRUE;
}
catch (\Throwable $th) {
\Civi::log()->error(E::ts("Error updating Sales opportunity menu"), [
'context' => [
'backtrace' => $th->getTraceAsString(),
'message' => $th->getMessage(),
],
]);
}

return FALSE;
}

/**
* Updates the Case Category Sub Menus label.
*/
protected function updateCaseCategorySubmenusLabel() {
$menuData = CRM_Prospect_Helper_CaseTypeCategory::getDataForMenu();
$menu = new SalesOpportunityTrackingMenu();
$caseCategoryPermission = new CaseCategoryPermission();
$permissions = $caseCategoryPermission->get($menuData['name']);
$submenus = $menu->getSubmenus($menuData, $permissions);

foreach ($submenus as $item) {
\Civi\Api4\Navigation::update(FALSE)
->addValue('label', $item['label'])
->addWhere('name', '=', $item['name'])
->execute();
}
}

/**
* Updates the Case Category Menu Label.
*/
protected function updateCaseCategoryMenuLabel() {
$menuData = CRM_Prospect_Helper_CaseTypeCategory::getDataForMenu();
$labelForMenu = ucfirst(strtolower($menuData['label']));

\Civi\Api4\Navigation::update(FALSE)
->addValue('label', $labelForMenu)
->addWhere('name', '=', $menuData['name'])
->execute();
}

}