if ($this->_action & CRM_Core_Action::ADD) {
$defaults['object_type'] = 1;
- $defaults['priority'] = 0;
+ $defaults['deny'] = 0;
+ $defaults['priority'] = 1 + CRM_Utils_Weight::getMax(CRM_ACL_DAO_ACL::class, NULL, 'priority');
}
$showHide = new CRM_Core_ShowHideBlocks();
$this->addRadio('deny', ts('Mode'), [
0 => ts('Allow'),
1 => ts('Deny'),
- ]);
- $this->add('number', 'priority', ts('Priority'));
+ ], [], NULL, TRUE);
+ $this->add('number', 'priority', ts('Priority'), ['min' => 1], TRUE);
$this->addFormRule(['CRM_ACL_Form_ACL', 'formRule']);
}
$params['id'] = $this->_id;
}
+ $params['priority'] = \CRM_Utils_Weight::updateOtherWeights(CRM_ACL_DAO_ACL::class, $this->_values['priority'] ?? NULL, $params['priority'], NULL, 'priority');
CRM_ACL_BAO_ACL::writeRecord($params);
}
}
{* file to handle db changes in 5.64.alpha1 during upgrade *}
+UPDATE `civicrm_acl` SET `priority` = `id`;
+
-- fix mis-casing of field name. Note the php function doesn't permit the name change hence it is here
-- but field is not localised.
ALTER TABLE civicrm_uf_group
*/
namespace Civi\Api4;
+use Civi\Api4\Generic\Traits\SortableEntity;
+
/**
* ACL (Access Control List).
*
* @searchable none
* @see https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control
* @since 5.19
+ * @orderBy priority
* @package Civi\Api4
*/
class ACL extends Generic\DAOEntity {
+ use SortableEntity;
}
</tr>
<tr class="crm-acl-form-block-priority">
<td class="label">{$form.priority.label}</td>
- <td>{$form.priority.label}<br />
+ <td>{$form.priority.html}<br />
<span class="description">{ts}Higher priority ACL rules will override lower priority rules{/ts}</span>
</td>
</tr>
<table id="options" class="display">
<thead>
<tr class="columnheader">
- <th id="sortable">{ts}Role{/ts}</th>
+ <th>{ts}Role{/ts}</th>
<th>{ts}Operation{/ts}</th>
<th>{ts}Type of Data{/ts}</th>
<th>{ts}Which Data{/ts}</th>
<th>{ts}Description{/ts}</th>
<th>{ts}Enabled?{/ts}</th>
<th>{ts}Mode{/ts}</th>
- <th>{ts}Priority{/ts}</th>
+ <th id="sortable">{ts}Priority{/ts}</th>
<th></th>
</tr>
</thead>