MyBB Community Forums

Full Version: Edit Plugin to Support UTF8
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
<?php

/********************************************************************************
 *
 *  Posts required to access threads
 *  Author: Pratik Unadkat (crazy4cs)
 *  Copyright: © 2011 Pratik Unadkat (crazy4cs)
 *  
 *  Website: http://www.mybb-world.com , http://www.ubers.org/
 *  License: license.txt
 *  Any codes in this plugin are copyrighted and not allowed to be reproduced.
 * 
 *  Requires specified post count set by admin to view specified threads.
 *
 ********************************************************************************/

if(!defined("IN_MYBB"))
	die("This file cannot be accessed directly.");

$plugins->add_hook("showthread_start", "prat");


function prat_info()
{
	return array(
		"name"			=> "Posts required to access threads.",
		"description"	=> "Requires specified post count set by admin to view specified threads.",
		"website"		=> "http://www.mybb-world.com",
		"version"		=> "1.0",
		"author"		=> "Pratik Unadkat (crazy4cs)",
		"authorsite"	=> "http://www.ubers.org",
		"compatibility"  => "16*",
		'guid'        => "aa56c67f00f9013e92e625f2181416b5"
	);
}
function prat_activate()
{
	global $db;
	
$settings_group = array(
		'name' => 'prat',
		'title' => 'Posts required to access threads',
		'description' => 'Settings for posts required to access threads plugin.',
		'disporder' => '1',
		'isdefault' => 'no'
	);
	$db->insert_query('settinggroups',$settings_group);
	$gid = $db->insert_id();
	
	$setting1 = array(
		'name' => 'prat_enabled',
		'title' => 'Want to enable this plugin?',
		'description' => 'By enabling this, the plugin would function.',
		'optionscode' => 'yesno',
		'value' => '0',
		'disporder' => '2',
		'gid' => intval($gid)
	);
	$db->insert_query('settings',$setting1);

	$prat_posts = array(
		"name" => "prat_posts",
		"title" => "Required posts.",
		"description" => "Enter how much posts should be required to access the specified threads.",
		"optionscode" => "text",
		"value" => "",
		"disporder" => "3",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $prat_posts);

     $prat_gid = array(
		"name" => "prat_gid",
		"title" => "Groups not allowed.",
		"description" => "Group ids (gid) of the user who cannot view specified threads until above specified post count is achieved, separate each gid with a <strong>comma</strong>.",
		"optionscode" => "text",
		"value" => "",
		"disporder" => "4",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $prat_gid);
	
	$prat_tid = array(
		"name" => "prat_tid",
		"title" => "Blocked threads.",
		"description" => "Enter the thread id <strong>(tid)</strong> of the threads you would like to block to above specified users until they achieved the specified post count. Separate each tid with a <strong>comma</strong>.",
		"optionscode" => "text",
		"value" => "",
		"disporder" => "5",
		"gid" => intval($gid),
		);
	$db->insert_query("settings", $prat_tid);
	
rebuild_settings();
}

function prat_deactivate()
{
	global $db;

$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='prat'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='prat_enabled'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='prat_posts'");		
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='prat_gid'");	
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='prat_tid'");

rebuild_settings();
}
	

function prat()	
{
global $tid, $mybb, $db;	

$groups = explode(',', $mybb->settings['prat_gid']);
$posts = explode(',', $mybb->settings['prat_posts']);
$threads = explode(',', $mybb->settings['prat_tid']);
$require = $mybb->settings['prat_posts'] - $mybb->user['postnum'];
	
if($mybb->settings['prat_enabled'] == 1)
{

if($mybb->user['postnum'] < $mybb->settings['prat_posts'] && in_array($tid, $threads) && in_array($mybb->user['usergroup'] , $groups))
{
	error("Πρέπει να έχεις <strong>{$mybb->settings['prat_posts']}</strong> posts για να έχεις πρόσβαση στο συγκεκριμένο thread.! Αυτη τη στιγμή έχεις <strong>{$mybb->user['postnum']}</strong>, άρα χρειάζεσε ακόμα <strong>{$require}</strong> posts");
}

}
}
	
?>

Im editing the above plugin,how i can modify it to support my language?
Thanks.
You will have to edit all the internal strings of this plugin, since there is no language file associated with it!
Can you be more specific please?
You have to translate this line to your own language:

error("Πρέπει να έχεις <strong>{$mybb->settings['prat_posts']}</strong> posts για να έχεις πρόσβαση στο συγκεκριμένο thread.! Αυτη τη στιγμή έχεις <strong>{$mybb->user['postnum']}</strong>, άρα χρειάζεσε ακόμα <strong>{$require}</strong> posts");
This is the translated error output in my language.But when the visitor see that instead of letter see some symbols.
Oh, I see. You just have to encode the file with UTF-8. Install a text editor like Notepad++, open up the file, go to the Encoding menu, select UTF-8 without BOM, save the file and re-upload.
Worked great.Thanks
Something else.If i wanted to run this plugin NOT for the threads but for the forums,what should i do?I tried to modify it by changing the tid variable and put some hooks like forumdisplay_thread,index_start.But its not working.