<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
/**
* Class constructor
*/
- function __construct() {
+ public function __construct() {
parent::__construct();
}
/**
* 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
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the flattened values.
*
* @return object CRM_Core_DAO_Tag object on success, otherwise null
- * @access public
* @static
*/
- static function retrieve(&$params, &$defaults) {
+ public static function retrieve(&$params, &$defaults) {
$tag = new CRM_Core_DAO_Tag();
$tag->copyValues($params);
if ($tag->find(TRUE)) {
*
* @return mixed
*/
- function getTree($usedFor = NULL, $excludeHidden = FALSE) {
+ public function getTree($usedFor = NULL, $excludeHidden = FALSE) {
if (!isset($this->tree)) {
$this->buildTree($usedFor, $excludeHidden);
}
* @param null $usedFor
* @param bool $excludeHidden
*/
- function buildTree($usedFor = NULL, $excludeHidden = FALSE) {
+ public function buildTree($usedFor = NULL, $excludeHidden = FALSE) {
$sql = "SELECT id, parent_id, name, description, is_selectable FROM civicrm_tag";
$whereClause = array();
*
* @return array
*/
- static function getTagsUsedFor($usedFor = array('civicrm_contact'),
+ public static function getTagsUsedFor($usedFor = array(
+ 'civicrm_contact'),
$buildSelect = TRUE,
- $all = FALSE,
- $parentId = NULL
+ $all = FALSE,
+ $parentId = NULL
) {
$tags = array();
/**
* Function to retrieve tags
*
- * @param string $usedFor which type of tag entity
- * @param array $tags tags array
- * @param int $parentId parent id if you want need only children
- * @param string $separator separator to indicate children
- * @param boolean $formatSelectable add special property for non-selectable
+ * @param string $usedFor
+ * Which type of tag entity.
+ * @param array $tags
+ * Tags array.
+ * @param int $parentId
+ * Parent id if you want need only children.
+ * @param string $separator
+ * Separator to indicate children.
+ * @param bool $formatSelectable
+ * Add special property for non-selectable.
* tag, so they cannot be selected
*
* @return array
*/
- static function getTags($usedFor = 'civicrm_contact',
+ static function getTags(
+ $usedFor = 'civicrm_contact',
&$tags = array(),
- $parentId = NULL,
+ $parentId = NULL,
$separator = ' ',
$formatSelectable = FALSE
) {
$formattedTags = array();
foreach ($tags as $key => $tag) {
if (!empty($tag[2])) {
- $key = $tag[2]. "-" . $key;
+ $key = $tag[2] . "-" . $key;
}
$formattedTags[$key] = $tag[0] . $tag[1];
}
/**
* Delete the tag
*
- * @param int $id tag id
+ * @param int $id
+ * Tag id.
*
* @return boolean
- * @access public
* @static
*
*/
- static function del($id) {
+ public static function del($id) {
// since this is a destructive operation, lets make sure
// id is a postive number
CRM_Utils_Type::validate($id, 'Positive');
* contact object. the params array could contain additional unused name/value
* pairs
*
- * @param array $params (reference) an assoc array of name/value pairs
- * @param array $ids (optional) the array that holds all the db ids - we are moving away from this in bao
+ * @param array $params
+ * (reference) an assoc array of name/value pairs.
+ * @param array $ids
+ * (optional) the array that holds all the db ids - we are moving away from this in bao.
* signatures
*
* @return object CRM_Core_DAO_Tag object on success, otherwise null
- * @access public
* @static
*/
- static function add(&$params, $ids = array()) {
+ public static function add(&$params, $ids = array()) {
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('tag', $ids));
if (!$id && !self::dataExists($params)) {
return NULL;
// if we modify parent tag, then we need to update all children
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'),
+ array(
+ 1 => array($params['used_for'], 'String'),
2 => array($tag->id, 'Integer'),
)
);
/**
* Check if there is data to create the object
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
* @return boolean
- * @access public
* @static
*/
- static function dataExists(&$params) {
+ public static function dataExists(&$params) {
// 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') {
/**
* Get the tag sets for a entity object
*
- * @param string $entityTable entity_table
+ * @param string $entityTable
+ * Entity_table.
*
* @return array $tagSets array of tag sets
- * @access public
* @static
*/
- static function getTagSet($entityTable) {
+ 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";
/**
* Get the tags that are not children of a tagset.
*
- * @return array $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() {
+ public static function getTagsNotInTagset() {
$tags = $tagSets = array();
// first get all the tag sets
$query = "SELECT id FROM civicrm_tag WHERE is_tagset=1 AND parent_id IS NULL";
return $tags;
}
}
-