/**
  * Load/require all files related to an entity.
  *
  * This should not normally be called because it's does a file-system scan; it's
  * only appropriate when introspection is really required (eg for "getActions").
  *
  * @param string $entity
  *   API entity name.
  * @param int $version
  *   API version.
  */
 protected function loadEntity($entity, $version)
 {
     $camelName = _civicrm_api_get_camel_name($entity, $version);
     // Check for master entity file; to match _civicrm_api_resolve(), only load the first one
     $stdFile = 'api/v' . $version . '/' . $camelName . '.php';
     if (\CRM_Utils_File::isIncludable($stdFile)) {
         require_once $stdFile;
     }
     // Check for standalone action files; to match _civicrm_api_resolve(), only load the first one
     $loaded_files = array();
     // array($relativeFilePath => TRUE)
     $include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
     foreach ($include_dirs as $include_dir) {
         foreach (array($camelName, 'Generic') as $name) {
             $action_dir = implode(DIRECTORY_SEPARATOR, array($include_dir, 'api', "v{$version}", $name));
             if (!is_dir($action_dir)) {
                 continue;
             }
             $iterator = new \DirectoryIterator($action_dir);
             foreach ($iterator as $fileinfo) {
                 $file = $fileinfo->getFilename();
                 if (array_key_exists($file, $loaded_files)) {
                     continue;
                     // action provided by an earlier item on include_path
                 }
                 $parts = explode(".", $file);
                 if (end($parts) == "php" && !preg_match('/Tests?\\.php$/', $file)) {
                     require_once $action_dir . DIRECTORY_SEPARATOR . $file;
                     $loaded_files[$file] = TRUE;
                 }
             }
         }
     }
 }
 /**
  * Return a set of SQL queries whose cummulative weights will mark matched
  * records for the RuleGroup::threasholdQuery() to retrieve.
  */
 public function tableQuery()
 {
     // make sure we've got a fetched dbrecord, not sure if this is enforced
     if (!$this->name == NULL || $this->is_reserved == NULL) {
         $this->find(TRUE);
     }
     // Reserved Rule Groups can optionally get special treatment by
     // implementing an optimization class and returning a query array.
     if ($this->is_reserved && CRM_Utils_File::isIncludable("CRM/Dedupe/BAO/QueryBuilder/{$this->name}.php")) {
         include_once "CRM/Dedupe/BAO/QueryBuilder/{$this->name}.php";
         $class = "CRM_Dedupe_BAO_QueryBuilder_{$this->name}";
         $command = empty($this->params) ? 'internal' : 'record';
         $queries = call_user_func(array($class, $command), $this);
     } else {
         // All other rule groups have queries generated by the member dedupe
         // rules defined in the administrative interface.
         // Find all rules contained by this script sorted by weight so that
         // their execution can be short circuited on RuleGroup::fillTable()
         $bao = new CRM_Dedupe_BAO_Rule();
         $bao->dedupe_rule_group_id = $this->id;
         $bao->orderBy('rule_weight DESC');
         $bao->find();
         // Generate a SQL query for each rule in the rule group that is
         // tailored to respect the param and contactId options provided.
         $queries = array();
         while ($bao->fetch()) {
             $bao->contactIds = $this->contactIds;
             $bao->params = $this->params;
             // Skipping empty rules? Empty rules shouldn't exist; why check?
             if ($query = $bao->sql()) {
                 $queries["{$bao->rule_table}.{$bao->rule_field}.{$bao->rule_weight}"] = $query;
             }
         }
     }
     // if there are no rules in this rule group
     // add an empty query fulfilling the pattern
     if (!$queries) {
         $queries = array('SELECT 0 id1, 0 id2, 0 weight LIMIT 0');
         $this->noRules = TRUE;
     }
     return $queries;
 }
  /**
   * @return string
   */
  function getTemplateFileName() {
    $defaultTpl = parent::getTemplateFileName();

    if (in_array($this->_outputMode, array('print', 'pdf'))) {
      if ($this->_params['templates']) {
        $defaultTpl = 'CRM/Extendedreport/Form/Report/CustomTemplates/' . $this->_params['templates'] . '.tpl';
      }
    }

    if (!CRM_Utils_File::isIncludable('templates/' . $defaultTpl)) {
      $defaultTpl = 'CRM/Report/Form.tpl';
    }
    if (CRM_Utils_Array::value('templates', $this->_params) == 1) {
      //
    }
    return $defaultTpl;
  }
Exemple #4
0
/**
 * Check if the function is deprecated.
 *
 * @param string $entity
 * @param array $result
 *
 * @return string|array|null
 */
