本文整理汇总了PHP中CRM_Financial_BAO_FinancialType::permissionedFinancialTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialType::permissionedFinancialTypes方法的具体用法?PHP CRM_Financial_BAO_FinancialType::permissionedFinancialTypes怎么用?PHP CRM_Financial_BAO_FinancialType::permissionedFinancialTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Financial_BAO_FinancialType
的用法示例。
在下文中一共展示了CRM_Financial_BAO_FinancialType::permissionedFinancialTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assembleBasicPermissions
/**
* @param bool $all
* @param bool $descriptions
* whether to return descriptions
*
* @return array
*/
public static function assembleBasicPermissions($all = FALSE, $descriptions = FALSE)
{
$config = CRM_Core_Config::singleton();
$prefix = ts('CiviCRM') . ': ';
$permissions = self::getCorePermissions($descriptions);
if (self::isMultisiteEnabled()) {
$permissions['administer Multiple Organizations'] = array($prefix . ts('administer Multiple Organizations'));
}
if (!$descriptions) {
foreach ($permissions as $name => $attr) {
$permissions[$name] = array_shift($attr);
}
}
if (!$all) {
$components = CRM_Core_Component::getEnabledComponents();
} else {
$components = CRM_Core_Component::getComponents();
}
foreach ($components as $comp) {
$perm = $comp->getPermissions(FALSE, $descriptions);
if ($perm) {
$info = $comp->getInfo();
foreach ($perm as $p => $attr) {
if (!is_array($attr)) {
$attr = array($attr);
}
$attr[0] = $info['translatedName'] . ': ' . $attr[0];
if ($descriptions) {
$permissions[$p] = $attr;
} else {
$permissions[$p] = $attr[0];
}
}
}
}
// Add any permissions defined in hook_civicrm_permission implementations.
$module_permissions = $config->userPermissionClass->getAllModulePermissions($descriptions);
$permissions = array_merge($permissions, $module_permissions);
CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions, $descriptions);
return $permissions;
}
示例2: testPermissionedFinancialTypes
/**
* Check method testPermissionedFinancialTypes()
*/
public function testPermissionedFinancialTypes()
{
// First get all core permissions
$permissions = $checkPerms = CRM_Core_Permission::getCorePermissions();
$this->setACL();
CRM_Financial_BAO_FinancialType::permissionedFinancialTypes($permissions, TRUE);
$financialTypes = CRM_Contribute_PseudoConstant::financialType();
$prefix = ts('CiviCRM') . ': ';
$actions = array('add', 'view', 'edit', 'delete');
foreach ($financialTypes as $id => $type) {
foreach ($actions as $action) {
$checkPerms[$action . ' contributions of type ' . $type] = array($prefix . ts($action . ' contributions of type ') . $type, ts(ucfirst($action) . ' contributions of type ') . $type);
}
}
$checkPerms['administer CiviCRM Financial Types'] = array($prefix . ts('administer CiviCRM Financial Types'), ts('Administer access to Financial Types'));
$this->assertEquals($permissions, $checkPerms, 'Verify that permissions for each financial type have been added');
}