Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 08-07-2005, 08:43 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Edit a default array() with a hook

Okay, how would I go about doing this?

PHP Code:
$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
PHP Code:
'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!!!

Thanks!
Reply With Quote
  #2  
Old 08-07-2005, 08:45 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here we go

PHP Code:
$var['blah3'] = $vbphrase['blah3']; 
Reply With Quote
  #3  
Old 08-07-2005, 08:48 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Jesus, I hate when stupid ++++ like that goes public. :ermm:
Reply With Quote
  #4  
Old 08-07-2005, 08:51 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

????
Reply With Quote
  #5  
Old 08-07-2005, 08:57 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
$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:
PHP Code:
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:
PHP Code:
$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?

Quote:
????
I was alittle embarrassed at first.
Reply With Quote
  #6  
Old 08-07-2005, 09:38 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 08-07-2005, 09:47 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Kirby, I have requested this at vB.com.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:54 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04152 seconds
  • Memory Usage 2,247KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete