aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Achievements.php
diff options
context:
space:
mode:
authorWave <wave72@users.noreply.github.com>2016-07-22 10:55:02 +0200
committerGitHub <noreply@github.com>2016-07-22 10:55:02 +0200
commit744ad84714fe0f7a3d90250a4ff02dc4327b9061 (patch)
tree595fb74ec9ea0bc7130d18bd7993d719a222d343 /Zotlabs/Module/Achievements.php
parentc38c79d71c8ef70ef649f83e322f1984b75ee2dd (diff)
parent7d897a3f03bd57ed556433eb84a41963ba44e02e (diff)
downloadvolse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.gz
volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.tar.bz2
volse-hubzilla-744ad84714fe0f7a3d90250a4ff02dc4327b9061.zip
Merge pull request #6 from redmatrix/dev
Dev
Diffstat (limited to 'Zotlabs/Module/Achievements.php')
-rw-r--r--Zotlabs/Module/Achievements.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/Zotlabs/Module/Achievements.php b/Zotlabs/Module/Achievements.php
new file mode 100644
index 000000000..1529448d3
--- /dev/null
+++ b/Zotlabs/Module/Achievements.php
@@ -0,0 +1,93 @@
+<?php
+namespace Zotlabs\Module;
+
+
+class Achievements extends \Zotlabs\Web\Controller {
+
+ function get() {
+ // This doesn't work, so
+ if (! is_developer())
+ return;
+
+ if(argc() > 1)
+ $which = argv(1);
+ else {
+ notice( t('Requested profile is not available.') . EOL );
+ return;
+ }
+
+ $profile = 0;
+ $profile = argv(1);
+ profile_load($which,$profile);
+
+ $r = q("select channel_id from channel where channel_address = '%s'",
+ dbesc($which)
+ );
+ if($r) {
+ $owner = intval($r[0]['channel_id']);
+ }
+
+ $observer = \App::get_observer();
+ $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
+ $perms = get_all_perms($owner,$ob_hash);
+ if(! $perms['view_profile']) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ $newmembertext = t('Some blurb about what to do when you\'re new here');
+
+
+ // By default, all badges are false
+ $contactbadge = false;
+ $profilebadge = false;
+ $keywordsbadge = false;
+
+ // Check number of contacts. Award a badge if over 10
+ // We'll figure these out on each page load instead of
+ // writing them to the DB because that will mean one needs
+ // to retain their achievements - eg, you can't add
+ // a bunch of channels just to get your badge, and then
+ // delete them all again. If these become popular or
+ // used in profiles or something, we may need to reconsider
+ // and add a table for this - because this won't scale.
+
+ $r = q("select * from abook where abook_channel = %d",
+ intval($owner)
+ );
+
+ if (count($r))
+ $contacts = count($r);
+ // We're checking for 11 to adjust for the abook record for self
+ if ($contacts >= 11)
+ $contactbadge = true;
+
+ // Check if an about field in the profile has been created.
+
+ $r = q("select * from profile where uid = %d and about <> ''",
+ intval($owner)
+ );
+
+ if ($r)
+ $profilebadge = 1;
+
+ // Check if keywords have been set
+
+ $r = q("select * from profile where uid = %d and keywords <> ''",
+ intval($owner)
+ );
+
+ if($r)
+ $keywordsbadge = 1;
+
+ return replace_macros(get_markup_template("achievements.tpl"), array(
+ '$newmembertext' => $newmembertext,
+ '$profilebadge' => $profilebadge,
+ '$contactbadge' => $contactbadge,
+ '$keywordsbadge' => $keywordsbadge,
+ '$channelsbadge' => $channelsbadge
+ ));
+
+ }
+
+}