예제 #1
0
 /**
  * @param $activityTypesXML
  * @param bool $maxInst
  * @param bool $isLabel
  * @param bool $maskAction
  *
  * @return array
  */
 public function activityTypes($activityTypesXML, $maxInst = FALSE, $isLabel = FALSE, $maskAction = FALSE)
 {
     $activityTypes =& $this->allActivityTypes(TRUE, TRUE);
     $result = array();
     foreach ($activityTypesXML as $activityTypeXML) {
         foreach ($activityTypeXML as $recordXML) {
             $activityTypeName = (string) $recordXML->name;
             $maxInstances = (string) $recordXML->max_instances;
             $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes);
             if ($activityTypeInfo['id']) {
                 if ($maskAction) {
                     if ($maskAction == 'edit' && '0' === (string) $recordXML->editable) {
                         $result[$maskAction][] = $activityTypeInfo['id'];
                     }
                 } else {
                     if (!$maxInst) {
                         //if we want,labels of activities should be returned.
                         if ($isLabel) {
                             $result[$activityTypeInfo['id']] = $activityTypeInfo['label'];
                         } else {
                             $result[$activityTypeInfo['id']] = $activityTypeName;
                         }
                     } else {
                         if ($maxInstances) {
                             $result[$activityTypeName] = $maxInstances;
                         }
                     }
                 }
             }
         }
     }
     // call option value hook
     CRM_Utils_Hook::optionValues($result, 'case_activity_type');
     return $result;
 }
예제 #2
0
파일: OptionGroup.php 프로젝트: kidaa30/yes
 /**
  * This function retrieves all the values for the specific option group by name
  * this is primarily used to create various html based form elements
  * (radio, select, checkbox etc). OptionGroups for most cases have the
  * 'label' in the label colum and the 'id' or 'name' in the value column
  *
  * @param string $name
  *   name of the option group.
  * @param bool $flip
  *   results are return in id => label format if false.
  *                            if true, the results are reversed
  * @param bool $grouping
  *   if true, return the value in 'grouping' column.
  * @param bool $localize
  *   if true, localize the results before returning.
  * @param string $condition
  *   add another condition to the sql query.
  * @param string $labelColumnName
  *   the column to use for 'label'.
  * @param bool $onlyActive
  *   return only the action option values.
  * @param bool $fresh
  *   ignore cache entries and go back to DB.
  * @param string $keyColumnName
  *   the column to use for 'key'.
  *
  * @return array
  *   the values as specified by the above params
  * @void
  */
 public static function &values($name, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $condition = NULL, $labelColumnName = 'label', $onlyActive = TRUE, $fresh = FALSE, $keyColumnName = 'value')
 {
     $cache = CRM_Utils_Cache::singleton();
     $cacheKey = self::createCacheKey($name, $flip, $grouping, $localize, $condition, $labelColumnName, $onlyActive, $keyColumnName);
     if (!$fresh) {
         // Fetch from static var
         if (array_key_exists($cacheKey, self::$_cache)) {
             return self::$_cache[$cacheKey];
         }
         // Fetch from main cache
         $var = $cache->get($cacheKey);
         if ($var) {
             return $var;
         }
     }
     $query = "\nSELECT  v.{$labelColumnName} as {$labelColumnName} ,v.{$keyColumnName} as value, v.grouping as grouping\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  v.option_group_id = g.id\n  AND  g.name            = %1\n  AND  g.is_active       = 1 ";
     if ($onlyActive) {
         $query .= " AND  v.is_active = 1 ";
     }
     if (in_array($name, self::$_domainIDGroups)) {
         $query .= " AND v.domain_id = " . CRM_Core_Config::domainID();
     }
     if ($condition) {
         $query .= $condition;
     }
     $query .= " ORDER BY v.weight";
     $p = array(1 => array($name, 'String'));
     $dao = CRM_Core_DAO::executeQuery($query, $p);
     $var = self::valuesCommon($dao, $flip, $grouping, $localize, $labelColumnName);
     // call option value hook
     CRM_Utils_Hook::optionValues($var, $name);
     self::$_cache[$cacheKey] = $var;
     $cache->set($cacheKey, $var);
     return $var;
 }
예제 #3
0
 static function &values($name, $flip = false, $grouping = false, $localize = false, $condition = null, $valueColumnName = 'label', $onlyActive = true)
 {
     $cacheKey = "CRM_OG_{$name}_{$flip}_{$grouping}_{$localize}_{$condition}_{$valueColumnName}_{$onlyActive}";
     $cache =& CRM_Utils_Cache::singleton();
     $var = $cache->get($cacheKey);
     if ($var) {
         return $var;
     }
     $query = "\nSELECT  v.{$valueColumnName} as {$valueColumnName} ,v.value as value, v.grouping as grouping\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  v.option_group_id = g.id\n  AND  g.name            = %1\n  AND  g.is_active       = 1 ";
     if ($onlyActive) {
         $query .= " AND  v.is_active = 1 ";
     }
     if (in_array($name, self::$_domainIDGroups)) {
         $query .= " AND v.domain_id = " . CRM_Core_Config::domainID();
     }
     if ($condition) {
         $query .= $condition;
     }
     $query .= "  ORDER BY v.weight";
     $p = array(1 => array($name, 'String'));
     $dao =& CRM_Core_DAO::executeQuery($query, $p);
     $var =& self::valuesCommon($dao, $flip, $grouping, $localize, $valueColumnName);
     $cache->set($cacheKey, $var);
     // call option value hook
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::optionValues($var, $name);
     return $var;
 }