aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LICENSE13
-rw-r--r--addon/LICENSE5
-rw-r--r--addon/README127
-rw-r--r--boot.php14
-rw-r--r--include/items.php4
-rw-r--r--mod/directory.php9
-rw-r--r--mod/display.php8
-rw-r--r--mod/network.php8
-rw-r--r--mod/parse_url.php11
-rw-r--r--mod/profile.php7
10 files changed, 193 insertions, 13 deletions
diff --git a/LICENSE b/LICENSE
index 38b32db22..01fe880bd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -23,3 +23,16 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Friendika incorporates other software which may be licensed under different
+terms and conditions. Some system libraries which are supplied with and
+incorporated into Friendika were provided by their respective authors under
+the LGPL (Lesser GNU Public License) and may result in legal encumberance if
+you make any code changes to these libraries.
+
+Addon or "plugin" modules (within the 'addon' directory) are licensed under
+terms provided by the respective software author or authors of those works,
+and MAY include copyleft licenses such as GPLv3, AGPL, and/or commercial
+licenses. For the purposes of licensing, addon modules are considered separate
+standalone works.
+
diff --git a/addon/LICENSE b/addon/LICENSE
index 7dd931e30..2e6e056e8 100644
--- a/addon/LICENSE
+++ b/addon/LICENSE
@@ -10,8 +10,3 @@ plugin.
Addons/plugins may be licensed under copyleft or other license terms. Although
these projects may require Friendika to operate, no addon or plugin may
mandate any changes to the Friendika project license.
-
-If no license terms are set on an addon/plugin project, the Friendika BSD
-project license will apply to the work, but with the project author as the
-license owner and copyright holder.
-
diff --git a/addon/README b/addon/README
new file mode 100644
index 000000000..8d5088f78
--- /dev/null
+++ b/addon/README
@@ -0,0 +1,127 @@
+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.
+
+'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_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'
+
+
+
+
+
diff --git a/boot.php b/boot.php
index 7b7adba82..6565d40bd 100644
--- a/boot.php
+++ b/boot.php
@@ -1742,6 +1742,11 @@ if(! function_exists('contact_block')) {
function contact_block() {
$o = '';
$a = get_app();
+
+ $shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
+ if(! $shown)
+ $shown = 24;
+
if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0",
@@ -1754,8 +1759,9 @@ function contact_block() {
$o .= '<h4 class="contact-h4">' . t('No contacts') . '</h4>';
return $o;
}
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT 24",
- intval($a->profile['uid'])
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d",
+ intval($a->profile['uid']),
+ intval($shown)
);
if(count($r)) {
$o .= '<h4 class="contact-h4">' . $total . ' ' . t('Contacts') . '</h4><div id="contact-block">';
@@ -1778,7 +1784,9 @@ function contact_block() {
}
- call_hooks('contact_block_end', $o);
+ $arr = array('contacts' => $r, 'output' => $o);
+
+ call_hooks('contact_block_end', $arr);
return $o;
}}
diff --git a/include/items.php b/include/items.php
index c00ec93ae..22d47d44f 100644
--- a/include/items.php
+++ b/include/items.php
@@ -499,7 +499,9 @@ function get_atom_elements($feed,$item) {
$res['target'] .= '</target>' . "\n";
}
-// call_hooks('parse_atom', array('feed' => $feed, 'item' => $item, 'result' => $res));
+ $arr = array('feed' => $feed, 'item' => $item, 'result' => $res);
+
+ call_hooks('parse_atom', $arr);
return $res;
}
diff --git a/mod/directory.php b/mod/directory.php
index 49aac657c..062aae516 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -83,7 +83,7 @@ function directory_content(&$a) {
if(strlen($rr['gender']))
$details .= '<br />Gender: ' . $rr['gender'];
- $o .= replace_macros($tpl,array(
+ $entry = replace_macros($tpl,array(
'$id' => $rr['id'],
'$profile-link' => $profile_link,
'$photo' => $rr[$photo],
@@ -94,7 +94,14 @@ function directory_content(&$a) {
));
+ $arr = array('contact' => $rr, 'entry' => $entry);
+
+ call_hooks('directory_item', $arr);
+
+ $o .= $entry;
+
}
+
$o .= "<div class=\"directory-end\" ></div>\r\n";
$o .= paginate($a);
diff --git a/mod/display.php b/mod/display.php
index 990d0b431..fd845e608 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -241,7 +241,7 @@ function display_content(&$a) {
$indent .= ' shiny';
- $o .= replace_macros($template,array(
+ $tmp_item = replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
'$name' => $profile_name,
@@ -264,6 +264,12 @@ function display_content(&$a) {
'$comment' => $comment
));
+ $arr = array('item' => $item, 'output' => $tmp_item);
+ call_hooks('display_item', $arr);
+
+ $o .= $arr['output'];
+
+
}
}
else {
diff --git a/mod/network.php b/mod/network.php
index 43c55b8e3..ad6db2d1e 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -284,7 +284,7 @@ function network_content(&$a, $update = 0) {
// Build the HTML
- $o .= replace_macros($template,array(
+ $tmp_item = replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
'$name' => $profile_name,
@@ -306,6 +306,12 @@ function network_content(&$a, $update = 0) {
'$dislike' => $dislike,
'$comment' => $comment
));
+
+ $arr = array('item' => $item, 'output' => $tmp_item);
+ call_hooks('display_item', $arr);
+
+ $o .= $arr['output'];
+
}
}
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 1561eb8a3..b3b42b6cb 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -11,6 +11,16 @@ function parse_url_content(&$a) {
$template = "<a href=\"%s\" >%s</a>%s";
+
+ $arr = array('url' => $url, 'text' => '');
+
+ call_hooks('parse_link', $arr);
+
+ if(strlen($arr['text'])) {
+ echo $arr['text'];
+ killme();
+ }
+
if($url)
$s = fetch_url($url);
else {
@@ -18,6 +28,7 @@ function parse_url_content(&$a) {
killme();
}
+
if(! $s) {
echo sprintf($template,$url,$url,'');
killme();
diff --git a/mod/profile.php b/mod/profile.php
index ffc412805..cc0debd99 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -342,7 +342,7 @@ function profile_content(&$a, $update = 0) {
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$indent .= ' shiny';
- $o .= replace_macros($template,array(
+ $tmp_item = replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
'$name' => $profile_name,
@@ -360,6 +360,11 @@ function profile_content(&$a, $update = 0) {
'$dislike' => $dislike,
'$comment' => $comment
));
+
+ $arr = array('item' => $item, 'output' => $tmp_item);
+ call_hooks('display_item', $arr);
+
+ $o .= $arr['output'];
}
}