Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

users can set their github usernames for their profiles

  • Loading branch information...
commit 7c2923b9d96a8de968bc7ba2a3118d597c7d1974 0 parents
@cash cash authored
10 languages/en.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Github integration English language file
+ */
+
+$english = array(
+ 'profile:github_username' => 'Github username',
+);
+
+add_translation('en', $english);
10 manifest.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest>
+ <field key="author" value="Core developers" />
+ <field key="version" value="0.1" />
+ <field key="description" value="Github integration" />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Elgg Foundation 2011" />
+ <field key="license" value="GNU General Public License version 2" />
+ <field key="elgg_version" value="2010030101" />
+</plugin_manifest>
25 start.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Elgg community site integration with Github
+ */
+
+register_elgg_event_handler('init', 'system', 'community_github_init');
+
+function community_github_init() {
+ register_plugin_hook('profile:fields', 'profile', 'community_github_profile');
+
+ elgg_extend_view('profile/userdetails', 'github/hack', 1);
+}
+
+/**
+ * Add github username to profile
+ *
+ * @param string $hook The hook name
+ * @param string $type The hook type
+ * @param array $fields Array of current profile fields
+ * @return array
+ */
+function community_github_profile($hook, $type, $fields) {
+ $fields['github_username'] = 'github';
+ return $fields;
+}
6 views/default/github/hack.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * Ughh...better way to selectively change language string than this?
+ */
+
+add_translation('en', array('profile:github_username' => 'Github account'));
6 views/default/input/github.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * Collect github username
+ */
+
+echo elgg_view('input/text', $vars);
11 views/default/output/github.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Display link to github account
+ */
+
+$link = "https://github.com/{$vars['value']}";
+
+echo elgg_view('output/url', array(
+ 'text' => $link,
+ 'href' => $link,
+));
Please sign in to comment.
Something went wrong with that request. Please try again.