@@ -489,6 +489,14 @@ public function setDefaultValues() {
489
489
* Build the form object.
490
490
*/
491
491
public function buildQuickForm () {
492
+
493
+ // FIXME: This probably needs to be done in preprocess
494
+ if ($ this ->_action & CRM_Core_Action::UPDATE ) {
495
+ $ financialTypeID = CRM_Contribute_PseudoConstant::financialType ($ this ->_values ['financial_type_id ' ]);
496
+ if (!CRM_Core_Permission::check ('edit contributions of type ' . $ financialTypeID )) {
497
+ CRM_Core_Error::fatal (ts ('You do not have permission to access this page. ' ));
498
+ }
499
+ }
492
500
//@todo document the purpose of cdType (if still in use)
493
501
if ($ this ->_cdType ) {
494
502
CRM_Custom_Form_CustomData::buildQuickForm ($ this );
@@ -641,13 +649,23 @@ public function buildQuickForm() {
641
649
}
642
650
643
651
$ attributes = CRM_Core_DAO::getAttribute ('CRM_Contribute_DAO_Contribution ' );
652
+
653
+ // Check permissions for financial type first
654
+ $ financialTypes = CRM_Contribute_PseudoConstant::financialType ();
655
+
656
+ foreach ($ financialTypes as $ finTypeId => $ type ) {
657
+ if (!CRM_Core_Permission::check ('add new contributions of type ' . $ type )) {
658
+ unset($ financialTypes [$ finTypeId ]);
659
+ }
660
+ }
644
661
645
662
$ financialType = $ this ->add ('select ' , 'financial_type_id ' ,
646
663
ts ('Financial Type ' ),
647
- array ('' => ts ('- select - ' )) + CRM_Contribute_PseudoConstant:: financialType () ,
664
+ array ('' => ts ('- select - ' )) + $ financialTypes ,
648
665
TRUE ,
649
666
array ('onChange ' => "CRM.buildCustomData( 'Contribution', this.value ); " )
650
667
);
668
+
651
669
$ paymentInstrument = FALSE ;
652
670
if (!$ this ->_mode ) {
653
671
$ paymentInstrument = $ this ->add ('select ' , 'payment_instrument_id ' ,
0 commit comments