/**
 * This function returns the permissions defined by the volunteer extension.
 *
 * @param array $params
 *   Not presently used.
 * @return array
 */
function civicrm_api3_volunteer_util_getperms($params)
{
    $results = array();
    foreach (CRM_Volunteer_Permission::getVolunteerPermissions() as $k => $v) {
        $results[] = array('description' => $v[1], 'label' => $v[0], 'name' => $k, 'safe_name' => strtolower(str_replace(array(' ', '-'), '_', $k)));
    }
    return civicrm_api3_create_success($results, "VolunteerUtil", "getperms", $params);
}
 /**
  * Given a permission string or array, check for access requirements. For
  * VOL-71, if this is a permissions-challenged Joomla instance, don't enforce
  * CiviVolunteer-defined permissions.
  *
  * @param mixed $permissions The permission(s) to check as an array or string.
  *        See parent class for examples.
  * @return boolean
  */
 public static function check($permissions)
 {
     $permissions = (array) $permissions;
     if (!CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()) {
         array_walk_recursive($permissions, function (&$v, $k) {
             if (array_key_exists($v, CRM_Volunteer_Permission::getVolunteerPermissions())) {
                 $v = CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION;
             }
         });
     }
     return parent::check($permissions);
 }
 /**
  * Given a permission string or array, check for access requirements.
  *
  * @param mixed $permissions
  *   The permission(s) to check as an array or string. See parent class for examples.
  * @return boolean
  */
 public static function check($permissions)
 {
     $permissions = (array) $permissions;
     $isModulePermissionSupported = CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported();
     array_walk_recursive($permissions, function (&$v, $k) use($isModulePermissionSupported) {
         // For VOL-71, if this is a permissions-challenged Joomla instance, don't
         // enforce CiviVolunteer-defined permissions.
         if (!$isModulePermissionSupported) {
             if (array_key_exists($v, CRM_Volunteer_Permission::getVolunteerPermissions())) {
                 $v = CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION;
             }
         }
         // Ensure that checks for "edit own" pass if user has "edit all."
         if ($v === 'edit own volunteer projects' && self::check('edit all volunteer projects')) {
             $v = CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION;
         }
     });
     return parent::check($permissions);
 }
function volunteer_civicrm_angularModules(&$angularModule)
{
    $angularModule['volunteer'] = array('ext' => 'org.civicrm.volunteer', 'js' => array(0 => 'ang/volunteer.js', 1 => 'ang/volunteer/*.js', 2 => 'ang/volunteer/*/*.js'), 'css' => array(0 => 'ang/volunteer.css'), 'partials' => array(0 => 'ang/volunteer'), 'settings' => array(), 'volunteer' => true);
    // Perhaps the placement of this code is a little hackish; unless/until we
    // extend Civi\Angular\Page\Main, there doesn't appear to be a better
    // alternative. This populates CRM.permissions on the client side.
    CRM_Core_Resources::singleton()->addPermissions(array_keys(CRM_Volunteer_Permission::getVolunteerPermissions()))->addVars('org.civicrm.volunteer', array('currentContactId' => CRM_Core_Session::singleton()->getLoggedInContactID()));
}
/**
 * Implementation of hook_civicrm_permission.
 *
 * @param array $permissions Does not contain core perms -- only extension-defined perms.
 */
function volunteer_civicrm_permission(array &$permissions)
{
    // VOL-71: Until the Joomla/Civi integration is fixed, don't declare new perms
    // for Joomla installs
    if (CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()) {
        $permissions = array_merge($permissions, CRM_Volunteer_Permission::getVolunteerPermissions());
    }
}