Commit dc2cbda9 authored by ErikHommel's avatar ErikHommel
Browse files

permission change around logging

parent 6ed33f2d
## Version 2.5
* add checkPermission to KoalectLog update
* catch update koalect log if no api4
## Version 2.4
* add alterAPIPermissions hook to skip permission check for koalect_transaction create
......
......@@ -122,7 +122,6 @@ class CRM_Koalecttocivi_BAO_KoalectLog extends CRM_Koalecttocivi_DAO_KoalectLog
* @return mixed|void
*/
private static function logWithApi4(array $apiData, DateTime $logDate, string $entity, string $action, string $data) {
$name = NULL;
$logEntry = \Civi\Api4\KoalectLog::create()
->setCheckPermissions(FALSE)
->addValue('date_received', $logDate->format('Y-m-d H:i:s'))
......@@ -236,8 +235,7 @@ class CRM_Koalecttocivi_BAO_KoalectLog extends CRM_Koalecttocivi_DAO_KoalectLog
}
return FALSE;
}
/**
* Method to update the status of the log
*
......@@ -248,14 +246,23 @@ class CRM_Koalecttocivi_BAO_KoalectLog extends CRM_Koalecttocivi_DAO_KoalectLog
public static function updateStatus(int $logId, string $status) {
if (function_exists('civicrm_api4')) {
try {
$results = \Civi\Api4\KoalectLog::update()
\Civi\Api4\KoalectLog::update()
->addWhere('id', '=', $logId)
->addValue('status', $status)
->setCheckPermissions(FALSE)
->execute();
} catch (API_Exception $ex) {
Civi::log()->error(E::ts("Could not update the status of Koalect log ID ") . $logId
. E::ts(" to status ") . $status . E::ts(", error from API4 KoalectLog update: ") . $ex->getMessage());
}
}
else {
$query = "UPDATE civicrm_koalect_log SET status = %1 WHERE id = %2";
CRM_Core_DAO::executeQuery($query, [
1 => [$status, "String"],
2 => [$logId, "Integer"],
]);
}
}
/**
......
......@@ -32,7 +32,6 @@ class CRM_Koalecttocivi_KoalectTransaction {
* @return array
*/
public function process(array $data, array $apiData, int $logId) {
// temp debug during initial testing
try {
$fp = civicrm_api3('FormProcessor', 'koalect_transaction', $data);
CRM_Koalecttocivi_BAO_KoalectLog::updateStatus($logId, CRM_Koalecttocivi_BAO_KoalectLog::getStatusKey("processed"));
......
......@@ -51,11 +51,9 @@ class KoalectCampaign extends AbstractAction {
if (!empty($koalectCampaignId)) {
$koalectCampaign = new \CRM_Koalecttocivi_KoalectCampaign();
$campaignTypeId = $koalectCampaign->getCampaignTypeId($koalectCampaignId);
// temp debug during initial testing
if (!$campaignTypeId) {
$koalectCampaignName = $parameters->getParameter('koalect_campaign_name');
$campaignTypeId = $koalectCampaign->createCampaignType($koalectCampaignId, $koalectCampaignName);
// temp debug during initial testing
}
$output->setParameter('campaign_type_id', $campaignTypeId);
}
......
......@@ -52,12 +52,10 @@ class KoalectProject extends AbstractAction {
if (!empty($koalectProjectId)) {
$koalectProject = new \CRM_Koalecttocivi_KoalectProject();
$campaignId = $koalectProject->getCampaignId($koalectProjectId);
// temp debug during initial testing
if (!$campaignId) {
$koalectProjectName = $parameters->getParameter('koalect_project_name');
$koalectCampaignId = $parameters->getParameter('koalect_campaign_id');
$campaignId = $koalectProject->createCampaign($koalectCampaignId, $koalectProjectId, $koalectProjectName);
// temp debug during initial testing
}
$output->setParameter('campaign_id', $campaignId);
}
......
......@@ -14,9 +14,9 @@
<url desc="Support">https://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2022-07-01</releaseDate>
<version>2.4</version>
<develStage>beta</develStage>
<releaseDate>2022-07-21</releaseDate>
<version>2.5</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.0</ver>
</compatibility>
......@@ -24,7 +24,7 @@
<ext>de.systopia.xcm</ext>
<ext>form-processor</ext>
</requires>
<comments>Extension is being tested</comments>
<comments>Extension is being used</comments>
<classloader>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
......
......@@ -23,6 +23,9 @@ function koalecttocivi_civicrm_alterAPIPermissions($entity, $action, &$params, &
if ($entity == 'koalect_transaction' and $action == 'create') {
$params['check_permissions'] = FALSE;
}
if ($entity == 'koalect_transaction' and $action == 'create') {
$params['check_permissions'] = FALSE;
}
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment