Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
@ringmaster
ringmaster / gist:2376966
Created April 13, 2012 13:47
Allow $post to have $post->client_contact
public function filter_post_client_contact($client, $post)
{
if(intval($post->info->client_contact) != 0) {
$client = User::get($post->info->client_contact);
}
return $client;
}
$('.todo').live('keypress', function(ev){
create = _.reduce($('.todo'), function(memo, el) {
return memo && $(el).val() != '';
}, true);
if(create) {
$('#todolist').append(ich.t_todoitem({}));
}
});
public function action_plugin_activation( $plugin_file )
{
if(!User::get_by_name('github_hook')) {
User::create(array(
'username' => 'github_hook',
'email' => '[email protected]',
'password' => sha1(rand(0,pow(2,32)));
));
}
}
Query::__set_state(array(
'where' =>
QueryWhere::__set_state(array(
'operator' => 'AND',
'expressions' =>
array (
1 =>
QueryWhere::__set_state(array(
'operator' => 'AND',
'expressions' =>
@ringmaster
ringmaster / config.php
Created April 25, 2012 19:58
Habari Test Configuration
<?php
if(Utils::env_test()) {
Config::set( 'db_connection', array(
'connection_string'=>'sqlite:habari_unittest.db',
'username'=>'',
'password'=>'',
'prefix'=>''
));
Config::set('blog_data', array(
'admin_username' => 'admin',
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
/**
* Helper function: Displays the home page
* @param array $user_filters Additional arguments used to get the page content
*/
public function act_display_home( $user_filters = array() )
{
$paramarray['fallback'] = array(
'home',
'multiple',
);
@ringmaster
ringmaster / gist:2838993
Created May 30, 2012 21:10
Get a post, find posts with any of the same tags that match
<?php
$post = Posts::get(array('slug' => 'habari', 'fetch_fn' => 'get_row'));
$related = Posts::get( array( 'vocabulary' => array( 'any:tags' => $post->tags) ) );
Utils::debug($post->title, $related);
?>