INFRA-132 - s/null/NULL/
[civicrm-core.git] / CRM / Contact / BAO / Group.php
index cb56c7317810f0a19796b42644888945718499d7..843fca7c4d34ba04bba63fbc480051f386b2bfb5 100644 (file)
@@ -48,8 +48,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
    * of time. This is the inverse function of create. It also stores all the retrieved
    * values in the default array
    *
-   * @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 CRM_Contact_BAO_Group object
    * @static
@@ -69,9 +71,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
    * Delete the group and all the object that connect to
    * this group. Incredibly destructive
    *
-   * @param int $id group id
+   * @param int $id
+   *   Group id.
    *
-   * @return null
+   * @return NULL
    * @static
    *
    */
@@ -152,7 +155,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Get the count of a members in a group with the specific status
    *
-   * @param int $id group id
+   * @param int $id
+   *   Group id.
    * @param enum|string $status status of members in group
    *
    * @param bool $countChildGroups
@@ -220,13 +224,15 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Returns array of group object(s) matching a set of one or Group properties.
    *
-   * @param array $params Limits the set of groups returned.
-   * @param array $returnProperties Which properties should be included in the returned group objects.
+   * @param array $params
+   *   Limits the set of groups returned.
+   * @param array $returnProperties
+   *   Which properties should be included in the returned group objects.
    *                                       (member_count should be last element.)
    *
-   * @param null $sort
-   * @param null $offset
-   * @param null $rowCount
+   * @param NULL $sort
+   * @param NULL $offset
+   * @param NULL $rowCount
    *
    * @return array of group objects.
    *
@@ -300,9 +306,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Make sure that the user has permission to access this group
    *
-   * @param int $id   the id of the object
+   * @param int $id
+   *   The id of the object.
    *
