From 96b764425ea38cdd0d2f5259549a58d4718315ef Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 9 Nov 2015 15:56:20 +0100 Subject: [PATCH 01/48] move forumlist addon to core --- include/features.php | 41 ++++---- include/forums.php | 148 ++++++++++++++++++++++++++++ include/identity.php | 8 ++ mod/network.php | 2 + view/global.css | 41 ++++++-- view/templates/profile_advanced.tpl | 6 ++ view/templates/widget_forumlist.tpl | 45 +++++++++ 7 files changed, 267 insertions(+), 24 deletions(-) create mode 100644 include/forums.php create mode 100644 view/templates/widget_forumlist.tpl diff --git a/include/features.php b/include/features.php index 1307132a6..8eee2daa1 100644 --- a/include/features.php +++ b/include/features.php @@ -29,39 +29,46 @@ function get_features() { // 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('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.')), ), // 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')), + array('forumlist', t('List Forums'), t('Enable widget to display the forums your are connected with')), + 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')), ), // 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')), + 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')), ), // 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')), + 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')), + ), + + // 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')), ), ); diff --git a/include/forums.php b/include/forums.php new file mode 100644 index 000000000..c51516242 --- /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'))) + 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; +} \ No newline at end of file diff --git a/include/identity.php b/include/identity.php index 6faddffd3..fad7c99dd 100644 --- a/include/identity.php +++ b/include/identity.php @@ -525,6 +525,7 @@ if(! function_exists('get_events')) { function advanced_profile(&$a) { $o = ''; + $uid = $a->profile['uid']; $o .= replace_macros(get_markup_template("section_title.tpl"),array( '$title' => t('Profile') @@ -603,6 +604,13 @@ 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')) { + require_once('include/forums.php'); + $show_forumlist = true; + $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/mod/network.php b/mod/network.php index 42c416b32..07a6bbd8e 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_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/view/global.css b/view/global.css index 1a71b2195..29373941e 100644 --- a/view/global.css +++ b/view/global.css @@ -260,29 +260,56 @@ a { } /* poke */ #poke-desc { - margin: 5px 0 10px; + margin: 5px 0 10px; } #poke-wrapper { - padding: 10px 0 0px; + padding: 10px 0 0px; } #poke-recipient, #poke-action, #poke-privacy-settings { - margin: 10px 0 30px; + margin: 10px 0 30px; } #poke-recip-label, #poke-action-label, #prvmail-message-label { - margin: 10px 0 10px; + margin: 10px 0 10px; } ul.credits { - list-style: none; + list-style: none; } ul.credits li { - float: left; - width: 240px; + float: left; + width: 240px; } .contact-entry-photo img { max-width: 80px; max-height: 80px; } + +/* forumlist widget */ +#hide-forum-list { + opacity: 0.3; + filter:alpha(opacity=30); +} + +#hide-forum-list:hover { + opacity: 1.0; + filter:alpha(opacity=100); +} + + +#forumlist-settings-label, #forumlist-random-label, #forumlist-profile-label, #forumlist-network-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#forumlist-max-forumlists, #forumlist-random, #forumlist-profile, #forumlist-network { + float: left; +} + +.forumlist-img { + height: 20px; + width: 20px; +} \ No newline at end of file diff --git a/view/templates/profile_advanced.tpl b/view/templates/profile_advanced.tpl index 40b3f24f7..084fdf3b7 100644 --- a/view/templates/profile_advanced.tpl +++ b/view/templates/profile_advanced.tpl @@ -167,5 +167,11 @@ {{/if}} +{{if $profile.forumlist}} +
+
{{$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..f3c1cbc4c --- /dev/null +++ b/view/templates/widget_forumlist.tpl @@ -0,0 +1,45 @@ + + +
+

{{$title}}

+ + {{foreach $forums as $forum}} + {{if $forum.id <= $visible_forums}} +
+ + {{$forum.link_desc}} + + {{$forum.name}} +
+ {{/if}} + + {{if $forum.id > $visible_forums}} + + {{/if}} + {{/foreach}} + + {{if $total > $visible_forums }} + + {{/if}} + +
\ No newline at end of file From abf9ebd4668a39b702f52106726e765c989c6353 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Tue, 10 Nov 2015 12:53:56 +0100 Subject: [PATCH 02/48] forumlist: small fix --- view/templates/widget_forumlist.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/templates/widget_forumlist.tpl b/view/templates/widget_forumlist.tpl index f3c1cbc4c..030633263 100644 --- a/view/templates/widget_forumlist.tpl +++ b/view/templates/widget_forumlist.tpl @@ -18,7 +18,7 @@ function showHideForumlist() { {{foreach $forums as $forum}} {{if $forum.id <= $visible_forums}} -
+ \ No newline at end of file +
From 84bb703a000864b783b11fd68521b8adc54d8286 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 11 Nov 2015 23:40:26 +0100 Subject: [PATCH 11/48] forumlist: dbupdate - small optical fix --- update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.php b/update.php index b6faa8508..f2fa3d21f 100644 --- a/update.php +++ b/update.php @@ -1681,7 +1681,7 @@ function update_1190() { $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%d' ", dbesc('forumlist') -); + ); foreach ($r as $rr) { $uid = $rr['uid']; From 666e1198d45dd2f90ac67e558d7a65dd36e18e81 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 11 Nov 2015 23:47:09 +0100 Subject: [PATCH 12/48] forumlist: dbupdate - small includel fix --- update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.php b/update.php index f2fa3d21f..45288cb5a 100644 --- a/update.php +++ b/update.php @@ -1662,7 +1662,7 @@ function update_1188() { function update_1190() { - require_once('/include/plugins.php'); + require_once('include/plugins.php'); if (plugin_enabled('forumlist')) { $plugin = 'forumlist'; From c95afa525e4a2e8ca97ac88b59f4a61473f8611d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 12 Nov 2015 08:59:29 +0100 Subject: [PATCH 13/48] Some SQL queries were optimized to reduce the amount of write operations. --- include/api.php | 66 ++++++++++++++++++++++++++--------------------- include/items.php | 28 +++++++++++--------- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/include/api.php b/include/api.php index 35ebaef03..873006ac2 100644 --- a/include/api.php +++ b/include/api.php @@ -285,7 +285,7 @@ * Unique contact to contact url. */ function api_unique_id_to_url($id){ - $r = q("SELECT url FROM unique_contacts WHERE id=%d LIMIT 1", + $r = q("SELECT `url` FROM `unique_contacts` WHERE `id`=%d LIMIT 1", intval($id)); if ($r) return ($r[0]["url"]); @@ -390,9 +390,9 @@ $r = array(); if ($url != "") - $r = q("SELECT * FROM unique_contacts WHERE url='%s' LIMIT 1", $url); + $r = q("SELECT * FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", $url); elseif ($nick != "") - $r = q("SELECT * FROM unique_contacts WHERE nick='%s' LIMIT 1", $nick); + $r = q("SELECT * FROM `unique_contacts` WHERE `nick`='%s' LIMIT 1", $nick); if ($r) { // If no nick where given, extract it from the address @@ -505,14 +505,14 @@ } // Fetching unique id - $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url']))); + $r = q("SELECT id FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url']))); // If not there, then add it if (count($r) == 0) { - q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')", + q("INSERT INTO `unique_contacts` (`url`, `name`, `nick`, `avatar`) VALUES ('%s', '%s', '%s', '%s')", dbesc(normalise_link($uinfo[0]['url'])), dbesc($uinfo[0]['name']),dbesc($uinfo[0]['nick']), dbesc($uinfo[0]['micro'])); - $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url']))); + $r = q("SELECT `id` FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url']))); } $network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']); @@ -552,36 +552,44 @@ function api_item_get_user(&$a, $item) { - $author = q("SELECT * FROM unique_contacts WHERE url='%s' LIMIT 1", + $author = q("SELECT * FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($item['author-link']))); if (count($author) == 0) { - q("INSERT INTO unique_contacts (url, name, avatar) VALUES ('%s', '%s', '%s')", - dbesc(normalise_link($item["author-link"])), dbesc($item["author-name"]), dbesc($item["author-avatar"])); + q("INSERT INTO `unique_contacts` (`url`, `name`, `avatar`) VALUES ('%s', '%s', '%s')", + dbesc(normalise_link($item["author-link"])), dbesc($item["author-name"]), dbesc($item["author-avatar"])); - $author = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", + $author = q("SELECT `id` FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($item['author-link']))); } else if ($item["author-link"].$item["author-name"] != $author[0]["url"].$author[0]["name"]) { - q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE (`name` != '%s' OR `avatar` != '%s') AND url = '%s'", - dbesc($item["author-name"]), dbesc($item["author-avatar"]), - dbesc($item["author-name"]), dbesc($item["author-avatar"]), - dbesc(normalise_link($item["author-link"]))); + $r = q("SELECT `id` FROM `unique_contacts` WHERE `name` = '%s' AND `avatar` = '%s' AND url = '%s'", + dbesc($item["author-name"]), dbesc($item["author-avatar"]), + dbesc(normalise_link($item["author-link"]))); + + if (!$r) + q("UPDATE `unique_contacts` SET `name` = '%s', `avatar` = '%s' WHERE `url` = '%s'", + dbesc($item["author-name"]), dbesc($item["author-avatar"]), + dbesc(normalise_link($item["author-link"]))); } - $owner = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", + $owner = q("SELECT `id` FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($item['owner-link']))); if (count($owner) == 0) { - q("INSERT INTO unique_contacts (url, name, avatar) VALUES ('%s', '%s', '%s')", - dbesc(normalise_link($item["owner-link"])), dbesc($item["owner-name"]), dbesc($item["owner-avatar"])); + q("INSERT INTO `unique_contacts` (`url`, `name`, `avatar`) VALUES ('%s', '%s', '%s')", + dbesc(normalise_link($item["owner-link"])), dbesc($item["owner-name"]), dbesc($item["owner-avatar"])); - $owner = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", + $owner = q("SELECT `id` FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", dbesc(normalise_link($item['owner-link']))); } else if ($item["owner-link"].$item["owner-name"] != $owner[0]["url"].$owner[0]["name"]) { - q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE (`name` != '%s' OR `avatar` != '%s') AND url = '%s'", - dbesc($item["owner-name"]), dbesc($item["owner-avatar"]), - dbesc($item["owner-name"]), dbesc($item["owner-avatar"]), - dbesc(normalise_link($item["owner-link"]))); + $r = q("SELECT `id` FROM `unique_contacts` WHERE `name` = '%s' AND `avatar` = '%s' AND url = '%s'", + dbesc($item["owner-name"]), dbesc($item["owner-avatar"]), + dbesc(normalise_link($item["owner-link"]))); + + if (!$r) + q("UPDATE `unique_contacts` SET `name` = '%s', `avatar` = '%s' WHERE `url` = '%s'", + dbesc($item["owner-name"]), dbesc($item["owner-avatar"]), + dbesc(normalise_link($item["owner-link"]))); } // Comments in threads may appear as wall-to-wall postings. @@ -952,7 +960,7 @@ $in_reply_to_status_id= intval($lastwall['parent']); $in_reply_to_status_id_str = (string) intval($lastwall['parent']); - $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($lastwall['item-author']))); + $r = q("SELECT * FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($lastwall['item-author']))); if ($r) { if ($r[0]['nick'] == "") $r[0]['nick'] = api_get_nick($r[0]["url"]); @@ -1074,7 +1082,7 @@ $in_reply_to_status_id = intval($lastwall['parent']); $in_reply_to_status_id_str = (string) intval($lastwall['parent']); - $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($reply[0]['item-author']))); + $r = q("SELECT * FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($reply[0]['item-author']))); if ($r) { if ($r[0]['nick'] == "") $r[0]['nick'] = api_get_nick($r[0]["url"]); @@ -1135,9 +1143,9 @@ $userlist = array(); if (isset($_GET["q"])) { - $r = q("SELECT id FROM unique_contacts WHERE name='%s'", dbesc($_GET["q"])); + $r = q("SELECT id FROM `unique_contacts` WHERE `name`='%s'", dbesc($_GET["q"])); if (!count($r)) - $r = q("SELECT id FROM unique_contacts WHERE nick='%s'", dbesc($_GET["q"])); + $r = q("SELECT `id` FROM `unique_contacts` WHERE `nick`='%s'", dbesc($_GET["q"])); if (count($r)) { foreach ($r AS $user) { @@ -2180,7 +2188,7 @@ intval(api_user()), intval($in_reply_to_status_id)); if ($r) { - $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($r[0]['author-link']))); + $r = q("SELECT * FROM `unique_contacts` WHERE `url` = '%s'", dbesc(normalise_link($r[0]['author-link']))); if ($r) { if ($r[0]['nick'] == "") @@ -2439,7 +2447,7 @@ $stringify_ids = (x($_REQUEST,'stringify_ids')?$_REQUEST['stringify_ids']:false); - $r = q("SELECT unique_contacts.id FROM contact, unique_contacts WHERE contact.nurl = unique_contacts.url AND `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra", + $r = q("SELECT `unique_contact`.`id` FROM contact, `unique_contacts` WHERE contact.nurl = unique_contacts.url AND `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra", intval(api_user()) ); @@ -2887,7 +2895,7 @@ function api_get_nick($profile) { //} if ($nick != "") { - q("UPDATE unique_contacts SET nick = '%s' WHERE `nick` != '%s' AND url = '%s'", + q("UPDATE `unique_contacts` SET `nick` = '%s' WHERE `nick` != '%s' AND url = '%s'", dbesc($nick), dbesc($nick), dbesc(normalise_link($profile))); return($nick); } diff --git a/include/items.php b/include/items.php index ebda49e9a..995d4c366 100644 --- a/include/items.php +++ b/include/items.php @@ -2440,26 +2440,28 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if ($name_updated > $contact_updated) $contact_updated = $name_updated; - $r = q("select * from contact where uid = %d and id = %d limit 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($contact['uid']), intval($contact['id']) ); - $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d", + $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s'", dbesc(notags(trim($new_name))), dbesc(datetime_convert()), intval($contact['uid']), - intval($contact['id']) + intval($contact['id']), + dbesc(notags(trim($new_name))) ); // do our best to update the name on content items - if(count($r)) { - q("update item set `author-name` = '%s' where `author-name` = '%s' and `author-link` = '%s' and uid = %d", + if(count($r) AND (notags(trim($new_name)) != $r[0]['name'])) { + q("UPDATE `item` SET `author-name` = '%s' WHERE `author-name` = '%s' AND `author-link` = '%s' AND `uid` = %d AND `author-name` != '%s'", dbesc(notags(trim($new_name))), dbesc($r[0]['name']), dbesc($r[0]['url']), - intval($contact['uid']) + intval($contact['uid']), + dbesc(notags(trim($new_name))) ); } } @@ -3178,26 +3180,28 @@ function local_delivery($importer,$data) { if ($name_updated > $contact_updated) $contact_updated = $name_updated; - $r = q("select * from contact where uid = %d and id = %d limit 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($importer['importer_uid']), intval($importer['id']) ); - $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d", + $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s'", dbesc(notags(trim($new_name))), dbesc(datetime_convert()), intval($importer['importer_uid']), - intval($importer['id']) + intval($importer['id']), + dbesc(notags(trim($new_name))) ); // do our best to update the name on content items - if(count($r)) { - q("update item set `author-name` = '%s' where `author-name` = '%s' and `author-link` = '%s' and uid = %d", + if(count($r) AND (notags(trim($new_name)) != $r[0]['name'])) { + q("UPDATE `item` SET `author-name` = '%s' WHERE `author-name` = '%s' AND `author-link` = '%s' AND `uid` = %d AND `author-name` != '%s'", dbesc(notags(trim($new_name))), dbesc($r[0]['name']), dbesc($r[0]['url']), - intval($importer['importer_uid']) + intval($importer['importer_uid']), + dbesc(notags(trim($new_name))) ); } } From dd2ed42863747c0096d6eb63f2751606140aaa75 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 12 Nov 2015 16:42:27 +0100 Subject: [PATCH 14/48] forumlist: dbupdate - new try --- update.php | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/update.php b/update.php index 45288cb5a..8abad1629 100644 --- a/update.php +++ b/update.php @@ -1662,48 +1662,61 @@ function update_1188() { function update_1190() { - require_once('include/plugins.php'); + require_once('include/plugin.php'); + + set_config('system', 'maintenance', 1); if (plugin_enabled('forumlist')) { $plugin = 'forumlist'; $plugins = get_config('system','addon'); $plugins_arr = array(); + if($plugins) { - $plugins_arr = explode(',',str_replace(' ', '',$plugins)); + $plugins_arr = explode(",",str_replace(" ", "",$plugins)); + $idx = array_search($plugin, $plugins_arr); if ($idx !== false){ unset($plugins_arr[$idx]); uninstall_plugin($plugin); - set_config('system','addon', implode(', ',$plugins_arr)); + set_config('system','addon', implode(", ",$plugins_arr)); } } } - $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%d' ", + // select old formlist addon entries + $r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ", dbesc('forumlist') ); - foreach ($r as $rr) { - $uid = $rr['uid']; - $family = $rr['cat']; - $key = $rr['k']; - $value = $rr['v']; + // convert old forumlist addon entries in new config entries + if (count($r)) { + foreach ($r as $rr) { + $uid = $rr['uid']; + $family = $rr['cat']; + $key = $rr['k']; + $value = $rr['v']; - if ($key === 'randomize') - del_pconfig($uid,$family,$key); + if ($key === 'randomise') + del_pconfig($uid,$family,$key); - if ($key === 'show_on_profile') { - if ($value) - set_pconfig($uid,feature,forumlist_profile,$value); + if ($key === 'show_on_profile') { + if ($value) + set_pconfig($uid,feature,forumlist_profile,$value); - del_pconfig($uid,$family,$key); - } + del_pconfig($uid,$family,$key); + } - if ($key === 'show_on_network') { - if ($value) - set_pconfig($uid,feature,forumlist,$value); + if ($key === 'show_on_network') { + if ($value) + set_pconfig($uid,feature,forumlist_widget,$value); - del_pconfig($uid,$family,$key); + del_pconfig($uid,$family,$key); + } } } + + set_config('system', 'maintenance', 0); + + return UPDATE_SUCCESS; + } From 3648094927d85a01eb5ee9d0a17dbc1450bfea0b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 12 Nov 2015 21:43:42 +0100 Subject: [PATCH 15/48] Local delivery of comments to soap boxes are working now --- include/delivery.php | 4 ++-- include/notifier.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/delivery.php b/include/delivery.php index 659add2ad..51ffe48d7 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -342,8 +342,8 @@ function delivery_run(&$argv, &$argc){ // If we are setup as a soapbox we aren't accepting input from this person - if($x[0]['page-flags'] == PAGE_SOAPBOX) - break; + //if($x[0]['page-flags'] == PAGE_SOAPBOX) + // break; require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); diff --git a/include/notifier.php b/include/notifier.php index 0f9cc8046..79bf7d51c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -736,8 +736,8 @@ function notifier_run(&$argv, &$argc){ // If we are setup as a soapbox we aren't accepting input from this person - if($x[0]['page-flags'] == PAGE_SOAPBOX) - break; + //if($x[0]['page-flags'] == PAGE_SOAPBOX) + // break; require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); From 1ea82ea355e15674766d313fa534b185ec2b0da5 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 12 Nov 2015 21:55:33 +0100 Subject: [PATCH 16/48] Only allow non top level posts to soap boxes --- include/delivery.php | 6 +++--- include/notifier.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/delivery.php b/include/delivery.php index 51ffe48d7..cdd59451f 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -340,10 +340,10 @@ function delivery_run(&$argv, &$argc){ $ssl_policy = get_config('system','ssl_policy'); fix_contact_ssl_policy($x[0],$ssl_policy); - // If we are setup as a soapbox we aren't accepting input from this person + // If we are setup as a soapbox we aren't accepting top level posts from this person - //if($x[0]['page-flags'] == PAGE_SOAPBOX) - // break; + if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) + break; require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); diff --git a/include/notifier.php b/include/notifier.php index 79bf7d51c..9dac5f114 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -734,10 +734,10 @@ function notifier_run(&$argv, &$argc){ $ssl_policy = get_config('system','ssl_policy'); fix_contact_ssl_policy($x[0],$ssl_policy); - // If we are setup as a soapbox we aren't accepting input from this person + // If we are setup as a soapbox we aren't accepting top level posts from this person - //if($x[0]['page-flags'] == PAGE_SOAPBOX) - // break; + if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) + break; require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); From 5a8d66e2d4315a00eb45dec4b7f5fb88ed3dbc02 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 12 Nov 2015 23:34:33 +0100 Subject: [PATCH 17/48] Just removed blanks with tabs --- mod/wall_upload.php | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 8e7eaa027..8bf471d3d 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -16,10 +16,10 @@ function wall_upload_post(&$a, $desktopmode = true) { ); if(! count($r)){ - if ($r_json) { - echo json_encode(array('error'=>t('Invalid request.'))); - killme(); - } + if ($r_json) { + echo json_encode(array('error'=>t('Invalid request.'))); + killme(); + } return; } } else { @@ -29,10 +29,10 @@ function wall_upload_post(&$a, $desktopmode = true) { ); } } else { - if ($r_json) { - echo json_encode(array('error'=>t('Invalid request.'))); - killme(); - } + if ($r_json) { + echo json_encode(array('error'=>t('Invalid request.'))); + killme(); + } return; } @@ -73,18 +73,18 @@ function wall_upload_post(&$a, $desktopmode = true) { if(! $can_post) { - if ($r_json) { - echo json_encode(array('error'=>t('Permission denied.'))); - killme(); - } + if ($r_json) { + echo json_encode(array('error'=>t('Permission denied.'))); + killme(); + } notice( t('Permission denied.') . EOL ); killme(); } if(! x($_FILES,'userfile') && ! x($_FILES,'media')){ - if ($r_json) { - echo json_encode(array('error'=>t('Invalid request.'))); - } + if ($r_json) { + echo json_encode(array('error'=>t('Invalid request.'))); + } killme(); } @@ -118,10 +118,10 @@ function wall_upload_post(&$a, $desktopmode = true) { } if ($src=="") { - if ($r_json) { - echo json_encode(array('error'=>t('Invalid request.'))); - killme(); - } + if ($r_json) { + echo json_encode(array('error'=>t('Invalid request.'))); + killme(); + } notice(t('Invalid request.').EOL); killme(); } @@ -243,9 +243,9 @@ function wall_upload_post(&$a, $desktopmode = true) { $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash); if (!$r){ if ($r_json) { - echo json_encode(array('error'=>'')); - killme(); - } + echo json_encode(array('error'=>'')); + killme(); + } return false; } $picture = array(); @@ -260,16 +260,16 @@ function wall_upload_post(&$a, $desktopmode = true) { $picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt(); if ($r_json) { - echo json_encode(array('picture'=>$picture)); - killme(); - } + echo json_encode(array('picture'=>$picture)); + killme(); + } return $picture; } if ($r_json) { - echo json_encode(array('ok'=>true)); - killme(); - } + echo json_encode(array('ok'=>true)); + killme(); + } /* mod Waitman Gobble NO WARRANTY */ From e239f0a82e5ec506a42d66852691b88693b31351 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 13 Nov 2015 00:16:39 +0100 Subject: [PATCH 18/48] forumlist: dbupdate - fix - delete hooks and addon entry manually --- update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/update.php b/update.php index 8abad1629..caa167617 100644 --- a/update.php +++ b/update.php @@ -1677,7 +1677,10 @@ function update_1190() { $idx = array_search($plugin, $plugins_arr); if ($idx !== false){ unset($plugins_arr[$idx]); - uninstall_plugin($plugin); + //delete forumlist manually from addon and hook table + // since uninstall_plugin() don't work here + q("DELETE FROM `addon` WHERE `name` = 'forumlist' "); + q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' "); set_config('system','addon', implode(", ",$plugins_arr)); } } From 86e720c99da7748000a3dbe2939db2af7b698ad9 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 13 Nov 2015 00:33:32 +0100 Subject: [PATCH 19/48] forumlist: some more doxygen for plugin.php --- include/plugin.php | 89 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 18 deletions(-) diff --git a/include/plugin.php b/include/plugin.php index c504db5da..965b823b0 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,9 +1,17 @@ * * Author: Jane * * + * *\endcode + * @param string $plugin the name of the plugin + * @return array with the plugin information */ if (! function_exists('get_plugin_info')){ @@ -276,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')){ @@ -351,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'); @@ -413,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)) { @@ -443,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)) { From 11905c0bec823d7ceb657c99a1ab8d4180ccba51 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 13 Nov 2015 08:45:14 +0100 Subject: [PATCH 20/48] The avatar picture wasn't updated at the contact table --- include/items.php | 32 ++++++++++++++++++++++++++++++-- mod/profile_photo.php | 12 +++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/items.php b/include/items.php index ebda49e9a..3261e9468 100644 --- a/include/items.php +++ b/include/items.php @@ -2381,6 +2381,19 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $contact_updated = $photo_timestamp; require_once("include/Photo.php"); + $photos = import_profile_photo($photo_url,$contact['uid'],$contact['id']); + + q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' + WHERE `uid` = %d AND `id` = %d", + dbesc(datetime_convert()), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + intval($contact['uid']), + intval($contact['id']) + ); + + /* $photo_failure = false; $have_photo = false; @@ -2433,7 +2446,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) intval($contact['uid']), intval($contact['id']) ); - } + }*/ } if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) { @@ -3119,6 +3132,21 @@ function local_delivery($importer,$data) { logger('local_delivery: Updating photo for ' . $importer['name']); require_once("include/Photo.php"); + + $photos = import_profile_photo($photo_url,$importer['importer_uid'],$importer['id']); + + q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' + WHERE `uid` = %d AND `id` = %d", + dbesc(datetime_convert()), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + intval($importer['importer_uid']), + intval($importer['id']) + ); + + + /* $photo_failure = false; $have_photo = false; @@ -3171,7 +3199,7 @@ function local_delivery($importer,$data) { intval($importer['importer_uid']), intval($importer['id']) ); - } + } */ } if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name-date'])) { diff --git a/mod/profile_photo.php b/mod/profile_photo.php index aa8809059..b7e9340ce 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -79,7 +79,7 @@ function profile_photo_post(&$a) { $im->scaleImage(80); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile); - + if($r === false) notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL ); @@ -97,8 +97,14 @@ function profile_photo_post(&$a) { dbesc($base_image['resource-id']), intval(local_user()) ); - } - else { + + $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d", + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6'), + intval(local_user()) + ); + } else { $r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d", dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'), dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'), From fa4ee05312e44ace9fa97030ff7a49a7834e1e33 Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Fri, 13 Nov 2015 09:36:22 +0100 Subject: [PATCH 21/48] Remove anonymous function, 5.2 is still minimal requirement --- include/html2bbcode.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 10a2fd13e..736150134 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -90,9 +90,11 @@ function html2bbcode($message) $message = str_replace("\r", "", $message); - $message = preg_replace_callback("|
([^<]*)
|ism", function($m) { + function _replace_code_cb($m){ return "".str_replace("\n","
\n",$m[1]). "
"; - }, $message); + } + + $message = preg_replace_callback("|
([^<]*)
|ism", "_replace_code_cb", $message); $message = str_replace(array( "
  • ", From c951123b764ada7f65b0319a2e1b1bf4b02202b0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 13 Nov 2015 09:45:15 +0100 Subject: [PATCH 22/48] Cleaned code --- include/items.php | 111 ---------------------------------------------- 1 file changed, 111 deletions(-) diff --git a/include/items.php b/include/items.php index 3261e9468..7a4648872 100644 --- a/include/items.php +++ b/include/items.php @@ -2392,61 +2392,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) intval($contact['uid']), intval($contact['id']) ); - - /* - $photo_failure = false; - $have_photo = false; - - $r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d LIMIT 1", - intval($contact['id']), - intval($contact['uid']) - ); - if(count($r)) { - $resource_id = $r[0]['resource-id']; - $have_photo = true; - } - else { - $resource_id = photo_new_resource(); - } - - $img_str = fetch_url($photo_url,true); - // guess mimetype from headers or filename - $type = guess_image_type($photo_url,true); - - - $img = new Photo($img_str, $type); - if($img->is_valid()) { - if($have_photo) { - q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `contact-id` = %d AND `uid` = %d", - dbesc($resource_id), - intval($contact['id']), - intval($contact['uid']) - ); - } - - $img->scaleImageSquare(175); - - $hash = $resource_id; - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 4); - - $img->scaleImage(80); - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 5); - - $img->scaleImage(48); - $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 6); - - $a = get_app(); - - q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' - WHERE `uid` = %d AND `id` = %d", - dbesc(datetime_convert()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-5.'.$img->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-6.'.$img->getExt()), - intval($contact['uid']), - intval($contact['id']) - ); - }*/ } if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) { @@ -3144,62 +3089,6 @@ function local_delivery($importer,$data) { intval($importer['importer_uid']), intval($importer['id']) ); - - - /* - $photo_failure = false; - $have_photo = false; - - $r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d LIMIT 1", - intval($importer['id']), - intval($importer['importer_uid']) - ); - if(count($r)) { - $resource_id = $r[0]['resource-id']; - $have_photo = true; - } - else { - $resource_id = photo_new_resource(); - } - - $img_str = fetch_url($photo_url,true); - // guess mimetype from headers or filename - $type = guess_image_type($photo_url,true); - - - $img = new Photo($img_str, $type); - if($img->is_valid()) { - if($have_photo) { - q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `contact-id` = %d AND `uid` = %d", - dbesc($resource_id), - intval($importer['id']), - intval($importer['importer_uid']) - ); - } - - $img->scaleImageSquare(175); - - $hash = $resource_id; - $r = $img->store($importer['importer_uid'], $importer['id'], $hash, basename($photo_url), 'Contact Photos', 4); - - $img->scaleImage(80); - $r = $img->store($importer['importer_uid'], $importer['id'], $hash, basename($photo_url), 'Contact Photos', 5); - - $img->scaleImage(48); - $r = $img->store($importer['importer_uid'], $importer['id'], $hash, basename($photo_url), 'Contact Photos', 6); - - $a = get_app(); - - q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' - WHERE `uid` = %d AND `id` = %d", - dbesc(datetime_convert()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-5.'.$img->getExt()), - dbesc($a->get_baseurl() . '/photo/' . $hash . '-6.'.$img->getExt()), - intval($importer['importer_uid']), - intval($importer['id']) - ); - } */ } if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name-date'])) { From ab1edca0be8f60d86db4e4342e8bed3eae7f734e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 13 Nov 2015 10:15:30 +0100 Subject: [PATCH 23/48] Profile photos are now having an extension --- mod/profile_photo.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mod/profile_photo.php b/mod/profile_photo.php index b7e9340ce..4e8d279a9 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -99,15 +99,15 @@ function profile_photo_post(&$a) { ); $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d", - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6'), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()), intval(local_user()) ); } else { $r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d", - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'), - dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()), + dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()), intval($_REQUEST['profile']), intval(local_user()) ); From 0a9e017d34c83b0d4db91a9aeefbc8b8c2e99117 Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Fri, 13 Nov 2015 10:56:06 +0100 Subject: [PATCH 24/48] Installer use static css, fix #2071 --- mod/install.php | 8 ++++ view/install/green.png | Bin 0 -> 323 bytes view/install/info.png | Bin 0 -> 2152 bytes view/install/red.png | Bin 0 -> 316 bytes view/install/style.css | 58 ++++++++++++++++++++++++++++ view/install/yellow.png | Bin 0 -> 280 bytes view/templates/install.tpl | 2 +- view/templates/install_checks.tpl | 16 ++++++-- view/templates/install_db.tpl | 2 +- view/templates/install_settings.tpl | 2 +- 10 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 view/install/green.png create mode 100644 view/install/info.png create mode 100644 view/install/red.png create mode 100644 view/install/style.css create mode 100644 view/install/yellow.png diff --git a/mod/install.php b/mod/install.php index e30c30689..8434b38e3 100755 --- a/mod/install.php +++ b/mod/install.php @@ -11,6 +11,14 @@ function install_init(&$a){ echo "ok"; killme(); } + + // We overwrite current theme css, because during install we could not have a working mod_rewrite + // so we could not have a css at all. Here we set a static css file for the install procedure pages + $a->config['system']['theme'] = "../install"; + $a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css"; + + + global $install_wizard_pass; if (x($_POST,'pass')) $install_wizard_pass = intval($_POST['pass']); diff --git a/view/install/green.png b/view/install/green.png new file mode 100644 index 0000000000000000000000000000000000000000..a4de276be9b4d1a08727ec4a52d33e68b0961b2f GIT binary patch literal 323 zcmV-J0lfZ+P)`40kVw{u&@y$2wJ9+cmvCndLm=Dmk`A&rB(@8hkzhnAcfHg7PHBQ z2+3l6FvT$M&CL7%_m?cAQ#(ZmEgWEi5qe0a~+e^7w_LQ_JeeM0rA4im*9Mdc9o<|H3};!b5vos#Bd7xnw7f2=UplD{4^II zZ?87cpYZrG+nq&O!NRxKi3yw}o*R#{Y6s6nk#k!S8psP)1Ua`6*$`0{lF+K6$ho5^ zOIYZ0QRLiSgcKnp{mFW9f3g^;G&cBr)2!5SVmJ+9Nybp6XFWw?mc^D&$%o6&R*Sl z^1|M8SN5C%axd=z3ZA&J@8ZQhXMpUhd(U0od+zF9pqevRcAf?*zP0!4jlE|s1N9DX zwEH5^*APF#83-@$Jaq{s3liLO4uuPm0)`~A8aR9RX{h3TpnwIdIfq>(TnmH&j1Exj zfYDyKjc`MdU5g?Jw*?$)zzD_RFjB>LgOUNnw5z*OY()1CuAm^*M!5P%SArh_Q}D}@ zAirQBjS2Y7a~BQwH!DP_?@bCQ|J&Bq}{~lC|Guj;Z^Zwk* zj-vF=RTn<&wPZ>7R%Ip1Dt7#PEPL^<2;r#x@4kq9PGnRMVvVztb-Dh6QDLp*a<(hd ztM}CI=G<~uQQqiYJgfdBHt%MEK3$=GWuZR=4_d!0WfBqLgaE@az@L^rEF&lDxUEl-p(5yqg~Q%p?rwN?6x3_)P~?qXP#~hP;#zzba-3- z(<}VX;a>R8v#$Iw!Q@mG$u56xJ^*6$Zn|DP7P>NM_1!7&a!uvVG5B0%w%NO< zw&rTg(SYB-es2G~ri+QO@vSvW;U+VSE*`s zR!sfoE7lE`XD4}Szx<~eRNYj^5ZV0q?56}qqc5@o*K0Ea8DRpPydp?nb&iX^ zohIlL$Z_}Zo28Zq%~+S$-joqnRabfIzCzoW?RiaP?;JjvEzS+^I6{rSG|5c5dP1+U zv5q6uu%fuMT~=Afam}y)oSpy0CrLl<{v3FGQs1-5c5RsD=2R65w1PK$#8w$Vp{xi!jT>RmgZlAPl#c#jUVNCzt z**g80x#pJEiKu{O518NCS5!zbU$d?H@x#-&?(a+6N$+FC1NZ%2Hd$uAuG-t2zdFx% zJ`~|Q{CSS}SB)pr*KPT~+QcyJgUu49*`GG8EOPd&``dQyj>)BEtg2n%HK%vk*+ky@ z*Kn1u>h$-wm&#SQ`JVe+YjFSXwA}w6441S_FEva3bNY|){EFhd`pRndZ>##h3Okg3 zD0bZ8BpCNWH9GaLg2nU1<$=waq4So^_O7a#X?J*C81rw_T|VmVuk&g@C$0W>>&LpE z3w=Z{&YyDmUM%+tznhG8Z2x}cYHIub364s;Sz2)}zS7`7L;mNq=EExSEWk{!TH+c} zl9E`GYL#4+3Zxi}3=9o*4J>sH%|Z+;t&A45hw-(S{CvBH510H!xZf3ZexS9St--gvGKJ4zgnS ziF%SLZswf1GiT0Ctf4DCK?iLd;~g^$(9h(rWqz_IzQ?WY=wJ;Y0txb1)jz6{$3C2nK?wi^&)NK8N7-3uk|EX0Hvt(@J7 z5_b^Lhk5*>T^N23R6iXn-kL%c&51$ O00006ht5C7#i%bWNf^FmeT1hDD@7O+(Alip&gcT2!~QSXc))NA{h*dkWseFWOx71 z&wh(Hqv-DLs3C} zZ%j@>#HKOOE6=9jO}a}LC0uXqPAv82%aHhs$x^6+$+ic?AUTfR97Ca|jpt$vjk^+n z53hllK;!y?KOs~|sA_YO#?6IF7)51npmEOvNI-_9C=JAAD^Q70*^WW}Z=Xp=kg{>2 eJjycty3SALnpzFy2)~N}0000{{$title}} +

    {{$title}}

    {{$pass}}

    diff --git a/view/templates/install_checks.tpl b/view/templates/install_checks.tpl index ca12425f0..10a197482 100644 --- a/view/templates/install_checks.tpl +++ b/view/templates/install_checks.tpl @@ -1,12 +1,22 @@ -

    {{$title}}

    +

    {{$title}}

    {{$pass}}

    {{foreach $checks as $check}} - + {{if $check.help}} - + {{/if}} {{/foreach}}
    {{$check.title}} {{if $check.required}}(required){{/if}}
    {{$check.title}} + {{if $check.status}} + Ok + {{else}} + {{if $check.required}} + Requirement not satisfied + {{else}} + Optional requirement not satisfied + {{/if}} + {{/if}} + {{if $check.required}}(required){{/if}}
    {{$check.help}}
    {{$check.help}}
    diff --git a/view/templates/install_db.tpl b/view/templates/install_db.tpl index f66bf119e..6b6c1c1e6 100644 --- a/view/templates/install_db.tpl +++ b/view/templates/install_db.tpl @@ -1,6 +1,6 @@ -

    {{$title}}

    +

    {{$title}}

    {{$pass}}

    diff --git a/view/templates/install_settings.tpl b/view/templates/install_settings.tpl index 735672fe6..8d6823f11 100644 --- a/view/templates/install_settings.tpl +++ b/view/templates/install_settings.tpl @@ -1,6 +1,6 @@ -

    {{$title}}

    +

    {{$title}}

    {{$pass}}

    From 6605e30cf2eea2cffe6dd208af1615db9d212d40 Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Fri, 13 Nov 2015 10:56:37 +0100 Subject: [PATCH 25/48] pass to all templates by default --- include/text.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/text.php b/include/text.php index b5010864e..f210bff72 100644 --- a/include/text.php +++ b/include/text.php @@ -20,6 +20,10 @@ function replace_macros($s,$r) { $stamp1 = microtime(true); $a = get_app(); + + // pass $baseurl to all templates + $r['$baseurl'] = $a->get_baseurl(); + $t = $a->template_engine(); try { From cec5afe2c92dbe2ed0f8fd604b002fc69b7190da Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 13 Nov 2015 23:49:37 +0100 Subject: [PATCH 26/48] forumlist: don't raise db version in dbstructure.php --- include/dbstructure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index 7d8f89df6..0dd74ab15 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -2,7 +2,7 @@ require_once("boot.php"); require_once("include/text.php"); -define('NEW_UPDATE_ROUTINE_VERSION', 1191); +define('NEW_UPDATE_ROUTINE_VERSION', 1170); /* * send the email and do what is needed to do on update fails From e1774acbde8ba70bd5ef2893ddddb7091ef84433 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 13 Nov 2015 23:55:01 +0100 Subject: [PATCH 27/48] Bugfix: Avoid error messages because of an already used function --- include/html2bbcode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 736150134..28e251aee 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -85,15 +85,15 @@ function deletenode(&$doc, $node) $child->parentNode->removeChild($child); }} +function _replace_code_cb($m){ + return "".str_replace("\n","
    \n",$m[1]). "
    "; +} + function html2bbcode($message) { $message = str_replace("\r", "", $message); - function _replace_code_cb($m){ - return "".str_replace("\n","
    \n",$m[1]). "
    "; - } - $message = preg_replace_callback("|
    ([^<]*)
    |ism", "_replace_code_cb", $message); $message = str_replace(array( From 830870c58ee1883f741e5af5a9f3e2d9329c3477 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 14 Nov 2015 08:07:09 +0100 Subject: [PATCH 28/48] Fix for issue 2060: When password is provided during the register process now the user is redirected correctly. --- mod/register.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mod/register.php b/mod/register.php index c4dc382cb..4c4fcc2af 100644 --- a/mod/register.php +++ b/mod/register.php @@ -100,6 +100,9 @@ function register_post(&$a) { ). EOL ); } + } else { + info( t('Registration successful.') . EOL ) ; + goaway(z_root()); } } elseif($a->config['register_policy'] == REGISTER_APPROVE) { From 47d6e4364257fbe6e1fbd00e74b7965e5191c00d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 14 Nov 2015 09:27:24 +0100 Subject: [PATCH 29/48] Sort the plugin configuration on the admin page by name --- mod/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/admin.php b/mod/admin.php index 21731eb51..d9a17dcad 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -135,7 +135,7 @@ function admin_content(&$a) { /* get plugins admin page */ - $r = q("SELECT name FROM `addon` WHERE `plugin_admin`=1"); + $r = q("SELECT `name` FROM `addon` WHERE `plugin_admin`=1 ORDER BY `name`"); $aside['plugins_admin']=Array(); foreach ($r as $h){ $plugin =$h['name']; From b53ae0d42af7cc4c2a682bec7229669dba114ca6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 17 Nov 2015 08:39:09 +0100 Subject: [PATCH 30/48] Bugfix: The own avatar was (sometimes?) changed back when it was changed. --- include/items.php | 8 ++++---- mod/dfrn_poll.php | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/items.php b/include/items.php index 65c49bf26..c4310c24e 100644 --- a/include/items.php +++ b/include/items.php @@ -2384,7 +2384,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $photos = import_profile_photo($photo_url,$contact['uid'],$contact['id']); q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' - WHERE `uid` = %d AND `id` = %d", + WHERE `uid` = %d AND `id` = %d AND NOT `self`", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), @@ -2403,7 +2403,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) intval($contact['id']) ); - $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s'", + $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s' AND NOT `self`", dbesc(notags(trim($new_name))), dbesc(datetime_convert()), intval($contact['uid']), @@ -3083,7 +3083,7 @@ function local_delivery($importer,$data) { $photos = import_profile_photo($photo_url,$importer['importer_uid'],$importer['id']); q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' - WHERE `uid` = %d AND `id` = %d", + WHERE `uid` = %d AND `id` = %d AND NOT `self`", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), @@ -3102,7 +3102,7 @@ function local_delivery($importer,$data) { intval($importer['id']) ); - $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s'", + $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d AND `name` != '%s' AND NOT `self`", dbesc(notags(trim($new_name))), dbesc(datetime_convert()), intval($importer['importer_uid']), diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index b5f60a039..d6a07186a 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -476,8 +476,8 @@ function dfrn_poll_content(&$a) { // URL reply if($dfrn_version < 2.2) { - $s = fetch_url($r[0]['poll'] - . '?dfrn_id=' . $encrypted_id + $s = fetch_url($r[0]['poll'] + . '?dfrn_id=' . $encrypted_id . '&type=profile-check' . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&challenge=' . $challenge @@ -493,7 +493,7 @@ function dfrn_poll_content(&$a) { 'sec' => $sec )); } - + $profile = ((count($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); switch($destination_url) { @@ -506,7 +506,7 @@ function dfrn_poll_content(&$a) { case 'status': case '': $dest = $a->get_baseurl() . '/profile/' . $profile; - break; + break; default: $dest = $destination_url . '?f=&redir=1'; break; @@ -564,5 +564,3 @@ function dfrn_poll_content(&$a) { } } } - - From 4b21512f56060cada46440aac7091a7ab9595681 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 17 Nov 2015 19:56:32 +0100 Subject: [PATCH 31/48] This is a quick fix for the the forumlist. --- view/templates/widget_forumlist.tpl | 10 +++++----- view/theme/vier/style.css | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/view/templates/widget_forumlist.tpl b/view/templates/widget_forumlist.tpl index 4d155fd0a..0298dc6ff 100644 --- a/view/templates/widget_forumlist.tpl +++ b/view/templates/widget_forumlist.tpl @@ -18,7 +18,7 @@ function showHideForumlist() { {{foreach $forums as $forum}} {{if $forum.id <= $visible_forums}} -