/**
 * (Delegated) Implementation of hook_civicrm_caseTypes
 *
 * Find any and return any files matching "xml/case/*.xml"
 *
 * Note: This hook only runs in CiviCRM 4.4+.
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
 */
function _volunteer_civix_civicrm_caseTypes(&$caseTypes)
{
    if (!is_dir(__DIR__ . '/xml/case')) {
        return;
    }
    foreach (_volunteer_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
        $name = preg_replace('/\\.xml$/', '', basename($file));
        if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
            $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
            CRM_Core_Error::fatal($errorMessage);
            // throw new CRM_Core_Exception($errorMessage);
        }
        $caseTypes[$name] = array('module' => 'org.civicrm.volunteer', 'name' => $name, 'file' => $file);
    }
}
Exemplo n.º 2
0
/**
 * Search directory tree for files which match a glob pattern
 *
 * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
 * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
 *
 * @param $dir string, base dir
 * @param $pattern string, glob pattern, eg "*.txt"
 * @return array(string)
 */
function _volunteer_civix_find_files($dir, $pattern)
{
    if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
        return CRM_Utils_File::findFiles($dir, $pattern);
    }
    $todos = array($dir);
    $result = array();
    while (!empty($todos)) {
        $subdir = array_shift($todos);
        foreach (_volunteer_civix_glob("{$subdir}/{$pattern}") as $match) {
            if (!is_dir($match)) {
                $result[] = $match;
            }
        }
        if ($dh = opendir($subdir)) {
            while (FALSE !== ($entry = readdir($dh))) {
                $path = $subdir . DIRECTORY_SEPARATOR . $entry;
                if ($entry[0] == '.') {
                } elseif (is_dir($path)) {
                    $todos[] = $path;
                }
            }
            closedir($dh);
        }
    }
    return $result;
}
/**
* (Delegated) Implements hook_civicrm_angularModules().
*
* Find any and return any files matching "ang/*.ang.php"
*
* Note: This hook only runs in CiviCRM 4.5+.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
*/
function _volunteer_civix_civicrm_angularModules(&$angularModules)
{
    if (!is_dir(__DIR__ . '/ang')) {
        return;
    }
    $files = _volunteer_civix_glob(__DIR__ . '/ang/*.ang.php');
    foreach ($files as $file) {
        $name = preg_replace(':\\.ang\\.php$:', '', basename($file));
        $module = (include $file);
        if (empty($module['ext'])) {
            $module['ext'] = 'org.civicrm.volunteer';
        }
        $angularModules[$name] = $module;
    }
}