X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FTag.php;h=2aa097f503290c6ceed37efaa1069bfccf616315;hb=3838662faff56daff7b4fbbd25c60a4b7242a484;hp=3689539a98ff865e4d2ee6dcc1609efa47dcae2d;hpb=a055fd3bcb8341e6a9c25e32432cf4f4776a2781;p=civicrm-core.git diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index 3689539a98..2aa097f503 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -1,9 +1,9 @@ tree)) { $this->buildTree($usedFor, $excludeHidden); @@ -72,6 +78,10 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { return $this->tree; } + /** + * @param null $usedFor + * @param bool $excludeHidden + */ function buildTree($usedFor = NULL, $excludeHidden = FALSE) { $sql = "SELECT civicrm_tag.id, civicrm_tag.parent_id,civicrm_tag.name FROM civicrm_tag "; @@ -129,6 +139,14 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } } + /** + * @param array $usedFor + * @param bool $buildSelect + * @param bool $all + * @param null $parentId + * + * @return array + */ static function getTagsUsedFor($usedFor = array('civicrm_contact'), $buildSelect = TRUE, $all = FALSE, @@ -182,6 +200,14 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { return $tags; } + /** + * @param string $usedFor + * @param array $tags + * @param null $parentId + * @param string $separator + * + * @return array + */ static function getTags($usedFor = 'civicrm_contact', &$tags = array(), $parentId = NULL, @@ -314,7 +340,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { $tag = new CRM_Core_DAO_Tag(); // if parent id is set then inherit used for and is hidden properties - if (CRM_Utils_Array::value('parent_id', $params)) { + if (!empty($params['parent_id'])) { // get parent details $params['used_for'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $params['parent_id'], 'used_for'); } @@ -356,7 +382,9 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * @static */ static function dataExists(&$params) { - if (!empty($params['name'])) { + // Disallow empty values except for the number zero. + // TODO: create a utility for this since it's needed in many places + if (!empty($params['name']) || (string) $params['name'] === '0') { return TRUE; } @@ -387,8 +415,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { /** * Function to get the tags that are not children of a tagset. * - * @return $tags associated array of tag name and id - * @access public + * @return array $tags associated array of tag name and id@access public * @static */ static function getTagsNotInTagset() {