$dao = new CRM_ACL_DAO_ACL();
$dao->copyValues($params);
$dao->save();
+ return $dao;
}
static function retrieve(&$params, &$defaults) {
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
- 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_ACL_BAO_ACL' . '\',\'' . 'enable-disable' . '\' );"',
- 'ref' => 'disable-action',
+ 'ref' => 'crm-enable-disable',
'title' => ts('Disable ACL'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
- 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_ACL_BAO_ACL' . '\',\'' . 'disable-enable' . '\' );"',
- 'ref' => 'enable-action',
+ 'ref' => 'crm-enable-disable',
'title' => ts('Enable ACL'),
),
CRM_Core_Action::DELETE => array(
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | 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 |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ * File for the CiviCRM APIv3 acl functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_acl
+ *
+ */
+
+/**
+ * Save an acl
+ *
+ * Allowed @params array keys are:
+ * {@getfields acl_create}
+ * @example aclCreate.php
+ *
+ * @return array of newly created acl property values.
+ * @access public
+ */
+function civicrm_api3_acl_create($params) {
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Get an acl
+ *
+ * Allowed @params array keys are:
+ * {@getfields acl_get}
+ * @example aclCreate.php
+ *
+ * @return array of retrieved acl property values.
+ * @access public
+ */
+function civicrm_api3_acl_get($params) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Delete an acl
+ *
+ * Allowed @params array keys are:
+ * {@getfields acl_delete}
+ * @example aclCreate.php
+ *
+ * @return array of deleted values.
+ * @access public
+ */
+function civicrm_api3_acl_delete($params) {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
//hack to deal with incorrectly named BAO/DAO - see CRM-10859 -
// several of these have been removed but am not confident mailing_recipients is
// tests so have not tackled.
- // correct approach for im is unclear
if($name == 'mailing_recipients' || $name == 'MailingRecipients'){
return 'CRM_Mailing_BAO_Recipients';
}
- if(strtolower($name) == 'im'){
- return 'CRM_Core_BAO_IM';
+ // correct approach for im & acl is unclear
+ if (strtolower($name) == 'im' || strtolower($name) == 'acl') {
+ $name = strtoupper($name);
}
return CRM_Core_DAO_AllCoreTables::getFullName(_civicrm_api_get_camel_name($name, 3));
}
// Open action links in a popup
.on('click', 'a.button, a.action-item:not(".crm-enable-disable")', function() {
CRM.loadForm($(this).attr('href'), {
- openInline: 'a'
+ openInline: 'a:not(".crm-enable-disable")'
}).on('crmFormSuccess', function(e, data) {
// Refresh page when form completes
$('#crm-main-content-wrapper').crmSnippet('refresh');
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
- +--------------------------------------------------------------------+
- | 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 |
- +--------------------------------------------------------------------+
-
-*
+/**
* Copyright (C) 2012 Xavier Dutoit
* Licensed to CiviCRM under the Academic Free License version 3.0.
*
* to make it easier to customize the form (eg. hide a button...) it triggers a 'load' event on the form. you can then catch the load on your code (using the $('#id_of_the_form').on(function(){//do something
*/
-
(function($) {
$.fn.crmEditable = function (options) {
}
// param in : a dom object that contains the field name as a class crmf-xxx
var getFieldName = function (field) {
- if ($(field).data('field')) {
- return $(field).data('field');
- }
- var fieldName=field.className.match(/crmf-(\S*)/)[1];
+ var fieldName = $(field).data('field') || field.className.match(/crmf-(\S*)/)[1];
if (!fieldName) {
console && console.log && console.log("Couldn't get the crm-editable field name to modify. You need to set crmf-{field_name} or data-{field_name}");
- return false;
}
return fieldName;
}
</div>
{if $rows}
-<div class="">
<div id="ltype">
{strip}
{* handle enable/disable actions*}
- {include file="CRM/common/enableDisable.tpl"}
+ {include file="CRM/common/enableDisableApi.tpl"}
{include file="CRM/common/jsortable.tpl"}
<table id="options" class="display">
<thead>
</thead>
<tbody>
{foreach from=$rows item=row key=aclID}
- <tr id="row_{$aclID}"class="{cycle values="odd-row,even-row"} {$row.class} crm-acl {if NOT $row.is_active} disabled{/if}">
+ <tr id="acl-{$aclID}" class="{cycle values="odd-row,even-row"} {$row.class} crm-acl crm-entity {if NOT $row.is_active} disabled{/if}">
<td class="crm-acl-entity">{$row.entity}</td>
<td class="crm-acl-operation" >{$row.operation}</td>
<td class="crm-acl-object_name">{$row.object_name}</td>
<td class="crm-acl-object" >{$row.object}</td>
- <td class="crm-acl-name">{$row.name}</td>
+ <td class="crm-acl-name crm-editable" data-field="name">{$row.name}</td>
<td class="crm-acl-is_active" id="row_{$aclID}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
<td>{$row.action|replace:'xx':$aclID}</td>
</tr>
</div>
{/if}
</div>
+{include file="CRM/common/crmeditable.tpl"}
{elseif $action ne 1 and $action ne 2 and $action ne 8}
<div class="messages status no-popup">
<img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/>
{literal}
<script type="text/javascript">
cj(function($) {
- var $row, entity, id, enabled, snippet;
+ var $row, $table, entity, id, enabled;
function refresh() {
- snippet.crmSnippet('refresh');
+ if (false && $.fn.DataTable.fnIsDataTable($table[0])) { // fixme why doesn't this work?
+ $table.dataTable().fnDraw();
+ } else {
+ // Refresh an existing ajax container or create a new one
+ $row.closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet().crmSnippet('refresh');
+ }
CRM.alert('', enabled ? {/literal}'{ts escape="js"}Record Disabled{/ts}' : '{ts escape="js"}Record Enabled{/ts}'{literal}, 'success');
}
function save() {
- snippet = $row.closest('.crm-ajax-container');
- if (snippet.length && snippet.crmSnippet('option', 'block')) {
- snippet.block();
- }
+ $table = $row.closest('table');
+ $table.block();
CRM.api(entity, 'create', {id: id, is_active: enabled ? 0 : 1}, {success: refresh});
}