Ejemplo n.º 1
0
 /**
  * Get all the mailing components of a particular type.
  *
  * @param $type
  *   The type of component needed.
  *
  * @return array
  *   array reference of all mailing components
  */
 public static function &component($type = NULL)
 {
     $name = $type ? $type : 'ALL';
     if (!self::$component || !array_key_exists($name, self::$component)) {
         if (!self::$component) {
             self::$component = array();
         }
         if (!$type) {
             self::$component[$name] = NULL;
             CRM_Core_PseudoConstant::populate(self::$component[$name], 'CRM_Mailing_DAO_Component');
         } else {
             // we need to add an additional filter for $type
             self::$component[$name] = array();
             $object = new CRM_Mailing_DAO_Component();
             $object->component_type = $type;
             $object->selectAdd();
             $object->selectAdd("id, name");
             $object->orderBy('component_type, is_default, name');
             $object->is_active = 1;
             $object->find();
             while ($object->fetch()) {
                 self::$component[$name][$object->id] = $object->name;
             }
         }
     }
     return self::$component[$name];
 }