| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
private $_alreadyStyled = FALSE;
/**
- * Class constructor
+ * Class constructor.
+ *
+ * @param bool $styleLabels
+ * @param string $styleIndent
*/
public function __construct($styleLabels = FALSE, $styleIndent = " -- ") {
parent::__construct();
$this->_alreadyStyled = FALSE;
}
+ /**
+ * @return mixed
+ */
public function current() {
if ($this->_styleLabels &&
$this->valid() &&
!$this->_alreadyStyled
) {
- $styledGroup = clone($this->_current);
+ $styledGroup = clone($this->_current);
$nestingLevel = $this->getCurrentNestingLevel();
- $indent = '';
+ $indent = '';
while ($nestingLevel--) {
$indent .= $this->_styleIndent;
}
$nextGroup = $this->_getNextSiblingGroup($currentGroup);
if (!$nextGroup) {
// no sibling, find an ancestor w/ a sibling
- for (;; ) {
+ for (;;) {
// since we pop this array everytime, we should be
// reasonably safe from infinite loops, I think :)
$ancestor = array_pop($this->_parentStack);
*/
public function _getNextParentlessGroup(&$group = NULL) {
$lastParentlessGroup = $this->_lastParentlessGroup;
- $nextGroup = new CRM_Contact_BAO_Group();
+ $nextGroup = new CRM_Contact_BAO_Group();
$nextGroup->order_by = 'title ' . self::$_sortOrder;
$nextGroup->find();
if ($group == NULL) {
}
else {
/* if we get here, it could be because we're out of siblings
- * (in which case we return null) or because we're at the
- * top level groups which do not have parents but may still
- * have siblings, so check for that first.
- */
+ * (in which case we return null) or because we're at the
+ * top level groups which do not have parents but may still
+ * have siblings, so check for that first.
+ */
$nextGroup = $this->_getNextParentlessGroup($group);
if ($nextGroup) {
* Adds a new child group identified by $childGroupId to the group
* identified by $groupId
*
- * @param int $parentID id of the group to add the child to
- * @param int $childID id of the new child group
+ * @param int $parentID
+ * Id of the group to add the child to.
+ * @param int $childID
+ * Id of the new child group.
*
*
* @return void
* identified by $groupId; does not delete child group, just the
* association between the two
*
- * @param $parentID The id of the group to remove the child from
- * @param $childID The id of the child group being removed
- *
- * @return void
+ * @param $parentID
+ * The id of the group to remove the child from.
+ * @param $childID
+ * The id of the child group being removed.
*
+ * @return void
*/
public static function remove($parentID, $childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
* identified by $groupId; does not delete child group, just the
* association between the two
*
- * @param int $childID The id of the child group being removed
- *
- * @return void
+ * @param int $childID
+ * The id of the child group being removed.
*
+ * @return void
*/
public static function removeAllParentForChild($childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
* Returns true if the association between parent and child is present,
* false otherwise.
*
- * @param $parentID The parent id of the association
- * @param $childID The child id of the association
- *
- * @return boolean True if association is found, false otherwise.
+ * @param $parentID
+ * The parent id of the association.
+ * @param $childID
+ * The child id of the association.
*
+ * @return bool
+ * True if association is found, false otherwise.
*/
public static function isParentChild($parentID, $childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
* Returns true if if the given groupId has 1 or more child groups,
* false otherwise.
*
- * @param $groupId The id of the group to check for child groups
- *
- * @return boolean True if 1 or more child groups are found, false otherwise.
+ * @param $groupId
+ * The id of the group to check for child groups.
*
+ * @return bool
+ * True if 1 or more child groups are found, false otherwise.
*/
public static function hasChildGroups($groupId) {
$dao = new CRM_Contact_DAO_GroupNesting();
* Returns true if the given groupId has 1 or more parent groups,
* false otherwise.
*
- * @param $groupId The id of the group to check for parent groups
- *
- * @return boolean True if 1 or more parent groups are found, false otherwise.
+ * @param $groupId
+ * The id of the group to check for parent groups.
*
+ * @return bool
+ * True if 1 or more parent groups are found, false otherwise.
*/
public static function hasParentGroups($groupId) {
$dao = new CRM_Contact_DAO_GroupNesting();
* Returns true if checkGroupId is a parent of one of the groups in
* groupIds, false otherwise.
*
- * @param $groupIds Array of group ids (or one group id) to serve as the starting point
- * @param $checkGroupId The group id to check if it is a parent of the $groupIds group(s)
- *
- * @return boolean True if $checkGroupId points to a group that is a parent of one of the $groupIds groups, false otherwise.
+ * @param array $groupIds
+ * of group ids (or one group id) to serve as the starting point.
+ * @param $checkGroupId
+ * The group id to check if it is a parent of the $groupIds group(s).
*
+ * @return bool
+ * True if $checkGroupId points to a group that is a parent of one of the $groupIds groups, false otherwise.
*/
public static function isParentGroup($groupIds, $checkGroupId) {
if (!is_array($groupIds)) {
$parentGroupId = $dao->parent_group_id;
if ($parentGroupId == $checkGroupId) {
/* print "One of these: <pre>";
- print_r($groupIds);
- print "</pre> has groupId $checkGroupId as an ancestor.<br/>"; */
+ print_r($groupIds);
+ print "</pre> has groupId $checkGroupId as an ancestor.<br/>"; */
return TRUE;
}
* Returns true if checkGroupId is a child of one of the groups in
* groupIds, false otherwise.
*
- * @param $groupIds Array of group ids (or one group id) to serve as the starting point
- * @param $checkGroupId The group id to check if it is a child of the $groupIds group(s)
- *
- * @return boolean True if $checkGroupId points to a group that is a child of one of the $groupIds groups, false otherwise.
+ * @param array $groupIds
+ * of group ids (or one group id) to serve as the starting point.
+ * @param $checkGroupId
+ * The group id to check if it is a child of the $groupIds group(s).
*
+ * @return bool
+ * True if $checkGroupId points to a group that is a child of one of the $groupIds groups, false otherwise.
*/
public static function isChildGroup($groupIds, $checkGroupId) {
$childGroupId = $dao->child_group_id;
if ($childGroupId == $checkGroupId) {
/* print "One of these: <pre>";
- print_r($groupIds);
- print "</pre> has groupId $checkGroupId as a descendent.<br/><br/>"; */
+ print_r($groupIds);
+ print "</pre> has groupId $checkGroupId as a descendent.<br/><br/>"; */
return TRUE;
}
* Returns true if checkGroupId is an ancestor of one of the groups in
* groupIds, false otherwise.
*
- * @param $groupIds Array of group ids (or one group id) to serve as the starting point
- * @param $checkGroupId The group id to check if it is an ancestor of the $groupIds group(s)
- *
- * @return boolean True if $checkGroupId points to a group that is an ancestor of one of the $groupIds groups, false otherwise.
+ * @param array $groupIds
+ * of group ids (or one group id) to serve as the starting point.
+ * @param $checkGroupId
+ * The group id to check if it is an ancestor of the $groupIds group(s).
*
+ * @return bool
+ * True if $checkGroupId points to a group that is an ancestor of one of the $groupIds groups, false otherwise.
*/
public static function isAncestorGroup($groupIds, $checkGroupId) {
if (!is_array($groupIds)) {
$parentGroupId = $dao->parent_group_id;
if ($parentGroupId == $checkGroupId) {
/* print "One of these: <pre>";
- print_r($groupIds);
- print "</pre> has groupId $checkGroupId as an ancestor.<br/>"; */
+ print_r($groupIds);
+ print "</pre> has groupId $checkGroupId as an ancestor.<br/>"; */
return TRUE;
}
* Returns true if checkGroupId is a descendent of one of the groups in
* groupIds, false otherwise.
*
- * @param $groupIds Array of group ids (or one group id) to serve as the starting point
- * @param $checkGroupId The group id to check if it is a descendent of the $groupIds group(s)
- *
- * @return boolean True if $checkGroupId points to a group that is a descendent of one of the $groupIds groups, false otherwise.
+ * @param array $groupIds
+ * of group ids (or one group id) to serve as the starting point.
+ * @param $checkGroupId
+ * The group id to check if it is a descendent of the $groupIds group(s).
*
+ * @return bool
+ * True if $checkGroupId points to a group that is a descendent of one of the $groupIds groups, false otherwise.
*/
public static function isDescendentGroup($groupIds, $checkGroupId) {
if (!is_array($groupIds)) {
$childGroupId = $dao->child_group_id;
if ($childGroupId == $checkGroupId) {
/* print "One of these: <pre>";
- print_r($groupIds);
- print "</pre> has groupId $checkGroupId as a descendent.<br/><br/>"; */
+ print_r($groupIds);
+ print "</pre> has groupId $checkGroupId as a descendent.<br/><br/>"; */
return TRUE;
}
/**
* Returns array of group ids of ancestor groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids (passed by reference).
*
* @param bool $includeSelf
*
- * @return array $groupIdArray List of groupIds that represent the requested group and its ancestors@access public
+ * @return array
+ * List of groupIds that represent the requested group and its ancestors
*/
public static function getAncestorGroupIds($groupIds, $includeSelf = TRUE) {
if (!is_array($groupIds)) {
/**
* Returns array of ancestor groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids (passed by reference).
*
* @param bool $includeSelf
- * @return \An $groupArray List of ancestor groups@access public
+ * @return array
+ * List of ancestor groups
*/
public static function getAncestorGroups($groupIds, $includeSelf = TRUE) {
$groupIds = self::getAncestorGroupIds($groupIds, $includeSelf);
/**
* Returns array of group ids of child groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids (passed by reference).
*
- * @return array $groupIdArray List of groupIds that represent the requested group and its children@access public
+ * @return array
+ * List of groupIds that represent the requested group and its children
*/
public static function getChildGroupIds($groupIds) {
if (!is_array($groupIds)) {
/**
* Returns array of group ids of parent groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids (passed by reference).
*
- * @return array $groupIdArray List of groupIds that represent the requested group and its parents@access public
+ * @return array
+ * List of groupIds that represent the requested group and its parents
*/
public static function getParentGroupIds($groupIds) {
if (!is_array($groupIds)) {
/**
* Returns array of group ids of descendent groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids (passed by reference).
*
* @param bool $includeSelf
- * @return array $groupIdArray List of groupIds that represent the requested group and its descendents@access public
+ * @return array
+ * List of groupIds that represent the requested group and its descendents
*/
public static function getDescendentGroupIds($groupIds, $includeSelf = TRUE) {
if (!is_array($groupIds)) {
/**
* Returns array of descendent groups of the specified group.
*
- * @param $groupIds An array of valid group ids (passed by reference)
+ * @param array $groupIds
+ * An array of valid group ids
*
* @param bool $includeSelf
- * @return \An $groupArray List of descendent groups@access public
+ * @return array
+ * List of descendent groups
*/
public static function getDescendentGroups($groupIds, $includeSelf = TRUE) {
$groupIds = self::getDescendentGroupIds($groupIds, $includeSelf);
/**
* Returns array of group ids of valid potential child groups of the specified group.
*
- * @param $groupId The group id to get valid potential children for
+ * @param $groupId
+ * The group id to get valid potential children for.
*
- * @return array $groupIdArray List of groupIds that represent the valid potential children of the group@access public
+ * @return array
+ * List of groupIds that represent the valid potential children of the group
*/
public static function getPotentialChildGroupIds($groupId) {
$groups = CRM_Contact_BAO_Group::getGroups();
return $containingGroups;
}
+
}