function _civicrm_api3_deprecation_check($entity, $result = array())
{
    if ($entity) {
        $apiFile = "api/v3/{$entity}.php";
        if (CRM_Utils_File::isIncludable($apiFile)) {
            require_once $apiFile;
        }
        $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity);
        $fnName = "_civicrm_api3_{$lowercase_entity}_deprecation";
        if (function_exists($fnName)) {
            return $fnName($result);
        }
    }
}
 /**
  * @param $class
  */
 public function loadClass($class)
 {
     if ((0 === strncmp($class, 'CRM_', 4) || 0 === strncmp($class, 'api_v3_', 7) || 0 === strncmp($class, 'WebTest_', 8) || 0 === strncmp($class, 'E2E_', 4)) && FALSE === strpos($class, '\\')) {
         $file = strtr($class, '_', '/') . '.php';
         // There is some question about the best way to do this.
         // "require_once" is nice because it's simple and throws
         // intelligible errors.
         if (FALSE != stream_resolve_include_path($file)) {
             require_once $file;
         }
     } elseif (in_array($class, $this->civiTestClasses)) {
         $file = "tests/phpunit/CiviTest/{$class}.php";
         if (FALSE != stream_resolve_include_path($file)) {
             require_once $file;
         }
     } elseif ($class === 'CiviSeleniumSettings') {
         if (!empty($GLOBALS['_CV'])) {
             require_once 'tests/phpunit/CiviTest/CiviSeleniumSettings.auto.php';
         } elseif (CRM_Utils_File::isIncludable('tests/phpunit/CiviTest/CiviSeleniumSettings.php')) {
             require_once 'tests/phpunit/CiviTest/CiviSeleniumSettings.php';
         }
     }
 }
 /**
  * @param bool $force
  *
  * @return array
  * @throws Exception
  */
 public static function &getComponents($force = FALSE)
 {
     if (!isset(Civi::$statics[__CLASS__]['all']) || $force) {
         Civi::$statics[__CLASS__]['all'] = array();
         $cr = new CRM_Core_DAO_Component();
         $cr->find(FALSE);
         while ($cr->fetch()) {
             $infoClass = $cr->namespace . '_' . self::COMPONENT_INFO_CLASS;
             $infoClassFile = str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php';
             if (!CRM_Utils_File::isIncludable($infoClassFile)) {
                 continue;
             }
             require_once $infoClassFile;
             $infoObject = new $infoClass($cr->name, $cr->namespace, $cr->id);
             if ($infoObject->info['name'] !== $cr->name) {
                 CRM_Core_Error::fatal("There is a discrepancy between name in component registry and in info file ({$cr->name}).");
             }
             Civi::$statics[__CLASS__]['all'][$cr->name] = $infoObject;
             unset($infoObject);
         }
     }
     return Civi::$statics[__CLASS__]['all'];
 }
Exemple #7
0
/**
 * Load/require all files related to an entity.
 *
 * This should not normally be called because it's does a file-system scan; it's
 * only appropriate when introspection is really required (eg for "getActions").
 *
 * @param string $entity
 * @param int $version
 *
 * @return void
 */
function _civicrm_api_loadEntity($entity, $version = 3)
{
    /*
    $apiRequest = array();
    $apiRequest['entity'] = $entity;
    $apiRequest['action'] = 'pretty sure it will never exist. Trick to [try to] force resolve to scan everywhere';
    $apiRequest['version'] = $version;
    // look up function, file, is_generic
    $apiRequest = _civicrm_api_resolve($apiRequest);
    */
    $camelName = _civicrm_api_get_camel_name($entity, $version);
    // Check for master entity file; to match _civicrm_api_resolve(), only load the first one
    $stdFile = 'api/v' . $version . '/' . $camelName . '.php';
    if (CRM_Utils_File::isIncludable($stdFile)) {
        require_once $stdFile;
    }
    // Check for standalone action files; to match _civicrm_api_resolve(), only load the first one
    $loaded_files = array();
    // array($relativeFilePath => TRUE)
    $include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
    foreach ($include_dirs as $include_dir) {
        $action_dir = implode(DIRECTORY_SEPARATOR, array($include_dir, 'api', "v{$version}", $camelName));
        if (!is_dir($action_dir)) {
            continue;
        }
        $iterator = new DirectoryIterator($action_dir);
        foreach ($iterator as $fileinfo) {
            $file = $fileinfo->getFilename();
            if (array_key_exists($file, $loaded_files)) {
                continue;
                // action provided by an earlier item on include_path
            }
            $parts = explode(".", $file);
            if (end($parts) == "php" && !preg_match('/Tests?\\.php$/', $file)) {
                require_once $action_dir . DIRECTORY_SEPARATOR . $file;
                $loaded_files[$file] = TRUE;
            }
        }
    }
}