Merge pull request #5769 from monishdeb/CRM-16433
[civicrm-core.git] / CRM / ACL / API.php
index 7ada9d6f609d5cd3517ef7feefebae37a0aabfbf..f3681b3fa8702eb91c056b0150f1f95fd82cb7d1 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
 class CRM_ACL_API {
 
   /**
-   * The various type of permissions
+   * The various type of permissions.
    *
    * @var int
    */
@@ -54,8 +54,8 @@ class CRM_ACL_API {
    * @param int $contactID
    *   The contactID for whom the check is made.
    *
-   * @return boolean true if yes, else false
-   * @static
+   * @return bool
+   *   true if yes, else false
    */
   public static function check($str, $contactID = NULL) {
     if ($contactID == NULL) {
@@ -72,7 +72,7 @@ class CRM_ACL_API {
   }
 
   /**
-   * Get the permissioned where clause for the user
+   * Get the permissioned where clause for the user.
    *
    * @param int $type
    *   The type of permission needed.
@@ -86,15 +86,17 @@ class CRM_ACL_API {
    *   Whether to include only deleted contacts.
    * @param bool $skipDeleteClause
    *   Don't add delete clause if this is true,.
-   *               this means it is handled by generating query
+   *   this means it is handled by generating query
    *
-   * @return string the group where clause for this user
+   * @return string
+   *   the group where clause for this user
    */
-  public static function whereClause($type,
+  public static function whereClause(
+    $type,
     &$tables,
     &$whereTables,
-    $contactID        = NULL,
-    $onlyDeleted      = FALSE,
+    $contactID = NULL,
+    $onlyDeleted = FALSE,
     $skipDeleteClause = FALSE
   ) {
     // the default value which is valid for rhe final AND
@@ -141,7 +143,7 @@ class CRM_ACL_API {
   }
 
   /**
-   * Get all the groups the user has access to for the given operation
+   * Get all the groups the user has access to for the given operation.
    *
    * @param int $type
    *   The type of permission needed.
@@ -152,13 +154,14 @@ class CRM_ACL_API {
    * @param null $allGroups
    * @param null $includedGroups
    *
-   * @return array the ids of the groups for which the user has permissions
+   * @return array
+   *   the ids of the groups for which the user has permissions
    */
   public static function group(
     $type,
-    $contactID      = NULL,
-    $tableName      = 'civicrm_saved_search',
-    $allGroups      = NULL,
+    $contactID = NULL,
+    $tableName = 'civicrm_saved_search',
+    $allGroups = NULL,
     $includedGroups = NULL
   ) {
     if ($contactID == NULL) {
@@ -182,30 +185,31 @@ class CRM_ACL_API {
    * @param int $groupID
    * @param int $contactID
    *   The contactID for whom the check is made.
-   *
    * @param string $tableName
    * @param null $allGroups
    * @param null $includedGroups
    * @param bool $flush
    *
-   * @return array the ids of the groups for which the user has permissions
+   * @return array
+   *   the ids of the groups for which the user has permissions
    */
   public static function groupPermission(
     $type,
     $groupID,
-    $contactID      = NULL,
-    $tableName      = 'civicrm_saved_search',
-    $allGroups      = NULL,
+    $contactID = NULL,
+    $tableName = 'civicrm_saved_search',
+    $allGroups = NULL,
     $includedGroups = NULL,
     $flush = FALSE
   ) {
 
     static $cache = array();
+    $groups = array();
     //@todo this is pretty hacky!!!
     //adding a way for unit tests to flush the cache
     if ($flush) {
       $cache = array();
-      return;
+      return NULL;
     }
     if (!$contactID) {
       $session = CRM_Core_Session::singleton();
@@ -226,4 +230,5 @@ class CRM_ACL_API {
 
     return in_array($groupID, $groups) ? TRUE : FALSE;
   }
+
 }