Merge pull request #7825 from torrance/editable-button-fix-master
[civicrm-core.git] / extern / cxn.php
index cc40d1acace7a753a97b87fc72114d3038b8d85f..e8a975b94746213fe2458402e94a38878304650f 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2016                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -30,24 +30,6 @@ $config = CRM_Core_Config::singleton();
 
 CRM_Utils_System::loadBootStrap(array(), FALSE);
 
-$apiServer = new \Civi\Cxn\Rpc\ApiServer(new CRM_Cxn_CiviCxnStore());
-$apiServer->setLog(new CRM_Utils_SystemLogger());
-$apiServer->setRouter(function ($cxn, $entity, $action, $params) {
-  require_once 'api/v3/utils.php';
-
-  // Note: cxnId is authenticated before router is called.
-  $dao = new CRM_Cxn_DAO_Cxn();
-  $dao->cxn_id = $cxn['cxnId'];
-  if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) {
-    return civicrm_api3_create_error('Failed to lookup connection authorizations.');
-  }
-  if (!$dao->is_active) {
-    return civicrm_api3_create_error('Connection is inactive');
-  }
-
-  // FIXME: apply $dao->perm
-
-  return civicrm_api($entity, $action, $params);
-
-});
-$apiServer->handleAndRespond(file_get_contents('php://input'));
+CRM_Cxn_BAO_Cxn::createApiServer()
+  ->handle(file_get_contents('php://input'))
+  ->send();