Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • documentation/docs/dev
  • totten/dev
  • bgm/dev
  • ivan_compucorp/dev
  • seamuslee/dev
  • artfulrobot/dev
  • ufundo/dev
  • wmortada/dev
  • lucky091588/dev
  • DaveD/dev
  • jtwyman/dev
  • rukkykofi/dev
  • JonGold/dev
  • jaapjansma/developer-docs
  • alainb/dev
  • noah/dev
  • justinfreeman/dev
  • pradeep/dev
  • larssg/dev
  • eileen/dev
  • darrick/dev
  • mattwire/dev
  • colemanw/dev
  • homotechsual/dev
  • JoeMurray/dev
  • maynardsmith/dev
  • kurund/dev
  • rocxa/dev
  • AllenShaw/dev
  • bradleyt/dev
  • chrisgaraffa/dev
  • martin.w/dev
  • herbdool/dev
  • MattTrim1/dev
  • Detlev/dev
  • ErikHommel/dev
  • brienne/devdocs
  • pminf/dev
  • SarahFG/dev
  • ayduns/dev
  • JKingsnorth/dev
  • ginkgomzd/dev
  • nicol/dev
  • almeidam/dev
  • arthurm/dev
  • damilare/dev
  • semseysandor/dev
  • major/devdocs
  • usha.makoa/dev
  • yurg/dev
  • shaneonabike/dev
  • andie/dev
  • mmyriam/dev
  • gngn/dev
  • florian-dieckmann/dev
  • jade/dev
  • luke.stewart/dev
  • vinaygawade/dev
