CRM-15779 remove duplicate code block
[civicrm-core.git] / CRM / Contact / BAO / GroupContact.php
index 3d5d07fc0821e3213a5b6d4cef53afddd7d3ae30..505f92cf2379415b345cb124e6f60a781c337306 100644 (file)
@@ -51,7 +51,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param array  $params         (reference ) an assoc array of name/value pairs
    *
    * @return CRM_Contact_BAO_Group object
-   * @access public
    * @static
    */
   public static function add(&$params) {
@@ -74,7 +73,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param array  $params         (reference ) an assoc array of name/value pairs
    *
    * @return boolean
-   * @access public
    * @static
    */
   public static function dataExists(&$params) {
@@ -94,7 +92,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param array $values output values of the object
    *
    * @return array (reference)   the values that could be potentially assigned to smarty
-   * @access public
    * @static
    */
   public static function getValues(&$params, &$values) {
@@ -126,7 +123,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param int $tracking
    *
    * @return array             (total, added, notAdded) count of contacts added to group
-   * @access public
    * @static
    */
   static function addContactsToGroup(
@@ -175,7 +171,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param null $tracking
    *
    * @return array             (total, removed, notRemoved) count of contacts removed to group
-   * @access public
    * @static
    */
   static function removeContactsFromGroup(
@@ -272,7 +267,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    *
    * @param bool $visibility
    *
-   * @access public
    *
    * @return array $values this array has key-> group id and value group title
    * @static
@@ -447,7 +441,6 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @param  string $method    If we want the subscription history details for a specific method
    *
    * @return object of group contact
-   * @access public
    * @static
    */
   public static function getMembershipDetail($contactId, $groupID, $method = 'Email') {
@@ -488,7 +481,6 @@ SELECT    *
    *
    *
    * @return groupID
-   * @access public
    * @static
    */
   public static function getGroupId($groupContactID) {
@@ -510,7 +502,6 @@ SELECT    *
    * @param string $method
    *
    * @return void
-   * @access public
    * @static
    */
   public static function create(&$params, $contactId, $visibility = FALSE, $method = 'Admin') {
@@ -704,7 +695,6 @@ AND       group_id IN ( $groupIDString )
    * @param null $tracking
    *
    * @return array             (total, added, notAdded) count of contacts added to group
-   * @access public
    * @static
    */
   static function bulkAddContactsToGroup(
@@ -776,5 +766,28 @@ AND    contact_id IN ( $contactStr )
 
     return array($numContactsAdded, $numContactsNotAdded);
   }
-}
 
+  /**
+   * Get options for a given field.
+   * @see CRM_Core_DAO::buildOptions
+   *
+   * @param String $fieldName
+   * @param String $context : @see CRM_Core_DAO::buildOptionsContext
+   * @param Array $props : whatever is known about this dao object
+   *
+   * @return Array|bool
+   */
+  public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+    $params = array();
+
+    $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+
+    // Sort group list by hierarchy
+    // TODO: This will only work when api.entity is "group_contact". What about others?
+    if (($fieldName == 'group' || $fieldName == 'group_id') && ($context == 'search' || $context == 'create')) {
+      $options = CRM_Contact_BAO_Group::getGroupsHierarchy($options, NULL, '- ', TRUE);
+    }
+
+    return $options;
+  }
+}