Commit a0d6fe95 authored by jaapjansma's avatar jaapjansma
Browse files

Fixed broken dashlet

parent 7679145c
# Version 1.3.0 (not yet released)
# Version 1.2.0
* Made CSV Export download available for anonymous users.
......
......@@ -4,10 +4,10 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_Contact_DataProcessorContactSearch implements UIOutputInterface {
class CRM_Contact_DataProcessorContactSearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -5,9 +5,9 @@
*/
use CRM_Dataprocessor_ExtensionUtil as E;
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
class CRM_Contact_DataProcessorContactSummaryTab implements UIOutputInterface {
class CRM_Contact_DataProcessorContactSummaryTab implements UIFormOutputInterface {
/**
* Implements hook_civicrm_tabset().
......@@ -42,13 +42,13 @@ class CRM_Contact_DataProcessorContactSummaryTab implements UIOutputInterface {
$maxWeight++;
$sql = "SELECT o.*, d.name as data_processor_name
FROM civicrm_data_processor d
FROM civicrm_data_processor d
INNER JOIN civicrm_data_processor_output o ON d.id = o.data_processor_id
WHERE d.is_active = 1 AND o.type = 'contact_summary_tab'";
$dao = CRM_Core_DAO::executeQuery($sql);
while($dao->fetch()) {
$outputClass = $factory->getOutputByName($dao->type);
if (!$outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if (!$outputClass instanceof CRM_Contact_DataProcessorContactSummaryTab) {
continue;
}
$output = civicrm_api3('DataProcessorOutput', 'getsingle', ['id' => $dao->id]);
......
......@@ -123,7 +123,7 @@ class CRM_Dataprocessor_Form_DataProcessor extends CRM_Core_Form {
$outputs = CRM_Utils_Array::value('values', $outputs);
foreach($outputs as $idx => $output) {
$outputClass = $factory->getOutputByName($output['type']);
if ($outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if ($outputClass instanceof \Civi\DataProcessor\Output\UIFormOutputInterface) {
$outputs[$idx]['navigation_url'] = CRM_Utils_System::url($outputClass->getUrlToUi($output, $this->dataProcessor), array('reset' => '1'));
} elseif ($outputClass instanceof \Civi\DataProcessor\Output\UrlOutputInterface && $outputClass->checkPermission($output, $this->dataProcessor)) {
$outputs[$idx]['navigation_url'] = $outputClass->getUrl($output, $this->dataProcessor);
......
......@@ -38,7 +38,7 @@ class CRM_Dataprocessor_Form_ManageDataProcessors extends CRM_Core_Form {
$outputs = civicrm_api3('DataProcessorOutput', 'get',['data_processor_id' => $dataProcessor['id'], 'options' => ['limit' => 0]]);
foreach(CRM_Utils_Array::value('values', $outputs) as $outputIndex => $output) {
$outputClass = $factory->getOutputByName($output['type']);
if ($outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if ($outputClass instanceof \Civi\DataProcessor\Output\UIFormOutputInterface) {
$dataProcessors[$idx]['navigation'][$outputIndex]['url'] = CRM_Utils_System::url($outputClass->getUrlToUi($output, $dataProcessor), array('reset' => '1'));
$dataProcessors[$idx]['navigation'][$outputIndex]['title'] = $outputClass->getTitleForUiLink($output, $dataProcessor);
} elseif ($outputClass instanceof \Civi\DataProcessor\Output\UrlOutputInterface && $outputClass->checkPermission($output, $dataProcessor)) {
......
......@@ -4,6 +4,7 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
abstract class CRM_Dataprocessor_Form_Output_AbstractUIOutputForm extends CRM_Core_Form_Search {
......@@ -85,7 +86,7 @@ abstract class CRM_Dataprocessor_Form_Output_AbstractUIOutputForm extends CRM_Co
$this->assign('output', $this->dataProcessorOutput);
$outputClass = $factory->getOutputByName($this->dataProcessorOutput['type']);
if (!$outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if (!$outputClass instanceof UIOutputInterface) {
throw new \Exception('Invalid output');
}
......
......@@ -6,7 +6,7 @@
use \CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorDashlet_Dashlet implements Civi\DataProcessor\Output\OutputInterface {
class CRM_DataprocessorDashlet_Dashlet implements Civi\DataProcessor\Output\UIOutputInterface {
/**
* Returns true when this output has additional configuration
......@@ -152,5 +152,18 @@ class CRM_DataprocessorDashlet_Dashlet implements Civi\DataProcessor\Output\Outp
}
}
/**
* Checks whether the current user has access to this output
*
* @param array $output
* @param array $dataProcessor
* @return bool
*/
public function checkUIPermission($output, $dataProcessor) {
return CRM_Core_Permission::check(array(
$output['permission']
));
}
}
......@@ -4,11 +4,11 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_ActivitySearch implements UIOutputInterface {
class CRM_DataprocessorSearch_ActivitySearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -4,11 +4,11 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_CaseSearch implements UIOutputInterface {
class CRM_DataprocessorSearch_CaseSearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -4,11 +4,11 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_ContributionSearch implements UIOutputInterface {
class CRM_DataprocessorSearch_ContributionSearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -4,11 +4,11 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_MembershipSearch implements UIOutputInterface {
class CRM_DataprocessorSearch_MembershipSearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -4,11 +4,11 @@
* @license AGPL-3.0
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_ParticipantSearch implements UIOutputInterface {
class CRM_DataprocessorSearch_ParticipantSearch implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -5,11 +5,11 @@
*/
use Civi\DataProcessor\Output\UIOutputInterface;
use Civi\DataProcessor\Output\UIFormOutputInterface;
use CRM_Dataprocessor_ExtensionUtil as E;
class CRM_DataprocessorSearch_Search implements UIOutputInterface {
class CRM_DataprocessorSearch_Search implements UIFormOutputInterface {
/**
* Returns true when this filter has additional configuration
......
......@@ -9,7 +9,7 @@ namespace Civi\DataProcessor\Output;
/**
* This interface indicates that the output type is accessible from the user interface
*
* Interface UIOutputInterface
* Interface ExportOutputInterface
*
* @package Civi\DataProcessor\Output
*/
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\DataProcessor\Output;
/**
* This interface indicates that the output type is accessible from the user interface
*
* Interface UIOutputInterface
*
* @package Civi\DataProcessor\Output
*/
interface UIFormOutputInterface extends UIOutputInterface {
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string
*/
public function getUrlToUi($output, $dataProcessor);
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string
*/
public function getTitleForUiLink($output, $dataProcessor);
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string|false
*/
public function getIconForUiLink($output, $dataProcessor);
/**
* Returns the callback for the UI.
*
* @return string
*/
public function getCallbackForUi();
}
......@@ -32,14 +32,14 @@ class UIOutputHelper {
}
$sql = "
SELECT o.permission, p.id, p.title, o.configuration, o.type, o.id as output_id
FROM civicrm_data_processor_output o
INNER JOIN civicrm_data_processor p ON o.data_processor_id = p.id
SELECT o.permission, p.id, p.title, o.configuration, o.type, o.id as output_id
FROM civicrm_data_processor_output o
INNER JOIN civicrm_data_processor p ON o.data_processor_id = p.id
WHERE p.is_active = 1";
$dao = \CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$outputClass = $factory->getOutputByName($dao->type);
if ($outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if ($outputClass instanceof \Civi\DataProcessor\Output\UIFormOutputInterface) {
$output = civicrm_api3('DataProcessorOutput', 'getsingle', array('id' => $dao->output_id));
$dataprocessor = civicrm_api3('DataProcessor', 'getsingle', array('id' => $dao->id));
$url = $outputClass->getUrlToUi($output, $dataprocessor);
......@@ -191,7 +191,7 @@ class UIOutputHelper {
$configuration = $output['configuration'];
$title = $dataProcessor['title'];
if ($outputClass && $outputClass instanceof \Civi\DataProcessor\Output\UIOutputInterface) {
if ($outputClass && $outputClass instanceof \Civi\DataProcessor\Output\UIFormOutputInterface) {
$url = $outputClass->getUrlToUi($output, $dataProcessor);
$title = $outputClass->getTitleForUiLink($output, $dataProcessor);
}
......
......@@ -15,40 +15,6 @@ namespace Civi\DataProcessor\Output;
*/
interface UIOutputInterface extends OutputInterface {
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string
*/
public function getUrlToUi($output, $dataProcessor);
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string
*/
public function getTitleForUiLink($output, $dataProcessor);
/**
* Returns the url for the page/form this output will show to the user
*
* @param array $output
* @param array $dataProcessor
* @return string|false
*/
public function getIconForUiLink($output, $dataProcessor);
/**
* Returns the callback for the UI.
*
* @return string
*/
public function getCallbackForUi();
/**
* Checks whether the current user has access to this output
*
......@@ -58,4 +24,4 @@ interface UIOutputInterface extends OutputInterface {
*/
public function checkUIPermission($output, $dataProcessor);
}
\ No newline at end of file
}
......@@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-02-12</releaseDate>
<version>1.2.0</version>
<version>master</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
Markdown is supported
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