| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType {
/**
- * Fetch object based on array of properties
+ * Fetch object based on array of properties.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
- * @return CRM_Contact_BAO_ContactType object on success, null otherwise
- * @static
+ * @return CRM_Contact_BAO_ContactType|null
+ * object on success, null otherwise
*/
public static function retrieve(&$params, &$defaults) {
$contactType = new CRM_Contact_DAO_ContactType();
*
* @param bool $all
*
- * @return array of basic contact types information.
- * @static
+ * @return array
+ * Array of basic contact types information.
*/
public static function &basicTypeInfo($all = FALSE) {
static $_cache = NULL;
*
* @param bool $all
*
- * @return array of basic contact types
- * @static
+ * @return array
+ * Array of basic contact types
*/
public static function basicTypes($all = FALSE) {
return array_keys(self::basicTypeInfo($all));
* @param bool $ignoreCache
* @param bool $reset
*
- * @return array of sub type information
- * @static
+ * @return array
+ * Array of sub type information
*/
public static function &subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCache = FALSE, $reset = FALSE) {
static $_cache = NULL;
* @param string $columnName
* @param bool $ignoreCache
*
- * @return array of all subtypes OR list of subtypes associated to
- * a given basic contact type
- * @static
+ * @return array
+ * all subtypes OR list of subtypes associated to
+ * a given basic contact type
*/
public static function subTypes($contactType = NULL, $all = FALSE, $columnName = 'name', $ignoreCache = FALSE) {
if ($columnName == 'name') {
* retrieve subtype pairs with name as 'subtype-name' and 'label' as value
*
* @param array $contactType
- * ..
* @param bool $all
* @param string $labelPrefix
* @param bool $ignoreCache
*
- * @return list of subtypes with name as 'subtype-name' and 'label' as value
- * @static
+ * @return array
+ * list of subtypes with name as 'subtype-name' and 'label' as value
*/
public static function subTypePairs($contactType = NULL, $all = FALSE, $labelPrefix = '- ', $ignoreCache = FALSE) {
$subtypes = self::subTypeInfo($contactType, $all, $ignoreCache);
*
* @param bool $all
*
- * @return array of basic types + all subtypes.
- * @static
+ * @return array
+ * Array of basic types + all subtypes.
*/
public static function contactTypes($all = FALSE) {
return array_keys(self::contactTypeInfo($all));
* @param bool $all
* @param bool $reset
*
- * @return array of basic types + all subtypes.
- * @static
+ * @return array
+ * Array of basic types + all subtypes.
*/
public static function contactTypeInfo($all = FALSE, $reset = FALSE) {
static $_cache = NULL;
}
$dao = CRM_Core_DAO::executeQuery($sql,
- CRM_Core_DAO::$_nullArray,
+ array(),
FALSE,
'CRM_Contact_DAO_ContactType'
);
* @param null $typeName
* @param null $delimiter
*
- * @return array of basictypes with name as 'built-in name' and 'label' as value
- * @static
+ * @return array
+ * Array of basictypes with name as 'built-in name' and 'label' as value
*/
public static function contactTypePairs($all = FALSE, $typeName = NULL, $delimiter = NULL) {
$types = self::contactTypeInfo($all);
}
/**
- * Get a list of elements for select box
+ * Get a list of elements for select box.
* Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
* which was not handled well be anything that loaded & resaved the html (outside core)
* The use of this separator is now explicit in the calling functions as a step towards it's removal
*
* @return mixed
*/
- static function getSelectElements(
+ public static function getSelectElements(
$all = FALSE,
$isSeparator = TRUE,
$separator = '__'
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if (!empty($dao->parent_id)) {
- $key = $isSeparator ? $dao->parent_name . $separator . $dao->child_name : $dao->child_name;
+ $key = $isSeparator ? $dao->parent_name . $separator . $dao->child_name : $dao->child_name;
$label = "- {$dao->child_label}";
$pName = $dao->parent_name;
}
else {
- $key = $dao->child_name;
+ $key = $dao->child_name;
$label = $dao->child_label;
$pName = $dao->child_name;
}
}
/**
- * Check if a given type is a subtype
+ * Check if a given type is a subtype.
*
* @param string $subType
* Contact subType.
* @param bool $ignoreCache
*
- * @return boolean true if subType, false otherwise.
- * @static
+ * @return bool
+ * true if subType, false otherwise.
*/
public static function isaSubType($subType, $ignoreCache = FALSE) {
return in_array($subType, self::subTypes(NULL, TRUE, 'name', $ignoreCache));
/**
* Retrieve the basic contact type associated with given subType.
*
- * @param array/string $subType contact subType.
+ * @param array /string $subType contact subType.
* @return array/string of basicTypes.
- * @static
- *
*/
public static function getBasicType($subType) {
static $_cache = NULL;
* Contact subTypes.
* @param bool $ignoreCache
*
- * @return array of suppressed subTypes.
- * @static
+ * @return array
+ * Array of suppressed subTypes.
*/
public static function suppressSubTypes(&$subTypes, $ignoreCache = FALSE) {
$subTypes = array_diff($subTypes, self::subTypes(NULL, TRUE, 'name', $ignoreCache));
* @param bool $ignoreCache
* @param string $columnName
*
- * @return boolean true if contact extends, false otherwise.
- * @static
+ * @return bool
+ * true if contact extends, false otherwise.
*/
public static function isExtendsContactType($subType, $contactType, $ignoreCache = FALSE, $columnName = 'name') {
if (!is_array($subType)) {
}
/**
- * Create shortcuts menu for contactTypes
+ * Create shortcuts menu for contactTypes.
*
- * @return array of contactTypes
- * @static
+ * @return array
+ * of contactTypes
*/
public static function getCreateNewList() {
$shortCuts = array();
}
/**
- * Delete Contact SubTypes
+ * Delete Contact SubTypes.
*
* @param int $contactTypeId
* ID of the Contact Subtype to be deleted.
*
* @return bool
- * @static
*/
public static function del($contactTypeId) {
}
/**
- * Add or update Contact SubTypes
+ * Add or update Contact SubTypes.
*
* @param array $params
* An assoc array of name/value pairs.
*
- * @return object
- * @static
+ * @return object|void
*/
public static function add(&$params) {
// label or name
if (empty($params['id']) && empty($params['label'])) {
- return;
+ return NULL;
}
if (!empty($params['parent_id']) &&
!CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])
) {
- return;
+ return NULL;
}
$contactType = new CRM_Contact_DAO_ContactType();
$contactType->save();
if ($contactType->find(TRUE)) {
$contactName = $contactType->name;
- $contact = ucfirst($contactType->label);
- $active = $contactType->is_active;
+ $contact = ucfirst($contactType->label);
+ $active = $contactType->is_active;
}
if (!empty($params['id'])) {
}
/**
- * Update the is_active flag in the db
+ * Update the is_active flag in the db.
*
* @param int $id
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object DAO object on success, null otherwise
- * @static
+ * @return Object
+ * DAO object on success, null otherwise
*/
public static function setIsActive($id, $is_active) {
$params = array('id' => $id);
* @param string $subType
* Subtype.
*
- * @return boolean true/false.
- * @static
+ * @return bool
*/
public static function isAllowEdit($contactId, $subType = NULL) {
public static function hasRelationships($contactId, $contactType) {
$subTypeClause = NULL;
if (self::isaSubType($contactType)) {
- $subType = $contactType;
- $contactType = self::getBasicType($subType);
+ $subType = $contactType;
+ $contactType = self::getBasicType($subType);
$subTypeClause = " AND ( ( crt.contact_type_a = '{$contactType}' AND crt.contact_sub_type_a = '{$subType}') OR
( crt.contact_type_b = '{$contactType}' AND crt.contact_sub_type_b = '{$subType}') ) ";
}
$customSet = $subTypeClause = array();
foreach ($subtypeSet as $subtype) {
- $subtype = CRM_Utils_Type::escape($subtype, 'String');
- $subType = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR;
+ $subtype = CRM_Utils_Type::escape($subtype, 'String');
+ $subType = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR;
$subTypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%' ";
}
$query = "SELECT table_name
}
/**
- * Function that does something
+ * Function that does something.
* @todo what does this function do?
*
* @param int $contactID
*
* @return bool
*/
- static function deleteCustomSetForSubtypeMigration(
+ public static function deleteCustomSetForSubtypeMigration(
$contactID,
$contactType,
$oldSubtypeSet = array(),
$query = "DELETE FROM {$customTable} WHERE entity_id = %1";
return CRM_Core_DAO::singleValueQuery($query, array(1 => array($entityID, 'Integer')));
}
+
}