X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FGroupNesting.php;h=b065d4a1720cf4e3966c47cb43f3b3e4549d0e99;hb=cd2dfbd751a32826ac02c06d348b4bdd9d21109f;hp=6842abe134380e6afc5386747df0d1e16673a4f5;hpb=c490a46ac4bf490d3fbb31e35d24c6b43e764f00;p=civicrm-core.git
diff --git a/CRM/Contact/BAO/GroupNesting.php b/CRM/Contact/BAO/GroupNesting.php
index 6842abe134..b065d4a172 100644
--- a/CRM/Contact/BAO/GroupNesting.php
+++ b/CRM/Contact/BAO/GroupNesting.php
@@ -1,7 +1,7 @@
_styleLabels = $styleLabels;
$this->_styleIndent = $styleIndent;
@@ -61,7 +61,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
/**
* @param $sortOrder
*/
- function setSortOrder($sortOrder) {
+ public function setSortOrder($sortOrder) {
switch ($sortOrder) {
case 'ASC':
case 'DESC':
@@ -79,14 +79,14 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
/**
* @return string
*/
- function getSortOrder() {
+ public function getSortOrder() {
return self::$_sortOrder;
}
/**
* @return int
*/
- function getCurrentNestingLevel() {
+ public function getCurrentNestingLevel() {
return count($this->_parentStack);
}
@@ -95,7 +95,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* which is the first group (according to _sortOrder) that
* has no parent groups
*/
- function rewind() {
+ public function rewind() {
$this->_parentStack = array();
// calling _getNextParentlessGroup w/ no arguments
// makes it return the first parentless group
@@ -105,14 +105,17 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
$this->_alreadyStyled = FALSE;
}
- function current() {
+ /**
+ * @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;
}
@@ -127,7 +130,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
/**
* @return string
*/
- function key() {
+ public function key() {
$group = &$this->_current;
$ids = array();
foreach ($this->_parentStack as $parentGroup) {
@@ -144,7 +147,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
/**
* @return CRM_Contact_BAO_Group|null
*/
- function next() {
+ public function next() {
$currentGroup = &$this->_current;
$childGroup = $this->_getNextChildGroup($currentGroup);
if ($childGroup) {
@@ -155,7 +158,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
$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);
@@ -178,7 +181,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
/**
* @return bool
*/
- function valid() {
+ public function valid() {
if ($this->_current) {
return TRUE;
}
@@ -192,9 +195,9 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
*
* @return CRM_Contact_BAO_Group|null
*/
- function _getNextParentlessGroup(&$group = NULL) {
+ 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) {
@@ -220,7 +223,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
*
* @return CRM_Contact_BAO_Group|null
*/
- function _getNextChildGroup(&$parentGroup, &$group = NULL) {
+ public function _getNextChildGroup(&$parentGroup, &$group = NULL) {
$children = self::getChildGroupIds($parentGroup->id);
if (count($children) > 0) {
// we have child groups, so get the first one based on _sortOrder
@@ -251,7 +254,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
*
* @return CRM_Contact_BAO_Group|null
*/
- function _getNextSiblingGroup(&$group) {
+ public function _getNextSiblingGroup(&$group) {
$parentGroup = end($this->_parentStack);
if ($parentGroup) {
$nextGroup = $this->_getNextChildGroup($parentGroup, $group);
@@ -259,10 +262,10 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
}
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) {
@@ -277,14 +280,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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
- * @access public
*/
- static function add($parentID, $childID) {
+ public static function add($parentID, $childID) {
// TODO: Add checks here to make sure invalid nests can't be created
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "REPLACE INTO civicrm_group_nesting (child_group_id, parent_group_id) VALUES ($childID,$parentID);";
@@ -296,14 +300,14 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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.
*
- * @access public
+ * @return void
*/
- static function remove($parentID, $childID) {
+ public static function remove($parentID, $childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "DELETE FROM civicrm_group_nesting WHERE child_group_id = $childID AND parent_group_id = $parentID";
$dao->query($query);
@@ -314,13 +318,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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.
*
- * @access public
+ * @return void
*/
- static function removeAllParentForChild($childID) {
+ public static function removeAllParentForChild($childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "DELETE FROM civicrm_group_nesting WHERE child_group_id = $childID";
$dao->query($query);
@@ -330,14 +333,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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.
*
- * @access public
+ * @return bool
+ * True if association is found, false otherwise.
*/
- static function isParentChild($parentID, $childID) {
+ public static function isParentChild($parentID, $childID) {
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "SELECT id FROM civicrm_group_nesting WHERE child_group_id = $childID AND parent_group_id = $parentID";
$dao->query($query);
@@ -351,13 +355,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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.
*
- * @access public
+ * @return bool
+ * True if 1 or more child groups are found, false otherwise.
*/
- static function hasChildGroups($groupId) {
+ public static function hasChildGroups($groupId) {
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "SELECT child_group_id FROM civicrm_group_nesting WHERE parent_group_id = $groupId LIMIT 1";
//print $query . "\n
";
@@ -372,13 +376,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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.
*
- * @access public
+ * @return bool
+ * True if 1 or more parent groups are found, false otherwise.
*/
- static function hasParentGroups($groupId) {
+ public static function hasParentGroups($groupId) {
$dao = new CRM_Contact_DAO_GroupNesting();
$query = "SELECT parent_group_id FROM civicrm_group_nesting WHERE child_group_id = $groupId LIMIT 1";
$dao->query($query);
@@ -392,14 +396,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
* 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).
*
- * @access public
+ * @return bool
+ * True if $checkGroupId points to a group that is a parent of one of the $groupIds groups, false otherwise.
*/
- static function isParentGroup($groupIds, $checkGroupId) {
+ public static function isParentGroup($groupIds, $checkGroupId) {
if (!is_array($groupIds)) {
$groupIds = array($groupIds);
}
@@ -410,8 +415,8 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
$parentGroupId = $dao->parent_group_id;
if ($parentGroupId == $checkGroupId) {
/* print "One of these:
"; - print_r($groupIds); - print "has groupId $checkGroupId as an ancestor.
"; - print_r($groupIds); - print "has groupId $checkGroupId as a descendent.
"; - print_r($groupIds); - print "has groupId $checkGroupId as an ancestor.
"; - print_r($groupIds); - print "has groupId $checkGroupId as a descendent.