/**
* Get a list of setup-actions.
*
- * @return array
+ * @return array{array{title:string, callback: mixed, url: string}}
* List of available actions. See description in the hook-docs.
* @see CRM_Utils_Hook::mailSetupActions()
*/
];
CRM_Utils_Hook::mailSetupActions($setupActions);
+
+ foreach ($setupActions as $key => &$setupAction) {
+ if (!isset($setupAction['url'])) {
+ $setupAction['url'] = (string) Civi::url('//civicrm/ajax/setupMailAccount')->addQuery(['type' => $key]);
+ }
+ }
+
return $setupActions;
}
* - title: string
* - callback: string|array, the function which starts the setup process.
* The function is expected to return a 'url' for the config screen.
+ * - url: string (optional), a URL which starts the setup process.
+ * If omitted, then a default URL is generated. The effect of opening the URL is
+ * to invoke the `callback`.
* @return mixed
*/
public static function mailSetupActions(&$setupActions) {
<select id="crm-mail-setup" name="crm-mail-setup" class="crm-select2 crm-form-select" aria-label="{ts}Add Mail Account{/ts}">
<option value="" aria-hidden="true">{ts}Add Mail Account{/ts}</option>
{foreach from=$setupActions key=setupActionsName item=setupAction}
- <option value="{$setupActionsName|escape}">{$setupAction.title|escape}</option>
+ <option data-url="{$setupAction.url|escape}" value="{$setupActionsName|escape}">{$setupAction.title|escape}</option>
{/foreach}
</select>
</form>
return;
}
event.stopPropagation();
- var url = CRM.url('civicrm/ajax/setupMailAccount', {type: event.val});
- window.location = url;
+ window.location = cj(event.choice.element).data('url');
});
</script>
{/literal}