2021-01-02, 08:11 PM
Problems:
Function Activate Code:
Entire Plugin Code:
Would someone be able to point me in the right direction for fixing this issue? I am COMPLETELY new to creating plugins and this is my first attempt. I have followed the guides here that MyBB has provided and then followed the guide here to create templates on activation.
- When I add in the function for faceclaim_activate my site goes blank (for both admin end and front end).
- If I take out all the code inside function faceclaim_activate() { // empty } my site goes back to working.
- Plugin "Install & Activate" never changes but each time I click it it adds an additional setting group (same gid and everything) to the plugin settings area, which I then have to delete the extra each time, I never have the option to deactivate or uninstall.
Function Activate Code:
function faceclaim_activate()
{
global $db
$fq_active = $db->simple_select('templategroups', "COUNT (*) as count", "title = 'Face Claim Directory Templates'");
$fc_active = $db->fetch_field($fq_active, "count");
$db->free_result($fq_active);
if($fc_active < 1)
{
$fcdt = array(
"prefix" => "faceclaim",
"title" => "Face Claim Directory Templates",
);
$db->insert_query("templategroups", $fcdt);
}
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim',
"template" => $db->escape_string('<html>
<head>
<title>{$mybb->settings['bbname']} - Face Claim Directory</title>
{$headerinclude}
</head>
<body>
{$header}
<table width ="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}">
<tr>
<td colspan="2" class="thead"><strong>Face Claim Listing</strong></td>
</tr>
<tr>
<td class="tcat" colspan="2">Character</td>
<td class="tcat">Face Claim</td>
</tr>
</table>
<table width ="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}">
{$fc_dir}
</table>
{$footer}
</body>
</html>'),
"sid" => "-2",
"version" => $mybb->version + 1
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim_entry',
"template" => $db->escape_string('<tr>
<td class="trow1" width="50px">
<a href="{$users['profilelink']}">
<img src="{$users['avatar']}" onerror="this.onerror=null;this.src='/images/default_avatar.png';" width="50px" height="50px" style="border-radius: 50%;" />
</a>
</td>
<td class="trow1">
<a href="/member.php?action=profile&uid={$users['profilelink']}">
{$users['username']}
</a>
</td>
<td class="trow1">
{$users['faceclaim']}
</td>
</tr>'),
"sid" => "-2",
"version" => $mybb->version + 1,
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim_empty',
"template" => $db->escape_string('<tr>
<td class="trow1" colspan="2" align="center">
<i>There are currently no characters with face claims applicable. Please check back at a later date.</i>
</td>
</tr>'),
"sid" => "-2",
"version" => $mybb->version + 1,
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
rebuild_settings();
}
Entire Plugin Code:
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.");
}
function faceclaim_info()
{
return array(
"name" => "Face Claim Directory",
"description" => "Shows the face claim of characters in a list with character and player listed.",
"website" => "https://tay.kaonshosting.com/",
"author" => "Tay (isoldehn)",
"authorsite" => "https://tay.kaonshosting.com/",
"version" => "1.0",
"guid" => "",
"codename" => "fcdirectory",
"compatibility" => "18"
);
}
function faceclaim_install()
{
global $db, $mybb;
$fcsetting_group = array(
'name' => 'faceclaim_settings',
'title' => 'Face Claim Directory',
'description' => 'All FC Directory settings are located here.',
'disporder' => 5, // The order your setting group will display
'isdefault' => 0
);
$gid = $db->insert_query("settinggroups", $fcsetting_group);
$fcsetting_array = array(
'faceclaim_toggle' => array(
'title' => 'Enable / Disable',
'description' => 'Choose whether you would like to enable or disable this plugin.',
'optionscode' => 'yesno',
'value' => '0', // 0 = NO | 1 = YES
'disporder' => 1
),
'faceclaim_usergroups' => array(
'title' => 'Usergroups',
'description' => 'From the following selections, choose the usergroups you would like to display on the Face Claim Directory.',
'optionscode' => "groupselect",
'value' => '',
'disporder' => 2
),
);
foreach($fcsetting_array as $name => $setting)
{
$setting['name'] = $name;
$setting['gid'] = $gid;
$db->insert_query('settings', $setting);
}
rebuild_settings();
}
function faceclaim_is_installed()
{
global $db;
if($db->table_exists("faceclaim_settings"))
{
return true;
}
return false;
}
function faceclaim_uninstall()
{
global $db;
$db->delete_query('settings', "name IN ('faceclaim_toggle','faceclaim_usergroups'");
$db->delete_query('settinggroups', "name = 'fcsetting_group'");
$db->delete_query('templategroups', "title = 'Face Claim Directory Templates'");
rebuild_settings();
}
function faceclaim_activate()
{
global $db
$fq_active = $db->simple_select('templategroups', "COUNT (*) as count", "title = 'Face Claim Directory Templates'");
$fc_active = $db->fetch_field($fq_active, "count");
$db->free_result($fq_active);
if($fc_active < 1)
{
$fcdt = array(
"prefix" => "faceclaim",
"title" => "Face Claim Directory Templates",
);
$db->insert_query("templategroups", $fcdt);
}
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim',
"template" => $db->escape_string('<html>
<head>
<title>{$mybb->settings['bbname']} - Face Claim Directory</title>
{$headerinclude}
</head>
<body>
{$header}
<table width ="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}">
<tr>
<td colspan="2" class="thead"><strong>Face Claim Listing</strong></td>
</tr>
<tr>
<td class="tcat" colspan="2">Character</td>
<td class="tcat">Face Claim</td>
</tr>
</table>
<table width ="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}">
{$fc_dir}
</table>
{$footer}
</body>
</html>'),
"sid" => "-2",
"version" => $mybb->version + 1
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim_entry',
"template" => $db->escape_string('<tr>
<td class="trow1" width="50px">
<a href="{$users['profilelink']}">
<img src="{$users['avatar']}" onerror="this.onerror=null;this.src='/images/default_avatar.png';" width="50px" height="50px" style="border-radius: 50%;" />
</a>
</td>
<td class="trow1">
<a href="/member.php?action=profile&uid={$users['profilelink']}">
{$users['username']}
</a>
</td>
<td class="trow1">
{$users['faceclaim']}
</td>
</tr>'),
"sid" => "-2",
"version" => $mybb->version + 1,
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
$fcdt = array(
"tid" => NULL,
"title" => 'faceclaim_empty',
"template" => $db->escape_string('<tr>
<td class="trow1" colspan="2" align="center">
<i>There are currently no characters with face claims applicable. Please check back at a later date.</i>
</td>
</tr>'),
"sid" => "-2",
"version" => $mybb->version + 1,
"dateline" => time(),
);
$db->insert_query("templates", $fcdt);
rebuild_settings();
}
function faceclaim_deactivate()
{
global $db;
$db->delete_query('templates', "title LIKE 'faceclaim_%' AND sid='-2'");
rebuild_settings();
}
Would someone be able to point me in the right direction for fixing this issue? I am COMPLETELY new to creating plugins and this is my first attempt. I have followed the guides here that MyBB has provided and then followed the guide here to create templates on activation.