58 results
Show changes
Commits on Source (3113)
Showing
with 982 additions and 333 deletions
name: Mark stale issues and pull requests
on:
schedule:
- cron: "0 * * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has had no activity in 60 days and has been marked as stale, it will not be closed.'
stale-pr-message: 'This pull request has had no activity in 60 days and has been marked as stale, it will not be closed.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
days-before-stale: 60
days-before-close: -1
exempt-issue-labels: 'awaiting-approval,work-in-progress'
exempt-pr-labels: 'awaiting-approval,work-in-progress'
remove-stale-when-updated: 'True'
site
.idea
*~
Creative Commons Legal Code
Attribution-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined below) for the purposes of this
License.
c. "Creative Commons Compatible License" means a license that is listed
at https://creativecommons.org/compatiblelicenses that has been
approved by Creative Commons as being essentially equivalent to this
License, including, at a minimum, because that license: (i) contains
terms that have the same purpose, meaning and effect as the License
Elements of this License; and, (ii) explicitly permits the relicensing
of adaptations of works made available under that license under this
License or a Creative Commons jurisdiction license with the same
License Elements as this License.
d. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
e. "License Elements" means the following high-level license attributes
as selected by Licensor and indicated in the title of this License:
Attribution, ShareAlike.
f. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
g. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
h. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
i. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
j. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
k. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(c), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(c), as requested.
b. You may Distribute or Publicly Perform an Adaptation only under the
terms of: (i) this License; (ii) a later version of this License with
the same License Elements as this License; (iii) a Creative Commons
jurisdiction license (either this or a later license version) that
contains the same License Elements as this License (e.g.,
Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible
License. If you license the Adaptation under one of the licenses
mentioned in (iv), you must comply with the terms of that license. If
you license the Adaptation under the terms of any of the licenses
mentioned in (i), (ii) or (iii) (the "Applicable License"), you must
comply with the terms of the Applicable License generally and the
following provisions: (I) You must include a copy of, or the URI for,
the Applicable License with every copy of each Adaptation You
Distribute or Publicly Perform; (II) You may not offer or impose any
terms on the Adaptation that restrict the terms of the Applicable
License or the ability of the recipient of the Adaptation to exercise
the rights granted to that recipient under the terms of the Applicable
License; (III) You must keep intact all notices that refer to the
Applicable License and to the disclaimer of warranties with every copy
of the Work as included in the Adaptation You Distribute or Publicly
Perform; (IV) when You Distribute or Publicly Perform the Adaptation,
You may not impose any effective technological measures on the
Adaptation that restrict the ability of a recipient of the Adaptation
from You to exercise the rights granted to that recipient under the
terms of the Applicable License. This Section 4(b) applies to the
Adaptation as incorporated in a Collection, but this does not require
the Collection apart from the Adaptation itself to be made subject to
the terms of the Applicable License.
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Ssection 3(b), in the case of an
Adaptation, a credit identifying the use of the Work in the Adaptation
(e.g., "French translation of the Work by Original Author," or
"Screenplay based on original Work by Original Author"). The credit
required by this Section 4(c) may be implemented in any reasonable
manner; provided, however, that in the case of a Adaptation or
Collection, at a minimum such credit will appear, if a credit for all
contributing authors of the Adaptation or Collection appears, then as
part of these credits and in a manner at least as prominent as the
credits for the other contributing authors. For the avoidance of
doubt, You may only use the credit required by this Section for the
purpose of attribution in the manner set out above and, by exercising
Your rights under this License, You may not implicitly or explicitly
assert or imply any connection with, sponsorship or endorsement by the
Original Author, Licensor and/or Attribution Parties, as appropriate,
of You or Your use of the Work, without the separate, express prior
written permission of the Original Author, Licensor and/or Attribution
Parties.
d. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of the License.
Creative Commons may be contacted at https://creativecommons.org/.
# CiviCRM Developer Guide
* **Issues have moved to https://lab.civicrm.org/documentation/docs/dev/-/issues**
* **Submit new merge/pull requests at https://lab.civicrm.org/documentation/docs/dev**
A documentation guide for people who develop with/for [CiviCRM](https://civicrm.org).
- [Read published version](http://docs.civicrm.org/dev/en/master)
- [Learn how to edit](https://docs.civicrm.org/dev/en/master/documentation/#how-to-edit)
This Developer Guide will likely be merged into the
[civicrm-core](https://github.com/civicrm/civicrm-core/) repo at some point.
\ No newline at end of file
# Docs Infrastructure Links
- [Docs Publisher system and issue queue](https://lab.civicrm.org/documentation/docs-publisher)
- [Docs Book definitions for the Docs Publisher](https://lab.civicrm.org/documentation/docs-books)
- [Docs Working Group meta issue queue](https://lab.civicrm.org/documentation/meta)
......@@ -5,6 +5,9 @@
* Where should we store deprecated documentation? Should we include it at all?
* Should we rename `develop.md` (`core/develop.md` vs `extension/develop.md`?)
## Style Guide
* Add guide for using footnotes
## Tasks
* Finish importing [GitHub for CiviCRM](https://wiki.civicrm.org/confluence/display/CRMDOC43/GitHub+for+CiviCRM) to `develop.md` and `develop-deprecated.md`.
......
#!/usr/bin/env python
import yaml
import re
from os.path import dirname, abspath, join
PROJECT_ROOT = dirname(dirname(abspath(__file__)))
DOCS_ROOT = join(PROJECT_ROOT, 'docs/')
MKDOCS_YAML_FILE = join(PROJECT_ROOT, 'mkdocs.yml')
OUTPUT_FILE = join(DOCS_ROOT, 'hooks/', 'list.md')
HEADER = """# All hooks
<!--
-- DO NOT EDIT
--
-- This entire page is auto-generated by the following command:
-- ./bin/hook-summary.py
--
-->
This is an overview list of all available hooks and the event listeners that
are supported for use outside of core. Any event listeners not listed here
are not supported for use outside of core & could change without notice
"""
def findBetween( s, first, last ):
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
def getSummary(hookFile):
content = open(join(DOCS_ROOT + hookFile), 'r').read()
summary = findBetween(content, '## Summary', '##')
summary = re.sub('This hook (is)?(was)?', '', summary)
summary = re.sub('\s+', ' ', summary).strip()
if not (summary.endswith('.')):
summary = summary + '.'
return summary
output = f = open(OUTPUT_FILE, 'w')
with open(MKDOCS_YAML_FILE, 'r') as f:
doc = yaml.load(f, Loader=yaml.FullLoader)
pages = doc["nav"]
for section in pages:
if "Hooks" in section:
hookSection = section.get("Hooks")
output.write(HEADER)
for section in hookSection:
categoryHooks = list()
category, hookList = section.popitem()
if isinstance(hookList, list):
for hookDetails in hookList:
hookName = list(hookDetails)[0]
if re.match("^(<del>)?hook_civicrm_*", hookName) or re.match("^civi", hookName):
categoryHooks.append(hookDetails)
if len(categoryHooks) > 0:
output.write('\n## {}\n\n'.format(category))
for hookDetails in categoryHooks:
hookName, hookFile = hookDetails.popitem()
summary = getSummary(hookFile)
hookNameForLink = hookFile.replace('hooks/', '')
output.write('* **[{}]({})** - {}\n'.format(hookName, hookNameForLink, summary))
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
$wiki_url = 'https://wiki.civicrm.org/confluence/display/CRMDOC';
$cache_dir = __DIR__ . '/wiki_cache';
chdir($cache_dir);
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
if ( file_exists($hook_name) ) {
echo "SKIPPING: $hook_name (already cached)";
}
else {
echo "DOWNLOADING: $hook_name" . PHP_EOL;
system("curl '$wiki_url/$hook_name' > '$hook_name'");
}
echo PHP_EOL;
}
}
echo "DONE" . PHP_EOL;
<?php
$hooks_by_category = [
"Database" => [
['name' => "hook_civicrm_copy", 'is_deprecated' => false],
['name' => "hook_civicrm_custom", 'is_deprecated' => false],
['name' => "hook_civicrm_managed", 'is_deprecated' => false],
['name' => "hook_civicrm_merge", 'is_deprecated' => false],
['name' => "hook_civicrm_post", 'is_deprecated' => false],
['name' => "hook_civicrm_pre", 'is_deprecated' => false],
['name' => "hook_civicrm_trigger_info", 'is_deprecated' => false],
['name' => "hook_civicrm_referenceCounts", 'is_deprecated' => false],
['name' => "hook_civicrm_postSave_table_name", 'is_deprecated' => false],
],
"Extension lifecycle" => [
['name' => "hook_civicrm_disable", 'is_deprecated' => false],
['name' => "hook_civicrm_enable", 'is_deprecated' => false],
['name' => "hook_civicrm_install", 'is_deprecated' => false],
['name' => "hook_civicrm_uninstall", 'is_deprecated' => false],
['name' => "hook_civicrm_upgrade", 'is_deprecated' => false],
['name' => "hook_civicrm_postInstall", 'is_deprecated' => false],
],
"Form" => [
['name' => "hook_civicrm_alterContent", 'is_deprecated' => false],
['name' => "hook_civicrm_buildForm", 'is_deprecated' => false],
['name' => "hook_civicrm_postProcess", 'is_deprecated' => false],
['name' => "hook_civicrm_validateForm", 'is_deprecated' => false],
['name' => "hook_civicrm_alterTemplateFile", 'is_deprecated' => false],
['name' => "hook_civicrm_preProcess", 'is_deprecated' => false],
['name' => "hook_civicrm_idsException", 'is_deprecated' => false],
],
"GUI" => [
['name' => "hook_civicrm_buildAmount", 'is_deprecated' => false],
['name' => "hook_civicrm_caseSummary", 'is_deprecated' => false],
['name' => "hook_civicrm_customFieldOptions", 'is_deprecated' => true],
['name' => "hook_civicrm_dashboard", 'is_deprecated' => false],
['name' => "hook_civicrm_links", 'is_deprecated' => false],
['name' => "hook_civicrm_navigationMenu", 'is_deprecated' => false],
['name' => "hook_civicrm_pageRun", 'is_deprecated' => false],
['name' => "hook_civicrm_searchColumns", 'is_deprecated' => false],
['name' => "hook_civicrm_searchTasks", 'is_deprecated' => false],
['name' => "hook_civicrm_summary", 'is_deprecated' => false],
['name' => "hook_civicrm_summaryActions", 'is_deprecated' => false],
['name' => "hook_civicrm_tabs", 'is_deprecated' => true],
['name' => "hook_civicrm_xmlMenu", 'is_deprecated' => false],
['name' => "hook_civicrm_tabset", 'is_deprecated' => false],
['name' => "hook_civicrm_dashboard_defaults", 'is_deprecated' => false],
['name' => "hook_civicrm_contact_get_displayname", 'is_deprecated' => false],
['name' => "hook_civicrm_fieldOptions", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMenu", 'is_deprecated' => false],
],
"Mail" => [
['name' => "hook_civicrm_alterMailParams", 'is_deprecated' => false],
['name' => "hook_civicrm_emailProcessor", 'is_deprecated' => false],
['name' => "hook_civicrm_emailProcessorContact", 'is_deprecated' => false],
['name' => "hook_civicrm_mailingGroups", 'is_deprecated' => false],
['name' => "hook_civicrm_postEmailSend", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailer", 'is_deprecated' => false],
['name' => "hook_civicrm_unsubscribeGroups", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailContent", 'is_deprecated' => false],
['name' => "hook_civicrm_postMailing", 'is_deprecated' => false],
],
"Permission" => [
['name' => "hook_civicrm_aclGroup", 'is_deprecated' => false],
['name' => "hook_civicrm_aclWhereClause", 'is_deprecated' => false],
['name' => "hook_civicrm_alterAPIPermissions", 'is_deprecated' => false],
['name' => "hook_civicrm_permission_check", 'is_deprecated' => false],
['name' => "hook_civicrm_permission", 'is_deprecated' => false],
['name' => "hook_civicrm_selectWhereClause", 'is_deprecated' => false],
],
"Uncategorized" => [
['name' => "hook_civicrm_alterCalculatedMembershipStatus", 'is_deprecated' => false],
['name' => "hook_civicrm_alterBarcode", 'is_deprecated' => false],
['name' => "hook_civicrm_alterBadge", 'is_deprecated' => false],
['name' => "hook_civicrm_alterPaymentProcessorParams", 'is_deprecated' => false],
['name' => "hook_civicrm_alterSettingsFolders", 'is_deprecated' => false],
['name' => "hook_civicrm_alterSettingsMetaData", 'is_deprecated' => false],
['name' => "hook_civicrm_apiWrappers", 'is_deprecated' => false],
['name' => "hook_civicrm_buildStateProvinceForCountry", 'is_deprecated' => false],
['name' => "hook_civicrm_config", 'is_deprecated' => false],
['name' => "hook_civicrm_contactListQuery", 'is_deprecated' => true],
['name' => "hook_civicrm_cron", 'is_deprecated' => false],
['name' => "hook_civicrm_dupeQuery", 'is_deprecated' => false],
['name' => "hook_civicrm_export", 'is_deprecated' => false],
['name' => "hook_civicrm_import", 'is_deprecated' => false],
['name' => "hook_civicrm_membershipTypeValues", 'is_deprecated' => false],
['name' => "hook_civicrm_tokens", 'is_deprecated' => false],
['name' => "hook_civicrm_tokenValues", 'is_deprecated' => false],
['name' => "hook_civicrm_queryObjects", 'is_deprecated' => false],
['name' => "hook_civicrm_check", 'is_deprecated' => false],
['name' => "hook_civicrm_optionValues", 'is_deprecated' => true],
['name' => "hook_civicrm_coreResourceList", 'is_deprecated' => false],
['name' => "hook_civicrm_angularModules", 'is_deprecated' => false],
['name' => "hook_civicrm_container", 'is_deprecated' => false],
['name' => "hook_civicrm_crudLink", 'is_deprecated' => false],
['name' => "hook_civicrm_fileSearches", 'is_deprecated' => false],
['name' => "hook_civicrm_notePrivacy", 'is_deprecated' => false],
['name' => "hook_civicrm_eventDiscount", 'is_deprecated' => false],
['name' => "hook_civicrm_recent", 'is_deprecated' => false],
['name' => "hook_civicrm_unhandledException", 'is_deprecated' => false],
['name' => "hook_civicrm_alterMailingLabelParams", 'is_deprecated' => false],
['name' => "hook_civicrm_geocoderFormat", 'is_deprecated' => false],
['name' => "hook_civicrm_alterLogTables", 'is_deprecated' => false],
],
"Case" => [
['name' => "hook_civicrm_caseChange", 'is_deprecated' => false],
['name' => "hook_civicrm_caseTypes", 'is_deprecated' => false],
['name' => "hook_civicrm_post_case_merge", 'is_deprecated' => false],
['name' => "hook_civicrm_pre_case_merge", 'is_deprecated' => false],
],
"Batch" => [
['name' => "hook_civicrm_batchItems", 'is_deprecated' => false],
['name' => "hook_civicrm_batchQuery", 'is_deprecated' => false],
],
"Entity" => [
['name' => "hook_civicrm_entityTypes", 'is_deprecated' => false],
],
"CiviRules" => [
['name' => "hook_civirules_alter_trigger_data", 'is_deprecated' => false],
['name' => "hook_civirules_logger", 'is_deprecated' => false],
],
"Profile" => [
['name' => "hook_civicrm_buildProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_buildUFGroupsForModule", 'is_deprecated' => false],
['name' => "hook_civicrm_processProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_searchProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_validateProfile", 'is_deprecated' => false],
['name' => "hook_civicrm_viewProfile", 'is_deprecated' => false],
],
"Report" => [
['name' => "hook_civicrm_alterReportVar", 'is_deprecated' => false],
],
];
\ No newline at end of file
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
$cache_dir = __DIR__ . '/wiki_cache';
$root_dir = dirname(dirname(__DIR__));
$hooks_dir = "$root_dir/docs/hooks";
function clean_markdown($markdown) {
// add domain name to all hyperlinks that point to the wiki
$pattern = '@\]\((/confluence[^)]*)\)@';
$replace = '](https://wiki.civicrm.org$1)';
$markdown = preg_replace($pattern,$replace,$markdown);
// set all headings of level 3 and above to level 2
$pattern = '@^(##)(#+) (.*)$@m';
$replace = '## $3';
$markdown = preg_replace($pattern,$replace,$markdown);
return $markdown;
}
# create hooks directory if needed
if ( !is_dir($hooks_dir) ) {
mkdir($hooks_dir);
}
chdir($hooks_dir);
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
$markdown_file = "$hook_name.md";
$html = "$cache_dir/$hook_name";
if ( file_exists($html) && !file_exists($markdown_file) ) {
echo "converting $hook_name ... ";
$conv_output_array = array();
$conv_status = 1;
exec("webpage2md $html", $conv_output_array, $conv_status);
if( $conv_status == 0 ) {
$conv_output = implode("\n",$conv_output_array);
$conv_output = clean_markdown($conv_output);
file_put_contents($markdown_file, $conv_output);
echo "done" . PHP_EOL;
}
else {
echo "ERROR CONVERTING $hook_name" . PHP_EOL;
echo "$conv_output";
}
}
else if ( !file_exists($html) ) {
echo "WARNING: $hook_name not yet fetched" . PHP_EOL;
}
else if ( file_exists($markdown_file) ) {
echo "ignoring $hook_name (markdown file already exists)" . PHP_EOL;
}
}
}
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
echo "- Hooks:" . PHP_EOL;
foreach ($hooks_by_category as $category => $hooks) {
echo " - $category hooks:" . PHP_EOL;
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
if ( $hook['is_deprecated'] ) {
$menu_name = "<del>$hook_name</del>";
}
else {
$menu_name = $hook_name;
}
echo " - $menu_name: hooks/$hook_name.md" . PHP_EOL;
}
}
#!/usr/bin/env php
<?php
include __DIR__ . '/hooks-by-category.php';
foreach ($hooks_by_category as $category => $hooks) {
foreach ($hooks as $hook) {
$hook_name = $hook['name'];
echo "$hook_name hooks/$hook_name" . PHP_EOL;
}
}
# Ignore everything in this directory
*
# Except this file
!.gitignore
\ No newline at end of file
## FormBuilder Behaviors
### Overview
Simply put, a **Behavior** extends the functionality of an **entity**.
Behaviors are PHP classes written by a developer, which can be enabled in the GUI to affect how entities behave on a form.
Each Behavior class declares some configuration metadata which automatically appears in the Afform GUI. The user can
make selections to enable and configure the behavior.
To enact its functionality, a behavior class can listen to any Civi hook or event, notably `civi.afform.prefill` and `civi.afform.submit`.
These events are called for every entity on a form, and will include information such as the entity name, type, and any
behaviors that have been configured for that entity.
### Examples
A good example to emulate is the [Contact Dedupe Behavior](https://github.com/civicrm/civicrm-core/blob/master/ext/afform/core/Civi/Afform/Behavior/ContactDedupe.php).
```php
class ContactDedupe extends AbstractBehavior implements EventSubscriberInterface {
```
It starts off by extending the `AbstractBehavior` class, which makes it discoverable to Afform,
and also implementing `EventSubscriberInterface`, which is the recommended way to subscribe to events. That interface
requires a `getSubscribedEvents` function:
```php
/**
* @return array
*/
public static function getSubscribedEvents() {
return [
'civi.afform.submit' => ['onAfformSubmit', 101],
];
}
```
That registers the callback function named `onAfformSubmit` in the same class, to be called every time an Afform entity
is about to be saved.
The next 4 functions are part of the `AfformBehavior` interface, and provide enough information for the AfformAdmin GUI
to show the behavior to the user for configuration:
```php
public static function getEntities():array {
return \CRM_Contact_BAO_ContactType::basicTypes();
}
public static function getTitle():string {
return E::ts('Duplicate Matching');
}
public static function getDescription():string {
return E::ts('Update existing contact instead of creating a new one based on a dedupe rule.');
}
public static function getModes(string $entityName):array {
...
}
```
Note that `getEntities` does not simply return "Contact" because Afform considers "Individual", "Household" and "Organization"
to all be their own entities.
The `getModes` function returns an array of operation modes (in this case dedupe rules) for a particular entity type.
So if your Behavior can act on more than one entity type as this one can, pay attention to the `$entityName` parameter
and only return modes relevant to that type of entity (in this case, there are different dedupe rules for "Individual" vs
"Organization", etc).
Finally, the callback registered with `getSubscribedEvents`:
```php
public static function onAfformSubmit(AfformSubmitEvent $event) {
$entity = $event->getEntity();
$dedupeMode = $entity['contact-dedupe'] ?? NULL;
if ($event->getEntityType() !== 'Contact' || !$dedupeMode) {
return;
}
// Apply dedupe rule if contact isn't already identified
foreach ($event->records as $index => $record) {
$supportedJoins = ['Address', 'Email', 'Phone', 'IM'];
$values = $record['fields'] ?? [];
foreach ($supportedJoins as $joinEntity) {
if (!empty($record['joins'][$joinEntity][0])) {
$values += \CRM_Utils_Array::prefixKeys($record['joins'][$joinEntity][0], strtolower($joinEntity) . '_primary.');
}
}
$match = Contact::getDuplicates(FALSE)
->setValues($values)
->setDedupeRule($dedupeMode)
->execute()->first();
if (!empty($match['id'])) {
$event->setEntityId($index, $match['id']);
}
}
}
```
This function checks the `contact-dedupe` mode set by the Admin (this is a kebab-case version of the class name)
and takes action on every record being saved for that entity (normally one entity saves one record, but because of the
AfRepeat feature, entities should always be treated as if they may be multivalued).
# Afform Core
The core of the Afform extension is an AngularJS module factory. Traditionally, to [add a new AngularJS module
in CiviCRM](../framework/angular/quickstart.md), one must create an `.ang.php` file, a js module file, some
controllers, components & templates, plus a page route to bootstrap AngularJS and load the module.
Afform Core does all that for you, all you need is a template `.aff.html` file and an optional configuration `.aff.json` file.
## Creating a Form in an Extension
As an extension author, you can define a form along with its default, canonical content.
Simply create a file `ang/MYFORM.aff.html`. In this example, we create a form named `helloWorld`:
1. Make sure you're in the directory with your extension (`cd /path/to/extension`)
2. Make an `ang` directory in your extension. (`mkdir ang`)
3. Add some HTML/JS code to your `aff.html` file. `echo '<div>Hello {{routeParams.name}}</div>' > ang/helloWorld.aff.html`
4. Add some JSON config to your `aff.json` file. `echo '{"server_route": "civicrm/hello-world"}' > ang/helloWorld.aff.json`
5. Flush the caches so CiviCRM picks up the new form. `cv flush`
A few things to note:
* The `ang` folder is the typical location for AngularJS modules in CiviCRM extensions.
* We defined a route `civicrm/hello-world`. This appears in the same routing system used by CiviCRM forms. It also supports properties such as `title` (page title) and `is_public` (defaults to `false`).
* After creating a new form or file, we should flush the cache.
* If you're going to actively edit/revise the content of the file, then you should navigate to **Administer > System Settings > Debugging** and disable asset caching.
* The extension `*.aff.html` represents an AngularJS HTML document. It has access to all the general features of Angular HTML (discussed more later).
* In AngularJS, there is a distinction between a "module" (unit-of-code to be shared; usually appears as `camelCase`) and a "directive" (a custom HTML element; may appear as `camelCase` or as `kebab-case` depending on context). Afform supports a tactical simplification in which one `*.aff.html` corresponds to one eponymous module and one eponymous directive.
Now that we've created a form, we'll want to determine its URL. As with most CiviCRM forms, the URL depends on the CMS configuration. Here is an example from a local Drupal 7 site:
We can use `cv` to get full URLs for any `civicrm/*` URL like so:
* `cv url "civicrm/hello-world"` returns `http://dmaster.localhost/civicrm/hello-world`
* `cv url "civicrm/hello-world/#/?name=world"` returns `http://dmaster.localhost/civicrm/hello-world/#/?name=world`
Open the URLs and see what you get.
## Form Overrides
Afform files inside an extension (aka a _"Packaged"_ form), are considered the default state, or _"base"_.
If you fetch your form via API (e.g. the APIv4 Explorer), `civicrm_api4('Afform', 'get')` will return something like this:
```
[
{
name: "helloWorld" // this corresponds to file name minus .aff.html extensions
server_route: "civicrm/hello-world" // as defined in helloWorld.aff.json
has_base: true,
has_local: false,
...
},
...
]
```
The calculated field `'has_base'` is **`true`** because the Afform files are packaged in an extension.
`'has_local'` is **`false`** for now. However, site builders can modify your form without touching your extensnion code
simply by making a copy of the form in their local files directory. In that case the form would be considered _overridden_
and Afform would automatically use the local copy in favor of the one on your extension and the same api call would return
data from the new files with `has_local: true`.
## Form Builder Events
### `civi.afform_admin.metadata`
*Alter metadata for the Form Builder GUI*
**Since:** CiviCRM 5.50
**Type:** `GenericHookEvent`
**Params:**
- **`entities`** (array) List of entities that can be used in the Form Builder GUI. Each item has array keys:
- `name` (string)
- `label` (string)
- `icon` (string:"fa-*")
- `type` (string:"primary"|"secondary")
- `defaults` (string:js object).
- **`elements`** (array) Static elements that can be added to a form, keyed by name. Each item has array keys:
- `title` (string) Title shown in Editor
- `afform_type` (array) Form types this element is used for
- `element` (array) Default markup for this element
- `directive` (string) Specify directive name in dash format (should match `['element']['#tag']`)
- `admin_tpl` (string) Editor template. Extensions can provide their own template for editing this element type,
by adding an Angular module with base page `'civicrm/admin/afform'`.
- **`inputTypes`** (array) Form widgets used to represent a field.
- **`styles`** (array) Bootstrap3 style strings.
- **`permissions`** (array) Permissions that can be set for an Afform.
- **`dateRanges`** (array) Date range options.
### `civi.afform.prefill`
*Prefill entity data when the form is being viewed.*
**Since:** CiviCRM 5.56
**Type:** `AfformPrefillEvent`
**Methods:**
- **getAfform()**: `array`
- **getFormDataModel()**: `Civi\Afform\FormDataModel`
- **getApiRequest()**: `Civi\Api4\Action\Afform\Prefill`
- **getEntityType()**: `string`
- **getEntityName()**: `string`
- **getSecureApi4()**: `callable`
- **setEntityId(int $index, int $id)**
- **setJoinIds(int $index, string $joinEntity, array $joinIds)**
### `civi.afform.validate`
*Validate submission of an Afform.*
**Since:** CiviCRM 5.56
**Type:** `AfformValidateEvent`
**Methods:**
- **getAfform()**: `array`
- **getFormDataModel()**: `Civi\Afform\FormDataModel`
- **getApiRequest()**: `Civi\Api4\Action\Afform\Submit`
- **getEntityValues()**: `array`
- **setError(string $errorMsg)**
### `civi.afform.submit`
*Handle submission of an `<af-form>` entity (or set of entities in the case of `<af-repeat>`).*
**Since:** CiviCRM 5.31
**Type:** `AfformSubmitEvent`
**Methods:**
- **getAfform()**: `array`
- **getFormDataModel()**: `Civi\Afform\FormDataModel`
- **getApiRequest()**: `Civi\Api4\Action\Afform\Submit`
- **getEntityType()**: `string`
- **getEntityName()**: `string`
- **getRecords()**: `array`
- **getSecureApi4()**: `callable`
- **setEntityId(int $index, int $id)**
- **setRecords(array $records)**
- **setJoinIds(int $index, string $joinEntity, array $joinIds)**
Form Builder provides a flexible form interface allowing editing a variety of CiviCRM entities as well as a developer interface.
## Exposing an entity to Form Builder
### Via event listener
The Form Builder GUI can be extended via the [`civi.afform_admin.metadata`](afform-events.md) event.
This event is used for adding entities, elements, input types, etc.
### Via an Afform entityType declaration file
It is also possible to expose entities in Form Builder by adding a declaration. To do this:
1. Add the [mixin](../framework/mixin/index.md) `<mixin>afform-entity-php@1.0.0</mixin>` to your extension's `info.xml` file (note: for backward compatability with versions < 5.50 you must [add a shim](https://github.com/eileenmcnaughton/deduper/pull/26).
2. Ensure the entity in question has apiv4 CRUD entities (these get generated automatically if using [civix with an extension](https://docs.civicrm.org/dev/en/latest/step-by-step/create-entity/#4-generate-sql-dao-and-bao-files))
3. Create a php file in the following location - `afformEntities/EntityName.php` as you can see [here in the `deduper` extension](https://github.com/eileenmcnaughton/deduper/blob/master/afformEntities/ContactNamePair.php). For more complex examples [see core](https://github.com/civicrm/civicrm-core/tree/master/ext/afform/admin/afformEntities).
```php
<?php
use CRM_MyExtension_ExtensionUtil as E;
return [
'type' => 'primary',
'defaults' => "{}",
'boilerplate' => [
['#tag' => 'af-field', 'name' => 'name'],
['#tag' => 'af-field', 'name' => 'xxx'],
],
];
```
4. The boilerplate specifies the fields that are automatically added to a new Submission Form. In the example above, the fields 'name' and 'xxx' would be added.
5. An entity can be available for "Submission forms" and/or for "Field blocks". In order for the entity to be available for Submission forms, add `'type' => 'primary'` [example](https://github.com/civicrm/civicrm-core/blob/master/ext/afform/admin/afformEntities/Individual.php) or only as Field blocks, leave blank or add `'type' => 'join'` [example](https://github.com/civicrm/civicrm-core/blob/master/ext/afform/admin/afformEntities/Address.php). A Field block (or join) is only available in relation to a primary entity.
[Core afform entities](https://github.com/civicrm/civicrm-core/tree/master/ext/afform/admin/afformEntities) have examples of other parameters that can be added such as `repeat_max`, `unique_fields`, `boilerplate`, `icon`, `alterFields`, and `data` defaults. Be sure to test them out to see what works best with a custom entity.
!!! tip "Making fields available for use in Form Builder"
If an expected element for an Entity is missing from Form Builder, it's likely that `input_type` needs to be added to the field. See [Entities](../../framework/entities) for possible values.
Find the `getFields` function in the corresponding `.entityType.php` file for that Entity and add an appropriate input type.
(for older entities using legacy xml schema files, the corresponding tag would be `<html><type>` and the code generator script would need to be run after updating).
## Introduction
Form-Builder (aka `afform`) is a core extension currently in active development.
It is intended to become the main building tool for CiviCRM forms and layouts going forwards.
## Embedding
Afforms can be embedded on any CiviCRM page as Angular directives; they also can be configured to
automatically appear on the dashboard or contact summary screen. Afforms can be embedded into
other Afforms simply by including the directive for one Afform in the markup of another; Angular
dependencies will be resolved automatically.
### Embedding in Smarty Templates
*Adding Afforms to traditional Smarty-based pages or forms can be a transitional step away from legacy screens*
**PHP Code**
```php
Civi::service('angularjs.loader')
->addModules('afformMyForm');
$this->assign('myAfformVars', $optionalVars);
```
Note - to figure out what to put in 'name' look at the name in the FormBuilder listing for your form. In the above example the 'name' would be the entire 'afformMyForm' (there isn't a magic prefix).
**Template Code**
```
<crm-angular-js modules="afformMyForm">
<form id="bootstrap-theme">
<afform-my-form options='{$myAfformVars|@json_encode}'></afform-my-form>
</form>
</crm-angular-js>
```
## Afform Types
- **form**: A form which submits through the `Afform::submit` api, editable in the form-builder GUI.
- **block**: A snippet meant to be incorporated into a larger form.
- **system** (default): Non-editable forms.
- **search**: An afform with an embedded [SearchKit Display](../searchkit/displays.md) and optional search filter fields.
## Afform markup
Althought angularjs offers extensive functionality it is recommended that, where possible, CiviCRM Angular forms are written using just html and CiviCRM afform markup. The reason being that there is demand to be able to render these forms using different front end libraries (eg. React) and funding is being sought to that end. If this does proceed then the first piece of work is likely to be rendering existing FormBuilder forms via React - something that would work seamlessly if no native
angularjs markup is used.
The CiviCRM Afform markup includes
| Type | Example |Notes |
| ------ | ------ | ------ |
| form embedding markup | `<contact-basic></contact-basic>` |Embed a FormBuilder form as defined in `contactBasic.aff.html` & `contactBasic.aff.js`|
| api 3 access markup | ``` <div af-api3="af-api3="['Contact','getsingle', {id: options.contact_id}]" af-api3-ctrl="contact"> </div> ``` |Call api v3 & assign results to variable `contact`|
| api 4 access markup | ```<div af-api4="['Afform', 'get', {select: ['name','title','is_public','server_route', 'has_local', 'has_base'], orderBy: {name:'ASC'}}]" af-api4-ctrl="listCtrl"></div>``` |Call api v4 & assign results to variable `listCtrl`|
A [SearchKit Display](../searchkit/displays.md) can be embedded in an Afform.
This switches the form fields from "create" to "get" mode so they can work as search filters.
Search Displays embedded in an Afform will use the permissions of the form to determine
whether they may be viewed; if a user has access to the Afform then SearchKit will grant
permission to view the Display as well.
\ No newline at end of file
# Entity Relationship Diagrams
Entity Relationship Diagrams provide a different view into how the entities accessed through the API are related to each other.
Most of the entities in APIv4 and APIv3 are mapped directly to tables in the CiviCRM database. A few are not, notably the Order API and the Payment API.
Collected below are a number of Entity-Relationship Diagrams. The diagrams were generated by [DBeaver](https://dbeaver.io/), with notes added manually. Each foreign key relationship that is defined in the database between two tables is represented by a line connecting the tables. A table can also have a relationship with itself, for example, a parent_id field linking to a different record in the same table.
The lines do not indicate the specific fields joined by the relationship unfortunately. The solid circle at the end of a relationship line touches the table that has a foreign key referencing another table. So the solid dot indicates the 'beginning' of the relationship, and is touching the 'source' table. When the foreign key field in the souce table is defined as NOT NULL, then the other end of the relationship line will go straight into the destination table. However, if foreign key field in the source table is optional, then there is a rectangle on the end touching the destination table.
CiviCRM has a field naming convention that helps in determining which field is a foreign key to a different table. A table named civicrm_tablename1 has a field named id as its unique primary key. References from other tables to that id field are named tablename1_id. (There are a few exceptions, such as when two fields in one table reference the key of a single other table, for different purposes.)
CiviCRM has non-standard patterns that it uses to implement one table references one amongst several other tables. We term this a pseudo foreign key. In most cases there is a pair of fields, entity_table and entity_id, with entity_table containing the name of the table being referenced and entity_id representing the value of id of the record in that field being referenced. A different pattern is present in the civicrm_value_* tables that are dynamically created to store custom fields that extend various entities in CiviCRM. In that case, entity_id present in the table, and the entity_table value is found in the appropriate civicrm_custom_group.extends field.
To aid in viewing and understanding the 200+ tables in CiviCRM, each diagram collects a handful of related tables.
For convenience, here is a clickable list of the Entity-Relationship Diagrams below:
- [ACLs](#acls)
- [Activities](#activities)
- [Batches and Queues](#batches-and-queues)
- [Cases](#cases)
- [Contact Info](#contact-info)
- [Contribution Financial](#contribution-financial)
- [Contribution Page](#contribution-financial)
- [Contributions recur](#contributions-recur)
- [Custom Fields](#custom-fields)
- [Deduping](#deduping)
- [External Providers](#external-providers)
- [Groups, Tags and Campaigns](#groups-tags-and-campaigns)
- [Interfaces](#interfaces)
- [Line Items](#line-items)
- [Mailings](#mailings)
- [Participants](#participants)
- [Pledges](#pledges)
- [Price fields and Premiums](#price-fields-and-premiums)
- [Relationships](#relationships)
- [System](#system)
## ACLs
ACLs are Access Control Lists that define permissions that a user has to view data of different sorts.
![ACLs](../../img/ERDs/ACLs.png)
## Activities
![Activities](../../img/ERDs/Activities.png)
The purpose of an Activity is specific to the activity_type. There can be custom fieldset defined for Activities, including for specific types.
## Batches and Queues
![Batches and Queues](../../img/ERDs/Batches_and_Queues.png)
The queue and queue_item tables are general purpose, and helpful when long-running processes need to have a backlog of tasks. The batch table was originally created to support financial batches, both those created by navigating to Contributions > Batch Data Entry, and ones created manually at Contributions > Accounting Batches > New Batch.
## Cases
![Cases](../../img/ERDs/Cases.png)
These are the primary tables used by CiviCase, though it also makes extensive use of Activities.
## Contact Info
![Contact Info](../../img/ERDs/Contact_Info.png)
This diagram illustrates the various tables containing contact information. These tables are more normalized than some schemas in data sources that contain multiple fields for the same type of content, for example, email1 and email2 or phone1 and phone2.
## Contribution Financial
![Contribution Financial](../../img/ERDs/Contribution_Financial.png)
This diagram includes tables related to accounting information for contributions, memberships and event registrations. Double entry bookkeeping is represented by debit and credit accounts in civicrm_financial_trxn and civicrm_financial_item for most entries, and occasionally for some simple transactions by the from and to account fields in civicrm_financial_trxn. These are the authoritative entries for auditing purposes. The amount fields in civicrm_contribution and civicrm_line_item are often more convenient for some reporting purposes. However, the civicrm_contribution.financial_type_id table is a deprecated field since it cannot accurately represent transactions with multiple line items with different financial types.
## Contribution Page
![Contribution Page](../../img/ERDs/Contribution_Page.png)
This diagram includes tables that store the settings defined when useing Contributions > Manage Contribution Page, and under Contributions > Manage Price Sets.
## Contributions recur
![Contributions recur](../../img/ERDs/Contributions_recur.png)
Recurring contributions, and memberships that are paid with them, are illustrated here.
## Custom Fields
![Custom Fields](../../img/ERDs/Custom_Fields.png)
CiviCRM databases typically have many sets of custom fields defined, and many tables named civicrm_value_*.
## Deduping
![Deduping](../../img/ERDs/Deduping.png)
The dedupe_rule_group has one record per rule in the user interface at Contacts > Find and Merge Duplicate Contacts. The dedupe_rule table has one row per 'field' entry for a particular rule.
## External Providers
![External Providers](../../img/ERDs/External_Providers.png)
These tables are used to store information used to connect to some standard external services.
## Groups, Tags and Campaigns
![Groups, Tags and Campaigns](../../img/ERDs/Groups__Tags_and_Campaigns.png)
Groups, Tags and Campaigns help to segment and relate entities in CiviCRM.
## Interfaces
![Interfaces](../../img/ERDs/Interfaces.png)
These tables define some menu and navigation elements in CiviCRM and permissions for users to see them.
## Line Items
![Line Items](../../img/ERDs/Line_Items.png)
There may be one or more line items related to a contribution, and each may relate to a membership, event registration or a different purpose.
## Mailings
![Mailings](../../img/ERDs/Mailings.png)
CiviMail is a powerful bulk emailing solution. Some of the tables in this diagram relate to the content of the emails, others are used during sending, and the remainder contain information on recipients interactions with those emails.
## Participants and Events
![Participants](../../img/ERDs/Participants.png)
Participants register in events. The registrations are stored in the same tables regardless of whether the event is paid or free.
## Pledges
![Pledges](../../img/ERDs/Pledges.png)
Pledges are prototypically used during capital campaigns to store promises to donate a certain amount over a period of time through payments to be specified later. When payments are made against the pledge, it reduces the amount owing.
## Price fields and Premiums
![Price fields](../../img/ERDs/Price_fields.png)
Price fields are part of the configuration of what people can buy or donate to through a CiviCRM site. Price_field_values are the options for certain types of price_fields; other price field types like a text entry field for an amount do not require price_field_values.
Premiums are used by fundraisers to incentivize people to donate more, with products representing things like mugs or Tshirts that are given away for donating over a certain level.
## Relationships
![Relationships](../../img/ERDs/Relationships.png)
Relationships can be created between contacts. Relationship types can be used to limit which contacts can be involved in a relationship (eg only organizations can be employers and only individuals can be employees). Relationships can be used to define permissions, for example, parents can be allowed to see and edit their children's information.
## System
![System](../../img/ERDs/System.png)
This diagram includes some of the more important system tables.
# The CiviCRM API
CiviCRM has a stable comprehensive **API** (Application Programming
Interface) that can be used to access and manage data in CiviCRM. The
API is the recommended way for any CiviCRM extension, CMS module, or
external program to interact with CiviCRM.
Utilizing the API is superior to accessing core functions directly (e.g.
calling raw SQL, or calling functions within the BAO files)
because the API offers a consistent interface to CiviCRM's features. It is
designed to function predictably with every new release so as to preserve
backwards compatibility of the API for several versions of CiviCRM. If
you decide to use other ways to collect data (like your own SQL statements),
you risk running into future problems when changes to the schema and
BAO arguments inevitably occur.
The best place to begin working with the API is your own ***test*** install of
CiviCRM, using the API explorer and the API parameter list.
## API explorer
The API explorer gives you the possibility to actually
try out the API in action and is available at
```text
http://[CIVICRM\_URL]/civicrm/api/explorer
```
You can select the entity you want to
use, for example `Contact` and the action you want to perform, for
example `Get`. Again, be careful as the API explorer will actually
perform your actions! So if you delete a contact to check what API
call to use, it will really delete the contact. The API explorer
will show you the specific code necessary to execute the API call you
have been testing.
Try out the [API explorer on the demo site], *after you login as demo/demo*.
[API explorer on the demo site]: http://drupal.sandbox.civicrm.org/civicrm/api/explorer
## API parameter list
The API parameter list shows all available entities which
can be manipulated by the API and is available at:
```text
http://[CIVICRM_URL]/civicrm/api/doc
```
You will first get a list of all the API entities.
If you click on an entity you will get a list of parameters that are
available for that specific entity, with the type of the parameter.
This can be very useful if you want to check what you can retrieve
with the API and what parameters you can use to refine your get
action or complete your create or update action.
## API Examples
CiviCRM ships with API examples included in the distribution. You can
find the examples specific to your installed version at:
`<civicrm_root>/api/v3/examples`
[Explore these examples on GitHub](https://github.com/civicrm/civicrm-core/tree/master/api/v3/examples)
## Changelog
All important changes made to the API are be recorded on the wiki at:
[API changes](https://wiki.civicrm.org/confluence/display/CRMDOC/API+changes)