diff --git a/boot.php b/boot.php index 0c6683b0a..d4c5ec093 100644 --- a/boot.php +++ b/boot.php @@ -19,7 +19,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Lily of the valley'); define ( 'FRIENDICA_VERSION', '3.4.3-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1190 ); +define ( 'DB_UPDATE_VERSION', 1191 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/features.php b/include/features.php index 1307132a6..263960457 100644 --- a/include/features.php +++ b/include/features.php @@ -1,19 +1,54 @@ $uid, 'feature' => $feature, 'enabled' => $x); call_hooks('feature_enabled',$arr); return($arr['enabled']); } +/** + * @brief check if feature is enabled or disabled by default + * + * @param string $feature + * @return boolean + */ +function get_feature_default($feature) { + $f = get_features(); + foreach($f as $cat) { + foreach($cat as $feat) { + if(is_array($feat) && $feat[0] === $feature) + return $feat[3]; + } + } + return false; +} + +/** + * @ brief get a list of all available features + * The array includes the setting group, the setting name, + * explainations for the setting and if it's enabled or disabled + * by default + * + * @return array + */ function get_features() { $arr = array( @@ -22,46 +57,53 @@ function get_features() { 'general' => array( t('General Features'), //array('expire', t('Content Expiration'), t('Remove old posts/comments after a period of time')), - array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles')), + array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles'),false), array('photo_location', t('Photo Location'), t('Photo metadata is normally stripped. This extracts the location (if present) prior to stripping metadata and links it to a map.'),false), ), // Post composition 'composition' => array( t('Post Composition Features'), - array('richtext', t('Richtext Editor'), t('Enable richtext editor')), - array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')), - array('aclautomention', t('Auto-mention Forums'), t('Add/remove mention when a fourm page is selected/deselected in ACL window.')), + array('richtext', t('Richtext Editor'), t('Enable richtext editor'),false), + array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them'),false), + array('aclautomention', t('Auto-mention Forums'), t('Add/remove mention when a fourm page is selected/deselected in ACL window.'),false), ), // Network sidebar widgets 'widgets' => array( t('Network Sidebar Widgets'), - array('archives', t('Search by Date'), t('Ability to select posts by date ranges')), - array('groups', t('Group Filter'), t('Enable widget to display Network posts only from selected group')), - array('networks', t('Network Filter'), t('Enable widget to display Network posts only from selected network')), - array('savedsearch', t('Saved Searches'), t('Save search terms for re-use')), + array('archives', t('Search by Date'), t('Ability to select posts by date ranges'),false), + array('forumlist_widget', t('List Forums'), t('Enable widget to display the forums your are connected with'),true), + array('groups', t('Group Filter'), t('Enable widget to display Network posts only from selected group'),false), + array('networks', t('Network Filter'), t('Enable widget to display Network posts only from selected network'),false), + array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false), ), // Network tabs 'net_tabs' => array( t('Network Tabs'), - array('personal_tab', t('Network Personal Tab'), t('Enable tab to display only Network posts that you\'ve interacted on')), - array('new_tab', t('Network New Tab'), t('Enable tab to display only new Network posts (from the last 12 hours)')), - array('link_tab', t('Network Shared Links Tab'), t('Enable tab to display only Network posts with links in them')), + array('personal_tab', t('Network Personal Tab'), t('Enable tab to display only Network posts that you\'ve interacted on'),false), + array('new_tab', t('Network New Tab'), t('Enable tab to display only new Network posts (from the last 12 hours)'),false), + array('link_tab', t('Network Shared Links Tab'), t('Enable tab to display only Network posts with links in them'),false), ), // Item tools 'tools' => array( t('Post/Comment Tools'), - array('multi_delete', t('Multiple Deletion'), t('Select and delete multiple posts/comments at once')), - array('edit_posts', t('Edit Sent Posts'), t('Edit and correct posts and comments after sending')), - array('commtag', t('Tagging'), t('Ability to tag existing posts')), - array('categories', t('Post Categories'), t('Add categories to your posts')), - array('filing', t('Saved Folders'), t('Ability to file posts under folders')), - array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments')), - array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator')), - array('ignore_posts', t('Mute Post Notifications'), t('Ability to mute notifications for a thread')), + array('multi_delete', t('Multiple Deletion'), t('Select and delete multiple posts/comments at once'),false), + array('edit_posts', t('Edit Sent Posts'), t('Edit and correct posts and comments after sending'),false), + array('commtag', t('Tagging'), t('Ability to tag existing posts'),false), + array('categories', t('Post Categories'), t('Add categories to your posts'),false), + array('filing', t('Saved Folders'), t('Ability to file posts under folders'),false), + array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments')), + array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator'),false), + array('ignore_posts', t('Mute Post Notifications'), t('Ability to mute notifications for a thread'),false), + ), + + // Advanced Profile Settings + 'advanced_profile' => array( + t('Advanced Profile Settings'), + array('forumlist_profile', t('List Forums'), t('Show visitors public community forums at the Advanced Profile Page'),false), ), ); diff --git a/include/forums.php b/include/forums.php new file mode 100644 index 000000000..e604a3156 --- /dev/null +++ b/include/forums.php @@ -0,0 +1,148 @@ + forum url + * 'name' => forum name + * 'id' => number of the key from the array + * 'micro' => contact photo in format micro + */ +function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false) { + + $forumlist = array(); + + $order = (($showhidden) ? '' : ' AND `hidden` = 0 '); + $order .= (($lastitem) ? ' ORDER BY `last-item` ASC ' : ' ORDER BY `name` ASC '); + $select = '`forum` = 1'; + if ($showprivate) { + $select = '( `forum` = 1 OR `prv` = 1 )'; + } + + $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` FROM contact + WHERE `network`= 'dfrn' AND $select AND `uid` = %d + AND `blocked` = 0 AND `hidden` = 0 AND `pending` = 0 AND `archive` = 0 + $order ", + intval($uid) + ); + + foreach($contacts as $contact) { + $forumlist[] = array( + 'url' => $contact['url'], + 'name' => $contact['name'], + 'id' => $contact['id'], + 'micro' => $contact['micro'], + ); + } + return($forumlist); +} + + +/** + * @brief Forumlist widget + * + * Sidebar widget to show subcribed friendica forums. If activated + * in the settings, it appears at the notwork page sidebar + * + * @param App $a + * @return string + */ +function widget_forumlist($a) { + + if(! intval(feature_enabled(local_user(),'forumlist_widget'))) + return; + + $o = ''; + + //sort by last updated item + $lastitem = true; + + $contacts = get_forumlist($a->user['uid'],true,$lastitem, true); + $total = count($contacts); + $visible_forums = 10; + + if(count($contacts)) { + + $id = 0; + + foreach($contacts as $contact) { + + $entry = array( + 'url' => $a->get_baseurl() . '/network?f=&cid=' . $contact['id'], + 'external_url' => $a->get_baseurl() . '/redir/' . $contact['id'], + 'name' => $contact['name'], + 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), + 'id' => ++$id, + ); + $entries[] = $entry; + } + + $tpl = get_markup_template('widget_forumlist.tpl'); + + $o .= replace_macros($tpl,array( + '$title' => t('Forums'), + '$forums' => $entries, + '$link_desc' => t('External link to forum'), + '$total' => $total, + '$visible_forums' => $visible_forums, + '$showmore' => t('show more'), + )); + } + + return $o; +} + +/** + * @brief Format forumlist as contact block + * + * This function is used to show the forumlist in + * the advanced profile. + * + * @param int $uid + * @return string + * + */ +function forumlist_profile_advanced($uid) { + + $profile = intval(feature_enabled($uid,'forumlist_profile')); + if(! $profile) + return; + + $o = ''; + + // place holder in case somebody wants configurability + $show_total = 9999; + + //don't sort by last updated item + $lastitem = false; + + $contacts = get_forumlist($uid,false,$lastitem,false); + + $total_shown = 0; + + foreach($contacts as $contact) { + $forumlist .= micropro($contact,false,'forumlist-profile-advanced'); + $total_shown ++; + if($total_shown == $show_total) + break; + } + + if(count($contacts) > 0) + $o .= $forumlist; + return $o; +} diff --git a/include/identity.php b/include/identity.php index 6faddffd3..3ab65d9e6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1,4 +1,9 @@ profile['uid']; - $o .= replace_macros(get_markup_template("section_title.tpl"),array( + $o .= replace_macros(get_markup_template('section_title.tpl'),array( '$title' => t('Profile') )); @@ -603,6 +609,11 @@ function advanced_profile(&$a) { if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); + + //show subcribed forum if it is enabled in the usersettings + if (feature_enabled($uid,'forumlist_profile')) { + $profile['forumlist'] = array( t('Forums:'), forumlist_profile_advanced($uid)); + } if ($a->profile['uid'] == local_user()) $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile')); diff --git a/include/plugin.php b/include/plugin.php index 5a4755c31..965b823b0 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,7 +1,17 @@ 0)); +} - - +/** + * @brief registers a hook. + * + * @param string $hook the name of the hook + * @param string $file the name of the file that hooks into + * @param string $function the name of the function that the hook will call + * @param int $priority A priority (defaults to 0) + * @return mixed|bool + */ if(! function_exists('register_hook')) { function register_hook($hook,$file,$function,$priority=0) { @@ -129,6 +162,14 @@ function register_hook($hook,$file,$function,$priority=0) { return $r; }} +/** + * @brief unregisters a hook. + * + * @param string $hook the name of the hook + * @param string $file the name of the file that hooks into + * @param string $function the name of the function that the hook called + * @return array + */ if(! function_exists('unregister_hook')) { function unregister_hook($hook,$file,$function) { @@ -155,7 +196,15 @@ function load_hooks() { } }} - +/** + * @brief Calls a hook. + * + * Use this function when you want to be able to allow a hook to manipulate + * the provided data. + * + * @param string $name of the hook to call + * @param string|array &$data to transmit to the callback handler + */ if(! function_exists('call_hooks')) { function call_hooks($name, &$data = null) { $stamp1 = microtime(true); @@ -178,7 +227,7 @@ function call_hooks($name, &$data = null) { } else { // remove orphan hooks - q("delete from hook where hook = '%s' and file = '%s' and function = '%s'", + q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'", dbesc($name), dbesc($hook[0]), dbesc($hook[1]) @@ -204,16 +253,20 @@ function plugin_is_app($name) { return false; }} -/* - * parse plugin comment in search of plugin infos. - * like +/** + * @brief Parse plugin comment in search of plugin infos. * - * * Name: Plugin + * like + * \code + *...* Name: Plugin * * Description: A plugin which plugs in - * * Version: 1.2.3 + * . * Version: 1.2.3 * * Author: John * * Author: Jane * * + * *\endcode + * @param string $plugin the name of the plugin + * @return array with the plugin information */ if (! function_exists('get_plugin_info')){ @@ -265,16 +318,20 @@ function get_plugin_info($plugin){ }} -/* - * parse theme comment in search of theme infos. +/** + * @brief Parse theme comment in search of theme infos. + * * like - * - * * Name: My Theme + * \code + * ..* Name: My Theme * * Description: My Cool Theme - * * Version: 1.2.3 + * . * Version: 1.2.3 * * Author: John * * Maintainer: Jane * * + * \endcode + * @param string $theme the name of the theme + * @return array */ if (! function_exists('get_theme_info')){ @@ -340,7 +397,14 @@ function get_theme_info($theme){ return $info; }} - +/** + * @brief Returns the theme's screenshot. + * + * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg]. + * + * @param sring $theme The name of the theme + * @return string + */ function get_theme_screenshot($theme) { $a = get_app(); $exts = array('.png','.jpg'); @@ -402,7 +466,7 @@ function service_class_allows($uid,$property,$usage = false) { $service_class = $a->user['service_class']; } else { - $r = q("select service_class from user where uid = %d limit 1", + $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); if($r !== false and count($r)) { @@ -432,7 +496,7 @@ function service_class_fetch($uid,$property) { $service_class = $a->user['service_class']; } else { - $r = q("select service_class from user where uid = %d limit 1", + $r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); if($r !== false and count($r)) { diff --git a/mod/network.php b/mod/network.php index 42c416b32..903ee4154 100644 --- a/mod/network.php +++ b/mod/network.php @@ -112,6 +112,7 @@ function network_init(&$a) { require_once('include/group.php'); require_once('include/contact_widgets.php'); require_once('include/items.php'); + require_once('include/forums.php'); if(! x($a->page,'aside')) $a->page['aside'] = ''; @@ -145,6 +146,7 @@ function network_init(&$a) { } $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network',true,$group_id) : ''); + $a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? widget_forumlist($a) : ''); $a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network',local_user(),false); $a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : '')); $a->page['aside'] .= saved_searches($search); diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index f013c9084..ba310a105 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -1,6 +1,8 @@ $a->config["sitename"]); - if (nodeinfo_plugin_enabled("appnet")) + if (plugin_enabled("appnet")) $nodeinfo["services"]["inbound"][] = "appnet"; - if (nodeinfo_plugin_enabled("appnet") OR nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("appnet") OR plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "appnet"; - if (nodeinfo_plugin_enabled("blogger")) + if (plugin_enabled("blogger")) $nodeinfo["services"]["outbound"][] = "blogger"; - if (nodeinfo_plugin_enabled("dwpost")) + if (plugin_enabled("dwpost")) $nodeinfo["services"]["outbound"][] = "dreamwidth"; - if (nodeinfo_plugin_enabled("fbpost") OR nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("fbpost") OR plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "facebook"; - if (nodeinfo_plugin_enabled("statusnet")) { + if (plugin_enabled("statusnet")) { $nodeinfo["services"]["inbound"][] = "gnusocial"; $nodeinfo["services"]["outbound"][] = "gnusocial"; } - if (nodeinfo_plugin_enabled("gpluspost") OR nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("gpluspost") OR plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "google"; - if (nodeinfo_plugin_enabled("ijpost")) + if (plugin_enabled("ijpost")) $nodeinfo["services"]["outbound"][] = "insanejournal"; - if (nodeinfo_plugin_enabled("libertree")) + if (plugin_enabled("libertree")) $nodeinfo["services"]["outbound"][] = "libertree"; - if (nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "linkedin"; - if (nodeinfo_plugin_enabled("ljpost")) + if (plugin_enabled("ljpost")) $nodeinfo["services"]["outbound"][] = "livejournal"; - if (nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "pinterest"; - if (nodeinfo_plugin_enabled("posterous")) + if (plugin_enabled("posterous")) $nodeinfo["services"]["outbound"][] = "posterous"; - if (nodeinfo_plugin_enabled("pumpio")) { + if (plugin_enabled("pumpio")) { $nodeinfo["services"]["inbound"][] = "pumpio"; $nodeinfo["services"]["outbound"][] = "pumpio"; } @@ -118,13 +120,13 @@ function nodeinfo_init(&$a){ if ($smtp) $nodeinfo["services"]["outbound"][] = "smtp"; - if (nodeinfo_plugin_enabled("tumblr")) + if (plugin_enabled("tumblr")) $nodeinfo["services"]["outbound"][] = "tumblr"; - if (nodeinfo_plugin_enabled("twitter") OR nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("twitter") OR plugin_enabled("buffer")) $nodeinfo["services"]["outbound"][] = "twitter"; - if (nodeinfo_plugin_enabled("wppost")) + if (plugin_enabled("wppost")) $nodeinfo["services"]["outbound"][] = "wordpress"; $nodeinfo["metadata"]["protocols"] = $nodeinfo["protocols"]; @@ -134,7 +136,7 @@ function nodeinfo_init(&$a){ $nodeinfo["metadata"]["services"] = $nodeinfo["services"]; - if (nodeinfo_plugin_enabled("twitter")) + if (plugin_enabled("twitter")) $nodeinfo["metadata"]["services"]["inbound"][] = "twitter"; header('Content-type: application/json; charset=utf-8'); @@ -142,17 +144,14 @@ function nodeinfo_init(&$a){ exit; } -function nodeinfo_plugin_enabled($plugin) { - $r = q("SELECT * FROM `addon` WHERE `installed` = 1 AND `name` = '%s'", $plugin); - return((bool)(count($r) > 0)); -} + function nodeinfo_cron() { $a = get_app(); // If the plugin "statistics_json" is enabled then disable it and actrivate nodeinfo. - if (nodeinfo_plugin_enabled("statistics_json")) { + if (plugin_enabled("statistics_json")) { set_config("system", "nodeinfo", true); $plugin = "statistics_json"; diff --git a/mod/statistics_json.php b/mod/statistics_json.php index 9f97d6ac7..21a9a0521 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -1,5 +1,9 @@ +
{{$profile.forumlist.0}}
+
{{$profile.forumlist.1}}
+ +{{/if}} diff --git a/view/templates/widget_forumlist.tpl b/view/templates/widget_forumlist.tpl new file mode 100644 index 000000000..4d155fd0a --- /dev/null +++ b/view/templates/widget_forumlist.tpl @@ -0,0 +1,45 @@ + + +
+

{{$title}}

+ + {{foreach $forums as $forum}} + {{if $forum.id <= $visible_forums}} + + {{/if}} + + {{if $forum.id > $visible_forums}} + + {{/if}} + {{/foreach}} + + {{if $total > $visible_forums }} +
    + +
+ {{/if}} + +
diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 87f41ae15..3ab1c7edb 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -9,9 +9,9 @@ * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/ */ -require_once("mod/nodeinfo.php"); -require_once("mod/proxy.php"); +require_once("include/plugin.php"); require_once("include/socgraph.php"); +require_once("mod/proxy.php"); function vier_init(&$a) { @@ -305,49 +305,49 @@ function vier_community_info() { $r = array(); - if (nodeinfo_plugin_enabled("appnet")) + if (plugin_enabled("appnet")) $r[] = array("photo" => "images/appnet.png", "name" => "App.net"); - if (nodeinfo_plugin_enabled("buffer")) + if (plugin_enabled("buffer")) $r[] = array("photo" => "images/buffer.png", "name" => "Buffer"); - if (nodeinfo_plugin_enabled("blogger")) + if (plugin_enabled("blogger")) $r[] = array("photo" => "images/blogger.png", "name" => "Blogger"); - if (nodeinfo_plugin_enabled("dwpost")) + if (plugin_enabled("dwpost")) $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth"); - if (nodeinfo_plugin_enabled("fbpost")) + if (plugin_enabled("fbpost")) $r[] = array("photo" => "images/facebook.png", "name" => "Facebook"); - if (nodeinfo_plugin_enabled("ifttt")) + if (plugin_enabled("ifttt")) $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"); - if (nodeinfo_plugin_enabled("statusnet")) + if (plugin_enabled("statusnet")) $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social"); - if (nodeinfo_plugin_enabled("gpluspost")) + if (plugin_enabled("gpluspost")) $r[] = array("photo" => "images/googleplus.png", "name" => "Google+"); - //if (nodeinfo_plugin_enabled("ijpost")) + //if (plugin_enabled("ijpost")) // $r[] = array("photo" => "images/", "name" => ""); - if (nodeinfo_plugin_enabled("libertree")) + if (plugin_enabled("libertree")) $r[] = array("photo" => "images/libertree.png", "name" => "Libertree"); - //if (nodeinfo_plugin_enabled("ljpost")) + //if (plugin_enabled("ljpost")) // $r[] = array("photo" => "images/", "name" => ""); - if (nodeinfo_plugin_enabled("pumpio")) + if (plugin_enabled("pumpio")) $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io"); - if (nodeinfo_plugin_enabled("tumblr")) + if (plugin_enabled("tumblr")) $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr"); - if (nodeinfo_plugin_enabled("twitter")) + if (plugin_enabled("twitter")) $r[] = array("photo" => "images/twitter.png", "name" => "Twitter"); - if (nodeinfo_plugin_enabled("wppost")) + if (plugin_enabled("wppost")) $r[] = array("photo" => "images/wordpress", "name" => "Wordpress"); if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))