return \Drupal::currentUser()->hasPermission($str);
}
+ /**
+ * Get all the contact emails for users that have a specific permission.
+ *
+ * @param string $permissionName
+ * Name of the permission we are interested in.
+ *
+ * @return string
+ * a comma separated list of email addresses
+ */
+ public function permissionEmails($permissionName) {
+ static $_cache = array();
+
+ if (isset($_cache[$permissionName])) {
+ return $_cache[$permissionName];
+ }
+
+ $role_ids = array_map(
+ function (\Drupal\user\RoleInterface $role) {
+ return $role->id();
+ }, user_roles(TRUE, $permissionName)
+ );
+ $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('roles' => $role_ids));
+ $uids = array_keys($users);
+
+ $_cache[$permissionName] = self::getContactEmails($uids);
+ return $_cache[$permissionName];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function upgradePermissions($permissions) {
+ $civicrm_perms = array_keys(CRM_Core_Permission::getCorePermissions());
+ if (empty($civicrm_perms)) {
+ throw new CRM_Core_Exception("Cannot upgrade permissions: permission list missing");
+ }
+
+ $roles = user_roles(TRUE);
+ foreach ($roles as $role) {
+ foreach ($civicrm_perms as $permission) {
+ $role->revokePermission($permission);
+ }
+ }
+ }
+
}
public function createEventDispatcher($container) {
$dispatcher = new ContainerAwareEventDispatcher($container);
$dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\InstallationCanary', 'check'));
+ $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\DatabaseInitializer', 'initialize'));
$dispatcher->addListener('hook_civicrm_post::Activity', array('\Civi\CCase\Events', 'fireCaseChange'));
$dispatcher->addListener('hook_civicrm_post::Case', array('\Civi\CCase\Events', 'fireCaseChange'));
$dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\Events', 'delegateToXmlListeners'));
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | 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 |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Core;
+
+use Civi\Core\Event\SystemInstallEvent;
+
+/**
+ * Class DatabaseInitializer
+ * @package Civi\Core
+ */
+class DatabaseInitializer {
+
+ /**
+ * Flush system to build the menu and MySQL triggers
+ *
+ * @param \Civi\Core\Event\SystemInstallEvent $event
+ * @throws \CRM_Core_Exception
+ */
+ public static function initialize(SystemInstallEvent $event) {
+ $api_params = array(
+ 'version' => 3,
+ 'triggers' => 1,
+ 'session' => 1,
+ );
+ civicrm_api('System', 'flush', $api_params);
+ }
+
+}
if [ -n "$DO_FLUSH" ]; then
pushd "$CALLEDPATH/.."
- # run the cli script to build the menu and the triggers
- "$PHP5PATH"php bin/cli.php -e System -a flush --triggers 1 --session 1
-
# reset config_backend and userFrameworkResourceURL which gets set
# when config object is initialized
$MYSQLCMD -e "UPDATE civicrm_domain SET config_backend = NULL; UPDATE civicrm_setting SET value = NULL WHERE name = 'userFrameworkResourceURL';"