PDA

View Full Version : Edit a default array() with a hook


Logikos
08-07-2005, 08:43 PM
Okay, how would I go about doing this?


$var = array(
'blah1' => $vbphrase['blah1'],
'blah1' => $vbphrase['blah1']
);

($hook = vBulletinHook::fetch_hook('some_hook')) ? eval($hook) : false;


Thats the code in the file. How would I add

'blah3' => $vbphrase['blah3']


With that hook sitting right underneath? I'm finishing a tutorial for vB.org, and I need to figure that out to finish it. Kirby come help!!! :p

Thanks!

Andreas
08-07-2005, 08:45 PM
Here we go :)


$var['blah3'] = $vbphrase['blah3'];

Logikos
08-07-2005, 08:48 PM
Jesus, I hate when stupid ++++ like that goes public. :ermm:

Andreas
08-07-2005, 08:51 PM
????

Logikos
08-07-2005, 08:57 PM
Okay, I knew it wasn't that easy. Let me tell you what I'm doing. I want to add a custom admincp permissions.

In adminpermission.php there is:

$permsphrase = array(
'canadminsettings' => $vbphrase['can_administer_settings'],
'canadminstyles' => $vbphrase['can_administer_styles'],
'canadminlanguages' => $vbphrase['can_administer_languages'],
'canadminforums' => $vbphrase['can_administer_forums'],
'canadminthreads' => $vbphrase['can_administer_threads'],
'canadmincalendars' => $vbphrase['can_administer_calendars'],
'canadminusers' => $vbphrase['can_administer_users'],
'canadminpermissions' => $vbphrase['can_administer_user_permissions'],
'canadminfaq' => $vbphrase['can_administer_faq'],
'canadminimages' => $vbphrase['can_administer_images'],
'canadminbbcodes' => $vbphrase['can_administer_bbcodes'],
'canadmincron' => $vbphrase['can_administer_cron'],
'canadminmaintain' => $vbphrase['can_run_maintenance'],
'canadminupgrade' => $vbphrase['can_run_upgrades'],
'canadminplugins' => $vbphrase['can_administer_plugins'],
);

($hook = vBulletinHook::fetch_hook('admin_permissions')) ? eval($hook) : false;


A few lines under is:

if ($_REQUEST['do'] == 'edit')
{
print_form_header('adminpermissions', 'update');
construct_hidden_code('userid', $vbulletin->GPC['userid']);
construct_hidden_code('oldpermissions', $user['adminpermissions']);
print_table_header(construct_phrase($vbphrase['x_y_id_z'], $vbphrase['administrator_permissions'], $user['username'], $user['userid']));
print_label_row("$vbphrase[administrator]: <a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;u=" . $vbulletin->GPC['userid'] . "\">$user[username]</a>", '<div align="' . $stylevar['right'] .'"><input type="button" class="button" value=" ' . $vbphrase['all_yes'] . ' " onclick="js_check_all_option(this.form, 1);" /> <input type="button" class="button" value=" ' . $vbphrase['all_no'] . ' " onclick="js_check_all_option(this.form, 0);" /></div>', 'thead');

foreach (convert_bits_to_array($user['adminpermissions'], $ADMINPERMISSIONS) AS $field => $value)
{
if ($field == 'canadminupgrade')
{
construct_hidden_code("adminpermissions[$field]", $value);
}
else
{
print_yes_no_row($permsphrase["$field"], "adminpermissions[$field]", $value);
}
}

print_select_row($vbphrase['control_panel_style_choice'], 'cssprefs', array_merge(array('' => "($vbphrase[default])"), fetch_cpcss_options()), $user['cssprefs']);

print_submit_row();
}


As you can see my edit which would be:

$permsphrase['canadmintextreplacements'] = $vbphrase['can_administer_text_replacements'];


I was hoping to figure out how to add custom admin perms using the hooks system for my modification, but it's not as easy as I thought. I thought I almost had it and was going make a tutorial, but I'm a little frustrated with this.

Do you plan on releasing such a tutorial?

????
I was alittle embarrassed at first. :p

Andreas
08-07-2005, 09:38 PM
You can't use the standard form for custom Admin Permissions, you must create your own Form.
=> Another Hook in the edit handler before print_submit_row() would help.

Logikos
08-07-2005, 09:47 PM
Thanks Kirby, I have requested this at vB.com. :)