From 473e582d1f3e5067c1aecee9c9f2f579864db3ef Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sun, 31 Aug 2014 16:58:17 +0100 Subject: [PATCH 1/4] Add check_upstream_directory() to check that your directory is still a directory, and if it isn't, let find_upstream_directory() find you a new one. --- include/dir_fns.php | 20 ++++++++++++++++++++ include/poller.php | 3 +++ 2 files changed, 23 insertions(+) diff --git a/include/dir_fns.php b/include/dir_fns.php index 815b6a197..5fad6567e 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -30,6 +30,26 @@ function find_upstream_directory($dirmode) { return array('url' => $preferred); } +function check_upstream_directory() { + /** + * Directories may come and go over time. We will need to check that our + * directory server is still valid occasionally, and reset to something that + * is if our directory has gone offline for any reason + */ + $directory = get_config('system','directory_server'); + if ($directory) { + $r = q("select * from site where site_url = '%s' and (site_flags & %d) ", + dbesc($directory), + intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY|DIRECTORY_MODE_STANDALONE) + ); + } + // If we've got something, it's still a directory. If we haven't, we need to reset and let find_upstream_directory() fix it + if (! $r) { + set_config('system','directory_server',''); + } + return; +} + function dir_sort_links() { $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( diff --git a/include/poller.php b/include/poller.php index 546a2d6d1..b9d728e8d 100644 --- a/include/poller.php +++ b/include/poller.php @@ -111,6 +111,9 @@ function poller_run($argv, $argc){ if(($d2 != $d1) && ($h1 == $h2)) { + require_once('include/dir_fns.php'); + check_upstream_directory(); + call_hooks('cron_daily',datetime_convert()); From 393b3bb213ad086f0628418d1511231bedbc370e Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Tue, 2 Sep 2014 01:58:53 +0100 Subject: [PATCH 2/4] If you have a new channel (or a new hub searching for an old channel) which uses an xchan_url other than channel or profile, chanview will fail to find $a->poi and fail as there is no way to import the xchan. Instead of giving up and presenting an error, we'll send you to the requested URL anyway. If we send you with a Zid, there's a good chance you'll authenticate because xchans are like glitter - once you've got one, they get everywhere, and there's a good chance you'll know *somebody* at the hub. . --- mod/chanview.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mod/chanview.php b/mod/chanview.php index 449a98bb1..3bf0f3268 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -74,15 +74,19 @@ function chanview_content(&$a) { } if(! $a->poi) { - notice( t('Channel not found.') . EOL); - return; +// We don't know who this is, and we can't figure it out from the URL +// On the plus side, there's a good chance we know somebody else at that +// hub so sending them there with a Zid will probably work anyway. + $url = ($_REQUEST['url']); + if($observer) + $url = zid($url); } - + if ($a->poi) { $url = $a->poi['xchan_url']; if($observer) $url = zid($url); - + } // let somebody over-ride the iframed viewport presentation // or let's just declare this a failed experiment. @@ -97,4 +101,4 @@ function chanview_content(&$a) { // return $o; -} \ No newline at end of file +} From ab031664facfb640a8a6589fb9abe018549ad173 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Tue, 2 Sep 2014 02:34:04 +0100 Subject: [PATCH 3/4] Move achievements on, but just a tad. --- mod/achievements.php | 23 +++++++++++++---------- view/tpl/achievements.tpl | 9 +++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 view/tpl/achievements.tpl diff --git a/mod/achievements.php b/mod/achievements.php index 1910def73..1d0018b08 100644 --- a/mod/achievements.php +++ b/mod/achievements.php @@ -1,6 +1,9 @@ 1) $which = argv(1); @@ -28,6 +31,9 @@ function achievements_content(&$a) { return; } + $newmembertext = t('Some blurb about what to do when you\'re new here'); + + // By default, all badges are false $contactbadge = false; $profilebadge = false; @@ -70,15 +76,12 @@ function achievements_content(&$a) { if($r) $keywordsbadge = 1; -// FIXME - stick ths in a template, and make it look pretty. - $o .= "Template not implemented"; - $o .= "If this is one, you get the profile badge" . $profilebadge . "
"; - $o .= "If this is one, you get the contact badge" . $contactbadge . "
"; - $o .= "If this is one you get the keywords badge" . $keywordsbadge . "
"; - $o .= "I haven't done the top level posts badge yet" . $toplevelpostsbadge . "
"; - $o .= "I haven't done the number of channels badge yet" . $channelsbadge; - - -return $o; + return replace_macros(get_markup_template("achievements.tpl"), array( + '$newmembertext' => $newmembertext, + '$profilebadge' => $profilebadge, + '$contactbadge' => $contactbadge, + '$keywordsbadge' => $keywordsbadge, + '$channelsbadge' => $channelsbadge +)); } diff --git a/view/tpl/achievements.tpl b/view/tpl/achievements.tpl new file mode 100644 index 000000000..67fde6211 --- /dev/null +++ b/view/tpl/achievements.tpl @@ -0,0 +1,9 @@ +
+

{{$newmembertext}}

+ +
+
+
+
+ +
From 6d7897a955319d7d83a558258936528d70501a89 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Tue, 2 Sep 2014 02:37:23 +0100 Subject: [PATCH 4/4] Don't forget the ifs. Now we just need to write some blurb, find some images, add a link, and decide what to do with non-earned badges...basically all of it. --- view/tpl/achievements.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/view/tpl/achievements.tpl b/view/tpl/achievements.tpl index 67fde6211..2b80b9e80 100644 --- a/view/tpl/achievements.tpl +++ b/view/tpl/achievements.tpl @@ -1,9 +1,9 @@

{{$newmembertext}}

-
-
-
-
+{{if $profilebadge}}
{{/if}} +{{if $contactbadge}}
{{/if}} +{{if $keywordsbadge}}
{{/if}} +{{if $channelsbadge}}
{{/if}}