First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
221
sites/all/modules/civicrm/CRM/ACL/API.php
Normal file
221
sites/all/modules/civicrm/CRM/ACL/API.php
Normal file
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_API {
|
||||
|
||||
/**
|
||||
* The various type of permissions.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const EDIT = 1;
|
||||
const VIEW = 2;
|
||||
const DELETE = 3;
|
||||
const CREATE = 4;
|
||||
const SEARCH = 5;
|
||||
const ALL = 6;
|
||||
|
||||
/**
|
||||
* Given a permission string, check for access requirements
|
||||
*
|
||||
* @param string $str
|
||||
* The permission to check.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
*
|
||||
* @return bool
|
||||
* true if yes, else false
|
||||
*/
|
||||
public static function check($str, $contactID = NULL) {
|
||||
if ($contactID == NULL) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
// anonymous user
|
||||
$contactID = 0;
|
||||
}
|
||||
|
||||
return CRM_ACL_BAO_ACL::check($str, $contactID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissioned where clause for the user.
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param array $tables
|
||||
* (reference ) add the tables that are needed for the select clause.
|
||||
* @param array $whereTables
|
||||
* (reference ) add the tables that are needed for the where clause.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
* @param bool $onlyDeleted
|
||||
* 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
|
||||
* @param bool $skipOwnContactClause
|
||||
* Do not add 'OR contact_id = $userID' to the where clause.
|
||||
* This is a hideously inefficient query and should be avoided
|
||||
* wherever possible.
|
||||
*
|
||||
* @return string
|
||||
* the group where clause for this user
|
||||
*/
|
||||
public static function whereClause(
|
||||
$type,
|
||||
&$tables,
|
||||
&$whereTables,
|
||||
$contactID = NULL,
|
||||
$onlyDeleted = FALSE,
|
||||
$skipDeleteClause = FALSE,
|
||||
$skipOwnContactClause = FALSE
|
||||
) {
|
||||
// the default value which is valid for the final AND
|
||||
$deleteClause = ' ( 1 ) ';
|
||||
if (!$skipDeleteClause) {
|
||||
if (CRM_Core_Permission::check('access deleted contacts') and $onlyDeleted) {
|
||||
$deleteClause = '(contact_a.is_deleted)';
|
||||
}
|
||||
else {
|
||||
// CRM-6181
|
||||
$deleteClause = '(contact_a.is_deleted = 0)';
|
||||
}
|
||||
}
|
||||
|
||||
// first see if the contact has edit / view all contacts
|
||||
if (CRM_Core_Permission::check('edit all contacts') ||
|
||||
($type == self::VIEW && CRM_Core_Permission::check('view all contacts'))
|
||||
) {
|
||||
return $deleteClause;
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
$contactID = (int) $contactID;
|
||||
|
||||
$where = implode(' AND ',
|
||||
array(
|
||||
CRM_ACL_BAO_ACL::whereClause($type,
|
||||
$tables,
|
||||
$whereTables,
|
||||
$contactID
|
||||
),
|
||||
$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') ||
|
||||
$type == self::VIEW && CRM_Core_Permission::check('view my contact'))
|
||||
) {
|
||||
$where = "(contact_a.id = $contactID OR ($where))";
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the groups the user has access to for the given operation.
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param null $allGroups
|
||||
* @param null $includedGroups
|
||||
*
|
||||
* @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,
|
||||
$includedGroups = NULL
|
||||
) {
|
||||
if ($contactID == NULL) {
|
||||
$contactID = CRM_Core_Session::getLoggedInContactID();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
// anonymous user
|
||||
$contactID = 0;
|
||||
}
|
||||
|
||||
return CRM_ACL_BAO_ACL::group($type, $contactID, $tableName, $allGroups, $includedGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has access to this group for operation $type
|
||||
*
|
||||
* @param int $type
|
||||
* The type of permission needed.
|
||||
* @param int $groupID
|
||||
* @param int $contactID
|
||||
* The contactID for whom the check is made.
|
||||
* @param string $tableName
|
||||
* @param null $allGroups
|
||||
* @param null $includedGroups
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function groupPermission(
|
||||
$type,
|
||||
$groupID,
|
||||
$contactID = NULL,
|
||||
$tableName = 'civicrm_saved_search',
|
||||
$allGroups = NULL,
|
||||
$includedGroups = NULL
|
||||
) {
|
||||
|
||||
if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) {
|
||||
Civi::$statics[__CLASS__]['group_permission'] = array();
|
||||
}
|
||||
|
||||
if (!$contactID) {
|
||||
$contactID = CRM_Core_Session::singleton()->getLoggedInContactID();
|
||||
}
|
||||
|
||||
$key = "{$tableName}_{$type}_{$contactID}";
|
||||
if (!array_key_exists($key, Civi::$statics[__CLASS__]['group_permission'])) {
|
||||
Civi::$statics[__CLASS__]['group_permission'][$key] = self::group($type, $contactID, $tableName, $allGroups, $includedGroups);
|
||||
}
|
||||
|
||||
return in_array($groupID, Civi::$statics[__CLASS__]['group_permission'][$key]);
|
||||
}
|
||||
|
||||
}
|
1006
sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php
Normal file
1006
sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php
Normal file
File diff suppressed because it is too large
Load diff
172
sites/all/modules/civicrm/CRM/ACL/BAO/Cache.php
Normal file
172
sites/all/modules/civicrm/CRM/ACL/BAO/Cache.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Access Control Cache.
|
||||
*/
|
||||
class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache {
|
||||
|
||||
static $_cache = NULL;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function &build($id) {
|
||||
if (!self::$_cache) {
|
||||
self::$_cache = array();
|
||||
}
|
||||
|
||||
if (array_key_exists($id, self::$_cache)) {
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
// check if this entry exists in db
|
||||
// if so retrieve and return
|
||||
self::$_cache[$id] = self::retrieve($id);
|
||||
if (self::$_cache[$id]) {
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
self::$_cache[$id] = CRM_ACL_BAO_ACL::getAllByContact($id);
|
||||
self::store($id, self::$_cache[$id]);
|
||||
return self::$_cache[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function retrieve($id) {
|
||||
$query = "
|
||||
SELECT acl_id
|
||||
FROM civicrm_acl_cache
|
||||
WHERE contact_id = %1
|
||||
";
|
||||
$params = array(1 => array($id, 'Integer'));
|
||||
|
||||
if ($id == 0) {
|
||||
$query .= " OR contact_id IS NULL";
|
||||
}
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
|
||||
$cache = array();
|
||||
while ($dao->fetch()) {
|
||||
$cache[$dao->acl_id] = 1;
|
||||
}
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param array $cache
|
||||
*/
|
||||
public static function store($id, &$cache) {
|
||||
foreach ($cache as $aclID => $data) {
|
||||
$dao = new CRM_ACL_DAO_Cache();
|
||||
if ($id) {
|
||||
$dao->contact_id = $id;
|
||||
}
|
||||
$dao->acl_id = $aclID;
|
||||
|
||||
$cache[$aclID] = 1;
|
||||
|
||||
$dao->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public static function deleteEntry($id) {
|
||||
if (self::$_cache &&
|
||||
array_key_exists($id, self::$_cache)
|
||||
) {
|
||||
unset(self::$_cache[$id]);
|
||||
}
|
||||
|
||||
$query = "
|
||||
DELETE FROM civicrm_acl_cache
|
||||
WHERE contact_id = %1
|
||||
";
|
||||
$params = array(1 => array($id, 'Integer'));
|
||||
CRM_Core_DAO::executeQuery($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public static function updateEntry($id) {
|
||||
// rebuilds civicrm_acl_cache
|
||||
self::deleteEntry($id);
|
||||
self::build($id);
|
||||
|
||||
// rebuilds civicrm_acl_contact_cache
|
||||
CRM_Contact_BAO_Contact_Permission::cache($id, CRM_Core_Permission::VIEW, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all the cache entries.
|
||||
*/
|
||||
public static function resetCache() {
|
||||
if (!CRM_Core_Config::isPermitCacheFlushMode()) {
|
||||
return;
|
||||
}
|
||||
// reset any static caching
|
||||
self::$_cache = NULL;
|
||||
|
||||
$query = "
|
||||
DELETE
|
||||
FROM civicrm_acl_cache
|
||||
WHERE modified_date IS NULL
|
||||
OR (modified_date <= %1)
|
||||
";
|
||||
$params = array(1 => array(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
|
||||
// CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe
|
||||
if (CRM_Core_Transaction::isActive()) {
|
||||
CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () {
|
||||
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
|
||||
});
|
||||
}
|
||||
else {
|
||||
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
104
sites/all/modules/civicrm/CRM/ACL/BAO/EntityRole.php
Normal file
104
sites/all/modules/civicrm/CRM/ACL/BAO/EntityRole.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Access Control EntityRole.
|
||||
*/
|
||||
class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
|
||||
static $_entityTable = NULL;
|
||||
|
||||
/**
|
||||
* Get entity table.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function entityTable() {
|
||||
if (!self::$_entityTable) {
|
||||
self::$_entityTable = array(
|
||||
'civicrm_contact' => ts('Contact'),
|
||||
'civicrm_group' => ts('Group'),
|
||||
);
|
||||
}
|
||||
return self::$_entityTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return CRM_ACL_DAO_EntityRole
|
||||
*/
|
||||
public static function create(&$params) {
|
||||
$dao = new CRM_ACL_DAO_EntityRole();
|
||||
$dao->copyValues($params);
|
||||
$dao->save();
|
||||
return $dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param $defaults
|
||||
*/
|
||||
public static function retrieve(&$params, &$defaults) {
|
||||
CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the is_active flag in the db.
|
||||
*
|
||||
* @param int $id
|
||||
* Id of the database record.
|
||||
* @param bool $is_active
|
||||
* Value we want to set the is_active field.
|
||||
*
|
||||
* @return Object
|
||||
* DAO object on success, null otherwise
|
||||
*/
|
||||
public static function setIsActive($id, $is_active) {
|
||||
return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Entity Role records.
|
||||
*
|
||||
* @param int $entityRoleId
|
||||
* ID of the EntityRole record to be deleted.
|
||||
*
|
||||
*/
|
||||
public static function del($entityRoleId) {
|
||||
$entityDAO = new CRM_ACL_DAO_EntityRole();
|
||||
$entityDAO->id = $entityRoleId;
|
||||
$entityDAO->find(TRUE);
|
||||
$entityDAO->delete();
|
||||
}
|
||||
|
||||
}
|
358
sites/all/modules/civicrm/CRM/ACL/DAO/ACL.php
Normal file
358
sites/all/modules/civicrm/CRM/ACL/DAO/ACL.php
Normal file
|
@ -0,0 +1,358 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/ACL.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f56c9ad63ff247e68abf2c7c70ff65ba)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_ACL constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* ACL Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
/**
|
||||
* Is this ACL entry Allow (0) or Deny (1) ?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $deny;
|
||||
/**
|
||||
* Table of the object possessing this ACL entry (Contact, Group, or ACL Group)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* ID of the object possessing this ACL
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* What operation does this ACL entry control?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $operation;
|
||||
/**
|
||||
* The table of the object controlled by this ACL entry
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $object_table;
|
||||
/**
|
||||
* The ID of the object controlled by this ACL entry
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $object_id;
|
||||
/**
|
||||
* If this is a grant/revoke entry, what table are we granting?
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $acl_table;
|
||||
/**
|
||||
* ID of the ACL or ACL group being granted/revoked
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_id;
|
||||
/**
|
||||
* Is this property active?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL ID') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'name' => array(
|
||||
'name' => 'name',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Name') ,
|
||||
'description' => 'ACL Name.',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
) ,
|
||||
) ,
|
||||
'deny' => array(
|
||||
'name' => 'deny',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('Deny ACL?') ,
|
||||
'description' => 'Is this ACL entry Allow (0) or Deny (1) ?',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Radio',
|
||||
) ,
|
||||
) ,
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Entity') ,
|
||||
'description' => 'Table of the object possessing this ACL entry (Contact, Group, or ACL Group)',
|
||||
'required' => true,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Entity ID') ,
|
||||
'description' => 'ID of the object possessing this ACL',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'operation' => array(
|
||||
'name' => 'operation',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Operation') ,
|
||||
'description' => 'What operation does this ACL entry control?',
|
||||
'required' => true,
|
||||
'maxlength' => 8,
|
||||
'size' => CRM_Utils_Type::EIGHT,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
) ,
|
||||
'pseudoconstant' => array(
|
||||
'callback' => 'CRM_ACL_BAO_ACL::operation',
|
||||
)
|
||||
) ,
|
||||
'object_table' => array(
|
||||
'name' => 'object_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Object') ,
|
||||
'description' => 'The table of the object controlled by this ACL entry',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'object_id' => array(
|
||||
'name' => 'object_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Object ID') ,
|
||||
'description' => 'The ID of the object controlled by this ACL entry',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_table' => array(
|
||||
'name' => 'acl_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('ACL Table') ,
|
||||
'description' => 'If this is a grant/revoke entry, what table are we granting?',
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_id' => array(
|
||||
'name' => 'acl_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Group ID') ,
|
||||
'description' => 'ID of the ACL or ACL group being granted/revoked',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('ACL Is Active?') ,
|
||||
'description' => 'Is this property active?',
|
||||
'table_name' => 'civicrm_acl',
|
||||
'entity' => 'ACL',
|
||||
'bao' => 'CRM_ACL_BAO_ACL',
|
||||
'localizable' => 0,
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
) ,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_acl_id' => array(
|
||||
'name' => 'index_acl_id',
|
||||
'field' => array(
|
||||
0 => 'acl_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl::0::acl_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
223
sites/all/modules/civicrm/CRM/ACL/DAO/Cache.php
Normal file
223
sites/all/modules/civicrm/CRM/ACL/DAO/Cache.php
Normal file
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/Cache.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:f65002b394a3b1f9c18de75751364acc)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_Cache constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl_cache';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Foreign Key to Contact
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $contact_id;
|
||||
/**
|
||||
* Foreign Key to ACL
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_id;
|
||||
/**
|
||||
* When was this cache entry last modified
|
||||
*
|
||||
* @var timestamp
|
||||
*/
|
||||
public $modified_date;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl_cache';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'acl_id', 'civicrm_acl', 'id');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache ID') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'contact_id' => array(
|
||||
'name' => 'contact_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache Contact') ,
|
||||
'description' => 'Foreign Key to Contact',
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
) ,
|
||||
'acl_id' => array(
|
||||
'name' => 'acl_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Cache ACL') ,
|
||||
'description' => 'Foreign Key to ACL',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
'FKClassName' => 'CRM_ACL_DAO_ACL',
|
||||
) ,
|
||||
'modified_date' => array(
|
||||
'name' => 'modified_date',
|
||||
'type' => CRM_Utils_Type::T_TIMESTAMP,
|
||||
'title' => ts('Cache Modified Date') ,
|
||||
'description' => 'When was this cache entry last modified',
|
||||
'required' => false,
|
||||
'table_name' => 'civicrm_acl_cache',
|
||||
'entity' => 'Cache',
|
||||
'bao' => 'CRM_ACL_BAO_Cache',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl_cache', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl_cache', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_acl_id' => array(
|
||||
'name' => 'index_acl_id',
|
||||
'field' => array(
|
||||
0 => 'acl_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_cache::0::acl_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
248
sites/all/modules/civicrm/CRM/ACL/DAO/EntityRole.php
Normal file
248
sites/all/modules/civicrm/CRM/ACL/DAO/EntityRole.php
Normal file
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*
|
||||
* Generated from xml/schema/CRM/ACL/EntityRole.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:b6780a8cf74433fd38a0c7f9e6161986)
|
||||
*/
|
||||
require_once 'CRM/Core/DAO.php';
|
||||
require_once 'CRM/Utils/Type.php';
|
||||
/**
|
||||
* CRM_ACL_DAO_EntityRole constructor.
|
||||
*/
|
||||
class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static $_tableName = 'civicrm_acl_entity_role';
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static $_log = false;
|
||||
/**
|
||||
* Unique table ID
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $id;
|
||||
/**
|
||||
* Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $acl_role_id;
|
||||
/**
|
||||
* Table of the object joined to the ACL Role (Contact or Group)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_table;
|
||||
/**
|
||||
* ID of the group/contact object being joined
|
||||
*
|
||||
* @var int unsigned
|
||||
*/
|
||||
public $entity_id;
|
||||
/**
|
||||
* Is this property active?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_active;
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
$this->__table = 'civicrm_acl_entity_role';
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Returns foreign keys and entity references.
|
||||
*
|
||||
* @return array
|
||||
* [CRM_Core_Reference_Interface]
|
||||
*/
|
||||
static function getReferenceColumns() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['links'])) {
|
||||
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
|
||||
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName() , 'entity_id', NULL, 'id', 'entity_table');
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['links'];
|
||||
}
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = array(
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('Entity Role') ,
|
||||
'description' => 'Unique table ID',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'acl_role_id' => array(
|
||||
'name' => 'acl_role_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Role ID') ,
|
||||
'description' => 'Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_table' => array(
|
||||
'name' => 'entity_table',
|
||||
'type' => CRM_Utils_Type::T_STRING,
|
||||
'title' => ts('Entity Table') ,
|
||||
'description' => 'Table of the object joined to the ACL Role (Contact or Group)',
|
||||
'required' => true,
|
||||
'maxlength' => 64,
|
||||
'size' => CRM_Utils_Type::BIG,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'entity_id' => array(
|
||||
'name' => 'entity_id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => ts('ACL Entity ID') ,
|
||||
'description' => 'ID of the group/contact object being joined',
|
||||
'required' => true,
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
'is_active' => array(
|
||||
'name' => 'is_active',
|
||||
'type' => CRM_Utils_Type::T_BOOLEAN,
|
||||
'title' => ts('ACL Entity Role is Active') ,
|
||||
'description' => 'Is this property active?',
|
||||
'table_name' => 'civicrm_acl_entity_role',
|
||||
'entity' => 'EntityRole',
|
||||
'bao' => 'CRM_ACL_BAO_EntityRole',
|
||||
'localizable' => 0,
|
||||
) ,
|
||||
);
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
/**
|
||||
* Return a mapping from field-name to the corresponding key (as used in fields()).
|
||||
*
|
||||
* @return array
|
||||
* Array(string $name => string $uniqueName).
|
||||
*/
|
||||
static function &fieldKeys() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
|
||||
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fieldKeys'];
|
||||
}
|
||||
/**
|
||||
* Returns the names of this table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static function getTableName() {
|
||||
return self::$_tableName;
|
||||
}
|
||||
/**
|
||||
* Returns if this table needs to be logged
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLog() {
|
||||
return self::$_log;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &import($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl_entity_role', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function &export($prefix = false) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl_entity_role', $prefix, array());
|
||||
return $r;
|
||||
}
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = array(
|
||||
'index_role' => array(
|
||||
'name' => 'index_role',
|
||||
'field' => array(
|
||||
0 => 'acl_role_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_entity_role::0::acl_role_id',
|
||||
) ,
|
||||
'index_entity' => array(
|
||||
'name' => 'index_entity',
|
||||
'field' => array(
|
||||
0 => 'entity_table',
|
||||
1 => 'entity_id',
|
||||
) ,
|
||||
'localizable' => false,
|
||||
'sig' => 'civicrm_acl_entity_role::0::entity_table::entity_id',
|
||||
) ,
|
||||
);
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
}
|
300
sites/all/modules/civicrm/CRM/ACL/Form/ACL.php
Normal file
300
sites/all/modules/civicrm/CRM/ACL/Form/ACL.php
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Form_ACL extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = parent::setDefaultValues();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::ADD) {
|
||||
$defaults['object_type'] = 1;
|
||||
}
|
||||
|
||||
$showHide = new CRM_Core_ShowHideBlocks();
|
||||
|
||||
if (isset($defaults['object_table'])) {
|
||||
switch ($defaults['object_table']) {
|
||||
case 'civicrm_saved_search':
|
||||
$defaults['group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 1;
|
||||
$showHide->addShow("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_uf_group':
|
||||
$defaults['uf_group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 2;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addShow("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_custom_group':
|
||||
$defaults['custom_group_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 3;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addShow("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
break;
|
||||
|
||||
case 'civicrm_event':
|
||||
$defaults['event_id'] = $defaults['object_id'];
|
||||
$defaults['object_type'] = 4;
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addShow("id-event-acl");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
|
||||
// Don't assign showHide elements to template in DELETE mode (fields to be shown and hidden don't exist)
|
||||
if (!($this->_action & CRM_Core_Action::DELETE)) {
|
||||
$showHide->addToTemplate();
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
$this->setPageTitle(ts('ACL'));
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL');
|
||||
|
||||
$this->add('text', 'name', ts('Description'), CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL', 'name'), TRUE);
|
||||
|
||||
$operations = array('' => ts('- select -')) + CRM_ACL_BAO_ACL::operation();
|
||||
$this->add('select',
|
||||
'operation',
|
||||
ts('Operation'),
|
||||
$operations, TRUE
|
||||
);
|
||||
|
||||
$objTypes = array(
|
||||
'1' => ts('A group of contacts'),
|
||||
'2' => ts('A profile'),
|
||||
'3' => ts('A set of custom data fields'),
|
||||
);
|
||||
|
||||
if (CRM_Core_Permission::access('CiviEvent')) {
|
||||
$objTypes['4'] = ts('Events');
|
||||
}
|
||||
|
||||
$extra = array('onclick' => "showObjectSelect();");
|
||||
$this->addRadio('object_type',
|
||||
ts('Type of Data'),
|
||||
$objTypes,
|
||||
$extra,
|
||||
' ', TRUE
|
||||
);
|
||||
|
||||
$label = ts('Role');
|
||||
$role = array(
|
||||
'-1' => ts('- select role -'),
|
||||
'0' => ts('Everyone'),
|
||||
) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$this->add('select', 'entity_id', $label, $role, TRUE);
|
||||
|
||||
$group = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Groups'),
|
||||
) + CRM_Core_PseudoConstant::group();
|
||||
|
||||
$customGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Custom Groups'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
|
||||
|
||||
$ufGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Profiles'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
|
||||
|
||||
$event = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Events'),
|
||||
) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
|
||||
|
||||
$this->add('select', 'group_id', ts('Group'), $group);
|
||||
$this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup);
|
||||
$this->add('select', 'uf_group_id', ts('Profile'), $ufGroup);
|
||||
$this->add('select', 'event_id', ts('Event'), $event);
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_ACL_Form_ACL', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function formRule($params) {
|
||||
$showHide = new CRM_Core_ShowHideBlocks();
|
||||
|
||||
// Make sure role is not -1
|
||||
if ($params['entity_id'] == -1) {
|
||||
$errors['entity_id'] = ts('Please assign this permission to a Role.');
|
||||
}
|
||||
|
||||
$validOperations = array('View', 'Edit');
|
||||
$operationMessage = ts("Only 'View' and 'Edit' operations are valid for this type of data");
|
||||
|
||||
// Figure out which type of object we're permissioning on and make sure user has selected a value.
|
||||
switch ($params['object_type']) {
|
||||
case 1:
|
||||
if ($params['group_id'] == -1) {
|
||||
$errors['group_id'] = ts('Please select a Group (or ALL Groups).');
|
||||
$showHide->addShow("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ($params['uf_group_id'] == -1) {
|
||||
$errors['uf_group_id'] = ts('Please select a Profile (or ALL Profiles).');
|
||||
$showHide->addShow("id-profile-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ($params['custom_group_id'] == -1) {
|
||||
$errors['custom_group_id'] = ts('Please select a set of Custom Data (or ALL Custom Data).');
|
||||
$showHide->addShow("id-custom-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
$showHide->addHide("id-event-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ($params['event_id'] == -1) {
|
||||
$errors['event_id'] = ts('Please select an Event (or ALL Events).');
|
||||
$showHide->addShow("id-event-acl");
|
||||
$showHide->addHide("id-custom-acl");
|
||||
$showHide->addHide("id-group-acl");
|
||||
$showHide->addHide("id-profile-acl");
|
||||
}
|
||||
if (!in_array($params['operation'], $validOperations)) {
|
||||
$errors['operation'] = $operationMessage;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$showHide->addToTemplate();
|
||||
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// note this also resets any ACL cache
|
||||
CRM_Core_BAO_Cache::deleteGroup('contact fields');
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_ACL_BAO_ACL::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
|
||||
$params['deny'] = 0;
|
||||
$params['entity_table'] = 'civicrm_acl_role';
|
||||
|
||||
// Figure out which type of object we're permissioning on and set object_table and object_id.
|
||||
switch ($params['object_type']) {
|
||||
case 1:
|
||||
$params['object_table'] = 'civicrm_saved_search';
|
||||
$params['object_id'] = $params['group_id'];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$params['object_table'] = 'civicrm_uf_group';
|
||||
$params['object_id'] = $params['uf_group_id'];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$params['object_table'] = 'civicrm_custom_group';
|
||||
$params['object_id'] = $params['custom_group_id'];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$params['object_table'] = 'civicrm_event';
|
||||
$params['object_id'] = $params['event_id'];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->_id) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
CRM_ACL_BAO_ACL::create($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
151
sites/all/modules/civicrm/CRM/ACL/Form/ACLBasic.php
Normal file
151
sites/all/modules/civicrm/CRM/ACL/Form/ACLBasic.php
Normal file
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Form_ACLBasic extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
|
||||
if ($this->_id ||
|
||||
$this->_id === '0'
|
||||
) {
|
||||
$defaults['entity_id'] = $this->_id;
|
||||
|
||||
$query = "
|
||||
SELECT object_table
|
||||
FROM civicrm_acl
|
||||
WHERE entity_id = %1
|
||||
AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
";
|
||||
$params = array(1 => array($this->_id, 'Integer'));
|
||||
$dao = CRM_Core_DAO::executeQuery($query, $params);
|
||||
$defaults['object_table'] = array();
|
||||
while ($dao->fetch()) {
|
||||
$defaults['object_table'][$dao->object_table] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permissions = array_flip(CRM_Core_Permission::basicPermissions());
|
||||
$this->addCheckBox('object_table',
|
||||
ts('ACL Type'),
|
||||
$permissions,
|
||||
NULL, NULL, TRUE, NULL,
|
||||
array('</td><td>', '</td></tr><tr><td>')
|
||||
);
|
||||
|
||||
$label = ts('Role');
|
||||
$role = array(
|
||||
'-1' => ts('- select role -'),
|
||||
'0' => ts('Everyone'),
|
||||
) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
|
||||
|
||||
if ($this->_id) {
|
||||
$entityID->freeze();
|
||||
}
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($params) {
|
||||
if ($params['entity_id'] == -1) {
|
||||
$errors = array('entity_id' => ts('Role is a required field'));
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
if ($this->_id ||
|
||||
$this->_id === '0'
|
||||
) {
|
||||
$query = "
|
||||
DELETE
|
||||
FROM civicrm_acl
|
||||
WHERE entity_id = %1
|
||||
AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
";
|
||||
$deleteParams = array(1 => array($this->_id, 'Integer'));
|
||||
CRM_Core_DAO::executeQuery($query, $deleteParams);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params['operation'] = 'All';
|
||||
$params['deny'] = 0;
|
||||
$params['is_active'] = 1;
|
||||
$params['entity_table'] = 'civicrm_acl_role';
|
||||
$params['name'] = 'Core ACL';
|
||||
|
||||
foreach ($params['object_table'] as $object_table => $value) {
|
||||
if ($value) {
|
||||
$newParams = $params;
|
||||
unset($newParams['object_table']);
|
||||
$newParams['object_table'] = $object_table;
|
||||
CRM_ACL_BAO_ACL::create($newParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
78
sites/all/modules/civicrm/CRM/ACL/Form/EntityRole.php
Normal file
78
sites/all/modules/civicrm/CRM/ACL/Form/EntityRole.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Form_EntityRole extends CRM_Admin_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
parent::buildQuickForm();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$aclRoles = array('' => ts('- select -')) + CRM_Core_OptionGroup::values('acl_role');
|
||||
$this->add('select', 'acl_role_id', ts('ACL Role'),
|
||||
$aclRoles, TRUE
|
||||
);
|
||||
|
||||
$label = ts('Assigned to');
|
||||
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access');
|
||||
$this->add('select', 'entity_id', $label, $group, TRUE, array('class' => 'crm-select2 huge'));
|
||||
|
||||
$this->add('checkbox', 'is_active', ts('Enabled?'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_ACL_BAO_EntityRole::del($this->_id);
|
||||
CRM_Core_Session::setStatus(ts('Selected Entity Role has been deleted.'), ts('Record Deleted'), 'success');
|
||||
}
|
||||
else {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
if ($this->_id) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
$params['entity_table'] = 'civicrm_group';
|
||||
CRM_ACL_BAO_EntityRole::create($params);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
198
sites/all/modules/civicrm/CRM/ACL/Form/WordPress/Permissions.php
Normal file
198
sites/all/modules/civicrm/CRM/ACL/Form/WordPress/Permissions.php
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to Grant access to CiviCRM components and other CiviCRM permissions.
|
||||
*/
|
||||
class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
|
||||
CRM_Utils_System::setTitle('Wordpress Access Control');
|
||||
|
||||
// Get the core permissions array
|
||||
$permissionsArray = self::getPermissionArray();
|
||||
$permissionsDesc = self::getPermissionArray(TRUE);
|
||||
|
||||
// Get the wordpress roles, default capabilities and assign to the form
|
||||
// TODO: Create a new wordpress role (Anonymous user) and define capabilities in Wordpress Access Control
|
||||
global $wp_roles;
|
||||
if (!isset($wp_roles)) {
|
||||
$wp_roles = new WP_Roles();
|
||||
}
|
||||
foreach ($wp_roles->role_names as $role => $name) {
|
||||
// Dont show the permissions options for administrator, as they have all permissions
|
||||
if ($role !== 'administrator') {
|
||||
$roleObj = $wp_roles->get_role($role);
|
||||
if (!empty($roleObj->capabilities)) {
|
||||
foreach ($roleObj->capabilities as $ckey => $cname) {
|
||||
if (array_key_exists($ckey, $permissionsArray)) {
|
||||
$elementName = $role . '[' . $ckey . ']';
|
||||
$defaults[$elementName] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compose the checkbox array for each role, to assign to form
|
||||
$rolePerms[$role] = $permissionsArray;
|
||||
foreach ($rolePerms[$role] as $key => $value) {
|
||||
$elementName = $role . '[' . $key . ']';
|
||||
$this->add('checkbox', $elementName, $value);
|
||||
}
|
||||
$roles[$role] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setDefaults($defaults);
|
||||
|
||||
$descArray = array();
|
||||
foreach ($permissionsDesc as $perm => $attr) {
|
||||
if (count($attr) > 1) {
|
||||
$descArray[$perm] = $attr[1];
|
||||
}
|
||||
}
|
||||
$this->assign('permDesc', $descArray);
|
||||
$this->assign('rolePerms', $rolePerms);
|
||||
$this->assign('roles', $roles);
|
||||
|
||||
$this->addButtons(
|
||||
array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'spacing' => '',
|
||||
'isDefault' => FALSE,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$permissionsArray = self::getPermissionArray();
|
||||
|
||||
// Function to get Wordpress roles
|
||||
global $wp_roles;
|
||||
if (!isset($wp_roles)) {
|
||||
$wp_roles = new WP_Roles();
|
||||
}
|
||||
foreach ($wp_roles->role_names as $role => $name) {
|
||||
$roleObj = $wp_roles->get_role($role);
|
||||
|
||||
//Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked
|
||||
foreach ($permissionsArray as $key => $capability) {
|
||||
$roleObj->remove_cap($key);
|
||||
}
|
||||
|
||||
//Add the selected wordpress capabilities for the role
|
||||
$rolePermissions = $params[$role];
|
||||
if (!empty($rolePermissions)) {
|
||||
foreach ($rolePermissions as $key => $capability) {
|
||||
$roleObj->add_cap($key);
|
||||
}
|
||||
}
|
||||
|
||||
if ($role == 'anonymous_user') {
|
||||
// Get the permissions into a format that matches what we get from WP
|
||||
$allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings();
|
||||
foreach ($allWarningPermissions as $key => $permission) {
|
||||
$allWarningPermissions[$key] = CRM_Utils_String::munge(strtolower($permission));
|
||||
}
|
||||
$warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions));
|
||||
$warningPermissionNames = array();
|
||||
foreach ($warningPermissions as $permission) {
|
||||
$warningPermissionNames[$permission] = $permissionsArray[$permission];
|
||||
}
|
||||
if (!empty($warningPermissionNames)) {
|
||||
CRM_Core_Session::setStatus(
|
||||
ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array(
|
||||
1 => $wp_roles->role_names[$role],
|
||||
2 => implode(', ', $warningPermissionNames),
|
||||
)),
|
||||
ts('Unsafe Permission Settings')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// Changed the 'access_civicrm_nav_link' capability in civicrm.php file
|
||||
// But for some reason, if i remove 'Access CiviCRM' administrator and save, it is showing
|
||||
// 'You do not have sufficient permissions to access this page'
|
||||
// which should not happen for Super Admin and Administrators, as checking permissions for Super
|
||||
// Admin and Administrators always gives TRUE
|
||||
wp_civicrm_capability();
|
||||
|
||||
CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success");
|
||||
|
||||
// rebuild the menus to comply with the new permisssions/capabilites
|
||||
CRM_Core_Invoke::rebuildMenuAndCaches();
|
||||
|
||||
CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1');
|
||||
CRM_Utils_System::civiExit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the core civicrm permissions array.
|
||||
* This function should be shared from a similar one in
|
||||
* distmaker/utils/joomlaxml.php
|
||||
*
|
||||
* @param bool $descriptions
|
||||
* Whether to return permission descriptions
|
||||
*
|
||||
* @return array
|
||||
* civicrm permissions
|
||||
*/
|
||||
public static function getPermissionArray($descriptions = FALSE) {
|
||||
global $civicrm_root;
|
||||
|
||||
$permissions = CRM_Core_Permission::basicPermissions(FALSE, $descriptions);
|
||||
|
||||
$perms_array = array();
|
||||
foreach ($permissions as $perm => $title) {
|
||||
//order matters here, but we deal with that later
|
||||
$perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title;
|
||||
}
|
||||
|
||||
return $perms_array;
|
||||
}
|
||||
|
||||
}
|
262
sites/all/modules/civicrm/CRM/ACL/Page/ACL.php
Normal file
262
sites/all/modules/civicrm/CRM/ACL/Page/ACL.php
Normal file
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl',
|
||||
'qs' => 'reset=1&action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable ACL'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable ACL'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl',
|
||||
'qs' => 'reset=1&action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* Set the breadcrumb before beginning the standard page run.
|
||||
*/
|
||||
public function run() {
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access',
|
||||
'reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
// parent run
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
// get all acl's sorted by weight
|
||||
$acl = array();
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM civicrm_acl
|
||||
WHERE ( object_table IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group', 'civicrm_event' ) )
|
||||
ORDER BY entity_id
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$roles = CRM_Core_OptionGroup::values('acl_role');
|
||||
|
||||
$group = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Groups'),
|
||||
) + CRM_Core_PseudoConstant::group();
|
||||
$customGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Custom Groups'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
|
||||
$ufGroup = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Profiles'),
|
||||
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
|
||||
|
||||
$event = array(
|
||||
'-1' => ts('- select -'),
|
||||
'0' => ts('All Events'),
|
||||
) + CRM_Event_PseudoConstant::event();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$acl[$dao->id] = array();
|
||||
$acl[$dao->id]['name'] = $dao->name;
|
||||
$acl[$dao->id]['operation'] = $dao->operation;
|
||||
$acl[$dao->id]['entity_id'] = $dao->entity_id;
|
||||
$acl[$dao->id]['entity_table'] = $dao->entity_table;
|
||||
$acl[$dao->id]['object_table'] = $dao->object_table;
|
||||
$acl[$dao->id]['object_id'] = $dao->object_id;
|
||||
$acl[$dao->id]['is_active'] = $dao->is_active;
|
||||
|
||||
if ($acl[$dao->id]['entity_id']) {
|
||||
$acl[$dao->id]['entity'] = CRM_Utils_Array::value($acl[$dao->id]['entity_id'], $roles);
|
||||
}
|
||||
else {
|
||||
$acl[$dao->id]['entity'] = ts('Everyone');
|
||||
}
|
||||
|
||||
switch ($acl[$dao->id]['object_table']) {
|
||||
case 'civicrm_saved_search':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $group);
|
||||
$acl[$dao->id]['object_name'] = ts('Group');
|
||||
break;
|
||||
|
||||
case 'civicrm_uf_group':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $ufGroup);
|
||||
$acl[$dao->id]['object_name'] = ts('Profile');
|
||||
break;
|
||||
|
||||
case 'civicrm_custom_group':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $customGroup);
|
||||
$acl[$dao->id]['object_name'] = ts('Custom Group');
|
||||
break;
|
||||
|
||||
case 'civicrm_event':
|
||||
$acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $event);
|
||||
$acl[$dao->id]['object_name'] = ts('Event');
|
||||
break;
|
||||
}
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
if ($dao->is_active) {
|
||||
$action -= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
$acl[$dao->id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'ACL.manage.action',
|
||||
'ACL',
|
||||
$dao->id
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $acl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl';
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an ACL.
|
||||
*
|
||||
* @param int $mode
|
||||
* What mode for the form ?.
|
||||
* @param int $id
|
||||
* Id of the entity (for update, view operations).
|
||||
* @param bool $imageUpload
|
||||
* Not used in this case, but extended from CRM_Core_Page_Basic.
|
||||
* @param bool $pushUserContext
|
||||
* Not used in this case, but extended from CRM_Core_Page_Basic.
|
||||
*/
|
||||
public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = TRUE) {
|
||||
if ($mode & (CRM_Core_Action::UPDATE)) {
|
||||
if (isset($id)) {
|
||||
$aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id);
|
||||
CRM_Utils_System::setTitle(ts('Edit ACL – %1', array(1 => $aclName)));
|
||||
}
|
||||
}
|
||||
parent::edit($mode, $id, $imageUpload, $pushUserContext);
|
||||
}
|
||||
|
||||
}
|
196
sites/all/modules/civicrm/CRM/ACL/Page/ACLBasic.php
Normal file
196
sites/all/modules/civicrm/CRM/ACL/Page/ACLBasic.php
Normal file
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic {
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_ACL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl/basic',
|
||||
'qs' => 'reset=1&action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl/basic',
|
||||
'qs' => 'reset=1&action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
$id = $this->getIdAndAction();
|
||||
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
|
||||
// what action to take ?
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit($this->_action, $id);
|
||||
}
|
||||
|
||||
// finally browse the acl's
|
||||
$this->browse();
|
||||
|
||||
// This replaces parent run, but do parent's parent run
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
|
||||
// get all acl's sorted by weight
|
||||
$acl = array();
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM civicrm_acl
|
||||
WHERE ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) )
|
||||
ORDER BY entity_id
|
||||
";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
|
||||
$roles = CRM_Core_OptionGroup::values('acl_role');
|
||||
|
||||
$permissions = CRM_Core_Permission::basicPermissions();
|
||||
while ($dao->fetch()) {
|
||||
if (!array_key_exists($dao->entity_id, $acl)) {
|
||||
$acl[$dao->entity_id] = array();
|
||||
$acl[$dao->entity_id]['name'] = $dao->name;
|
||||
$acl[$dao->entity_id]['entity_id'] = $dao->entity_id;
|
||||
$acl[$dao->entity_id]['entity_table'] = $dao->entity_table;
|
||||
$acl[$dao->entity_id]['object_table'] = CRM_Utils_Array::value($dao->object_table, $permissions);
|
||||
$acl[$dao->entity_id]['is_active'] = 1;
|
||||
|
||||
if ($acl[$dao->entity_id]['entity_id']) {
|
||||
$acl[$dao->entity_id]['entity'] = $roles[$acl[$dao->entity_id]['entity_id']];
|
||||
}
|
||||
else {
|
||||
$acl[$dao->entity_id]['entity'] = ts('Any Role');
|
||||
}
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
|
||||
$acl[$dao->entity_id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->entity_id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'aclRole.manage.action',
|
||||
'ACLRole',
|
||||
$dao->entity_id
|
||||
);
|
||||
}
|
||||
elseif (!empty($permissions[$dao->object_table])) {
|
||||
$acl[$dao->entity_id]['object_table'] .= ", {$permissions[$dao->object_table]}";
|
||||
}
|
||||
}
|
||||
$this->assign('rows', $acl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_ACLBasic';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'Core ACLs';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl/basic';
|
||||
}
|
||||
|
||||
}
|
206
sites/all/modules/civicrm/CRM/ACL/Page/EntityRole.php
Normal file
206
sites/all/modules/civicrm/CRM/ACL/Page/EntityRole.php
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| 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-2017
|
||||
*/
|
||||
class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic {
|
||||
|
||||
public $useLivePageJS = TRUE;
|
||||
|
||||
/**
|
||||
* The action links that we need to display for the browse screen.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $_links = NULL;
|
||||
|
||||
/**
|
||||
* Get BAO Name.
|
||||
*
|
||||
* @return string
|
||||
* Classname of BAO.
|
||||
*/
|
||||
public function getBAOName() {
|
||||
return 'CRM_ACL_BAO_EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get action Links.
|
||||
*
|
||||
* @return array
|
||||
* (reference) of action links
|
||||
*/
|
||||
public function &links() {
|
||||
if (!(self::$_links)) {
|
||||
self::$_links = array(
|
||||
CRM_Core_Action::UPDATE => array(
|
||||
'name' => ts('Edit'),
|
||||
'url' => 'civicrm/acl/entityrole',
|
||||
'qs' => 'action=update&id=%%id%%',
|
||||
'title' => ts('Edit ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::DISABLE => array(
|
||||
'name' => ts('Disable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Disable ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::ENABLE => array(
|
||||
'name' => ts('Enable'),
|
||||
'ref' => 'crm-enable-disable',
|
||||
'title' => ts('Enable ACL Role Assignment'),
|
||||
),
|
||||
CRM_Core_Action::DELETE => array(
|
||||
'name' => ts('Delete'),
|
||||
'url' => 'civicrm/acl/entityrole',
|
||||
'qs' => 'action=delete&id=%%id%%',
|
||||
'title' => ts('Delete ACL Role Assignment'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return self::$_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the page.
|
||||
*
|
||||
* This method is called after the page is created. It checks for the
|
||||
* type of action and executes that action.
|
||||
* Finally it calls the parent's run method.
|
||||
*/
|
||||
public function run() {
|
||||
$id = $this->getIdAndAction();
|
||||
|
||||
// set breadcrumb to append to admin/access
|
||||
$breadCrumb = array(
|
||||
array(
|
||||
'title' => ts('Access Control'),
|
||||
'url' => CRM_Utils_System::url('civicrm/admin/access',
|
||||
'reset=1'
|
||||
),
|
||||
),
|
||||
);
|
||||
CRM_Utils_System::appendBreadCrumb($breadCrumb);
|
||||
CRM_Utils_System::setTitle(ts('Assign Users to Roles'));
|
||||
|
||||
// what action to take ?
|
||||
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
|
||||
$this->edit($this->_action, $id);
|
||||
}
|
||||
|
||||
// reset cache if enabled/disabled
|
||||
if ($this->_action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE)) {
|
||||
CRM_ACL_BAO_Cache::resetCache();
|
||||
}
|
||||
|
||||
// finally browse the acl's
|
||||
if ($this->_action & CRM_Core_Action::BROWSE) {
|
||||
$this->browse();
|
||||
}
|
||||
|
||||
// This replaces parent run, but do parent's parent run
|
||||
return CRM_Core_Page::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse all acls.
|
||||
*/
|
||||
public function browse() {
|
||||
|
||||
// get all acl's sorted by weight
|
||||
$entityRoles = array();
|
||||
$dao = new CRM_ACL_DAO_EntityRole();
|
||||
$dao->find();
|
||||
|
||||
$aclRoles = CRM_Core_OptionGroup::values('acl_role');
|
||||
$groups = CRM_Core_PseudoConstant::staticGroup();
|
||||
|
||||
while ($dao->fetch()) {
|
||||
$entityRoles[$dao->id] = array();
|
||||
CRM_Core_DAO::storeValues($dao, $entityRoles[$dao->id]);
|
||||
|
||||
$entityRoles[$dao->id]['acl_role'] = CRM_Utils_Array::value($dao->acl_role_id, $aclRoles);
|
||||
$entityRoles[$dao->id]['entity'] = $groups[$dao->entity_id];
|
||||
|
||||
// form all action links
|
||||
$action = array_sum(array_keys($this->links()));
|
||||
if ($dao->is_active) {
|
||||
$action -= CRM_Core_Action::ENABLE;
|
||||
}
|
||||
else {
|
||||
$action -= CRM_Core_Action::DISABLE;
|
||||
}
|
||||
|
||||
$entityRoles[$dao->id]['action'] = CRM_Core_Action::formLink(
|
||||
self::links(),
|
||||
$action,
|
||||
array('id' => $dao->id),
|
||||
ts('more'),
|
||||
FALSE,
|
||||
'entityRole.manage.action',
|
||||
'EntityRole',
|
||||
$dao->id
|
||||
);
|
||||
}
|
||||
$this->assign('rows', $entityRoles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of edit form.
|
||||
*
|
||||
* @return string
|
||||
* Classname of edit form.
|
||||
*/
|
||||
public function editForm() {
|
||||
return 'CRM_ACL_Form_EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit form name.
|
||||
*
|
||||
* @return string
|
||||
* name of this page.
|
||||
*/
|
||||
public function editName() {
|
||||
return 'ACL EntityRole';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user context.
|
||||
*
|
||||
* @param null $mode
|
||||
*
|
||||
* @return string
|
||||
* user context.
|
||||
*/
|
||||
public function userContext($mode = NULL) {
|
||||
return 'civicrm/acl/entityrole';
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue