X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FTag.php;h=5370623883002d9a715c6f16d014583ce3309d9e;hb=5d867d83ac582e4c45417c82610d569100d6da43;hp=e6d1efdf7d15a7219d22b7925866d2cb2e38279e;hpb=a6c01b45f0cdaee8677de72b8bf3e784d8b6b62a;p=civicrm-core.git diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index e6d1efdf7d..5370623883 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -35,14 +35,14 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { /** - * Class constructor + * Class constructor. */ public function __construct() { parent::__construct(); } /** - * 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. @@ -51,7 +51,6 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * * @return object * CRM_Core_DAO_Tag object on success, otherwise null - * @static */ public static function retrieve(&$params, &$defaults) { $tag = new CRM_Core_DAO_Tag(); @@ -127,8 +126,8 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * * @return array */ - public static function getTagsUsedFor($usedFor = array( - 'civicrm_contact'), + public static function getTagsUsedFor( + $usedFor = array('civicrm_contact'), $buildSelect = TRUE, $all = FALSE, $parentId = NULL @@ -182,7 +181,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } /** - * Function to retrieve tags + * Function to retrieve tags. * * @param string $usedFor * Which type of tag entity. @@ -198,7 +197,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * * @return array */ - static function getTags( + public static function getTags( $usedFor = 'civicrm_contact', &$tags = array(), $parentId = NULL, @@ -247,7 +246,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 'prefix' => '', 'name' => $dao->name, 'idPrefix' => $idPrefix, - ); + ); } else { $rows[] = array( @@ -256,7 +255,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 'name' => $dao->name, 'parent_id' => $dao->parent_id, 'idPrefix' => $idPrefix, - ); + ); } } @@ -267,14 +266,14 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // iterate through because we must modify the unplaced nodes list // during the loop. while (count($roots)) { - $new_roots = array(); - $current_rows = $rows; - $root = array_shift($roots); + $new_roots = array(); + $current_rows = $rows; + $root = array_shift($roots); $tags[$root['id']] = array( $root['prefix'], $root['name'], $root['idPrefix'], - ); + ); // As you find the children, append them to the end of the new set // of roots (maintain alphabetical ordering). Also remove the node @@ -287,7 +286,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 'prefix' => $tags[$root['id']][0] . $separator, 'name' => $row['name'], 'idPrefix' => $row['idPrefix'], - ); + ); unset($rows[$key]); } } @@ -315,14 +314,12 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } /** - * Delete the tag + * Delete the tag. * * @param int $id * Tag id. * - * @return boolean - * @static - * + * @return bool */ public static function del($id) { // since this is a destructive operation, lets make sure @@ -348,7 +345,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } /** - * Takes an associative array and creates a contact object + * Takes an associative array and creates a contact object. * * The function extract all the params it needs to initialize the create a * contact object. the params array could contain additional unused name/value @@ -362,7 +359,6 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * * @return object * CRM_Core_DAO_Tag object on success, otherwise null - * @static */ public static function add(&$params, $ids = array()) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('tag', $ids)); @@ -385,8 +381,8 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // save creator id and time if (!$tag->id) { - $session = CRM_Core_Session::singleton(); - $tag->created_id = $session->get('userID'); + $session = CRM_Core_Session::singleton(); + $tag->created_id = $session->get('userID'); $tag->created_date = date('YmdHis'); } @@ -397,7 +393,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { if ($tag->parent_id === 'null') { CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET used_for=%1 WHERE parent_id = %2", array( - 1 => array($params['used_for'], 'String'), + 1 => array($params['used_for'], 'String'), 2 => array($tag->id, 'Integer'), ) ); @@ -407,13 +403,12 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } /** - * Check if there is data to create the object + * Check if there is data to create the object. * * @param array $params * (reference ) an assoc array of name/value pairs. * - * @return boolean - * @static + * @return bool */ public static function dataExists(&$params) { // Disallow empty values except for the number zero. @@ -426,20 +421,24 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { } /** - * Get the tag sets for a entity object + * Get the tag sets for a entity object. * * @param string $entityTable * Entity_table. * * @return array * array of tag sets - * @static */ public static function getTagSet($entityTable) { $tagSets = array(); $query = "SELECT name, id FROM civicrm_tag WHERE is_tagset=1 AND parent_id IS NULL and used_for LIKE %1"; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('%' . $entityTable . '%', 'String')), TRUE, NULL, FALSE, FALSE); + $dao = CRM_Core_DAO::executeQuery($query, array( + 1 => array( + '%' . $entityTable . '%', + 'String', + ), + ), TRUE, NULL, FALSE, FALSE); while ($dao->fetch()) { $tagSets[$dao->id] = $dao->name; } @@ -452,8 +451,6 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * * @return array * associated array of tag name and id - * @access public - * @static */ public static function getTagsNotInTagset() { $tags = $tagSets = array(); @@ -478,4 +475,5 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { return $tags; } + }