Skip to content

Commit

Permalink
Adding cap, and action_jackson plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dasfisch committed Jun 25, 2012
1 parent 63d199a commit e80a0a2
Show file tree
Hide file tree
Showing 18 changed files with 853 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Capfile
@@ -0,0 +1,8 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'

Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks
22 changes: 22 additions & 0 deletions config/deploy.rb
@@ -0,0 +1,22 @@
set :application, "set your application name here"
set :repository, "set your repository location here"

set :scm, :subversion
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, "your web-server here" # Your HTTP server, Apache/etc
role :app, "your app-server here" # This may be the same as your `Web` server
role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
role :db, "your slave db-server here"

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end
115 changes: 115 additions & 0 deletions wordpress/wp-content/plugins/action_jackson/action_jackson.php
@@ -0,0 +1,115 @@
<?php
/*
Plugin Name: UserActions
Plugin URL: http://wordpress.org/
Description: Tracking of all User Actions
Author: Sebastian Frohm
Version: 0.1
*/

//include base definitions
//include('globals/USERACTIONS.constants.php');
@define('ACTIONJACSON_BASE_DIR', 'action_jackson/');

@define('ACTIONJACSON_ACTIONS_DIR', 'base/');
@define('ACTIONJACSON_INSTANCES_DIR', 'controllers/instances/');
@define('ACTIONJACSON_VIEWS_DIR', 'views/');

//include(USERACTIONS_ACTIONS_DIR.'UserActionsViews.actions.php');
//include(USERACTIONS_ACTIONS_DIR.'UserActionsAdmin.actions.php');
include('base/action_jackson_query.php');
include('models/post_action.php');
include('models/user_action.php');

function get_actions() {
global $current_user;
get_currentuserinfo();

$ajQuery = new ActionJacksonQuery();

$ajQuery->getUserActions('posts', 'ID', $current_user->ID);
//$ajQuery->getUserActions('term', 'term_id', $current_user->ID, null, null, null, 'category');
//$ajQuery->addUserAction(4, 'term', 'upvote', 'something', 1);
}

// add_action('init', 'get_actions');

add_filter('posts_results', 'getUserActions');
//add_filter('pre_get_posts', 'dont_suppress_filters');

function getUserActions($posts) {
global $current_user;

$existingIds = array();
$userId = (is_user_logged_in()) ? $current_user->ID : '1';

/**
* Check to see if there is anything in the $_GET
*/
$actionType = (isset($_GET['action']) && !empty($_GET['action'])) ? $_GET['action'] : null;
$page = (isset($_GET['paged']) && !empty($_GET['paged'])) ? $_GET['paged'] : 1;

foreach($posts as $post) {
$ids[] = $post->ID;

//$actions[] = new UserActionPost($post);
}
// public function getPostAction($object_type, $object_id, $post_action_id=null, $object_sub_type=null, $action_type=null, $limit=10, $page=1) {
$ajQuery = new ActionJacksonQuery();
$postActions = $ajQuery->getPostAction('posts', $ids, null, null, null, null, null, false);

$ids = array();

foreach($postActions as $postAction) {
$ids[] = $postAction->post_action_id;

$actions[] = new PostAction($postAction);
}

$userActions = $ajQuery->getUserActions($ids, $userId, $page, 10);

foreach($userActions as $userAction) {
foreach($actions as $action) {
if($action->id == $userAction->object_id) {
$action->user = $userAction;
$action->user = new UserAction($userAction);
}
}
}

foreach($posts as $post) {
foreach($actions as $action) {
if($action->objectId == $post->ID) {
$post->actions[] = $action;
}
}
}

return $posts;
}

function dont_suppress_filters($query){
$query->query_vars['suppress_filters'] = false;
return $query;
}

function addUserAction() {
$ajQuery = new ActionJacksonQuery();
$result = $ajQuery->addUserAction((int)$_POST['id'], $_POST['type'], $_POST['userAction'], $_POST['subtype'], (int)$_POST['user']);

echo json_encode($result);
exit;
}

add_action('wp_ajax_add_user_action', 'addUserAction');
add_action('wp_ajax_nopriv_add_user_action', 'addUserAction');


function asdf($user) {
echo 'in asdf <pre>';
var_dump($user);
exit;
}

add_filter('pre_user_query', 'asdf');

@@ -0,0 +1,67 @@
<?php
class FitStudioAdminActions {
public $views;

public function __construct() {
$this->views = new FitStudioViewActions();

add_action('admin_menu', array(&$this, 'initializeSideMenu'));
add_action('admin_init', array(&$this, 'setOptions'));
}

public function initializeSideMenu() {
add_options_page('UserActions', 'User Actions', 'manage_options', 'manage-fitstudio-hf', array(&$this, 'createForm'));
}

public function createForm() {
$data = array('me' => 'sebastian');

$this->views->openView('form', $data);
}

public function setOptions() {
register_setting('fitStudioOptions', 'fitStudioOptions-apiKey');
register_setting('fitStudioOptions', 'fitStudioOptions-visibility');
register_setting('fitStudioOptions', 'fitStudioOptions-apiUrl');
register_setting('fitStudioOptions', 'fitStudioOptions-siteSection');

add_settings_section('infoSection', 'Use this plugin to turn on the header/footer for FitStudio', array(&$this,'printVisibility'), 'manage-fitstudio-hf');
add_settings_field('apiUrl', '', array(&$this,'printApiUrl'), 'manage-fitstudio-hf', 'infoSection');
add_settings_field('apiKey', '', array(&$this,'printApiKey'), 'manage-fitstudio-hf', 'infoSection');
add_settings_field('toggleVisibility', '', array(&$this,'printVisibilityToggle'), 'manage-fitstudio-hf', 'infoSection');
add_settings_field('siteSection', '', array(&$this,'printSiteSection'), 'manage-fitstudio-hf', 'infoSection');
}

public function getOption($name) {
return get_option($name);
}

public function printVisibility() {
$this->views->openField();
}

public function printApiKey() {
$data = array('value' => $this->getOption('fitStudioOptions-apiKey'));

$this->views->openField('fields/keys', $data);
}

public function printVisibilityToggle() {
$data = array('value' => $this->getOption('fitStudioOptions-visibility'));

$this->views->openField('fields/visibility', $data);
}

public function printApiUrl() {
$data = array('value' => $this->getOption('fitStudioOptions-apiUrl'));

$this->views->openField('fields/url', $data);
}

public function printSiteSection() {
$data = array('value' => $this->getOption('fitStudioOptions-siteSection'));

$this->views->openField('fields/section', $data);
}
}
?>
@@ -0,0 +1,11 @@
<?php
class UserActions extends UserActionQuery {
private $_active;
private $_apiKey;
private $_url;
private $_siteSection;

public function __construct() {

}
}

0 comments on commit e80a0a2

Please sign in to comment.