aboutsummaryrefslogtreecommitdiffstats
path: root/addon/README
blob: 451b6ed7264fcc4702a1badd9e40b9ed8f99958e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Friendika Addon/Plugin development

This is an early specification and hook details may be subject to change.

Please see the sample addon 'randplace' for a working example of using these features.


You must register plugins with the system in the .htconfig.php file.

$a->config['system']['addon'] = 'plugin1name, plugin2name, another_name';

Plugin names cannot contain spaces and are used as filenames.


Register your plugin hooks during installation. 

	register_hook($hookname, $file, $function);

	$hookname is a string and corresponds to a known Friendika hook
	$file is a pathname relative to the top-level Friendika directory.
		This *should* be 'addon/plugin_name/plugin_name.php' in most cases.
	$function is a string and is the name of the function which will be executed
		when the hook is called.


Your hook functions will be called with at least one and possibly two arguments

	function myhook_function(&$a, &$b) {


	}

If you wish to make changes to the calling data, you must declare them as 
reference variables (with '&') during function declaration. 

$a is the Friendika 'App' class - which contains a wealth of information
about the current state of Friendika, such as which module has been called,
configuration info, the page contents at the point the hook was invoked, profile
and user information, etc. It is recommeded you call this '$a' to match its usage 
elsewhere.

$b can be called anything you like. This is information which is specific to the hook 
currently being processed, and generally contains information that is being immediately
processed or acted on that you can use, display, or alter. Remember to declare it with 
'&' if you wish to alter it.


Current hooks:

'authenticate' - called when a user attempts to login. 
	$b is an array
		'username' => the supplied username
		'password' => the supplied password
		'authenticated' => set this to non-zero to authenticate the user.
		'user_record' => successful authentication must also return a valid user record from the database


'logged_in' - called after a user has successfully logged in.
	$b contains the $a->user array


'display_item' - called when formatting a post for display.
	$b is an array
		'item' => The item (array) details pulled from the database
		'output' => the (string) HTML representation of this item prior to adding it 
			to the page  

'post_local' - called when a status post or comment is entered on the local system
	$b is the item array of the information to be stored in the database
		{Please note: body contents are bbcode - not HTML)

'post_local_end' - called when a local status post or comment has been stored on the local system
	$b is the item array of the information which has just been stored in the database
		{Please note: body contents are bbcode - not HTML)


'post_remote' - called when receiving a post from another source. This may also be used
	to post local activity or system generated messages.
	$b is the item array of information to be stored in the database and the item
	body is bbcode.

'settings_form' - called when generating the HTML for the user Settings page
	$b is the (string) HTML of the settings page before the final '</form>' tag.

'plugin_settings' - called when generating the HTML for the addon settings page
	$b is the (string) HTML of the addon settings page before the final '</form>' tag.

'settings_post' - called when the Settings and Addon Settings pages are submitted.
	$b is the $_POST array

'profile_advanced' - called when the HTML is generated for the 'Advanced profile', 
	corresponding to the 'Profile' tab within a person's profile page.
	$b is the (string) HTML representation of the generated profile

'directory_item' - called from the Directory page when formatting an item for display
	$b is an array
		'contact' => contact (array) record for the person from the database
		'entry' => the (string) HTML of the generated entry 

'profile_sidebar' - called when generating the sidebar "short" profile for a page
	$b is the (string) generated HTML of the entry
		(The profile array details are in $a->profile)

'contact_block_end' - called when formatting the block of contacts/friends on a 
	profile sidebar has completed
	$b is an array
		'contacts' => contact array of entries
		'output' => the (string) generated HTML of the contact block


*** = subject to change





Not yet documented:

'atom_feed'

'atom_feed_end'

'parse_atom'

'atom_author'

'atom_entry'

'parse_link'