Please make sure IN_MYBB is defined.");
}
function information_extension_rank()
{
global $lang;
extensions_lang('ranks');
return array(
'name' => 'Ranks',
'description' => $lang->ranks_plug_description,
'version' => '1.0',
'website' => 'http://www.mybb-es.com/',
'author' => 'Edson Ordaz',
'authorsite' => 'http://www.mybb-es.com/',
'achivements' => '*',
'admin_icon' => 'inc/plugins/achivements/extensions/ranks/ranks.png'
);
}
function active_extension_rank()
{
global $db, $lang;
extensions_lang('ranks');
$collation = $db->build_create_table_collation();
if(!$db->table_exists('ranks'))
{
$db->query("CREATE TABLE IF NOT EXISTS `".TABLE_PREFIX."ranks` (
`rid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`description` TEXT NOT NULL,
`apid` int(10) NOT NULL DEFAULT 0,
`atid` int(10) NOT NULL DEFAULT 0,
`arid` int(10) NOT NULL DEFAULT 0,
`toid` int(10) NOT NULL DEFAULT 0,
`rgid` int(10) NOT NULL DEFAULT 0,
`image` varchar(250) NOT NULL DEFAULT '',
`level` int(10) NOT NULL DEFAULT 0,
PRIMARY KEY (`rid`)
) ENGINE=MyISAM{$collation}");
}
if(!$db->field_exists("rank", "users"))
{
$db->add_column("users", "rank", "int(10) unsigned NOT NULL default '0'");
}
require_once MYBB_ROOT."inc/plugins/achivements/extensions/ranks/task.php";
if(!file_exists(MYBB_ROOT."inc/tasks/ranks.php"))
{
create_task();
}else{
create_task_tools();
}
extensions_add_template('ranks', '
{$mybb->settings[\'bbname\']} - {$lang->listranks}
{$headerinclude}
{$header}
{$lang->listranks} |
{$lang->image} |
{$lang->namedes} |
{$lang->posts} |
{$lang->threads} |
{$lang->reputation} |
{$lang->timeonline} |
{$lang->regdate} |
{$lang->level} |
{$ranks}
{$footer}
');
extensions_add_template('ranks_list', '
 |
{$rank[\'name\']} {$rank[\'description\']} |
{$rank[\'posts\']} |
{$rank[\'threads\']} |
{$rank[\'reputation\']} |
{$timeonline} |
{$regdate} |
{$rank[\'level\']} |
');
extensions_add_template('ranks_postbit', '
{$lang->rank}: ![{$rank[\'name\']} {$rank[\'name\']}]({$rank[\'image\']})
');
extensions_add_template('ranks_profile', '
{$lang->rankby} |
|
{$rank[\'name\']} {$rank[\'description\']}
|
');
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets('member_profile', '#{\$profilefields}#', '{\$profilefields}{\$rankprofile}');
find_replace_templatesets('postbit', '#'.preg_quote('{$post[\'user_details\']}').'#', "{\$post['user_details']}{\$post['rankpostbit']}");
find_replace_templatesets('postbit_classic', '#'.preg_quote('{$post[\'user_details\']}').'#', "{\$post['user_details']}{\$post['rankpostbit']}");
}
function deactivate_rank_extension()
{
global $db;
$query = $db->simple_select('ranks');
while($ranks = $db->fetch_array($query))
{
$delete_images = @unlink(MYBB_ROOT.$ranks['image']);
}
if($db->table_exists('ranks'))
{
$db->drop_table('ranks');
}
if($db->field_exists("rank", "users"))
{
$db->drop_column("users", "rank");
}
$db->delete_query("datacache", "title='ranks'");
extensions_remove_templates("'ranks', 'ranks_list', 'ranks_postbit', 'ranks_profile'");
$db->delete_query('tasks', 'file=\'ranks\'');
if(file_exists(MYBB_ROOT."inc/tasks/ranks.php"))
{
@unlink(MYBB_ROOT.'inc/tasks/ranks.php');
}
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets('member_profile', '#\