Skip to content

Instantly share code, notes, and snippets.

View brettp's full-sized avatar

Brett Profitt brettp

View GitHub Profile
@brettp
brettp / gist:940753
Created April 25, 2011 16:28
Elgg List Metadata on Entity
SELECT elgg_metadata.id, elgg_metadata.owner_guid, elgg_metadata.access_id, name.*, value.*, entity_guid
FROM elgg_metadata, elgg_metastrings name, elgg_metastrings value
WHERE name_id = name.id
AND value_id = value.id
AND entity_guid =
<?php
/**
* View an avatar
*/
$user = elgg_get_page_owner_entity();
// Get the size
$size = strtolower(get_input('size'));
if (!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar'))) {
<?php
require_once 'engine/start.php';
global $CONFIG;
var_dump($CONFIG->actions);
@brettp
brettp / gist:981376
Created May 19, 2011 18:12
Tabular json from table
/**
* Serializes inputs in a table to json preserving rows and cols
*
* Example:
* Doesn't work for multiple tables right now!
* var json = $('#table').toTabularJSON();
*
* If using inputs, think of each cell as an instance with limited scope. Use the same
* input names for consistency:
* <table>
@brettp
brettp / arrows_patch.diff
Created June 15, 2011 14:39
APLJHU Elgg Answers plugin arrow fix
diff --git a/www/mod/answers/views/default/answers/css.php b/www/mod/answers/views/default/answers/css.php
index ccda03b..c3092ca 100644
--- a/www/mod/answers/views/default/answers/css.php
+++ b/www/mod/answers/views/default/answers/css.php
@@ -16,27 +16,19 @@
margin: 0;
}
-.answer_rate span:after {
+.answer_rate .arrow {
@brettp
brettp / elgg_rewrite.conf
Created June 15, 2011 18:51
Elgg 1.8 nginx rewrite
rewrite action\/([A-Za-z0-9\_\-\/]+)$ engine/handlers/action_handler.php?action=$1 last;
rewrite pg\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 last;
rewrite pg\/([A-Za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1 last;
rewrite cache\/(.*)$ engine/handlers/cache_handler.php?request=$1 last;
rewrite services\/api\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/service_handler.php?handler=$1&request=$2 last;
rewrite export\/([A-Za-z]+)\/([0-9]+)\/?$ engine/handlers/export_handler.php?view=$1&guid=$2 last;
<?php
/**
* Elgg file search
*
* @package ElggFile
*/
// Load Elgg engine
@brettp
brettp / start.php
Created August 12, 2011 16:32
Elgg plugin to count number of times a user has logged in
<?php
/**
* Hook into the login, user event and increment the login count metadata.
*
* @param string $event
* @param string $type
* @param ElggUser $user
*/
function login_count($event, $type, $user) {
$login_count = $user->login_count;
@brettp
brettp / gist:1888009
Created February 22, 2012 22:32
Remove an item from a menu in Elgg
<?php
elgg_register_event_handler('init', 'system', 'remove_item_init');
function remove_item_init() {
elgg_register_plugin_hook_handler('register', 'menu:topbar', 'remove_friends');
}
function remove_friends($hook, $type, $menu_items, $option) {
foreach($menu_items as $i => $item) {
if ($item->getName() == 'friends') {
@brettp
brettp / gist:1925073
Created February 27, 2012 16:24
Elgg 1.8 elgg.get() test.
<?php
require_once(dirname(__FILE__) . "/engine/start.php");
$content = <<<JS
<script type="text/javascript">
// normalizes the url to the current <site_url>/activity
elgg.get('/activity', {
success: function(resultText, success, xhr) {
console.log(resultText);
}