Skip to content

Commit

Permalink
Merge pull request #1008 from compucorp/COMCL-505-fix-civicase-permis…
Browse files Browse the repository at this point in the history
…sion

COMCL-505: Remove unrequired APIv4 permission checks
  • Loading branch information
olayiwola-compucorp authored Mar 20, 2024
2 parents eab6405 + cc8a4b0 commit 7cec4b7
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions CRM/Civicase/Form/CaseSalesOrderContributionCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function buildQuickForm() {
$this->addRule('to_be_invoiced', ts('Invoice value is required'), 'required');
}

$statusOptions = OptionValue::get()
$statusOptions = OptionValue::get(FALSE)
->addSelect('value', 'label')
->addWhere('option_group_id:name', '=', 'case_sales_order_status')
->execute()
Expand Down Expand Up @@ -92,7 +92,7 @@ public function buildQuickForm() {
* {@inheritDoc}
*/
public function setDefaultValues() {
$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addWhere('id', '=', $this->id)
->addSelect('status_id')
->execute()
Expand Down Expand Up @@ -173,7 +173,7 @@ public function validateAmount(array $values) {
* Checks if the sales order has left over balance to be invoiced.
*/
public function hasRemainingBalance() {
$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addSelect('total_after_tax')
->addWhere('id', '=', $this->id)
->setLimit(1)
Expand All @@ -184,7 +184,7 @@ public function hasRemainingBalance() {
}

// Get all the previous contributions.
$contributions = Contribution::get()
$contributions = Contribution::get(FALSE)
->addSelect('total_amount')
->addWhere('Opportunity_Details.Quotation', '=', $this->id)
->execute()
Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Form/CaseSalesOrderInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function getContactIds(): array {

$salesOrderId = CRM_Utils_Request::retrieveValue('id', 'Positive');

$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addWhere('id', '=', $salesOrderId)
->execute()
->first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function getDefaultFeatures(CRM_Core_Form $form) {
$caseCategory = $form->getVar('_values')['value'];
$enabledFeatures = [];

$caseCategoryFeatures = CaseCategoryFeatures::get()
$caseCategoryFeatures = CaseCategoryFeatures::get(FALSE)
->addWhere('category_id', '=', $caseCategory)
->execute();

Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Hook/NavigationMenu/AlterForCaseMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function addCiviCaseInstanceMenu(array &$menu) {
* Returnd the ID of the case type category option group.
*/
private function getCaseTypeCategoryGroupId() {
$optionGroups = OptionGroup::get()
$optionGroups = OptionGroup::get(FALSE)
->addSelect('id')
->addWhere('name', '=', 'case_type_categories')
->setLimit(25)
Expand Down
4 changes: 2 additions & 2 deletions CRM/Civicase/Hook/Post/CaseSalesOrderPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function run($op, $objectName, $objectId, &$objectRef) {
return;
}

$contribution = Contribution::get()
$contribution = Contribution::get(FALSE)
->addSelect('Opportunity_Details.Case_Opportunity', 'Opportunity_Details.Quotation')
->addWhere('id', '=', $contributionId)
->execute()
Expand Down Expand Up @@ -63,7 +63,7 @@ private function updateQuotationFinancialStatuses(?int $salesOrderID): void {
$paymentStatusID = $caseSaleOrderContributionService->calculatePaymentStatus();
$invoicingStatusID = $caseSaleOrderContributionService->calculateInvoicingStatus();

CaseSalesOrder::update()
CaseSalesOrder::update(FALSE)
->addWhere('id', '=', $salesOrderID)
->addValue('invoicing_status_id', $invoicingStatusID)
->addValue('payment_status_id', $paymentStatusID)
Expand Down
6 changes: 3 additions & 3 deletions CRM/Civicase/Hook/Post/CreateSalesOrderContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function run($op, $objectName, $objectId, &$objectRef) {
return;
}

$salesOrder = CaseSalesOrder::get()
$salesOrder = CaseSalesOrder::get(FALSE)
->addSelect('status_id', 'case_id')
->addWhere('id', '=', $salesOrderId)
->execute()
Expand All @@ -51,7 +51,7 @@ public function run($op, $objectName, $objectId, &$objectRef) {
$paymentStatusID = $caseSaleOrderContributionService->calculatePaymentStatus();
$invoicingStatusID = $caseSaleOrderContributionService->calculateInvoicingStatus();

CaseSalesOrder::update()
CaseSalesOrder::update(FALSE)
->addWhere('id', '=', $salesOrderId)
->addValue('status_id', $salesOrderStatusId)
->addValue('invoicing_status_id', $invoicingStatusID)
Expand Down Expand Up @@ -90,7 +90,7 @@ private function shouldRun($op, $objectName) {
* Gets quotation ID by contribution ID.
*/
private function getQuotationId($id) {
return Contribution::get()
return Contribution::get(FALSE)
->addSelect('Opportunity_Details.Quotation')
->addWhere('id', '=', $id)
->execute()
Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Hook/Pre/DeleteSalesOrderContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function run($op, $objectName, $objectId, &$params) {
->addValue('payment_status_id', $paymentStatusId)
->execute();

$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addSelect('case_id')
->addWhere('id', '=', $salesOrderId)
->execute()
Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Hook/Tabset/CaseSalesOrderTabAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function addCaseSalesOrderTab(array &$tabs, $contactID, $weight) {
* Contact ID to retrieve count for.
*/
public function getContactSalesOrderCount(int $contactID) {
$result = CaseSalesOrder::get()
$result = CaseSalesOrder::get(FALSE)
->addSelect('COUNT(id) AS count')
->addWhere('client_id', '=', $contactID)
->execute()
Expand Down
2 changes: 1 addition & 1 deletion CRM/Civicase/Hook/Tokens/SalesOrderTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function evaluateSalesOrderTokens(TokenValueEvent $e) {
if (!empty($row->context['salesOrderId'])) {
$salesOrderId = $row->context['salesOrderId'];

$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addWhere('id', '=', $salesOrderId)
->execute()
->first();
Expand Down
4 changes: 2 additions & 2 deletions CRM/Civicase/Hook/alterMailParams/AttachQuotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public function run(array &$params, $context) {
* The contribution ID.
*/
private function getContributionQuotationInvoice($contributionId) {
$salesOrder = Contribution::get()
$salesOrder = Contribution::get(FALSE)
->addSelect('Opportunity_Details.Quotation')
->addWhere('Opportunity_Details.Quotation', 'IS NOT EMPTY')
->addWhere('id', '=', $contributionId)
->addChain('salesOrder', CaseSalesOrder::get()
->addChain('salesOrder', CaseSalesOrder::get(FALSE)
->addWhere('id', '=', '$Opportunity_Details.Quotation')
)
->execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function calculatePaymentStatus() {
* Updates opportunity financial details.
*/
public function updateOpportunityFinancialDetails(): void {
CiviCase::update()
CiviCase::update(FALSE)
->addValue('Case_Opportunity_Details.Total_Amount_Quoted', $this->calculateTotalQuotedAmount())
->addValue('Case_Opportunity_Details.Total_Amount_Invoiced', $this->calculateTotalInvoicedAmount())
->addValue('Case_Opportunity_Details.Invoicing_Status', $this->calculateInvoicingStatus())
Expand Down
6 changes: 3 additions & 3 deletions CRM/Civicase/Service/CaseTypeCategoryFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CRM_Civicase_Service_CaseTypeCategoryFeatures {
* Gets the available additional features.
*/
public function getFeatures() {
$optionValues = OptionValue::get()
$optionValues = OptionValue::get(FALSE)
->addSelect('id', 'label', 'value', 'name', 'option_group_id')
->addWhere('option_group_id:name', '=', self::NAME)
->execute();
Expand All @@ -33,13 +33,13 @@ public function getFeatures() {
* Array of Key\Pair value grouped by case instance id.
*/
public function retrieveCaseInstanceWithEnabledFeatures(array $features) {
$caseInstanceGroup = OptionGroup::get()->addWhere('name', '=', 'case_type_categories')->execute()[0] ?? NULL;
$caseInstanceGroup = OptionGroup::get(FALSE)->addWhere('name', '=', 'case_type_categories')->execute()[0] ?? NULL;

if (empty($caseInstanceGroup)) {
return [];
}

$result = CaseCategoryFeatures::get()
$result = CaseCategoryFeatures::get(FALSE)
->addSelect('*', 'option_value.label', 'option_value.name', 'feature_id:name', 'feature_id:label', 'navigation.id')
->addJoin('OptionValue AS option_value', 'LEFT',
['option_value.value', '=', 'category_id']
Expand Down
10 changes: 5 additions & 5 deletions Civi/Api4/Action/CaseSalesOrder/ContributionCreateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ private function createContributionWithLineItems(int $salesOrderId, array $price
* Array of price fields
*/
private function getDefaultPriceSetFields(): array {
$priceSet = PriceSet::get()
$priceSet = PriceSet::get(FALSE)
->addWhere('name', '=', 'default_contribution_amount')
->addWhere('is_quick_config', '=', 1)
->execute()
->first();

return PriceField::get()
return PriceField::get(FALSE)
->addWhere('price_set_id', '=', $priceSet['id'])
->addChain('price_field_value', PriceFieldValue::get()
->addChain('price_field_value', PriceFieldValue::get(FALSE)
->addWhere('price_field_id', '=', '$id')
)->execute()
->getArrayCopy();
Expand All @@ -169,7 +169,7 @@ private function getDefaultPriceSetFields(): array {
* Contribution ID.
*/
private function linkCaseSalesOrderToContribution(int $salesOrderId, int $contributionId): void {
$salesOrder = CaseSalesOrder::get()
$salesOrder = CaseSalesOrder::get(FALSE)
->addWhere('id', '=', $salesOrderId)
->execute()
->first();
Expand Down Expand Up @@ -201,7 +201,7 @@ private function updateCaseSalesOrderStatus(int $salesOrderId): void {
* pending status ID
*/
private function getPendingContributionStatusId(): ?int {
$pendingStatus = OptionValue::get()
$pendingStatus = OptionValue::get(FALSE)
->addSelect('value')
->addWhere('option_group_id:name', '=', 'contribution_status')
->addWhere('name', '=', 'pending')
Expand Down
2 changes: 1 addition & 1 deletion ang/civicase-features.ang.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function set_case_types_with_features_enabled(&$options) {
* Exposes case sales order statuses to Angular.
*/
function set_case_sales_order_status(&$options) {
$optionValues = OptionValue::get()
$optionValues = OptionValue::get(FALSE)
->addSelect('id', 'value', 'name', 'label')
->addWhere('option_group_id:name', '=', 'case_sales_order_status')
->execute();
Expand Down
2 changes: 1 addition & 1 deletion api/v3/Case/Getrelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function civicrm_api3_case_getrelations(array $params) {
])['values']
);

$relationships = Relationship::get()
$relationships = Relationship::get(FALSE)
->addSelect('relationship_type_id', 'contact_id_a', 'contact_id_b')
->addWhere('relationship_type.is_active', '=', TRUE)
->addWhere('is_active', '=', TRUE)
Expand Down
2 changes: 1 addition & 1 deletion api/v3/CaseSalesOrder/Getlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function _civicrm_api3_case_sales_order_getlist_output($result, $request) {
$output = [];
if (!empty($result['values'])) {
foreach ($result['values'] as $row) {
$caseSalesOrder = CaseSalesOrder::get()
$caseSalesOrder = CaseSalesOrder::get(FALSE)
->addSelect('contact.display_name', 'quotation_date')
->addJoin('Contact AS contact', 'LEFT', ['contact.id', '=', 'client_id'])
->addWhere('id', '=', $row['id'])
Expand Down

0 comments on commit 7cec4b7

Please sign in to comment.