Triqui modifications

Posted on Updated on

To use Triqui wordpress plugin with more than one user i made this in my homepage dobdob.metacortex.hu:

Install and activate plugin: Role Manager

change these lines in mochi.php:

function add_plugin_pages() {
	add_menu_page('MochiAds', 'MochiAds', 'manage_mochi', __FILE__, 'mt_toplevel_page',plugins_url('mochi/mochi.png'));
	add_submenu_page(__FILE__, 'Setup', 'Setup', 'manage_mochi', 'mochi-setup', 'mochi_setup');
	add_submenu_page(__FILE__, 'Feed Games', 'Feed Games', 'manage_mochi', 'mochi-feed-games', 'mochi_feed_games');
	add_submenu_page(__FILE__, 'Manage Games', 'Manage Games', 'manage_mochi', 'mochi-manage_games', 'mochi_manage_games');
}

Add these to function mochi_table():

// Set 'manage_mochi' Capabilities To Administrator
$role = get_role('administrator');
if(!$role->has_cap('manage_mochi')) {
	$role->add_cap('manage_mochi');
}

(NOTE: That mochi_manage will be added only if you first time activate the mochi plugin. If you already activated the plugin then temporarly copy this piece of code to another function which will run next time then remove)

change this in function mochi_add_games():

$post[‘post_author’] = get_the_author_id();

Then I added new users who should be allow to manage mochi plugin, I set them role to ‘Editor’ the with Role Manager I added permission: ‘Manage_mochi’

—-
Also I made this modifications in echo_game

function truncate($string, $del) {
$len = strlen($string);
if ($len > $del) {
$new = substr($string,0,$del).”…”;
return $new;
}
else return $string;
}

function echo_game($id){
global $wpdb;
$game = $wpdb->get_row(“select * from “.$wpdb->prefix.”mochi where id = $id”,ARRAY_A);
if($game[blog_url]){
$game[swf_url]=$game[blog_url];
}
$post = get_post($game[blog_id]);
$authordata = get_userdata($post->post_author);
echo “<div id = \”game_$game[id]\”><div class = \”divstyle_$game[status]\” style = \”background-image:url($game[thumbnail_url]);\”>”;
echo “<p><strong>$game[name] ($game[author])• <a class=\”thickbox\” title = \”$game[name]\” href = \””.WP_PLUGIN_URL.”/mochi/showswf.php?file=”.str_replace(“http://&#8221;,””,$game[swf_url]).”&h=$game[height]&w=$game[width]&keepThis=true&TB_iframe=true&height=$game[height]&width=$game[width]\”>Play</a></strong> • Approved on “.substr($game[feed_approval_created],0,10).” • Game size: “.round($game[swf_file_size]/1024).”kB • $game[width]x$game[height] <br>“;

echo “Status: <strong>$game[status]</strong>”;
if($game[status]==”published”){
echo” ($authordata->nickname)”;
if($game[blog_url]){
echo ” • publisher feature: <span class = \”gameon\”>ON</span> (you are getting publisher revenue from this game)   <button  class = \”mochibutton\” type = \”button\” onclick = \”jQuery(‘#game_$game[id]’).html(‘<div class = \’wip\’ style = \’background-image:url($game[thumbnail_url])\’>Deleting game…</div>’);jQuery.post(‘”.ADMIN_COOKIE_PATH.”/admin-ajax.php’,{action:’handle_mochi’,id:’$game[id]’,func:’toggle’},function(data){jQuery(‘#game_$game[id]’).html(data);});\”>Turn off</button>”;
}
else{
echo ” • publisher feature: <span class = \”gameoff\”>OFF</span> (you aren’t getting publisher revenue from this game)   <button class = \”mochibutton\” type = \”button\” onclick = \”jQuery(‘#game_$game[id]’).html(‘<div class = \’wip\’ style = \’background-image:url($game[thumbnail_url])\’>Downloading game…</div>’);jQuery.post(‘”.ADMIN_COOKIE_PATH.”/admin-ajax.php’,{action:’handle_mochi’,id:’$game[id]’,func:’toggle’},function(data){jQuery(‘#game_$game[id]’).html(data);});\”>Turn on</button>”;
}
}
else
{
$desc = truncate($game[description], 200);
echo ” • $desc”;
}
[…]

Blogged with the Flock Browser
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s