>{{cxn.app_meta.title}}</a>
</td>
<td><div ng-bind-html="cxn.app_meta.desc"></div></td>
- <td>{{cxn.is_active ? ts('Enabled') : ts('Disabled')}}</td>
+ <td>{{cxn.is_active=="1" ? ts('Enabled') : ts('Disabled')}}</td>
<td>
<span>
- <!--
- <a class="action-item crm-hover-button" ng-click="toggleCxn(cxn)">{{cxn.is_active ? ts('Disable') : ts('Enable') }}</a>
- -->
<a class="action-item crm-hover-button" ng-click="openLink(cxn.app_meta, 'settings', {title: ts('%1: Settings (External)', {1: cxn.app_meta.title})})" ng-show="cxn.app_meta.links.settings">{{ts('Settings')}}</a>
<span class="btn-slide crm-hover-button">{{ts('more')}}
<ul class="panel" style="display: none;">
{{ts('Support')}}
</a>
</li>
+ <li>
+ <a class="action-item crm-hover-button" ng-click="toggleCxn(cxn)">{{ cxn.is_active=="1" ? ts('Disable') : ts('Enable')}}</a>
+ </li>
<li>
<a class="action-item crm-hover-button"
crm-confirm='{width: "65%", resizable: true, title:ts("%1: Reconnect", {1: cxn.app_meta.title}), templateUrl: "~/crmCxn/ConfirmReconnectCtrl.html", export: {cxn: cxn, appMeta: findAppByAppId(cxn.app_guid)}}'
};
$scope.toggleCxn = function toggleCxn(cxn) {
- var reg = crmApi('Cxn', 'create', {id: cxn.id, is_active: !cxn.is_active, debug: 1}).then(function(){
- cxn.is_active = !cxn.is_active;
+ var is_active = (cxn.is_active=="1" ? 0 : 1); // we switch the flag
+ var reg = crmApi('Cxn', 'create', {id: cxn.id, app_guid: cxn.app_meta.appId, is_active: is_active, debug: 1}).then(function(){
+ cxn.is_active = is_active;
});
return block(crmStatus({start: ts('Saving...'), success: ts('Saved')}, reg));
};
'page' => $params['page'],
));
}
+
+/**
+ * Creates or modifies a Cxn row.
+ *
+ * @param array $params
+ * Array with keys:
+ * - id, cxn_guid OR app_guid: string.
+ * - is_active: boolean.
+ * - options: JSON
+ * @return page
+ * @throws Exception
+ */
+function civicrm_api3_cxn_create($params) {
+ $result = "";
+
+ try {
+ // get the ID
+ if (!empty($params['id'])) {
+ $cxnId = $params['id'];
+ }
+ else {
+ $cxnId = _civicrm_api3_cxn_parseCxnId($params);
+ }
+
+ // see if it's sth to update
+ if (isset($params['options']) || isset($params['is_active'])) {
+
+ $dao = new CRM_Cxn_DAO_Cxn();
+ $dao->id = $cxnId;
+
+ if ($dao->find()) {
+ if (isset($params['is_active'])) {
+ $dao->is_active = (int) $params['is_active'];
+ }
+ if (isset($params['options'])) {
+ $dao->options = $params['options'];
+ }
+
+ $result = $dao->save();
+ }
+
+ }
+ return civicrm_api3_create_success($result, $params, 'Cxn', 'create');
+
+ }
+ catch(Exception $ex){
+ throw $ex;
+ }
+}