add_hook('member_profile_end', 'profilemycode_run');
$plugins->add_hook('admin_profilefields_do_add', 'profilemycode_admin_do_edit');
$plugins->add_hook('admin_profilefields_do_edit', 'profilemycode_admin_do_edit');
$plugins->add_hook('admin_profilefields_add', 'profilemycode_admin_add');
$plugins->add_hook('admin_profilefields_edit', 'profilemycode_admin_edit');
function profilemycode_info()
{
return array(
'name' => 'MyCode in Profile Fields',
'description' => 'Gives admins the option to allow MyCode to be used in custom profile fields.',
'website' => 'http://mybbhacks.zingaburga.com/',
'author' => 'ZiNgA BuRgA',
'authorsite' => 'http://zingaburga.com/',
'version' => '1.0'
);
}
function profilemycode_activate()
{
global $db;
$db->query('ALTER TABLE '.TABLE_PREFIX.'profilefields ADD (`allowmycode` CHAR(3) NOT NULL DEFAULT "no")');
}
function profilemycode_deactivate()
{
global $db;
$db->query('ALTER TABLE '.TABLE_PREFIX.'profilefields DROP `allowmycode`');
}
function profilemycode_admin_add()
{
global $lang;
cpheader();
startform("profilefields.php", "" , "do_add");
starttable();
tableheader($lang->new_custom_field);
makeinputcode($lang->field_name, "name");
maketextareacode($lang->field_description, "description");
makeinputcode($lang->field_max_length, "maxlength");
makeinputcode($lang->field_length, "length", 20);
makeinputcode($lang->field_disporder, "disporder", "", 4);
makelabelcode($lang->field_type, "");
maketextareacode($lang->field_options, "options", "", 6, 50);
makeyesnocode($lang->field_required, "required", "no");
makeyesnocode($lang->field_editable, "editable", "yes");
makeyesnocode($lang->field_hidden, "hidden", "no");
makeyesnocode('Allow MyCode
Allow users to enter MyCode in the field (only works if field type is Textbox or Textarea)', "allowmycode", "no");
endtable();
endform($lang->add_field, $lang->reset_button);
cpfooter();
exit;
}
function profilemycode_admin_edit()
{
global $lang, $profilefield, $typesel;
cpheader();
startform("profilefields.php", "" , "do_edit");
makehiddencode("fid", $profilefield['fid']);
starttable();
$lang->edit_custom_field = sprintf($lang->edit_custom_field, $profilefield['name']);
tableheader($lang->edit_custom_field);
makeinputcode($lang->field_name, "name", "$profilefield[name]");
maketextareacode($lang->field_description, "description", $profilefield['description']);
makeinputcode($lang->field_max_length, "maxlength", $profilefield['maxlength']);
makeinputcode($lang->field_length, "length", $profilefield['length']);
makeinputcode($lang->field_disporder, "disporder", $profilefield['disporder'], 4);
makelabelcode($lang->field_type, "");
maketextareacode($lang->field_options, "options", $options, 6, 50);
makeyesnocode($lang->field_required, "required", $profilefield['required']);
makeyesnocode($lang->field_editable, "editable", $profilefield['editable']);
makeyesnocode($lang->field_hidden, "hidden", $profilefield['hidden']);
makeyesnocode('Allow MyCode
Allow users to enter MyCode in the field (only works if field type is Textbox or Textarea)', "allowmycode", $profilefield['allowmycode']);
endtable();
endform($lang->edit_field, $lang->reset_button);
cpfooter();
exit;
}
function profilemycode_admin_do_edit()
{
global $sqlarray, $mybb;
if($mybb->input['allowmycode'] == 'yes') $sqlarray['allowmycode'] = 'yes';
else $sqlarray['allowmycode'] = 'no';
}
function profilemycode_run()
{
// unfortunately, we have to redo all the profile processing code... :(
global $db, $profilefields, $field_hidden, $templates, $lang, $theme, $userfields;
if(!$profilefields) return;
$query = $db->simple_select(TABLE_PREFIX."profilefields", "*", "{$field_hidden}", array('order_by' => 'disporder'));
$bgcolor = "trow1";
while($customfield = $db->fetch_array($query))
{
$thing = explode("\n", $customfield['type'], "2");
$type = trim($thing[0]);
$field = "fid$customfield[fid]";
$useropts = explode("\n", $userfields[$field]);
$customfieldval = $comma = '';
if(is_array($useropts) && ($type == "multiselect" || $type == "checkbox"))
{
foreach($useropts as $val)
{
if($val != '')
$customfieldval .= "