Skip to content

Commit

Permalink
Merge pull request civicrm#8 from Edzelopez/CIVI-28
Browse files Browse the repository at this point in the history
CIVI-28 Bug fixes and modifications
  • Loading branch information
Edzelopez committed Mar 17, 2015
2 parents 6a1ec96 + a595568 commit d6bf0ff
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CRM/Contribute/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,9 @@ public static function buildSearchForm(&$form) {
);

// CRM-13848
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'view');
$form->addSelect('financial_type_id',
array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search')
array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => $financialTypes)
);

$form->add('select', 'contribution_page_id',
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public function buildQuickForm() {
$attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution');

// Check permissions for financial type first
CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes);
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add');

$financialType = $this->add('select', 'financial_type_id',
ts('Financial Type'),
Expand Down
10 changes: 3 additions & 7 deletions CRM/Contribute/Form/ContributionPage/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,12 @@ public function buildQuickForm() {

// financial Type
if (CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
$this->addSelect('financial_type_id', array(), TRUE);
$this->addSelect('financial_type_id', array('context' => 'search'), TRUE);
}
else {
CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes);
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add');

$financialType = $this->add('select', 'financial_type_id',
ts('Financial Type'),
array('' => ts('- select -')) + $financialTypes,
TRUE
);
$this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes), TRUE);
}

// name
Expand Down
5 changes: 4 additions & 1 deletion CRM/Event/Form/EventFees.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,13 @@ public static function buildQuickForm(&$form) {
$form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL,
array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);")
);

// Check permissions for financial type first
CRM_Financial_BAO_FinancialType::addFinancialTypes($financialTypes);

$form->add('select', 'financial_type_id',
ts('Financial Type'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
array('' => ts('- select -')) + $financialTypes
);

$form->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate'));
Expand Down
8 changes: 3 additions & 5 deletions CRM/Event/Form/ManageEvent/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,9 @@ public function buildQuickForm() {
if (CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
$this->addSelect('financial_type_id');
}
else {
$financialType = $this->add('select', 'financial_type_id',
ts('Financial Type'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType()
);
else {
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, 'add');
$this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes));
}
// add pay later options
$this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL,
Expand Down
6 changes: 3 additions & 3 deletions CRM/Financial/BAO/FinancialType.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ public static function permissionedFinancialTypes(&$permissions) {
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$prefix = ts('CiviCRM') . ': ';
foreach ($financialTypes as $id => $type) {
$permissions['add new contributions of type ' . $type] = $prefix . ts('add new contributions of type ' . $type);
$permissions['add contributions of type ' . $type] = $prefix . ts('add contributions of type ' . $type);
$permissions['view contributions of type ' . $type] = $prefix . ts('view contributions of type ' . $type);
$permissions['edit contributions of type ' . $type] = $prefix . ts('edit contributions of type ' . $type);
$permissions['delete contributions of type ' . $type] = $prefix . ts('delete contributions of type ' . $type);
}
$permissions['administer CiviCRM Financial Types'] = $prefix . ts('administer CiviCRM Financial Types');
}

public static function addFinancialTypes(&$financialTypes) {
public static function getAvailableFinancialTypes(&$financialTypes, $action) {
$financialTypes = CRM_Contribute_PseudoConstant::financialType();

foreach ($financialTypes as $finTypeId => $type) {
if (!CRM_Core_Permission::check('add new contributions of type ' . $type)) {
if (!CRM_Core_Permission::check($action . ' contributions of type ' . $type)) {
unset($financialTypes[$finTypeId]);
}
}
Expand Down

0 comments on commit d6bf0ff

Please sign in to comment.