INFRA-132 - CRM/Contact - Convert single-line @param to multi-line
[civicrm-core.git] / CRM / Contact / BAO / GroupNesting.php
index b8e4cb18f0cfbc7ec2c1c1f66c018b81591d814a..1a27086e77d0d79e9aca627cda4b926d2cb09324 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright U.S. PIRG Education Fund (c) 2007                        |
  | Licensed to CiviCRM under the Academic Free License version 3.0.   |
@@ -50,15 +50,18 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   private $_alreadyStyled = FALSE;
 
   /**
-   * class constructor
+   * Class constructor
    */
-  function __construct($styleLabels = FALSE, $styleIndent = "&nbsp;--&nbsp;") {
+  public function __construct($styleLabels = FALSE, $styleIndent = "&nbsp;--&nbsp;") {
     parent::__construct();
     $this->_styleLabels = $styleLabels;
     $this->_styleIndent = $styleIndent;
   }
 
-  function setSortOrder($sortOrder) {
+  /**
+   * @param $sortOrder
+   */
+  public function setSortOrder($sortOrder) {
     switch ($sortOrder) {
       case 'ASC':
       case 'DESC':
@@ -73,11 +76,17 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     }
   }
 
-  function getSortOrder() {
+  /**
+   * @return string
+   */
+  public function getSortOrder() {
     return self::$_sortOrder;
   }
 
-  function getCurrentNestingLevel() {
+  /**
+   * @return int
+   */
+  public function getCurrentNestingLevel() {
     return count($this->_parentStack);
   }
 
@@ -86,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
@@ -96,7 +105,7 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     $this->_alreadyStyled = FALSE;
   }
 
-  function current() {
+  public function current() {
     if ($this->_styleLabels &&
       $this->valid() &&
       !$this->_alreadyStyled
@@ -115,7 +124,10 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return $this->_current;
   }
 
-  function key() {
+  /**
+   * @return string
+   */
+  public function key() {
     $group = &$this->_current;
     $ids = array();
     foreach ($this->_parentStack as $parentGroup) {
@@ -129,7 +141,10 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return $key;
   }
 
-  function next() {
+  /**
+   * @return CRM_Contact_BAO_Group|null
+   */
+  public function next() {
     $currentGroup = &$this->_current;
     $childGroup = $this->_getNextChildGroup($currentGroup);
     if ($childGroup) {
@@ -160,7 +175,10 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return $nextGroup;
   }
 
-  function valid() {
+  /**
+   * @return bool
+   */
+  public function valid() {
     if ($this->_current) {
       return TRUE;
     }
@@ -169,7 +187,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     }
   }
 
-  function _getNextParentlessGroup(&$group = NULL) {
+  /**
+   * @param null $group
+   *
+   * @return CRM_Contact_BAO_Group|null
+   */
+  public function _getNextParentlessGroup(&$group = NULL) {
     $lastParentlessGroup = $this->_lastParentlessGroup;
     $nextGroup           = new CRM_Contact_BAO_Group();
     $nextGroup->order_by = 'title ' . self::$_sortOrder;
@@ -191,7 +214,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return NULL;
   }
 
-  function _getNextChildGroup(&$parentGroup, &$group = NULL) {
+  /**
+   * @param $parentGroup
+   * @param null $group
+   *
+   * @return CRM_Contact_BAO_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
@@ -217,7 +246,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return NULL;
   }
 
-  function _getNextSiblingGroup(&$group) {
+  /**
+   * @param $group
+   *
+   * @return CRM_Contact_BAO_Group|null
+   */
+  public function _getNextSiblingGroup(&$group) {
     $parentGroup = end($this->_parentStack);
     if ($parentGroup) {
       $nextGroup = $this->_getNextChildGroup($parentGroup, $group);
@@ -243,17 +277,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 $parentID
-   * @param $childID
+   * @param int $parentID
+   *   Id of the group to add the child to.
+   * @param int $childID
+   *   Id of the new child group.
    *
-   * @internal param \The $groupId id of the group to add the child to
-   * @internal param \The $childGroupId id of the new child group
-   *
-   * @return           void
    *
-   * @access public
+   * @return void
    */
-  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);";
@@ -265,14 +297,15 @@ 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
+   * @param $parentID
+   *   The id of the group to remove the child from.
+   * @param $childID
+   *   The id of the child group being removed.
    *
    * @return           void
    *
-   * @access public
    */
-  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);
@@ -283,14 +316,13 @@ 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            $childID          The id of the child group being removed
+   * @param int $childID
+   *   The id of the child group being removed.
    *
-   * @internal param \The $parentID id of the group to remove the child from
    * @return           void
    *
-   * @access public
    */
-  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);
@@ -300,14 +332,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
+   * @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.
    *
-   * @access public
    */
-  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);
@@ -321,13 +354,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
+   * @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.
    *
-   * @access public
    */
-  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<br><br>";
@@ -342,13 +375,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
+   * @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.
    *
-   * @access public
    */
-  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);
@@ -362,14 +395,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)
+   * @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.
    *
-   * @access public
    */
-  static function isParentGroup($groupIds, $checkGroupId) {
+  public static function isParentGroup($groupIds, $checkGroupId) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -393,14 +427,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
    * 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)
+   * @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.
    *
-   * @access public
    */
-  static function isChildGroup($groupIds, $checkGroupId) {
+  public static function isChildGroup($groupIds, $checkGroupId) {
 
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
@@ -426,14 +461,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
    * 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)
+   * @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.
    *
-   * @access public
    */
-  static function isAncestorGroup($groupIds, $checkGroupId) {
+  public static function isAncestorGroup($groupIds, $checkGroupId) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -466,14 +502,15 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
    * 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)
+   * @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.
    *
-   * @access public
    */
-  static function isDescendentGroup($groupIds, $checkGroupId) {
+  public static function isDescendentGroup($groupIds, $checkGroupId) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -505,13 +542,14 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of group ids of ancestor groups of the specified group.
    *
-   * @param             $groupIds             An array of valid group ids (passed by reference)
+   * @param $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
    */
-  static function getAncestorGroupIds($groupIds, $includeSelf = TRUE) {
+  public static function getAncestorGroupIds($groupIds, $includeSelf = TRUE) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -541,12 +579,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of ancestor groups of the specified group.
    *
-   * @param             $groupIds     An array of valid group ids (passed by reference)
+   * @param $groupIds
+   *   An array of valid group ids (passed by reference).
    *
    * @param bool $includeSelf
    * @return \An $groupArray   List of ancestor groups@access public
    */
-  static function getAncestorGroups($groupIds, $includeSelf = TRUE) {
+  public static function getAncestorGroups($groupIds, $includeSelf = TRUE) {
     $groupIds = self::getAncestorGroupIds($groupIds, $includeSelf);
     $params['id'] = $groupIds;
     return CRM_Contact_BAO_Group::getGroups($params);
@@ -555,11 +594,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of group ids of child groups of the specified group.
    *
-   * @param             $groupIds     An array of valid group ids (passed by reference)
+   * @param $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
    */
-  static function getChildGroupIds($groupIds) {
+  public static function getChildGroupIds($groupIds) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -576,11 +616,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of group ids of parent groups of the specified group.
    *
-   * @param             $groupIds               An array of valid group ids (passed by reference)
+   * @param $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
    */
-  static function getParentGroupIds($groupIds) {
+  public static function getParentGroupIds($groupIds) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -597,12 +638,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of group ids of descendent groups of the specified group.
    *
-   * @param             $groupIds               An array of valid group ids (passed by reference)
+   * @param $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
    */
-  static function getDescendentGroupIds($groupIds, $includeSelf = TRUE) {
+  public static function getDescendentGroupIds($groupIds, $includeSelf = TRUE) {
     if (!is_array($groupIds)) {
       $groupIds = array($groupIds);
     }
@@ -630,12 +672,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * Returns array of descendent groups of the specified group.
    *
-   * @param             $groupIds     An array of valid group ids (passed by reference)
+   * @param $groupIds
+   *   An array of valid group ids (passed by reference).
    *
    * @param bool $includeSelf
    * @return \An $groupArray   List of descendent groups@access public
    */
-  static function getDescendentGroups($groupIds, $includeSelf = TRUE) {
+  public static function getDescendentGroups($groupIds, $includeSelf = TRUE) {
     $groupIds = self::getDescendentGroupIds($groupIds, $includeSelf);
     $params['id'] = $groupIds;
     return CRM_Contact_BAO_Group::getGroups($params);
@@ -644,11 +687,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
   /**
    * 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
    */
-  static function getPotentialChildGroupIds($groupId) {
+  public static function getPotentialChildGroupIds($groupId) {
     $groups = CRM_Contact_BAO_Group::getGroups();
     $potentialChildGroupIds = array();
     foreach ($groups as $group) {
@@ -664,7 +708,13 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return $potentialChildGroupIds;
   }
 
-  static function getContainingGroups($contactId, $parentGroupId) {
+  /**
+   * @param int $contactId
+   * @param int $parentGroupId
+   *
+   * @return array
+   */
+  public static function getContainingGroups($contactId, $parentGroupId) {
     $groups = CRM_Contact_BAO_Group::getGroups();
     $containingGroups = array();
     foreach ($groups as $group) {
@@ -679,4 +729,3 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting implemen
     return $containingGroups;
   }
 }
-