// instantiate the new class
$this->_customClass = new $this->_customSearchClass( $this->_formValues );
+
+ // CRM-12747
+ if (isset($this->_customClass->_permissionedComponent) &&
+ !self::isPermissioned($this->_customClass->_permissionedComponent)) {
+ CRM_Utils_System::permissionDenied();
+ }
}
function setDefaultValues() {
public function getTitle() {
return ts('Custom Search');
}
-}
+ function isPermissioned($components) {
+ if (empty($components)) {
+ return TRUE;
+ }
+ if (is_array($components)) {
+ foreach ($components as $component) {
+ if (!CRM_Core_Permission::access($component)) {
+ return FALSE;
+ }
+ }
+ }
+ else {
+ if (!CRM_Core_Permission::access($components)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+}
\ No newline at end of file
*/
class CRM_Contact_Form_Search_Custom_ContribSYBNT implements CRM_Contact_Form_Search_Interface {
- protected $_formValues; function __construct(&$formValues) {
+ protected $_formValues;
+ public $_permissionedComponent;
+
+ function __construct(&$formValues) {
$this->_formValues = $formValues;
+ $this->_permissionedComponent = 'CiviContribute';
$this->_columns = array(
ts('Contact Id') => 'contact_id',
*/
class CRM_Contact_Form_Search_Custom_ContributionAggregate implements CRM_Contact_Form_Search_Interface {
- protected $_formValues; function __construct(&$formValues) {
- $this->_formValues = $formValues;
+ protected $_formValues;
+ public $_permissionedComponent;
+ function __construct(&$formValues) {
+ $this->_formValues = $formValues;
/**
* Define the columns for search result rows
*/
+
$this->_columns = array(
ts('Contact Id') => 'contact_id',
ts('Name') => 'sort_name',
ts('Donation Count') => 'donation_count',
ts('Donation Amount') => 'donation_amount',
);
+
+ // define component access permission needed
+ $this->_permissionedComponent = 'CiviContribute';
}
function buildForm(&$form) {
*/
class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
- protected $_formValues; function __construct(&$formValues) {
+ protected $_formValues;
+ public $_permissionedComponent;
+
+ function __construct(&$formValues) {
$this->_formValues = $formValues;
+ $this->_permissionedComponent = array('CiviContribute', 'CiviEvent');
/**
* Define the columns for search result rows
protected $_eventID = NULL;
- protected $_tableName = NULL; function __construct(&$formValues) {
+ protected $_tableName = NULL;
+ public $_permissionedComponent;
+
+ function __construct(&$formValues) {
parent::__construct($formValues);
$this->_eventID = CRM_Utils_Array::value('event_id',
if ($this->_eventID) {
$this->buildTempTable();
-
$this->fillTable();
}
+
+ // define component access permission needed
+ $this->_permissionedComponent = 'CiviEvent';
}
function __destruct() {
*/
class CRM_Contact_Form_Search_Custom_TagContributions implements CRM_Contact_Form_Search_Interface {
- protected $_formValues; function __construct(&$formValues) {
+ protected $_formValues;
+ public $_permissionedComponent;
+
+ function __construct(&$formValues) {
$this->_formValues = $formValues;
+ $this->_permissionedComponent = 'CiviContribute';
/**
* Define the columns for search result rows