Skip to content

Commit

Permalink
Merge pull request #1 from civicrm/master
Browse files Browse the repository at this point in the history
merge new
  • Loading branch information
sushantpaste authored May 1, 2019
2 parents 0f022bc + 0908f97 commit 2918a67
Show file tree
Hide file tree
Showing 2,448 changed files with 49,771 additions and 95,420 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Freeform Solutions - Herb van den Dool
Fuzion - Jitendra Purohit
Ginkgo Street Labs - Frank Gómez
Hossein Amin
JMA Consulting - Monish Deb
JMA Consulting - Joe Murray, Monish Deb
Johan Vervloet
John Kingsnorth
Joinery - Allen Shaw
Expand Down
16 changes: 6 additions & 10 deletions CRM/ACL/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,12 @@ public static function whereClause(
return $deleteClause;
}

$where = implode(' AND ',
array(
CRM_ACL_BAO_ACL::whereClause($type,
$tables,
$whereTables,
$contactID
),
$deleteClause,
)
$whereClause = CRM_ACL_BAO_ACL::whereClause($type,
$tables,
$whereTables,
$contactID
);
$where = implode(' AND ', [$whereClause, $deleteClause]);

// Add permission on self if we really hate our server or have hardly any contacts.
if (!$skipOwnContactClause && $contactID && (CRM_Core_Permission::check('edit my contact') ||
Expand Down Expand Up @@ -203,7 +199,7 @@ public static function groupPermission(
) {

if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) {
Civi::$statics[__CLASS__]['group_permission'] = array();
Civi::$statics[__CLASS__]['group_permission'] = [];
}

if (!$contactID) {
Expand Down
62 changes: 31 additions & 31 deletions CRM/ACL/BAO/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* @var string
*/
static $_entityTable = NULL;
static $_objectTable = NULL;
static $_operation = NULL;
public static $_entityTable = NULL;
public static $_objectTable = NULL;
public static $_operation = NULL;

static $_fieldKeys = NULL;
public static $_fieldKeys = NULL;

/**
* Get ACL entity table.
Expand All @@ -51,10 +51,10 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
*/
public static function entityTable() {
if (!self::$_entityTable) {
self::$_entityTable = array(
self::$_entityTable = [
'civicrm_contact' => ts('Contact'),
'civicrm_acl_role' => ts('ACL Role'),
);
];
}
return self::$_entityTable;
}
Expand All @@ -64,12 +64,12 @@ public static function entityTable() {
*/
public static function objectTable() {
if (!self::$_objectTable) {
self::$_objectTable = array(
self::$_objectTable = [
'civicrm_contact' => ts('Contact'),
'civicrm_group' => ts('Group'),
'civicrm_saved_search' => ts('Contact Group'),
'civicrm_admin' => ts('Import'),
);
];
}
return self::$_objectTable;
}
Expand All @@ -79,14 +79,14 @@ public static function objectTable() {
*/
public static function operation() {
if (!self::$_operation) {
self::$_operation = array(
self::$_operation = [
'View' => ts('View'),
'Edit' => ts('Edit'),
'Create' => ts('Create'),
'Delete' => ts('Delete'),
'Search' => ts('Search'),
'All' => ts('All'),
);
];
}
return self::$_operation;
}
Expand Down Expand Up @@ -120,14 +120,14 @@ public static function permissionClause(
CRM_Core_Error::deprecatedFunctionWarning('unknown - this is really old & not used in core');
$dao = new CRM_ACL_DAO_ACL();

$t = array(
$t = [
'ACL' => self::getTableName(),
'ACLRole' => 'civicrm_acl_role',
'ACLEntityRole' => CRM_ACL_DAO_EntityRole::getTableName(),
'Contact' => CRM_Contact_DAO_Contact::getTableName(),
'Group' => CRM_Contact_DAO_Group::getTableName(),
'GroupContact' => CRM_Contact_DAO_GroupContact::getTableName(),
);
];

$contact_id = CRM_Core_Session::getLoggedInContactID();

Expand Down Expand Up @@ -158,7 +158,7 @@ public static function permissionClause(
}
}

$query = array();
$query = [];

/* Query for permissions granted to all contacts in the domain */

Expand Down Expand Up @@ -261,9 +261,9 @@ public static function permissionClause(

$dao->query($union);

$allow = array(0);
$deny = array(0);
$override = array();
$allow = [0];
$deny = [0];
$override = [];

while ($dao->fetch()) {
/* Instant bypass for the following cases:
Expand Down Expand Up @@ -338,7 +338,7 @@ public static function permissionClause(
public static function getClause($table, $id, &$tables) {
$table = CRM_Utils_Type::escape($table, 'String');
$id = CRM_Utils_Type::escape($id, 'Integer');
$whereTables = array();
$whereTables = [];

$ssTable = CRM_Contact_BAO_SavedSearch::getTableName();

Expand Down Expand Up @@ -367,7 +367,7 @@ public static function getClause($table, $id, &$tables) {
* Assoc. array of the ACL rule's properties
*/
public function toArray($format = '%s', $hideEmpty = FALSE) {
$result = array();
$result = [];

if (!self::$_fieldKeys) {
$fields = CRM_ACL_DAO_ACL::fields();
Expand Down Expand Up @@ -397,7 +397,7 @@ public function toArray($format = '%s', $hideEmpty = FALSE) {
* Array of assoc. arrays of ACL rules
*/
public static function &getACLs($contact_id = NULL, $group_id = NULL, $aclRoles = FALSE) {
$results = array();
$results = [];

if (empty($contact_id)) {
return $results;
Expand Down Expand Up @@ -505,7 +505,7 @@ public static function &getACLRoles($contact_id = NULL, $group_id = NULL) {
}
}

$results = array();
$results = [];

$rule->query($query);

Expand Down Expand Up @@ -535,7 +535,7 @@ public static function &getGroupACLs($contact_id, $aclRoles = FALSE) {
$acl = self::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
$results = array();
$results = [];

if ($contact_id) {
$query = "
Expand Down Expand Up @@ -603,7 +603,7 @@ public static function &getGroupACLRoles($contact_id) {
AND $c2g.contact_id = $contact_id
AND $c2g.status = 'Added'";

$results = array();
$results = [];

$rule->query($query);

Expand Down Expand Up @@ -644,7 +644,7 @@ public static function &getGroupACLRoles($contact_id) {
* Assoc array of ACL rules
*/
public static function &getAllByContact($contact_id) {
$result = array();
$result = [];

/* First, the contact-specific ACLs, including ACL Roles */
$result += self::getACLs($contact_id, NULL, TRUE);
Expand Down Expand Up @@ -718,7 +718,7 @@ public static function check($str, $contactID) {
AND a.object_table = %1
AND a.id IN ( $aclKeys )
";
$params = array(1 => array($str, 'String'));
$params = [1 => [$str, 'String']];

$count = CRM_Core_DAO::singleValueQuery($query, $params);
return ($count) ? TRUE : FALSE;
Expand All @@ -736,7 +736,7 @@ public static function whereClause($type, &$tables, &$whereTables, $contactID =
$acls = CRM_ACL_BAO_Cache::build($contactID);

$whereClause = NULL;
$clauses = array();
$clauses = [];

if (!empty($acls)) {
$aclKeys = array_keys($acls);
Expand All @@ -755,12 +755,12 @@ public static function whereClause($type, &$tables, &$whereTables, $contactID =
$dao = CRM_Core_DAO::executeQuery($query);

// do an or of all the where clauses u see
$ids = array();
$ids = [];
while ($dao->fetch()) {
// make sure operation matches the type TODO
if (self::matchType($type, $dao->operation)) {
if (!$dao->object_id) {
$ids = array();
$ids = [];
$whereClause = ' ( 1 ) ';
break;
}
Expand Down Expand Up @@ -834,7 +834,7 @@ public static function group(
) {
$userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, (array) $includedGroups)));
if (empty(Civi::$statics[__CLASS__]['permissioned_groups'])) {
Civi::$statics[__CLASS__]['permissioned_groups'] = array();
Civi::$statics[__CLASS__]['permissioned_groups'] = [];
}
if (!empty(Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey])) {
return Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey];
Expand All @@ -846,7 +846,7 @@ public static function group(

$acls = CRM_ACL_BAO_Cache::build($contactID);

$ids = array();
$ids = [];
if (!empty($acls)) {
$aclKeys = array_keys($acls);
$aclKeys = implode(',', $aclKeys);
Expand All @@ -855,7 +855,7 @@ public static function group(
$cache = CRM_Utils_Cache::singleton();
$ids = $cache->get($cacheKey);
if (!$ids) {
$ids = array();
$ids = [];
$query = "
SELECT a.operation, a.object_id
FROM civicrm_acl_cache c, civicrm_acl a
Expand All @@ -866,7 +866,7 @@ public static function group(
GROUP BY a.operation,a.object_id
ORDER BY a.object_id
";
$params = array(1 => array($tableName, 'String'));
$params = [1 => [$tableName, 'String']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
if ($dao->object_id) {
Expand Down
17 changes: 11 additions & 6 deletions CRM/ACL/BAO/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache {

static $_cache = NULL;
public static $_cache = NULL;

/**
* @param int $id
Expand All @@ -45,7 +45,7 @@ class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache {
*/
public static function &build($id) {
if (!self::$_cache) {
self::$_cache = array();
self::$_cache = [];
}

if (array_key_exists($id, self::$_cache)) {
Expand Down Expand Up @@ -75,15 +75,15 @@ public static function retrieve($id) {
FROM civicrm_acl_cache
WHERE contact_id = %1
";
$params = array(1 => array($id, 'Integer'));
$params = [1 => [$id, 'Integer']];

if ($id == 0) {
$query .= " OR contact_id IS NULL";
}

$dao = CRM_Core_DAO::executeQuery($query, $params);

$cache = array();
$cache = [];
while ($dao->fetch()) {
$cache[$dao->acl_id] = 1;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public static function deleteEntry($id) {
DELETE FROM civicrm_acl_cache
WHERE contact_id = %1
";
$params = array(1 => array($id, 'Integer'));
$params = [1 => [$id, 'Integer']];
CRM_Core_DAO::executeQuery($query, $params);
}

Expand Down Expand Up @@ -154,7 +154,12 @@ public static function resetCache() {
WHERE modified_date IS NULL
OR (modified_date <= %1)
";
$params = array(1 => array(CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), 'String'));
$params = [
1 => [
CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(),
'String',
],
];
CRM_Core_DAO::singleValueQuery($query, $params);

// CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction
Expand Down
6 changes: 3 additions & 3 deletions CRM/ACL/BAO/EntityRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Access Control EntityRole.
*/
class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
static $_entityTable = NULL;
public static $_entityTable = NULL;

/**
* Get entity table.
Expand All @@ -44,10 +44,10 @@ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
*/
public static function entityTable() {
if (!self::$_entityTable) {
self::$_entityTable = array(
self::$_entityTable = [
'civicrm_contact' => ts('Contact'),
'civicrm_group' => ts('Group'),
);
];
}
return self::$_entityTable;
}
Expand Down
Loading

0 comments on commit 2918a67

Please sign in to comment.