Merge pull request #7743 from eileenmcnaughton/entityFinancialAccount
authorEileen McNaughton <eileen@mcnaughty.com>
Thu, 4 Feb 2016 04:03:18 +0000 (17:03 +1300)
committerEileen McNaughton <eileen@mcnaughty.com>
Thu, 4 Feb 2016 04:03:18 +0000 (17:03 +1300)
Add Entity Financial Account api

90 files changed:
CRM/Activity/Form/Task/Batch.php [changed mode: 0755->0644]
CRM/Activity/Form/Task/Delete.php [changed mode: 0755->0644]
CRM/Activity/Form/Task/PickProfile.php [changed mode: 0755->0644]
CRM/Batch/BAO/Batch.php [changed mode: 0755->0644]
CRM/Batch/Form/Batch.php [changed mode: 0755->0644]
CRM/Batch/Form/Entry.php [changed mode: 0755->0644]
CRM/Campaign/BAO/Query.php [changed mode: 0755->0644]
CRM/Campaign/Controller/Search.php [changed mode: 0755->0644]
CRM/Campaign/Form/Gotv.php [changed mode: 0755->0644]
CRM/Campaign/Form/Search.php [changed mode: 0755->0644]
CRM/Campaign/Form/Search/Campaign.php [changed mode: 0755->0644]
CRM/Campaign/Form/Search/Petition.php [changed mode: 0755->0644]
CRM/Campaign/Form/Search/Survey.php [changed mode: 0755->0644]
CRM/Campaign/Form/Task.php [changed mode: 0755->0644]
CRM/Campaign/Form/Task/Interview.php [changed mode: 0755->0644]
CRM/Campaign/Form/Task/Print.php [changed mode: 0755->0644]
CRM/Campaign/Form/Task/Result.php [changed mode: 0755->0644]
CRM/Campaign/PseudoConstant.php [changed mode: 0755->0644]
CRM/Campaign/Selector/Search.php [changed mode: 0755->0644]
CRM/Campaign/StateMachine/Search.php [changed mode: 0755->0644]
CRM/Campaign/Task.php [changed mode: 0755->0644]
CRM/Contact/Form/Task/Useradd.php [changed mode: 0755->0644]
CRM/Contact/Page/View/Useradd.php [changed mode: 0755->0644]
CRM/Contribute/Form/ContributionBase.php [changed mode: 0755->0644]
CRM/Core/BAO/ActionSchedule.php [changed mode: 0755->0644]
CRM/Core/BAO/OptionValue.php
CRM/Core/BAO/UFMatch.php
CRM/Core/Config/MagicMerge.php
CRM/Core/Form/ShortCode.php [changed mode: 0755->0644]
CRM/Core/OptionValue.php
CRM/Core/Payment.php [changed mode: 0755->0644]
CRM/Core/Payment/ProcessorForm.php [changed mode: 0755->0644]
CRM/Extension/ClassLoader.php [new file with mode: 0644]
CRM/Extension/Info.php
CRM/Extension/Mapper.php [changed mode: 0755->0644]
CRM/Extension/System.php
CRM/Mailing/Event/BAO/Bounce.php [changed mode: 0755->0644]
CRM/Mailing/Event/BAO/Delivered.php [changed mode: 0755->0644]
CRM/Mailing/Event/BAO/Opened.php [changed mode: 0755->0644]
CRM/Mailing/Event/BAO/TrackableURLOpen.php [changed mode: 0755->0644]
CRM/Mailing/Event/BAO/Unsubscribe.php [changed mode: 0755->0644]
CRM/Pledge/Page/AJAX.php [changed mode: 0755->0644]
CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl [changed mode: 0755->0644]
CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl [changed mode: 0755->0644]
CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl [changed mode: 0755->0644]
CRM/Upgrade/Incremental/php/FourFive.php [changed mode: 0755->0644]
CRM/Upgrade/Incremental/sql/4.6.alpha1.mysql.tpl [changed mode: 0755->0644]
CRM/Utils/System/Drupal8.php
Civi/Core/Container.php
Civi/Token/TokenRow.php [changed mode: 0755->0644]
api/v3/Mailing.php [changed mode: 0755->0644]
api/v3/MailingAB.php [changed mode: 0755->0644]
templates/CRM/Activity/Form/Task.tpl [changed mode: 0755->0644]
templates/CRM/Activity/Form/Task/Batch.tpl [changed mode: 0755->0644]
templates/CRM/Activity/Form/Task/Delete.tpl [changed mode: 0755->0644]
templates/CRM/Activity/Form/Task/PickProfile.tpl [changed mode: 0755->0644]
templates/CRM/Admin/Page/Reminders.tpl [changed mode: 0755->0644]
templates/CRM/Batch/Form/Entry.js [changed mode: 0755->0644]
templates/CRM/Batch/Form/Entry.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Gotv.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search/Campaign.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search/Common.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search/EmptyResults.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search/Petition.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Search/Survey.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Selector.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Task/Print.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Task/Reserve.tpl [changed mode: 0755->0644]
templates/CRM/Campaign/Form/Task/Result.tpl [changed mode: 0755->0644]
templates/CRM/Contact/Page/View/Useradd.tpl [changed mode: 0755->0644]
templates/CRM/Core/Form/ShortCode.tpl [changed mode: 0755->0644]
tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php [changed mode: 0755->0644]
tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php [changed mode: 0755->0644]
tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php [changed mode: 0755->0644]
tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php [changed mode: 0755->0644]
tests/phpunit/CRM/Financial/BAO/PaymentProcessorTypeTest.php [changed mode: 0755->0644]
tests/phpunit/Civi/API/Subscriber/WhitelistSubscriberTest.php [changed mode: 0755->0644]
tests/phpunit/CiviTest/CiviUnitTestCase.php [changed mode: 0755->0644]
tests/phpunit/CiviTest/bootstrap.php
tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php [changed mode: 0755->0644]
tests/phpunit/WebTest/Contribute/PCPAddTest.php [changed mode: 0755->0644]
tests/phpunit/WebTest/Contribute/UpdateContributionTest.php [changed mode: 0755->0644]
tests/phpunit/WebTest/Event/MultipleEventRegistrationbyCartTest.php [changed mode: 0755->0644]
tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php [changed mode: 0755->0644]
tests/phpunit/api/v3/MailingABTest.php [changed mode: 0755->0644]
tests/phpunit/api/v3/MailingTest.php [changed mode: 0755->0644]
xml/schema/Financial/EntityFinancialAccount.xml [changed mode: 0755->0644]
xml/schema/Financial/EntityFinancialTrxn.xml [changed mode: 0755->0644]
xml/schema/Financial/FinancialTrxn.xml [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 0e3bb21dc5e37d313b0d2059c1d5726ab70c4d96..6386676f99102821bebf6d3a46e3e44dfefea50c 100644 (file)
@@ -169,7 +169,7 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue {
    *
    * @return CRM_Core_DAO_OptionValue
    */
-  public static function add(&$params, $ids) {
+  public static function add(&$params, $ids = array()) {
     // CRM-10921: do not reset attributes to default if this is an update
     //@todo consider if defaults are being set in the right place. 'dumb' defaults like
     // these would be usefully set @ the api layer so they are visible to api users
index 151252ce811b614a6e0064da2a98464f9ea97037..b8b5901ef71783858d689546c9fcb612a7fed67f 100644 (file)
@@ -254,18 +254,19 @@ AND    domain_id = %2
       }
 
       if (!$found) {
-        if ($config->userSystem->is_drupal) {
-          $mail = 'mail';
-        }
-        elseif ($uf == 'WordPress') {
-          $mail = 'user_email';
-        }
-        else {
-          $mail = 'email';
-        }
-
+        // Not sure why we're testing for this. Is there ever a case
+        // in which $user is not an object?
         if (is_object($user)) {
-          $params = array('email-Primary' => $user->$mail);
+          if ($config->userSystem->is_drupal) {
+            $primary_email = $uniqId;
+          }
+          elseif ($uf == 'WordPress') {
+            $primary_email = $user->user_email;
+          }
+          else {
+            $primary_email = $user->email;
+          }
+          $params = array('email-Primary' => $primary_email);
         }
 
         if ($ctype == 'Organization') {
index b4282b657ddd2d410de1264976e357076cbcdea1..d4bc55978b7331f6aa3dbe158a1d4c80c5fc29ba 100644 (file)
@@ -225,7 +225,12 @@ class CRM_Core_Config_MagicMerge {
         if ($value) {
           $value = CRM_Utils_File::addTrailingSlash($value);
           if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) {
-            CRM_Utils_File::createDir($value);
+            if (!CRM_Utils_File::createDir($value, FALSE)) {
+              CRM_Core_Session::setStatus(ts('Failed to make directory (%1) at "%2". Please update the settings or file permissions.', array(
+                1 => $k,
+                2 => $value,
+              )));
+            }
           }
           if (isset($this->map[$k][2]) && in_array('restrict', $this->map[$k][2])) {
             CRM_Utils_File::restrictAccess($value);
old mode 100755 (executable)
new mode 100644 (file)
index 06c066cb7df05f7791453eb72f159ecb87c3929b..f0ea310aed3338b666e4e8a64514dbc5ca111263 100644 (file)
@@ -181,6 +181,7 @@ class CRM_Core_OptionValue {
    *
    */
   public static function addOptionValue(&$params, &$groupParams, &$action, &$optionValueID) {
+    $ids = array();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     // checking if the group name with the given id or name (in $groupParams) exists
     if (!empty($groupParams)) {
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/CRM/Extension/ClassLoader.php b/CRM/Extension/ClassLoader.php
new file mode 100644 (file)
index 0000000..7097d8d
--- /dev/null
@@ -0,0 +1,132 @@
+<?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        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ * $Id$
+ *
+ */
+class CRM_Extension_ClassLoader {
+
+  /**
+   * @var CRM_Extension_Mapper
+   */
+  protected $mapper;
+
+  /**
+   * @var CRM_Extension_Container_Interface
+   */
+  protected $container;
+
+  /**
+   * @var CRM_Extension_Manager
+   */
+  protected $manager;
+
+  /**
+   * @var \Composer\Autoload\ClassLoader
+   */
+  protected $loader;
+
+  /**
+   * CRM_Extension_ClassLoader constructor.
+   * @param \CRM_Extension_Mapper $mapper
+   * @param \CRM_Extension_Container_Interface $container
+   * @param \CRM_Extension_Manager $manager
+   */
+  public function __construct(\CRM_Extension_Mapper $mapper, \CRM_Extension_Container_Interface $container, \CRM_Extension_Manager $manager) {
+    $this->mapper = $mapper;
+    $this->container = $container;
+    $this->manager = $manager;
+  }
+
+  public function __destruct() {
+    if ($this->loader) {
+      $this->loader->unregister();
+      $this->loader = NULL;
+    }
+  }
+
+  /**
+   * Registers this instance as an autoloader.
+   * @return $this
+   */
+  public function register() {
+    // In pre-installation environments, don't bother with caching.
+    if (!defined('CIVICRM_TEMPLATE_COMPILEDIR') || !defined('CIVICRM_DSN') || \CRM_Utils_System::isInUpgradeMode()) {
+      return $this->buildClassLoader()->register();
+    }
+
+    $envId = \CRM_Core_Config_Runtime::getId();
+    $file = CIVICRM_TEMPLATE_COMPILEDIR . "/CachedExtLoader.{$envId}.php";
+    if (file_exists($file)) {
+      $loader = require $file;
+    }
+    else {
+      $loader = $this->buildClassLoader();
+      $ser = serialize($loader);
+      file_put_contents($file,
+        sprintf("<?php\nreturn unserialize(%s);", var_export($ser, 1))
+      );
+    }
+    return $loader->register();
+  }
+
+  /**
+   * @return \Composer\Autoload\ClassLoader
+   * @throws \CRM_Extension_Exception
+   * @throws \Exception
+   */
+  public function buildClassLoader() {
+    $loader = new \Composer\Autoload\ClassLoader();
+
+    $statuses = $this->manager->getStatuses();
+    foreach ($statuses as $key => $status) {
+      if ($status !== CRM_Extension_Manager::STATUS_INSTALLED) {
+        continue;
+      }
+      $path = $this->mapper->keyToBasePath($key);
+      $info = $this->mapper->keyToInfo($key);
+      if (!empty($info->classloader)) {
+        foreach ($info->classloader as $mapping) {
+          switch ($mapping['type']) {
+            case 'psr4':
+              $loader->setPsr4($mapping['prefix'], $path . '/' . $mapping['path']);
+              break;
+          }
+          $result[] = $mapping;
+        }
+      }
+    }
+
+    return $loader;
+  }
+
+}
index b5bf1049decda3c3edb56ad43662622cd696af6e..d0d8c94c051d4b2690d34485a8b50152d2d51200 100644 (file)
@@ -44,6 +44,13 @@ class CRM_Extension_Info {
   public $label = NULL;
   public $file = NULL;
 
+  /**
+   * @var array
+   *   Each item is a specification like:
+   *   array('type'=>'psr4', 'namespace'=>'Foo\Bar', 'path'=>'/foo/bar').
+   */
+  public $classloader = array();
+
   /**
    * Load extension info an XML file.
    *
@@ -124,6 +131,16 @@ class CRM_Extension_Info {
         }
         ksort($this->urls);
       }
+      elseif ($attr === 'classloader') {
+        $this->classloader = array();
+        foreach ($val->psr4 as $psr4) {
+          $this->classloader[] = array(
+            'type' => 'psr4',
+            'prefix' => (string) $psr4->attributes()->prefix,
+            'path' => (string) $psr4->attributes()->path,
+          );
+        }
+      }
       else {
         $this->$attr = CRM_Utils_XML::xmlObjToArray($val);
       }
old mode 100755 (executable)
new mode 100644 (file)
index 9ffccd35e6c4c0d3052d8d51158b87ce326a633b..92e5c36e7c576387619e8adf24de7005b85faa8c 100644 (file)
@@ -43,6 +43,11 @@ class CRM_Extension_System {
   private $browser = NULL;
   private $downloader = NULL;
 
+  /**
+   * @var CRM_Extension_ClassLoader
+   * */
+  private $classLoader;
+
   /**
    * The URL of the remote extensions repository.
    *
@@ -182,6 +187,16 @@ class CRM_Extension_System {
     return $this->mapper;
   }
 
+  /**
+   * @return \CRM_Extension_ClassLoader
+   */
+  public function getClassLoader() {
+    if ($this->classLoader === NULL) {
+      $this->classLoader = new CRM_Extension_ClassLoader($this->getMapper(), $this->getFullContainer(), $this->getManager());
+    }
+    return $this->classLoader;
+  }
+
   /**
    * Get the service for enabling and disabling extensions.
    *
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 09f95cd0d524572882a5a6180eca598c92554eb3..56085e95e6d249e2bde104deca8d0ab0792be3dc 100644 (file)
@@ -562,4 +562,59 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
     return $modules;
   }
 
+  /**
+   * @inheritDoc
+   */
+  public function getUniqueIdentifierFromUserObject($user) {
+    return $user->get('mail')->value;
+  }
+
+  /**
+   * @inheritDoc
+   */
+  public function getUserIDFromUserObject($user) {
+    return $user->get('uid')->value;
+  }
+
+  /**
+   * @inheritDoc
+   */
+  public function synchronizeUsers() {
+    $config = CRM_Core_Config::singleton();
+    if (PHP_SAPI != 'cli') {
+      set_time_limit(300);
+    }
+
+    $users = array();
+    $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties();
+
+    $uf = $config->userFramework;
+    $contactCount = 0;
+    $contactCreated = 0;
+    $contactMatching = 0;
+    foreach ($users as $user) {
+      $mail = $user->get('mail')->value;
+      if (empty($mail)) {
+        continue;
+      }
+      $uid = $user->get('uid')->value;
+      $contactCount++;
+      if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $uid, $mail, $uf, 1, 'Individual', TRUE)) {
+        $contactCreated++;
+      }
+      else {
+        $contactMatching++;
+      }
+      if (is_object($match)) {
+        $match->free();
+      }
+    }
+
+    return array(
+      'contactCount' => $contactCount,
+      'contactMatching' => $contactMatching,
+      'contactCreated' => $contactCreated,
+    );
+  }
+
 }
index 68404a6028ddd14ac9c05a42d1d3c3ad55841f0d..3a443f3759eb422fc2503693f5e4ab89100f5fbb 100644 (file)
@@ -379,6 +379,7 @@ class Container {
       \CRM_Core_DAO::init($runtime->dsn);
       \CRM_Utils_Hook::singleton(TRUE);
       \CRM_Extension_System::singleton(TRUE);
+      \CRM_Extension_System::singleton(TRUE)->getClassLoader()->register();
 
       $c = new self();
       \Civi::$statics[__CLASS__]['container'] = $c->loadContainer();
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e04cd6a8471fb200e818a8cb99d214fbf6a2d4a7..330c742259cf860ab5f64f3eb55bdde29070154b 100644 (file)
@@ -39,8 +39,10 @@ if (CIVICRM_UF === 'UnitTests') {
 function cv($cmd, $decode = 'json') {
   $cmd = 'cv ' . $cmd;
   $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => STDERR);
-  $env = $_ENV + array('CV_OUTPUT' => 'json');
-  $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__, $env);
+  $oldOutput = getenv('CV_OUTPUT');
+  putenv("CV_OUTPUT=json");
+  $process = proc_open($cmd, $descriptorSpec, $pipes, __DIR__);
+  putenv("CV_OUTPUT=$oldOutput");
   fclose($pipes[0]);
   $result = stream_get_contents($pipes[1]);
   fclose($pipes[1]);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)