-   * @return string   the permission that the user has (or null)
+   * @return string   the permission that the user has (or NULL)
    * @static
    */
   public static function checkPermission($id) {
@@ -338,9 +345,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Create a new group
    *
-   * @param array $params     Associative array of parameters
+   * @param array $params
+   *   Associative array of parameters.
    *
-   * @return object|null      The new group BAO (if created)
+   * @return object|NULL      The new group BAO (if created)
    * @static
    */
   public static function &create(&$params) {
@@ -370,7 +378,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
       $params['group_type'] = '';
     }
 
-    $session = CRM_Core_Session::singleton( );
+    $session = CRM_Core_Session::singleton();
     $cid = $session->get('userID');
     // this action is add
     if ($cid && empty($params['id'])) {
@@ -388,7 +396,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     // use metadata to translate the array to the appropriate DB type or altering the param in the api layer,
     // or at least altering the param in same section as 'group_type' rather than repeating here. However, further down
     // we need the $params one to be in it's original form & we are not sure what test coverage we have on that
-    if(isset($group->parents) && is_array($group->parents)) {
+    if (isset($group->parents) && is_array($group->parents)) {
       $group->parents = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
         array_keys($group->parents)
       ) . CRM_Core_DAO::VALUE_SEPARATOR;
@@ -519,9 +527,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Defines a new smart group
    *
-   * @param array $params     Associative array of parameters
+   * @param array $params
+   *   Associative array of parameters.
    *
-   * @return object|null      The new group BAO (if created)
+   * @return object|NULL      The new group BAO (if created)
    * @static
    */
   public static function createSmartGroup(&$params) {
@@ -546,10 +555,12 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Update the is_active flag in the db
    *
-   * @param int      $id        id of the database record
-   * @param boolean  $isActive  value we want to set the is_active field
+   * @param int $id
+   *   Id of the database record.
+   * @param bool $isActive
+   *   Value we want to set the is_active field.
    *
-   * @return Object             DAO object on sucess, null otherwise
+   * @return Object             DAO object on sucess, NULL otherwise
    * @static
    */
   public static function setIsActive($id, $isActive) {
@@ -559,7 +570,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * Build the condition to retrieve groups.
    *
-   * @param string $groupType type of group(Access/Mailing) OR the key of the group
+   * @param string $groupType
+   *   Type of group(Access/Mailing) OR the key of the group.
    * @param bool|\boolen $excludeHidden exclude hidden groups.
    *
    * @return string $condition
@@ -573,7 +585,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     elseif ($groupType == 'Access') {
       $value = CRM_Core_DAO::VALUE_SEPARATOR . '1' . CRM_Core_DAO::VALUE_SEPARATOR;
     }
-    elseif (!empty($groupType)){
+    elseif (!empty($groupType)) {
       // ie we have been given the group key
       $value = CRM_Core_DAO::VALUE_SEPARATOR . $groupType . CRM_Core_DAO::VALUE_SEPARATOR;
     }
@@ -606,7 +618,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   public static function getPermissionClause($force = FALSE) {
     static $clause = 1;
     static $retrieved = FALSE;
-    if ((!$retrieved || $force ) && !CRM_Core_Permission::check('view all contacts') && !CRM_Core_Permission::check('edit all contacts')) {
+    if ((!$retrieved || $force) && !CRM_Core_Permission::check('view all contacts') && !CRM_Core_Permission::check('edit all contacts')) {
       //get the allowed groups for the current user
       $groups = CRM_ACL_API::group(CRM_ACL_API::VIEW);
       if (!empty($groups)) {
@@ -632,7 +644,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
    * This function create the hidden smart group when user perform
    * contact seach and want to send mailing to search contacts.
    *
-   * @param  array $params ( reference ) an assoc array of name/value pairs
+   * @param array $params
+   *   ( reference ) an assoc array of name/value pairs.
    *
    * @return array ( smartGroupId, ssId ) smart group id and saved search id
    * @static
@@ -701,7 +714,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * This function is a wrapper for ajax group selector
    *
-   * @param  array   $params associated array for params record id.
+   * @param array $params
+   *   Associated array for params record id.
    *
    * @return array   $groupList associated array of group list
    *  -rp = rowcount
@@ -739,10 +753,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
         if (empty($params['parent_id']) && !empty($value['parents'])) {
           $groupIds = explode(',', $value['parents']);
           $title = array();
-          foreach($groupIds as $gId) {
+          foreach ($groupIds as $gId) {
             $title[] = $allGroups[$gId];
           }
-          $groupList[$id]['group_name'] .= '<div class="crm-row-parent-name"><em>'.ts('Child of').'</em>: ' . implode(', ', $title) . '</div>';
+          $groupList[$id]['group_name'] .= '<div class="crm-row-parent-name"><em>' . ts('Child of') . '</em>: ' . implode(', ', $title) . '</div>';
           $value['class'] = array_diff($value['class'], array('crm-row-parent'));
         }
         $value['class'][] = 'crm-entity';
@@ -769,7 +783,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * This function to get list of groups
    *
-   * @param  array $params associated array for params
+   * @param array $params
+   *   Associated array for params.
    *
    * @return array
    */
@@ -960,7 +975,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
         $where .= " AND status = 'Added'";
       }
       $dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE $where GROUP BY group_id");
-      while($dao->fetch()) {
+      while ($dao->fetch()) {
         $values[$dao->group_id]['count'] = $dao->count;
       }
     }
@@ -971,9 +986,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
   /**
    * This function to get hierarchical list of groups (parent followed by children)
    *
-   * @param  array $groupIDs array of group ids
+   * @param array $groupIDs
+   *   Array of group ids.
    *
-   * @param null $parents
+   * @param NULL $parents
    * @param string $spacer
    * @param bool $titleOnly
    *
@@ -1023,14 +1039,14 @@ WHERE  id IN $groupIdString
       $allGroups[$dao->id] = array(
         'title' => $dao->title,
         'visibility' => $dao->visibility,
-        'description' => $dao->description
+        'description' => $dao->description,
       );
 
       if ($dao->parents == $parents) {
         $roots[] = array(
           'id' => $dao->id,
           'prefix' => '',
-          'title' => $dao->title
+          'title' => $dao->title,
         );
       }
       else {
@@ -1041,7 +1057,7 @@ WHERE  id IN $groupIdString
           'id' => $dao->id,
           'prefix' => '',
           'title' => $dao->title,
-          'parents' => $parent
+          'parents' => $parent,
         );
       }
     }
@@ -1066,7 +1082,7 @@ WHERE  id IN $groupIdString
             $new_roots[] = array(
               'id' => $row['id'],
               'prefix' => $groups[$root['id']][0] . $spacer,
-              'title' => $row['title']
+              'title' => $row['title'],
             );
             unset($rows[$key]);
           }
@@ -1105,7 +1121,7 @@ WHERE  id IN $groupIdString
   /**
    * @param array $params
    *
-   * @return null|string
+   * @return NULL|string
    */
   public static function getGroupCount(&$params) {
     $whereClause = self::whereClause($params, FALSE);